From f842d7b505eb57ac589e47525eb14e9acc888c57 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Mon, 23 Oct 2023 16:40:58 -0500 Subject: [PATCH 001/417] Allow cloning `poison::Guard`s. (makes implementing `Mapped*Guard` easier) --- library/std/src/sync/poison.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/sync/poison.rs b/library/std/src/sync/poison.rs index 741312d5537e9..ababaa2f06635 100644 --- a/library/std/src/sync/poison.rs +++ b/library/std/src/sync/poison.rs @@ -55,6 +55,7 @@ impl Flag { } } +#[derive(Clone)] pub struct Guard { panicking: bool, } From 9be1321676dd3a90b180ce8e9b6ac2da1bd2272d Mon Sep 17 00:00:00 2001 From: Zachary S Date: Mon, 23 Oct 2023 16:26:35 -0500 Subject: [PATCH 002/417] Implement `MappedMutexGuard`. --- library/std/src/sync/mutex.rs | 193 ++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index b4ae6b7e07ebc..18bea6d58fba1 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -3,7 +3,10 @@ mod tests; use crate::cell::UnsafeCell; use crate::fmt; +use crate::marker::PhantomData; +use crate::mem::ManuallyDrop; use crate::ops::{Deref, DerefMut}; +use crate::ptr::NonNull; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; use crate::sys::locks as sys; @@ -213,6 +216,43 @@ impl !Send for MutexGuard<'_, T> {} #[stable(feature = "mutexguard", since = "1.19.0")] unsafe impl Sync for MutexGuard<'_, T> {} +/// An RAII mutex guard returned by `MutexGuard::map`, which can point to a +/// subfield of the protected data. When this structure is dropped (falls out +/// of scope), the lock will be unlocked. +/// +/// The main difference between `MappedMutexGuard` and [`MutexGuard`] is that the +/// former cannot be used with [`CondVar`], since that +/// could introduce soundness issues if the locked object is modified by another +/// thread while the `Mutex` is unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// [`Deref`] and [`DerefMut`] implementations. +/// +/// This structure is created by the [`map`] and [`try_map`] methods on +/// [`MutexGuard`]. +/// +/// [`map`]: MutexGuard::map +/// [`try_map`]: MutexGuard::try_map +/// [`CondVar`]: crate::sync::CondVar +#[must_use = "if unused the Mutex will immediately unlock"] +#[must_not_suspend = "holding a MappedMutexGuard across suspend \ + points can cause deadlocks, delays, \ + and cause Futures to not implement `Send`"] +#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[clippy::has_significant_drop] +pub struct MappedMutexGuard<'a, T: ?Sized + 'a> { + data: NonNull, + inner: &'a sys::Mutex, + poison_flag: &'a poison::Flag, + poison: poison::Guard, + _variance: PhantomData<&'a mut T>, +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl !Send for MappedMutexGuard<'_, T> {} +#[unstable(feature = "mapped_lock_guards", issue = "none")] +unsafe impl Sync for MappedMutexGuard<'_, T> {} + impl Mutex { /// Creates a new mutex in an unlocked state ready for use. /// @@ -552,3 +592,156 @@ pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex { pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag { &guard.lock.poison } + +impl<'a, T: ?Sized> MutexGuard<'a, T> { + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MutexGuard::map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + let value = NonNull::from(f(&mut *orig)); + MappedMutexGuard { + data: value, + inner: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MutexGuard::try_map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + match f(&mut *orig).map(NonNull::from) { + Some(value) => Ok(MappedMutexGuard { + data: value, + inner: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + }), + None => Err(ManuallyDrop::into_inner(orig)), + } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl Deref for MappedMutexGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { self.data.as_ref() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl DerefMut for MappedMutexGuard<'_, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { self.data.as_mut() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl Drop for MappedMutexGuard<'_, T> { + #[inline] + fn drop(&mut self) { + unsafe { + self.poison_flag.done(&self.poison); + self.inner.unlock(); + } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl fmt::Debug for MappedMutexGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&**self, f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl fmt::Display for MappedMutexGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MutexGuard::map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + let value = NonNull::from(f(&mut *orig)); + MappedMutexGuard { + data: value, + inner: orig.inner, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MutexGuard::try_map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + match f(&mut *orig).map(NonNull::from) { + Some(value) => Ok(MappedMutexGuard { + data: value, + inner: orig.inner, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + }), + None => Err(ManuallyDrop::into_inner(orig)), + } + } +} From ea97c1f2dc451ddd50c159cf04967f9be742de8a Mon Sep 17 00:00:00 2001 From: Zachary S Date: Mon, 23 Oct 2023 16:26:59 -0500 Subject: [PATCH 003/417] Implmement `MappedRwLock(Read|Write)Guard`. --- library/std/src/sync/rwlock.rs | 358 ++++++++++++++++++++++++++++++++- 1 file changed, 355 insertions(+), 3 deletions(-) diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 5d8967bfbe686..717f40db4c1c6 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -3,6 +3,8 @@ mod tests; use crate::cell::UnsafeCell; use crate::fmt; +use crate::marker::PhantomData; +use crate::mem::ManuallyDrop; use crate::ops::{Deref, DerefMut}; use crate::ptr::NonNull; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; @@ -105,7 +107,7 @@ unsafe impl Sync for RwLock {} #[cfg_attr(not(test), rustc_diagnostic_item = "RwLockReadGuard")] pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { // NB: we use a pointer instead of `&'a T` to avoid `noalias` violations, because a - // `Ref` argument doesn't hold immutability for its whole scope, only until it drops. + // `RwLockReadGuard` argument doesn't hold immutability for its whole scope, only until it drops. // `NonNull` is also covariant over `T`, just like we would have with `&T`. `NonNull` // is preferable over `const* T` to allow for niche optimization. data: NonNull, @@ -144,6 +146,63 @@ impl !Send for RwLockWriteGuard<'_, T> {} #[stable(feature = "rwlock_guard_sync", since = "1.23.0")] unsafe impl Sync for RwLockWriteGuard<'_, T> {} +/// RAII structure used to release the shared read access of a lock when +/// dropped, which can point to a subfield of the protected data. +/// +/// This structure is created by the [`map`] and [`try_map`] methods +/// on [`RwLockReadGuard`]. +/// +/// [`map`]: RwLockReadGuard::map +/// [`try_map`]: RwLockReadGuard::try_map +#[must_use = "if unused the RwLock will immediately unlock"] +#[must_not_suspend = "holding a MappedRwLockReadGuard across suspend \ + points can cause deadlocks, delays, \ + and cause Futures to not implement `Send`"] +#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[clippy::has_significant_drop] +pub struct MappedRwLockReadGuard<'a, T: ?Sized + 'a> { + // NB: we use a pointer instead of `&'a T` to avoid `noalias` violations, because a + // `MappedRwLockReadGuard` argument doesn't hold immutability for its whole scope, only until it drops. + // `NonNull` is also covariant over `T`, just like we would have with `&T`. `NonNull` + // is preferable over `const* T` to allow for niche optimization. + data: NonNull, + inner_lock: &'a sys::RwLock, +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl !Send for MappedRwLockReadGuard<'_, T> {} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +unsafe impl Sync for MappedRwLockReadGuard<'_, T> {} + +/// RAII structure used to release the exclusive write access of a lock when +/// dropped, which can point to a subfield of the protected data. +/// +/// This structure is created by the [`map`] and [`try_map`] methods +/// on [`RwLockWriteGuard`]. +/// +/// [`map`]: RwLockWriteGuard::map +/// [`try_map`]: RwLockWriteGuard::try_map +#[must_use = "if unused the RwLock will immediately unlock"] +#[must_not_suspend = "holding a MappedRwLockWriteGuard across suspend \ + points can cause deadlocks, delays, \ + and cause Future's to not implement `Send`"] +#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[clippy::has_significant_drop] +pub struct MappedRwLockWriteGuard<'a, T: ?Sized + 'a> { + data: NonNull, + inner_lock: &'a sys::RwLock, + poison_flag: &'a poison::Flag, + poison: poison::Guard, + _variance: PhantomData<&'a mut T>, +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl !Send for MappedRwLockWriteGuard<'_, T> {} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +unsafe impl Sync for MappedRwLockWriteGuard<'_, T> {} + impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// @@ -527,7 +586,10 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { // SAFETY: if and only if `lock.inner.write()` (or `lock.inner.try_write()`) has been // successfully called from the same thread before instantiating this object. unsafe fn new(lock: &'rwlock RwLock) -> LockResult> { - poison::map_result(lock.poison.guard(), |guard| RwLockWriteGuard { lock, poison: guard }) + poison::map_result(lock.poison.guard(), |guard| RwLockWriteGuard { + lock, + poison: guard, + }) } } @@ -559,12 +621,40 @@ impl fmt::Display for RwLockWriteGuard<'_, T> { } } +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl fmt::Debug for MappedRwLockReadGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl fmt::Display for MappedRwLockReadGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl fmt::Debug for MappedRwLockWriteGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl fmt::Display for MappedRwLockWriteGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Deref for RwLockReadGuard<'_, T> { type Target = T; fn deref(&self) -> &T { - // SAFETY: the conditions of `RwLockGuard::new` were satisfied when created. + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when created. unsafe { self.data.as_ref() } } } @@ -587,6 +677,37 @@ impl DerefMut for RwLockWriteGuard<'_, T> { } } +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl Deref for MappedRwLockReadGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { self.data.as_ref() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl Deref for MappedRwLockWriteGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { self.data.as_ref() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl DerefMut for MappedRwLockWriteGuard<'_, T> { + fn deref_mut(&mut self) -> &mut T { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { self.data.as_mut() } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Drop for RwLockReadGuard<'_, T> { fn drop(&mut self) { @@ -607,3 +728,234 @@ impl Drop for RwLockWriteGuard<'_, T> { } } } + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl Drop for MappedRwLockReadGuard<'_, T> { + fn drop(&mut self) { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { + self.inner_lock.read_unlock(); + } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "none")] +impl Drop for MappedRwLockWriteGuard<'_, T> { + fn drop(&mut self) { + self.poison_flag.done(&self.poison); + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { + self.inner_lock.write_unlock(); + } + } +} + +impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockReadGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the `RwLockReadGuard` used through + /// `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> + where + F: FnOnce(&T) -> &U, + U: ?Sized, + { + let orig = ManuallyDrop::new(orig); + let value = NonNull::from(f(&*orig)); + MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock } + } + + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockReadGuard::try_map(...)`. A method would interfere with methods + /// of the same name on the contents of the `RwLockReadGuard` used through + /// `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + U: ?Sized, + { + let orig = ManuallyDrop::new(orig); + match f(&*orig).map(NonNull::from) { + Some(value) => Ok(MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock }), + None => Err(ManuallyDrop::into_inner(orig)), + } + } +} + +impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data, + /// e.g. an enum variant. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockReadGuard::map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockReadGuard` + /// used through `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> + where + F: FnOnce(&T) -> &U, + U: ?Sized, + { + let orig = ManuallyDrop::new(orig); + let value = NonNull::from(f(&*orig)); + MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock } + } + + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. + /// The original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockReadGuard::try_map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockReadGuard` + /// used through `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + U: ?Sized, + { + let orig = ManuallyDrop::new(orig); + match f(&*orig).map(NonNull::from) { + Some(value) => Ok(MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock }), + None => Err(ManuallyDrop::into_inner(orig)), + } + } +} + +impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockWriteGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the `RwLockWriteGuard` used through + /// `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + let value = NonNull::from(f(&mut *orig)); + MappedRwLockWriteGuard { + data: value, + inner_lock: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockWriteGuard::try_map(...)`. A method would interfere with methods + /// of the same name on the contents of the `RwLockWriteGuard` used through + /// `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + match f(&mut *orig).map(NonNull::from) { + Some(value) => Ok(MappedRwLockWriteGuard { + data: value, + inner_lock: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + }), + None => Err(ManuallyDrop::into_inner(orig)), + } + } +} + +impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> { + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data, + /// e.g. an enum variant. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockWriteGuard::map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockWriteGuard` + /// used through `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + let value = NonNull::from(f(&mut *orig)); + MappedRwLockWriteGuard { + data: value, + inner_lock: orig.inner_lock, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data. + /// The original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockWriteGuard::try_map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockWriteGuard` + /// used through `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "none")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + let mut orig = ManuallyDrop::new(orig); + match f(&mut *orig).map(NonNull::from) { + Some(value) => Ok(MappedRwLockWriteGuard { + data: value, + inner_lock: orig.inner_lock, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + }), + None => Err(ManuallyDrop::into_inner(orig)), + } + } +} From 04f86304422cfc74a46ee7d53d04eb1e56572599 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Mon, 23 Oct 2023 16:36:13 -0500 Subject: [PATCH 004/417] Add comment about `Mapped(Mutex|RwLockWrite)Guard` variance. --- library/std/src/sync/mutex.rs | 28 +++++++++++-------- library/std/src/sync/rwlock.rs | 50 ++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 18bea6d58fba1..a435fba4f1ea2 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -238,9 +238,13 @@ unsafe impl Sync for MutexGuard<'_, T> {} #[must_not_suspend = "holding a MappedMutexGuard across suspend \ points can cause deadlocks, delays, \ and cause Futures to not implement `Send`"] -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] #[clippy::has_significant_drop] pub struct MappedMutexGuard<'a, T: ?Sized + 'a> { + // NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a + // `MappedMutexGuard` argument doesn't hold uniqueness for its whole scope, only until it drops. + // `NonNull` is covariant over `T`, so we add a `PhantomData<&'a mut T>` field + // below for the correct variance over `T` (invariance). data: NonNull, inner: &'a sys::Mutex, poison_flag: &'a poison::Flag, @@ -248,9 +252,9 @@ pub struct MappedMutexGuard<'a, T: ?Sized + 'a> { _variance: PhantomData<&'a mut T>, } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl !Send for MappedMutexGuard<'_, T> {} -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] unsafe impl Sync for MappedMutexGuard<'_, T> {} impl Mutex { @@ -602,7 +606,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { /// This is an associated function that needs to be used as /// `MutexGuard::map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, @@ -629,7 +633,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { /// `MutexGuard::try_map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. #[doc(alias = "filter_map")] - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, @@ -649,7 +653,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl Deref for MappedMutexGuard<'_, T> { type Target = T; @@ -658,14 +662,14 @@ impl Deref for MappedMutexGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl DerefMut for MappedMutexGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { unsafe { self.data.as_mut() } } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl Drop for MappedMutexGuard<'_, T> { #[inline] fn drop(&mut self) { @@ -676,14 +680,14 @@ impl Drop for MappedMutexGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl fmt::Debug for MappedMutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl fmt::Display for MappedMutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) @@ -699,7 +703,7 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { /// This is an associated function that needs to be used as /// `MutexGuard::map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, @@ -726,7 +730,7 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { /// `MutexGuard::try_map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. #[doc(alias = "filter_map")] - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 717f40db4c1c6..def0c8a16c7ce 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -158,7 +158,7 @@ unsafe impl Sync for RwLockWriteGuard<'_, T> {} #[must_not_suspend = "holding a MappedRwLockReadGuard across suspend \ points can cause deadlocks, delays, \ and cause Futures to not implement `Send`"] -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] #[clippy::has_significant_drop] pub struct MappedRwLockReadGuard<'a, T: ?Sized + 'a> { // NB: we use a pointer instead of `&'a T` to avoid `noalias` violations, because a @@ -169,10 +169,10 @@ pub struct MappedRwLockReadGuard<'a, T: ?Sized + 'a> { inner_lock: &'a sys::RwLock, } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl !Send for MappedRwLockReadGuard<'_, T> {} -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] unsafe impl Sync for MappedRwLockReadGuard<'_, T> {} /// RAII structure used to release the exclusive write access of a lock when @@ -187,9 +187,13 @@ unsafe impl Sync for MappedRwLockReadGuard<'_, T> {} #[must_not_suspend = "holding a MappedRwLockWriteGuard across suspend \ points can cause deadlocks, delays, \ and cause Future's to not implement `Send`"] -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] #[clippy::has_significant_drop] pub struct MappedRwLockWriteGuard<'a, T: ?Sized + 'a> { + // NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a + // `MappedRwLockWriteGuard` argument doesn't hold uniqueness for its whole scope, only until it drops. + // `NonNull` is covariant over `T`, so we add a `PhantomData<&'a mut T>` field + // below for the correct variance over `T` (invariance). data: NonNull, inner_lock: &'a sys::RwLock, poison_flag: &'a poison::Flag, @@ -197,10 +201,10 @@ pub struct MappedRwLockWriteGuard<'a, T: ?Sized + 'a> { _variance: PhantomData<&'a mut T>, } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl !Send for MappedRwLockWriteGuard<'_, T> {} -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] unsafe impl Sync for MappedRwLockWriteGuard<'_, T> {} impl RwLock { @@ -621,28 +625,28 @@ impl fmt::Display for RwLockWriteGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl fmt::Debug for MappedRwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl fmt::Display for MappedRwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl fmt::Debug for MappedRwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl fmt::Display for MappedRwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) @@ -677,7 +681,7 @@ impl DerefMut for RwLockWriteGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl Deref for MappedRwLockReadGuard<'_, T> { type Target = T; @@ -688,7 +692,7 @@ impl Deref for MappedRwLockReadGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl Deref for MappedRwLockWriteGuard<'_, T> { type Target = T; @@ -699,7 +703,7 @@ impl Deref for MappedRwLockWriteGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl DerefMut for MappedRwLockWriteGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard @@ -729,7 +733,7 @@ impl Drop for RwLockWriteGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl Drop for MappedRwLockReadGuard<'_, T> { fn drop(&mut self) { // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard @@ -740,7 +744,7 @@ impl Drop for MappedRwLockReadGuard<'_, T> { } } -#[unstable(feature = "mapped_lock_guards", issue = "none")] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] impl Drop for MappedRwLockWriteGuard<'_, T> { fn drop(&mut self) { self.poison_flag.done(&self.poison); @@ -762,7 +766,7 @@ impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { /// `RwLockReadGuard::map(...)`. A method would interfere with methods of /// the same name on the contents of the `RwLockReadGuard` used through /// `Deref`. - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> where F: FnOnce(&T) -> &U, @@ -784,7 +788,7 @@ impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { /// of the same name on the contents of the `RwLockReadGuard` used through /// `Deref`. #[doc(alias = "filter_map")] - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> where F: FnOnce(&T) -> Option<&U>, @@ -808,7 +812,7 @@ impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { /// `MappedRwLockReadGuard::map(...)`. A method would interfere with /// methods of the same name on the contents of the `MappedRwLockReadGuard` /// used through `Deref`. - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> where F: FnOnce(&T) -> &U, @@ -830,7 +834,7 @@ impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { /// methods of the same name on the contents of the `MappedRwLockReadGuard` /// used through `Deref`. #[doc(alias = "filter_map")] - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> where F: FnOnce(&T) -> Option<&U>, @@ -854,7 +858,7 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { /// `RwLockWriteGuard::map(...)`. A method would interfere with methods of /// the same name on the contents of the `RwLockWriteGuard` used through /// `Deref`. - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, @@ -882,7 +886,7 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { /// of the same name on the contents of the `RwLockWriteGuard` used through /// `Deref`. #[doc(alias = "filter_map")] - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, @@ -912,7 +916,7 @@ impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> { /// `MappedRwLockWriteGuard::map(...)`. A method would interfere with /// methods of the same name on the contents of the `MappedRwLockWriteGuard` /// used through `Deref`. - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, @@ -940,7 +944,7 @@ impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> { /// methods of the same name on the contents of the `MappedRwLockWriteGuard` /// used through `Deref`. #[doc(alias = "filter_map")] - #[unstable(feature = "mapped_lock_guards", issue = "none")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, From 20fa3a0d8f529b428eeacf7cce184345f200654d Mon Sep 17 00:00:00 2001 From: Zachary S Date: Mon, 23 Oct 2023 17:03:17 -0500 Subject: [PATCH 005/417] Fix Condvar typo, add public re-exports of Mapped*Guard. --- library/std/src/sync/mod.rs | 4 ++++ library/std/src/sync/mutex.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index f6a7c0a9f7549..ca62179e95b66 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -165,6 +165,8 @@ pub use core::sync::Exclusive; pub use self::barrier::{Barrier, BarrierWaitResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::condvar::{Condvar, WaitTimeoutResult}; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +pub use self::mutex::MappedMutexGuard; #[stable(feature = "rust1", since = "1.0.0")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] @@ -172,6 +174,8 @@ pub use self::mutex::{Mutex, MutexGuard}; pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult}; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index a435fba4f1ea2..5a419f4bd8465 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -221,7 +221,7 @@ unsafe impl Sync for MutexGuard<'_, T> {} /// of scope), the lock will be unlocked. /// /// The main difference between `MappedMutexGuard` and [`MutexGuard`] is that the -/// former cannot be used with [`CondVar`], since that +/// former cannot be used with [`Condvar`], since that /// could introduce soundness issues if the locked object is modified by another /// thread while the `Mutex` is unlocked. /// @@ -233,7 +233,7 @@ unsafe impl Sync for MutexGuard<'_, T> {} /// /// [`map`]: MutexGuard::map /// [`try_map`]: MutexGuard::try_map -/// [`CondVar`]: crate::sync::CondVar +/// [`Condvar`]: crate::sync::Condvar #[must_use = "if unused the Mutex will immediately unlock"] #[must_not_suspend = "holding a MappedMutexGuard across suspend \ points can cause deadlocks, delays, \ From 5533606fe0def63a62a3f75be4eb2d87081a05c4 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 24 Oct 2023 13:32:53 -0500 Subject: [PATCH 006/417] Add MappedMutexGuard and MappedRwLock*Guard tests. --- library/std/src/sync/mutex/tests.rs | 30 +++++++- library/std/src/sync/rwlock/tests.rs | 105 ++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/library/std/src/sync/mutex/tests.rs b/library/std/src/sync/mutex/tests.rs index 1786a3c09ffb5..cf69813baa3c5 100644 --- a/library/std/src/sync/mutex/tests.rs +++ b/library/std/src/sync/mutex/tests.rs @@ -1,6 +1,6 @@ use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::mpsc::channel; -use crate::sync::{Arc, Condvar, Mutex}; +use crate::sync::{Arc, Condvar, MappedMutexGuard, Mutex, MutexGuard}; use crate::thread; struct Packet(Arc<(Mutex, Condvar)>); @@ -188,6 +188,21 @@ fn test_mutex_arc_poison() { assert!(arc.is_poisoned()); } +#[test] +fn test_mutex_arc_poison_mapped() { + let arc = Arc::new(Mutex::new(1)); + assert!(!arc.is_poisoned()); + let arc2 = arc.clone(); + let _ = thread::spawn(move || { + let lock = arc2.lock().unwrap(); + let lock = MutexGuard::map(lock, |val| val); + assert_eq!(*lock, 2); // deliberate assertion failure to poison the mutex + }) + .join(); + assert!(arc.lock().is_err()); + assert!(arc.is_poisoned()); +} + #[test] fn test_mutex_arc_nested() { // Tests nested mutexes and access @@ -236,3 +251,16 @@ fn test_mutex_unsized() { let comp: &[i32] = &[4, 2, 5]; assert_eq!(&*mutex.lock().unwrap(), comp); } + +#[test] +fn test_mapping_mapped_guard() { + let arr = [0; 4]; + let mut lock = Mutex::new(arr); + let guard = lock.lock().unwrap(); + let guard = MutexGuard::map(guard, |arr| &mut arr[..2]); + let mut guard = MappedMutexGuard::map(guard, |slice| &mut slice[1..]); + assert_eq!(guard.len(), 1); + guard[0] = 42; + drop(guard); + assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); +} diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs index 1a9d3d3f12f3c..0a5eb7aac023f 100644 --- a/library/std/src/sync/rwlock/tests.rs +++ b/library/std/src/sync/rwlock/tests.rs @@ -1,6 +1,9 @@ use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::mpsc::channel; -use crate::sync::{Arc, RwLock, RwLockReadGuard, TryLockError}; +use crate::sync::{ + Arc, MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, + TryLockError, +}; use crate::thread; use rand::Rng; @@ -55,6 +58,19 @@ fn test_rw_arc_poison_wr() { assert!(arc.read().is_err()); } +#[test] +fn test_rw_arc_poison_mapped_w_r() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.write().unwrap(); + let _lock = RwLockWriteGuard::map(lock, |val| val); + panic!(); + }) + .join(); + assert!(arc.read().is_err()); +} + #[test] fn test_rw_arc_poison_ww() { let arc = Arc::new(RwLock::new(1)); @@ -69,6 +85,20 @@ fn test_rw_arc_poison_ww() { assert!(arc.is_poisoned()); } +#[test] +fn test_rw_arc_poison_mapped_w_w() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.write().unwrap(); + let _lock = RwLockWriteGuard::map(lock, |val| val); + panic!(); + }) + .join(); + assert!(arc.write().is_err()); + assert!(arc.is_poisoned()); +} + #[test] fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RwLock::new(1)); @@ -81,6 +111,21 @@ fn test_rw_arc_no_poison_rr() { let lock = arc.read().unwrap(); assert_eq!(*lock, 1); } + +#[test] +fn test_rw_arc_no_poison_mapped_r_r() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.read().unwrap(); + let _lock = RwLockReadGuard::map(lock, |val| val); + panic!(); + }) + .join(); + let lock = arc.read().unwrap(); + assert_eq!(*lock, 1); +} + #[test] fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RwLock::new(1)); @@ -94,6 +139,20 @@ fn test_rw_arc_no_poison_rw() { assert_eq!(*lock, 1); } +#[test] +fn test_rw_arc_no_poison_mapped_r_w() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.read().unwrap(); + let _lock = RwLockReadGuard::map(lock, |val| val); + panic!(); + }) + .join(); + let lock = arc.write().unwrap(); + assert_eq!(*lock, 1); +} + #[test] fn test_rw_arc() { let arc = Arc::new(RwLock::new(0)); @@ -179,6 +238,16 @@ fn test_rwlock_try_write() { } drop(read_guard); + let mapped_read_guard = RwLockReadGuard::map(lock.read().unwrap(), |_| &()); + + let write_result = lock.try_write(); + match write_result { + Err(TryLockError::WouldBlock) => (), + Ok(_) => assert!(false, "try_write should not succeed while mapped_read_guard is in scope"), + Err(_) => assert!(false, "unexpected error"), + } + + drop(mapped_read_guard); } #[test] @@ -257,3 +326,37 @@ fn test_read_guard_covariance() { } drop(lock); } + +#[test] +fn test_mapped_read_guard_covariance() { + fn do_stuff<'a>(_: MappedRwLockReadGuard<'_, &'a i32>, _: &'a i32) {} + let j: i32 = 5; + let lock = RwLock::new((&j, &j)); + { + let i = 6; + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map(guard, |(val, _val)| val); + do_stuff(guard, &i); + } + drop(lock); +} + +#[test] +fn test_mapping_mapped_guard() { + let arr = [0; 4]; + let mut lock = RwLock::new(arr); + let guard = lock.write().unwrap(); + let guard = RwLockWriteGuard::map(guard, |arr| &mut arr[..2]); + let mut guard = MappedRwLockWriteGuard::map(guard, |slice| &mut slice[1..]); + assert_eq!(guard.len(), 1); + guard[0] = 42; + drop(guard); + assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); + + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map(guard, |arr| &arr[..2]); + let guard = MappedRwLockReadGuard::map(guard, |slice| &slice[1..]); + assert_eq!(*guard, [42]); + drop(guard); + assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); +} From 6aebcbee0a4d232f675eb380269bb405b0a1cc32 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 24 Oct 2023 14:09:04 -0500 Subject: [PATCH 007/417] fix MappedMutexGuard::(try_)map doc typo. --- library/std/src/sync/mutex.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 5a419f4bd8465..1b3b4a3027cd7 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -701,7 +701,7 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { /// The `Mutex` is already locked, so this cannot fail. /// /// This is an associated function that needs to be used as - /// `MutexGuard::map(...)`. A method would interfere with methods of the + /// `MappedMutexGuard::map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> @@ -727,7 +727,7 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { /// The `Mutex` is already locked, so this cannot fail. /// /// This is an associated function that needs to be used as - /// `MutexGuard::try_map(...)`. A method would interfere with methods of the + /// `MappedMutexGuard::try_map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. #[doc(alias = "filter_map")] #[unstable(feature = "mapped_lock_guards", issue = "117108")] From 3ef4b083ac03fd25339be009e3ae525adab30d78 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Thu, 26 Oct 2023 13:33:54 -0500 Subject: [PATCH 008/417] Specify behavior if the closure passed to *Guard::*map panics. --- library/std/src/sync/mutex.rs | 78 +++++++++----- library/std/src/sync/mutex/tests.rs | 63 ++++++++++- library/std/src/sync/rwlock.rs | 156 ++++++++++++++++++++------- library/std/src/sync/rwlock/tests.rs | 136 +++++++++++++++++++++++ 4 files changed, 364 insertions(+), 69 deletions(-) diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 1b3b4a3027cd7..1b05247bb7c7c 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -612,10 +612,14 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { F: FnOnce(&mut T) -> &mut U, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - let value = NonNull::from(f(&mut *orig)); + // SAFETY: the conditions of `MutedGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { &mut *orig.lock.data.get() })); + let orig = ManuallyDrop::new(orig); MappedMutexGuard { - data: value, + data, inner: &orig.lock.inner, poison_flag: &orig.lock.poison, poison: orig.poison.clone(), @@ -639,16 +643,23 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { F: FnOnce(&mut T) -> Option<&mut U>, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - match f(&mut *orig).map(NonNull::from) { - Some(value) => Ok(MappedMutexGuard { - data: value, - inner: &orig.lock.inner, - poison_flag: &orig.lock.poison, - poison: orig.poison.clone(), - _variance: PhantomData, - }), - None => Err(ManuallyDrop::into_inner(orig)), + // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { &mut *orig.lock.data.get() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedMutexGuard { + data, + inner: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), } } } @@ -704,15 +715,19 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { /// `MappedMutexGuard::map(...)`. A method would interfere with methods of the /// same name on the contents of the `MutexGuard` used through `Deref`. #[unstable(feature = "mapped_lock_guards", issue = "117108")] - pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> + pub fn map(mut orig: Self, f: F) -> MappedMutexGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - let value = NonNull::from(f(&mut *orig)); + // SAFETY: the conditions of `MutedGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_mut() })); + let orig = ManuallyDrop::new(orig); MappedMutexGuard { - data: value, + data, inner: orig.inner, poison_flag: orig.poison_flag, poison: orig.poison.clone(), @@ -731,21 +746,28 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { /// same name on the contents of the `MutexGuard` used through `Deref`. #[doc(alias = "filter_map")] #[unstable(feature = "mapped_lock_guards", issue = "117108")] - pub fn try_map(orig: Self, f: F) -> Result, Self> + pub fn try_map(mut orig: Self, f: F) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - match f(&mut *orig).map(NonNull::from) { - Some(value) => Ok(MappedMutexGuard { - data: value, - inner: orig.inner, - poison_flag: orig.poison_flag, - poison: orig.poison.clone(), - _variance: PhantomData, - }), - None => Err(ManuallyDrop::into_inner(orig)), + // SAFETY: the conditions of `MutedGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_mut() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedMutexGuard { + data, + inner: orig.inner, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), } } } diff --git a/library/std/src/sync/mutex/tests.rs b/library/std/src/sync/mutex/tests.rs index cf69813baa3c5..19ec096c59334 100644 --- a/library/std/src/sync/mutex/tests.rs +++ b/library/std/src/sync/mutex/tests.rs @@ -1,6 +1,6 @@ use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::mpsc::channel; -use crate::sync::{Arc, Condvar, MappedMutexGuard, Mutex, MutexGuard}; +use crate::sync::{Arc, Condvar, MappedMutexGuard, Mutex, MutexGuard, TryLockError}; use crate::thread; struct Packet(Arc<(Mutex, Condvar)>); @@ -264,3 +264,64 @@ fn test_mapping_mapped_guard() { drop(guard); assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); } + +#[test] +fn panic_while_mapping_unlocked_poison() { + let lock = Mutex::new(()); + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let _guard = MutexGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MutexGuard::map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MutexGuard::map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let _guard = MutexGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MutexGuard::try_map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MutexGuard::try_map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let guard = MutexGuard::map::<(), _>(guard, |val| val); + let _guard = MappedMutexGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MappedMutexGuard::map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MappedMutexGuard::map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let guard = MutexGuard::map::<(), _>(guard, |val| val); + let _guard = MappedMutexGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MappedMutexGuard::try_map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MappedMutexGuard::try_map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + drop(lock); +} diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index def0c8a16c7ce..5c4e4a784dbf5 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -766,15 +766,23 @@ impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { /// `RwLockReadGuard::map(...)`. A method would interfere with methods of /// the same name on the contents of the `RwLockReadGuard` used through /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> where F: FnOnce(&T) -> &U, U: ?Sized, { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_ref() })); let orig = ManuallyDrop::new(orig); - let value = NonNull::from(f(&*orig)); - MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock } + MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } } /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. The @@ -787,6 +795,10 @@ impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { /// `RwLockReadGuard::try_map(...)`. A method would interfere with methods /// of the same name on the contents of the `RwLockReadGuard` used through /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. #[doc(alias = "filter_map")] #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> @@ -794,10 +806,17 @@ impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { F: FnOnce(&T) -> Option<&U>, U: ?Sized, { - let orig = ManuallyDrop::new(orig); - match f(&*orig).map(NonNull::from) { - Some(value) => Ok(MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock }), - None => Err(ManuallyDrop::into_inner(orig)), + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_ref() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + } + None => Err(orig), } } } @@ -812,15 +831,23 @@ impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { /// `MappedRwLockReadGuard::map(...)`. A method would interfere with /// methods of the same name on the contents of the `MappedRwLockReadGuard` /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> where F: FnOnce(&T) -> &U, U: ?Sized, { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_ref() })); let orig = ManuallyDrop::new(orig); - let value = NonNull::from(f(&*orig)); - MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock } + MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } } /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. @@ -833,6 +860,10 @@ impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { /// `MappedRwLockReadGuard::try_map(...)`. A method would interfere with /// methods of the same name on the contents of the `MappedRwLockReadGuard` /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. #[doc(alias = "filter_map")] #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> @@ -840,10 +871,17 @@ impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { F: FnOnce(&T) -> Option<&U>, U: ?Sized, { - let orig = ManuallyDrop::new(orig); - match f(&*orig).map(NonNull::from) { - Some(value) => Ok(MappedRwLockReadGuard { data: value, inner_lock: &orig.inner_lock }), - None => Err(ManuallyDrop::into_inner(orig)), + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_ref() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + } + None => Err(orig), } } } @@ -858,16 +896,24 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { /// `RwLockWriteGuard::map(...)`. A method would interfere with methods of /// the same name on the contents of the `RwLockWriteGuard` used through /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - let value = NonNull::from(f(&mut *orig)); + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { &mut *orig.lock.data.get() })); + let orig = ManuallyDrop::new(orig); MappedRwLockWriteGuard { - data: value, + data, inner_lock: &orig.lock.inner, poison_flag: &orig.lock.poison, poison: orig.poison.clone(), @@ -885,6 +931,10 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { /// `RwLockWriteGuard::try_map(...)`. A method would interfere with methods /// of the same name on the contents of the `RwLockWriteGuard` used through /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. #[doc(alias = "filter_map")] #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub fn try_map(orig: Self, f: F) -> Result, Self> @@ -892,16 +942,23 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { F: FnOnce(&mut T) -> Option<&mut U>, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - match f(&mut *orig).map(NonNull::from) { - Some(value) => Ok(MappedRwLockWriteGuard { - data: value, - inner_lock: &orig.lock.inner, - poison_flag: &orig.lock.poison, - poison: orig.poison.clone(), - _variance: PhantomData, - }), - None => Err(ManuallyDrop::into_inner(orig)), + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { &mut *orig.lock.data.get() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockWriteGuard { + data, + inner_lock: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), } } } @@ -916,16 +973,24 @@ impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> { /// `MappedRwLockWriteGuard::map(...)`. A method would interfere with /// methods of the same name on the contents of the `MappedRwLockWriteGuard` /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. #[unstable(feature = "mapped_lock_guards", issue = "117108")] - pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> + pub fn map(mut orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - let value = NonNull::from(f(&mut *orig)); + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_mut() })); + let orig = ManuallyDrop::new(orig); MappedRwLockWriteGuard { - data: value, + data, inner_lock: orig.inner_lock, poison_flag: orig.poison_flag, poison: orig.poison.clone(), @@ -943,23 +1008,34 @@ impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> { /// `MappedRwLockWriteGuard::try_map(...)`. A method would interfere with /// methods of the same name on the contents of the `MappedRwLockWriteGuard` /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. #[doc(alias = "filter_map")] #[unstable(feature = "mapped_lock_guards", issue = "117108")] - pub fn try_map(orig: Self, f: F) -> Result, Self> + pub fn try_map(mut orig: Self, f: F) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, U: ?Sized, { - let mut orig = ManuallyDrop::new(orig); - match f(&mut *orig).map(NonNull::from) { - Some(value) => Ok(MappedRwLockWriteGuard { - data: value, - inner_lock: orig.inner_lock, - poison_flag: orig.poison_flag, - poison: orig.poison.clone(), - _variance: PhantomData, - }), - None => Err(ManuallyDrop::into_inner(orig)), + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_mut() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockWriteGuard { + data, + inner_lock: orig.inner_lock, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), } } } diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs index 0a5eb7aac023f..9cc5e7a3a60f1 100644 --- a/library/std/src/sync/rwlock/tests.rs +++ b/library/std/src/sync/rwlock/tests.rs @@ -360,3 +360,139 @@ fn test_mapping_mapped_guard() { drop(guard); assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); } + +#[test] +fn panic_while_mapping_read_unlocked_no_poison() { + let lock = RwLock::new(()); + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let _guard = RwLockReadGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockReadGuard::map closure should release the read lock") + } + Err(TryLockError::Poisoned(_)) => { + panic!("panicking in a RwLockReadGuard::map closure should not poison the RwLock") + } + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let _guard = RwLockReadGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockReadGuard::try_map closure should release the read lock") + } + Err(TryLockError::Poisoned(_)) => { + panic!("panicking in a RwLockReadGuard::try_map closure should not poison the RwLock") + } + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockReadGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MappedRwLockReadGuard::map closure should release the read lock") + } + Err(TryLockError::Poisoned(_)) => { + panic!("panicking in a MappedRwLockReadGuard::map closure should not poison the RwLock") + } + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockReadGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => panic!( + "panicking in a MappedRwLockReadGuard::try_map closure should release the read lock" + ), + Err(TryLockError::Poisoned(_)) => panic!( + "panicking in a MappedRwLockReadGuard::try_map closure should not poison the RwLock" + ), + } + + drop(lock); +} + +#[test] +fn panic_while_mapping_write_unlocked_poison() { + let lock = RwLock::new(()); + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let _guard = RwLockWriteGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => panic!("panicking in a RwLockWriteGuard::map closure should poison the RwLock"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockWriteGuard::map closure should release the write lock") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let _guard = RwLockWriteGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => { + panic!("panicking in a RwLockWriteGuard::try_map closure should poison the RwLock") + } + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockWriteGuard::try_map closure should release the write lock") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let guard = RwLockWriteGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockWriteGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => { + panic!("panicking in a MappedRwLockWriteGuard::map closure should poison the RwLock") + } + Err(TryLockError::WouldBlock) => panic!( + "panicking in a MappedRwLockWriteGuard::map closure should release the write lock" + ), + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let guard = RwLockWriteGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockWriteGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => panic!( + "panicking in a MappedRwLockWriteGuard::try_map closure should poison the RwLock" + ), + Err(TryLockError::WouldBlock) => panic!( + "panicking in a MappedRwLockWriteGuard::try_map closure should release the write lock" + ), + Err(TryLockError::Poisoned(_)) => {} + } + + drop(lock); +} From 06ec7a7611bfcfd228507988a325f229d425598f Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 5 Dec 2023 18:10:39 -0600 Subject: [PATCH 009/417] fmt --- library/std/src/sync/rwlock.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 5c4e4a784dbf5..b985988d760c9 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -590,10 +590,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { // SAFETY: if and only if `lock.inner.write()` (or `lock.inner.try_write()`) has been // successfully called from the same thread before instantiating this object. unsafe fn new(lock: &'rwlock RwLock) -> LockResult> { - poison::map_result(lock.poison.guard(), |guard| RwLockWriteGuard { - lock, - poison: guard, - }) + poison::map_result(lock.poison.guard(), |guard| RwLockWriteGuard { lock, poison: guard }) } } From 84e797499b803aed222b027e466113d2947c38ad Mon Sep 17 00:00:00 2001 From: roife Date: Mon, 1 Jan 2024 16:17:22 +0800 Subject: [PATCH 010/417] Add autofix for functions in unnecessary_fallible_conversions --- .../unnecessary_fallible_conversions.rs | 101 ++++++++++++------ 1 file changed, 68 insertions(+), 33 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index 89cf20c14fc6a..b646c5953e414 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::get_parent_expr; use clippy_utils::ty::implements_trait; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind}; +use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::print::with_forced_trimmed_paths; @@ -29,6 +29,7 @@ fn check<'tcx>( node_args: ty::GenericArgsRef<'tcx>, kind: FunctionKind, primary_span: Span, + qpath: Option<&QPath<'_>>, ) { if let &[self_ty, other_ty] = node_args.as_slice() // useless_conversion already warns `T::try_from(T)`, so ignore it here @@ -45,47 +46,79 @@ fn check<'tcx>( && implements_trait(cx, self_ty, from_into_trait, &[other_ty]) && let Some(other_ty) = other_ty.as_type() { + // Extend the span to include the unwrap/expect call: + // `foo.try_into().expect("..")` + // ^^^^^^^^^^^^^^^^^^^^^^^ + // + // `try_into().unwrap()` specifically can be trivially replaced with just `into()`, + // so that can be machine-applicable let parent_unwrap_call = get_parent_expr(cx, expr).and_then(|parent| { if let ExprKind::MethodCall(path, .., span) = parent.kind && let sym::unwrap | sym::expect = path.ident.name { - Some(span) + // include `.` before `unwrap`/`expect` + Some(span.with_lo(expr.span.hi())) } else { None } }); - let (source_ty, target_ty, sugg, span, applicability) = match kind { - FunctionKind::TryIntoMethod if let Some(unwrap_span) = parent_unwrap_call => { - // Extend the span to include the unwrap/expect call: - // `foo.try_into().expect("..")` - // ^^^^^^^^^^^^^^^^^^^^^^^ - // - // `try_into().unwrap()` specifically can be trivially replaced with just `into()`, - // so that can be machine-applicable - ( - self_ty, - other_ty, - "into()", - primary_span.with_hi(unwrap_span.hi()), - Applicability::MachineApplicable, - ) + let span = if let Some(unwrap_call) = parent_unwrap_call { + primary_span.with_hi(unwrap_call.hi()) + } else { + primary_span + }; + + let qpath_spans = qpath.and_then(|qpath| match qpath { + QPath::Resolved(_, path) => { + let segments = path.segments.iter().map(|seg| seg.ident).collect::>(); + (segments.len() == 2).then(|| vec![segments[0].span, segments[1].span]) + }, + QPath::TypeRelative(_, seg) => Some(vec![seg.ident.span]), + QPath::LangItem(_, _) => unreachable!("`TryFrom` and `TryInto` are not lang items"), + }); + + let (source_ty, target_ty, sugg, applicability) = match (kind, &qpath_spans, parent_unwrap_call) { + (FunctionKind::TryIntoMethod, _, Some(unwrap_span)) => { + let sugg = vec![(primary_span, String::from("into")), (unwrap_span, String::new())]; + (self_ty, other_ty, sugg, Applicability::MachineApplicable) + }, + (FunctionKind::TryFromFunction, Some(spans), Some(unwrap_span)) => { + let sugg = match spans.len() { + 1 => vec![(spans[0], String::from("from")), (unwrap_span, String::new())], + 2 => vec![ + (spans[0], String::from("From")), + (spans[1], String::from("from")), + (unwrap_span, String::new()), + ], + _ => unreachable!(), + }; + (other_ty, self_ty, sugg, Applicability::MachineApplicable) + }, + (FunctionKind::TryIntoFunction, Some(spans), Some(unwrap_span)) => { + let sugg = match spans.len() { + 1 => vec![(spans[0], String::from("into")), (unwrap_span, String::new())], + 2 => vec![ + (spans[0], String::from("Into")), + (spans[1], String::from("into")), + (unwrap_span, String::new()), + ], + _ => unreachable!(), + }; + (self_ty, other_ty, sugg, Applicability::MachineApplicable) + }, + (FunctionKind::TryFromFunction, _, _) => { + let sugg = vec![(primary_span, String::from("From::from"))]; + (other_ty, self_ty, sugg, Applicability::Unspecified) + }, + (FunctionKind::TryIntoFunction, _, _) => { + let sugg = vec![(primary_span, String::from("Into::into"))]; + (self_ty, other_ty, sugg, Applicability::Unspecified) + }, + (FunctionKind::TryIntoMethod, _, _) => { + let sugg = vec![(primary_span, String::from("into"))]; + (self_ty, other_ty, sugg, Applicability::Unspecified) }, - FunctionKind::TryFromFunction => ( - other_ty, - self_ty, - "From::from", - primary_span, - Applicability::Unspecified, - ), - FunctionKind::TryIntoFunction => ( - self_ty, - other_ty, - "Into::into", - primary_span, - Applicability::Unspecified, - ), - FunctionKind::TryIntoMethod => (self_ty, other_ty, "into", primary_span, Applicability::Unspecified), }; span_lint_and_then( @@ -97,7 +130,7 @@ fn check<'tcx>( with_forced_trimmed_paths!({ diag.note(format!("converting `{source_ty}` to `{target_ty}` cannot fail")); }); - diag.span_suggestion(span, "use", sugg, applicability); + diag.multipart_suggestion("use", sugg, applicability); }, ); } @@ -113,6 +146,7 @@ pub(super) fn check_method(cx: &LateContext<'_>, expr: &Expr<'_>) { cx.typeck_results().node_args(expr.hir_id), FunctionKind::TryIntoMethod, path.ident.span, + None, ); } } @@ -135,6 +169,7 @@ pub(super) fn check_function(cx: &LateContext<'_>, expr: &Expr<'_>, callee: &Exp _ => return, }, callee.span, + Some(qpath), ); } } From 69cc9831553cf40c0ee63bfc614827c438c438bf Mon Sep 17 00:00:00 2001 From: roife Date: Mon, 1 Jan 2024 16:17:46 +0800 Subject: [PATCH 011/417] Add tests for autofix in unnecessary_fallible_conversions --- .../ui/unnecessary_fallible_conversions.fixed | 12 ++ tests/ui/unnecessary_fallible_conversions.rs | 14 ++ .../unnecessary_fallible_conversions.stderr | 124 +++++++++++++++++- 3 files changed, 147 insertions(+), 3 deletions(-) diff --git a/tests/ui/unnecessary_fallible_conversions.fixed b/tests/ui/unnecessary_fallible_conversions.fixed index 9668a6b99bf08..f6027fbfa6a9b 100644 --- a/tests/ui/unnecessary_fallible_conversions.fixed +++ b/tests/ui/unnecessary_fallible_conversions.fixed @@ -3,4 +3,16 @@ fn main() { let _: i64 = 0i32.into(); let _: i64 = 0i32.into(); + + let _ = i64::from(0i32); + let _ = i64::from(0i32); + + let _: i64 = i32::into(0); + let _: i64 = i32::into(0i32); + + let _ = >::from(0); + let _ = >::from(0); + + let _: i64 = >::into(0); + let _: i64 = >::into(0); } diff --git a/tests/ui/unnecessary_fallible_conversions.rs b/tests/ui/unnecessary_fallible_conversions.rs index 9fa6c08b1b07e..f9df782c4e25c 100644 --- a/tests/ui/unnecessary_fallible_conversions.rs +++ b/tests/ui/unnecessary_fallible_conversions.rs @@ -3,4 +3,18 @@ fn main() { let _: i64 = 0i32.try_into().unwrap(); let _: i64 = 0i32.try_into().expect("can't happen"); + + let _ = i64::try_from(0i32).unwrap(); + let _ = i64::try_from(0i32).expect("can't happen"); + + let _: i64 = i32::try_into(0).unwrap(); + let _: i64 = i32::try_into(0i32).expect("can't happen"); + + let _ = >::try_from(0) + .unwrap(); + let _ = >::try_from(0). + expect("can't happen"); + + let _: i64 = >::try_into(0).unwrap(); + let _: i64 = >::try_into(0).expect("can't happen"); } diff --git a/tests/ui/unnecessary_fallible_conversions.stderr b/tests/ui/unnecessary_fallible_conversions.stderr index 26b152515ac7c..603c079bc0eb2 100644 --- a/tests/ui/unnecessary_fallible_conversions.stderr +++ b/tests/ui/unnecessary_fallible_conversions.stderr @@ -2,19 +2,137 @@ error: use of a fallible conversion when an infallible one could be used --> $DIR/unnecessary_fallible_conversions.rs:4:23 | LL | let _: i64 = 0i32.try_into().unwrap(); - | ^^^^^^^^^^^^^^^^^^^ help: use: `into()` + | ^^^^^^^^^^^^^^^^^^^ | = note: converting `i32` to `i64` cannot fail = note: `-D clippy::unnecessary-fallible-conversions` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fallible_conversions)]` +help: use + | +LL - let _: i64 = 0i32.try_into().unwrap(); +LL + let _: i64 = 0i32.into(); + | error: use of a fallible conversion when an infallible one could be used --> $DIR/unnecessary_fallible_conversions.rs:5:23 | LL | let _: i64 = 0i32.try_into().expect("can't happen"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `into()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = 0i32.try_into().expect("can't happen"); +LL + let _: i64 = 0i32.into(); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:7:13 + | +LL | let _ = i64::try_from(0i32).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = i64::try_from(0i32).unwrap(); +LL + let _ = i64::from(0i32); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:8:13 + | +LL | let _ = i64::try_from(0i32).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = i64::try_from(0i32).expect("can't happen"); +LL + let _ = i64::from(0i32); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:10:18 + | +LL | let _: i64 = i32::try_into(0).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = i32::try_into(0).unwrap(); +LL + let _: i64 = i32::into(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:11:18 + | +LL | let _: i64 = i32::try_into(0i32).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = i32::try_into(0i32).expect("can't happen"); +LL + let _: i64 = i32::into(0i32); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:13:13 + | +LL | let _ = >::try_from(0) + | _____________^ +LL | | .unwrap(); + | |_________________^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = >::try_from(0) +LL + let _ = >::from(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:15:13 + | +LL | let _ = >::try_from(0). + | _____________^ +LL | | expect("can't happen"); + | |______________________________^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = >::try_from(0). +LL + let _ = >::from(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:18:18 + | +LL | let _: i64 = >::try_into(0).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = >::try_into(0).unwrap(); +LL + let _: i64 = >::into(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> $DIR/unnecessary_fallible_conversions.rs:19:18 + | +LL | let _: i64 = >::try_into(0).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = >::try_into(0).expect("can't happen"); +LL + let _: i64 = >::into(0); + | -error: aborting due to 2 previous errors +error: aborting due to 10 previous errors From 094ce3de3ee98842c9a2ffc74934959973da5d1b Mon Sep 17 00:00:00 2001 From: roife Date: Mon, 1 Jan 2024 16:28:34 +0800 Subject: [PATCH 012/417] Add comments for unnecessary_fallible_conversions --- .../unnecessary_fallible_conversions.rs | 1 + tests/ui/unnecessary_fallible_conversions.rs | 6 ++--- .../unnecessary_fallible_conversions.stderr | 22 ++++++++----------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index b646c5953e414..5306939163396 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -63,6 +63,7 @@ fn check<'tcx>( } }); + // If there is an unwrap/expect call, extend the span to include the call let span = if let Some(unwrap_call) = parent_unwrap_call { primary_span.with_hi(unwrap_call.hi()) } else { diff --git a/tests/ui/unnecessary_fallible_conversions.rs b/tests/ui/unnecessary_fallible_conversions.rs index f9df782c4e25c..9e4fd3b3f9037 100644 --- a/tests/ui/unnecessary_fallible_conversions.rs +++ b/tests/ui/unnecessary_fallible_conversions.rs @@ -10,10 +10,8 @@ fn main() { let _: i64 = i32::try_into(0).unwrap(); let _: i64 = i32::try_into(0i32).expect("can't happen"); - let _ = >::try_from(0) - .unwrap(); - let _ = >::try_from(0). - expect("can't happen"); + let _ = >::try_from(0).unwrap(); + let _ = >::try_from(0).expect("can't happen"); let _: i64 = >::try_into(0).unwrap(); let _: i64 = >::try_into(0).expect("can't happen"); diff --git a/tests/ui/unnecessary_fallible_conversions.stderr b/tests/ui/unnecessary_fallible_conversions.stderr index 603c079bc0eb2..c16dd239a8b57 100644 --- a/tests/ui/unnecessary_fallible_conversions.stderr +++ b/tests/ui/unnecessary_fallible_conversions.stderr @@ -81,35 +81,31 @@ LL + let _: i64 = i32::into(0i32); error: use of a fallible conversion when an infallible one could be used --> $DIR/unnecessary_fallible_conversions.rs:13:13 | -LL | let _ = >::try_from(0) - | _____________^ -LL | | .unwrap(); - | |_________________^ +LL | let _ = >::try_from(0).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: converting `i32` to `i64` cannot fail help: use | -LL - let _ = >::try_from(0) +LL - let _ = >::try_from(0).unwrap(); LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:15:13 + --> $DIR/unnecessary_fallible_conversions.rs:14:13 | -LL | let _ = >::try_from(0). - | _____________^ -LL | | expect("can't happen"); - | |______________________________^ +LL | let _ = >::try_from(0).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: converting `i32` to `i64` cannot fail help: use | -LL - let _ = >::try_from(0). +LL - let _ = >::try_from(0).expect("can't happen"); LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:18:18 + --> $DIR/unnecessary_fallible_conversions.rs:16:18 | LL | let _: i64 = >::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +118,7 @@ LL + let _: i64 = >::into(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:19:18 + --> $DIR/unnecessary_fallible_conversions.rs:17:18 | LL | let _: i64 = >::try_into(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 1cce757672d9a7ec5fd19628fa4e5f00b31c8f8a Mon Sep 17 00:00:00 2001 From: roife Date: Tue, 2 Jan 2024 01:23:44 +0800 Subject: [PATCH 013/417] Add error-annotations in tests for unnecessary_fallible_conversions --- .../ui/unnecessary_fallible_conversions.fixed | 25 +++++++++++++++++++ tests/ui/unnecessary_fallible_conversions.rs | 25 +++++++++++++++++++ .../unnecessary_fallible_conversions.stderr | 20 +++++++-------- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/tests/ui/unnecessary_fallible_conversions.fixed b/tests/ui/unnecessary_fallible_conversions.fixed index f6027fbfa6a9b..b6dd1f2677435 100644 --- a/tests/ui/unnecessary_fallible_conversions.fixed +++ b/tests/ui/unnecessary_fallible_conversions.fixed @@ -1,18 +1,43 @@ #![warn(clippy::unnecessary_fallible_conversions)] fn main() { + // --- TryFromMethod `T::try_from(u)` --- + let _: i64 = 0i32.into(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = 0i32.into(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `T::try_from(U)` --- let _ = i64::from(0i32); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _ = i64::from(0i32); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `U::try_into(t)` --- let _: i64 = i32::into(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = i32::into(0i32); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `>::try_from(U)` --- let _ = >::from(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _ = >::from(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `>::try_into(U)` --- let _: i64 = >::into(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = >::into(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used } diff --git a/tests/ui/unnecessary_fallible_conversions.rs b/tests/ui/unnecessary_fallible_conversions.rs index 9e4fd3b3f9037..6f8df7365e897 100644 --- a/tests/ui/unnecessary_fallible_conversions.rs +++ b/tests/ui/unnecessary_fallible_conversions.rs @@ -1,18 +1,43 @@ #![warn(clippy::unnecessary_fallible_conversions)] fn main() { + // --- TryFromMethod `T::try_from(u)` --- + let _: i64 = 0i32.try_into().unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = 0i32.try_into().expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `T::try_from(U)` --- let _ = i64::try_from(0i32).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _ = i64::try_from(0i32).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `U::try_into(t)` --- let _: i64 = i32::try_into(0).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = i32::try_into(0i32).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `>::try_from(U)` --- let _ = >::try_from(0).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _ = >::try_from(0).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `>::try_into(U)` --- let _: i64 = >::try_into(0).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = >::try_into(0).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used } diff --git a/tests/ui/unnecessary_fallible_conversions.stderr b/tests/ui/unnecessary_fallible_conversions.stderr index c16dd239a8b57..598f4ba91b3c0 100644 --- a/tests/ui/unnecessary_fallible_conversions.stderr +++ b/tests/ui/unnecessary_fallible_conversions.stderr @@ -1,5 +1,5 @@ error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:4:23 + --> $DIR/unnecessary_fallible_conversions.rs:6:23 | LL | let _: i64 = 0i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL + let _: i64 = 0i32.into(); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:5:23 + --> $DIR/unnecessary_fallible_conversions.rs:9:23 | LL | let _: i64 = 0i32.try_into().expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL + let _: i64 = 0i32.into(); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:7:13 + --> $DIR/unnecessary_fallible_conversions.rs:14:13 | LL | let _ = i64::try_from(0i32).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL + let _ = i64::from(0i32); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:8:13 + --> $DIR/unnecessary_fallible_conversions.rs:17:13 | LL | let _ = i64::try_from(0i32).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL + let _ = i64::from(0i32); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:10:18 + --> $DIR/unnecessary_fallible_conversions.rs:22:18 | LL | let _: i64 = i32::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL + let _: i64 = i32::into(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:11:18 + --> $DIR/unnecessary_fallible_conversions.rs:25:18 | LL | let _: i64 = i32::try_into(0i32).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL + let _: i64 = i32::into(0i32); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:13:13 + --> $DIR/unnecessary_fallible_conversions.rs:30:13 | LL | let _ = >::try_from(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:14:13 + --> $DIR/unnecessary_fallible_conversions.rs:33:13 | LL | let _ = >::try_from(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:16:18 + --> $DIR/unnecessary_fallible_conversions.rs:38:18 | LL | let _: i64 = >::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL + let _: i64 = >::into(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:17:18 + --> $DIR/unnecessary_fallible_conversions.rs:41:18 | LL | let _: i64 = >::try_into(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 3c9aa691471943e9a391e1445d4a4b699ee444ea Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Tue, 2 Jan 2024 21:35:34 -0500 Subject: [PATCH 014/417] Make `Barrier::new()` const --- library/std/src/sync/barrier.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/sync/barrier.rs b/library/std/src/sync/barrier.rs index ed3c55120847f..764fa284794e1 100644 --- a/library/std/src/sync/barrier.rs +++ b/library/std/src/sync/barrier.rs @@ -81,8 +81,10 @@ impl Barrier { /// let barrier = Barrier::new(10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_stable(feature = "const_barrier", since = "CURRENT_RUSTC_VERSION")] #[must_use] - pub fn new(n: usize) -> Barrier { + #[inline] + pub const fn new(n: usize) -> Barrier { Barrier { lock: Mutex::new(BarrierState { count: 0, generation_id: 0 }), cvar: Condvar::new(), From aca631fb9b444fbce3e52a092289518363c0af50 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 8 Jan 2024 13:14:30 -0500 Subject: [PATCH 015/417] Increase visibility of `join_path` and `split_paths` Add some crosslinking among `std::env` pages. Also add aliases to help anyone searching for `PATH`. --- library/std/src/env.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 30ac0512348ca..e662b26316b75 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -258,6 +258,9 @@ fn _var(key: &OsStr) -> Result { /// None => println!("{key} is not defined in the environment.") /// } /// ``` +/// +/// If expecting a delimited variable (such as `PATH`), [`split_paths`] +/// can be used to separate items. #[must_use] #[stable(feature = "env", since = "1.0.0")] pub fn var_os>(key: K) -> Option { @@ -441,6 +444,16 @@ pub struct SplitPaths<'a> { /// Returns an iterator over the paths contained in `unparsed`. The iterator /// element type is [`PathBuf`]. /// +/// On most Unix platforms, the separator is `:` and on Windows it is `;`. This +/// also performs unquoting on Windows. +/// +/// [`join_paths`] can be used to recombine elements. +/// +/// # Panics +/// +/// This will panic on systems where theere is no delimited `PATH` variable, +/// such as UEFI. +/// /// # Examples /// /// ``` @@ -456,6 +469,7 @@ pub struct SplitPaths<'a> { /// None => println!("{key} is not defined in the environment.") /// } /// ``` +#[doc(alias = "PATH")] #[stable(feature = "env", since = "1.0.0")] pub fn split_paths + ?Sized>(unparsed: &T) -> SplitPaths<'_> { SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) } @@ -496,7 +510,8 @@ pub struct JoinPathsError { /// /// Returns an [`Err`] (containing an error message) if one of the input /// [`Path`]s contains an invalid character for constructing the `PATH` -/// variable (a double quote on Windows or a colon on Unix). +/// variable (a double quote on Windows or a colon on Unix), or if the system +/// does not have a `PATH`-like variable (e.g. UEFI or WASI). /// /// # Examples /// @@ -550,6 +565,7 @@ pub struct JoinPathsError { /// ``` /// /// [`env::split_paths()`]: split_paths +#[doc(alias = "PATH")] #[stable(feature = "env", since = "1.0.0")] pub fn join_paths(paths: I) -> Result where From a0fcc8ebc0793afd66be06db3c338b0b4d43fe3c Mon Sep 17 00:00:00 2001 From: riverbl <94326797+riverbl@users.noreply.github.com> Date: Sun, 7 Jan 2024 13:58:39 +0000 Subject: [PATCH 016/417] Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public. --- library/std/src/ffi/mod.rs | 4 +- library/std/src/ffi/os_str.rs | 67 +++++++++++++++++++++- library/std/src/path.rs | 10 ++-- tests/rustdoc-js-std/osstring-to-string.js | 2 +- 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs index 97e78d1778677..1622308d9f56b 100644 --- a/library/std/src/ffi/mod.rs +++ b/library/std/src/ffi/mod.rs @@ -162,6 +162,7 @@ pub use core::ffi::FromBytesUntilNulError; pub use core::ffi::{CStr, FromBytesWithNulError}; #[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] pub use self::os_str::{OsStr, OsString}; #[stable(feature = "core_ffi_c", since = "1.64.0")] @@ -181,4 +182,5 @@ pub use core::ffi::c_void; )] pub use core::ffi::{VaList, VaListImpl}; -mod os_str; +#[unstable(feature = "os_str_display", issue = "120048")] +pub mod os_str; diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 81973182148ef..cd954f9e802f4 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1,3 +1,5 @@ +//! The [`OsStr`] and [`OsString`] types and associated utilities. + #[cfg(test)] mod tests; @@ -1173,6 +1175,32 @@ impl OsStr { pub fn eq_ignore_ascii_case>(&self, other: S) -> bool { self.inner.eq_ignore_ascii_case(&other.as_ref().inner) } + + /// Returns an object that implements [`Display`] for safely printing an + /// [`OsStr`] that may contain non-Unicode data. This may perform lossy + /// conversion, depending on the platform. If you would like an + /// implementation which escapes the [`OsStr`] please use [`Debug`] + /// instead. + /// + /// [`Display`]: fmt::Display + /// [`Debug`]: fmt::Debug + /// + /// # Examples + /// + /// ``` + /// #![feature(os_str_display)] + /// use std::ffi::OsStr; + /// + /// let s = OsStr::new("Hello, world!"); + /// println!("{}", s.display()); + /// ``` + #[unstable(feature = "os_str_display", issue = "120048")] + #[must_use = "this does not display the `OsStr`; \ + it returns an object that can be displayed"] + #[inline] + pub fn display(&self) -> Display<'_> { + Display { os_str: self } + } } #[stable(feature = "box_from_os_str", since = "1.17.0")] @@ -1467,9 +1495,42 @@ impl fmt::Debug for OsStr { } } -impl OsStr { - pub(crate) fn display(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(&self.inner, formatter) +/// Helper struct for safely printing an [`OsStr`] with [`format!`] and `{}`. +/// +/// An [`OsStr`] might contain non-Unicode data. This `struct` implements the +/// [`Display`] trait in a way that mitigates that. It is created by the +/// [`display`](OsStr::display) method on [`OsStr`]. This may perform lossy +/// conversion, depending on the platform. If you would like an implementation +/// which escapes the [`OsStr`] please use [`Debug`] instead. +/// +/// # Examples +/// +/// ``` +/// #![feature(os_str_display)] +/// use std::ffi::OsStr; +/// +/// let s = OsStr::new("Hello, world!"); +/// println!("{}", s.display()); +/// ``` +/// +/// [`Display`]: fmt::Display +/// [`format!`]: crate::format +#[unstable(feature = "os_str_display", issue = "120048")] +pub struct Display<'a> { + os_str: &'a OsStr, +} + +#[unstable(feature = "os_str_display", issue = "120048")] +impl fmt::Debug for Display<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.os_str, f) + } +} + +#[unstable(feature = "os_str_display", issue = "120048")] +impl fmt::Display for Display<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.os_str.inner, f) } } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 60562f64c90d9..20cac9f2a3c22 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -84,7 +84,7 @@ use crate::rc::Rc; use crate::str::FromStr; use crate::sync::Arc; -use crate::ffi::{OsStr, OsString}; +use crate::ffi::{os_str, OsStr, OsString}; use crate::sys; use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR}; @@ -2725,7 +2725,7 @@ impl Path { it returns an object that can be displayed"] #[inline] pub fn display(&self) -> Display<'_> { - Display { path: self } + Display { inner: self.inner.display() } } /// Queries the file system to get information about a file, directory, etc. @@ -3032,20 +3032,20 @@ impl fmt::Debug for Path { /// [`format!`]: crate::format #[stable(feature = "rust1", since = "1.0.0")] pub struct Display<'a> { - path: &'a Path, + inner: os_str::Display<'a>, } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(&self.path, f) + fmt::Debug::fmt(&self.inner, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.path.inner.display(f) + fmt::Display::fmt(&self.inner, f) } } diff --git a/tests/rustdoc-js-std/osstring-to-string.js b/tests/rustdoc-js-std/osstring-to-string.js index 17bb602a502af..3fdc0b9f24a3c 100644 --- a/tests/rustdoc-js-std/osstring-to-string.js +++ b/tests/rustdoc-js-std/osstring-to-string.js @@ -4,6 +4,6 @@ const EXPECTED = { 'query': 'OsString -> String', 'others': [ - { 'path': 'std::ffi::OsString', 'name': 'into_string' }, + { 'path': 'std::ffi::os_str::OsString', 'name': 'into_string' }, ] }; From 3b73e894eb2b9f8e540359613d2f2a1521d9f0a5 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Fri, 26 Jan 2024 23:22:48 -0500 Subject: [PATCH 017/417] i586_unknown_netbsd: use inline stack probes This is one of the last two targets still using "call" stack probes. --- compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs index 574dc658b78c5..69bba4775b4ab 100644 --- a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs @@ -4,7 +4,7 @@ pub fn target() -> Target { let mut base = base::netbsd::opts(); base.cpu = "pentium".into(); base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Call; + base.stack_probes = StackProbeType::Inline; Target { llvm_target: "i586-unknown-netbsdelf".into(), From eb05b07451b91c7a707adac828841fa1d99725bf Mon Sep 17 00:00:00 2001 From: roife Date: Fri, 2 Feb 2024 15:28:34 +0800 Subject: [PATCH 018/417] Move qpath_spans into FunctionKind --- .../unnecessary_fallible_conversions.rs | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index 5306939163396..4ef26cba468d8 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -12,15 +12,15 @@ use super::UNNECESSARY_FALLIBLE_CONVERSIONS; /// What function is being called and whether that call is written as a method call or a function /// call -#[derive(Copy, Clone)] +#[derive(Clone)] #[expect(clippy::enum_variant_names)] enum FunctionKind { /// `T::try_from(U)` - TryFromFunction, + TryFromFunction(Option>), /// `t.try_into()` TryIntoMethod, /// `U::try_into(t)` - TryIntoFunction, + TryIntoFunction(Option>), } fn check<'tcx>( @@ -29,15 +29,14 @@ fn check<'tcx>( node_args: ty::GenericArgsRef<'tcx>, kind: FunctionKind, primary_span: Span, - qpath: Option<&QPath<'_>>, ) { if let &[self_ty, other_ty] = node_args.as_slice() // useless_conversion already warns `T::try_from(T)`, so ignore it here && self_ty != other_ty && let Some(self_ty) = self_ty.as_type() && let Some(from_into_trait) = cx.tcx.get_diagnostic_item(match kind { - FunctionKind::TryFromFunction => sym::From, - FunctionKind::TryIntoMethod | FunctionKind::TryIntoFunction => sym::Into, + FunctionKind::TryFromFunction(_) => sym::From, + FunctionKind::TryIntoMethod | FunctionKind::TryIntoFunction(_) => sym::Into, }) // If `T: TryFrom` and `T: From` both exist, then that means that the `TryFrom` // _must_ be from the blanket impl and cannot have been manually implemented @@ -70,21 +69,12 @@ fn check<'tcx>( primary_span }; - let qpath_spans = qpath.and_then(|qpath| match qpath { - QPath::Resolved(_, path) => { - let segments = path.segments.iter().map(|seg| seg.ident).collect::>(); - (segments.len() == 2).then(|| vec![segments[0].span, segments[1].span]) - }, - QPath::TypeRelative(_, seg) => Some(vec![seg.ident.span]), - QPath::LangItem(_, _) => unreachable!("`TryFrom` and `TryInto` are not lang items"), - }); - - let (source_ty, target_ty, sugg, applicability) = match (kind, &qpath_spans, parent_unwrap_call) { - (FunctionKind::TryIntoMethod, _, Some(unwrap_span)) => { + let (source_ty, target_ty, sugg, applicability) = match (kind, parent_unwrap_call) { + (FunctionKind::TryIntoMethod, Some(unwrap_span)) => { let sugg = vec![(primary_span, String::from("into")), (unwrap_span, String::new())]; (self_ty, other_ty, sugg, Applicability::MachineApplicable) }, - (FunctionKind::TryFromFunction, Some(spans), Some(unwrap_span)) => { + (FunctionKind::TryFromFunction(Some(spans)), Some(unwrap_span)) => { let sugg = match spans.len() { 1 => vec![(spans[0], String::from("from")), (unwrap_span, String::new())], 2 => vec![ @@ -96,7 +86,7 @@ fn check<'tcx>( }; (other_ty, self_ty, sugg, Applicability::MachineApplicable) }, - (FunctionKind::TryIntoFunction, Some(spans), Some(unwrap_span)) => { + (FunctionKind::TryIntoFunction(Some(spans)), Some(unwrap_span)) => { let sugg = match spans.len() { 1 => vec![(spans[0], String::from("into")), (unwrap_span, String::new())], 2 => vec![ @@ -108,15 +98,15 @@ fn check<'tcx>( }; (self_ty, other_ty, sugg, Applicability::MachineApplicable) }, - (FunctionKind::TryFromFunction, _, _) => { + (FunctionKind::TryFromFunction(_), _) => { let sugg = vec![(primary_span, String::from("From::from"))]; (other_ty, self_ty, sugg, Applicability::Unspecified) }, - (FunctionKind::TryIntoFunction, _, _) => { + (FunctionKind::TryIntoFunction(_), _) => { let sugg = vec![(primary_span, String::from("Into::into"))]; (self_ty, other_ty, sugg, Applicability::Unspecified) }, - (FunctionKind::TryIntoMethod, _, _) => { + (FunctionKind::TryIntoMethod, _) => { let sugg = vec![(primary_span, String::from("into"))]; (self_ty, other_ty, sugg, Applicability::Unspecified) }, @@ -147,7 +137,6 @@ pub(super) fn check_method(cx: &LateContext<'_>, expr: &Expr<'_>) { cx.typeck_results().node_args(expr.hir_id), FunctionKind::TryIntoMethod, path.ident.span, - None, ); } } @@ -160,17 +149,25 @@ pub(super) fn check_function(cx: &LateContext<'_>, expr: &Expr<'_>, callee: &Exp && let Some(item_def_id) = cx.qpath_res(qpath, callee.hir_id).opt_def_id() && let Some(trait_def_id) = cx.tcx.trait_of_item(item_def_id) { + let qpath_spans = match qpath { + QPath::Resolved(_, path) => { + let segments = path.segments.iter().map(|seg| seg.ident).collect::>(); + (segments.len() == 2).then(|| vec![segments[0].span, segments[1].span]) + }, + QPath::TypeRelative(_, seg) => Some(vec![seg.ident.span]), + QPath::LangItem(_, _) => unreachable!("`TryFrom` and `TryInto` are not lang items"), + }; + check( cx, expr, cx.typeck_results().node_args(callee.hir_id), match cx.tcx.get_diagnostic_name(trait_def_id) { - Some(sym::TryFrom) => FunctionKind::TryFromFunction, - Some(sym::TryInto) => FunctionKind::TryIntoFunction, + Some(sym::TryFrom) => FunctionKind::TryFromFunction(qpath_spans), + Some(sym::TryInto) => FunctionKind::TryIntoFunction(qpath_spans), _ => return, }, callee.span, - Some(qpath), ); } } From e83c7d49dbc18112bfaa7197a87145a99a9570fc Mon Sep 17 00:00:00 2001 From: roife Date: Fri, 2 Feb 2024 18:59:33 +0800 Subject: [PATCH 019/417] Refactor sugg builder in unnecessary_fallible_conversions --- .../unnecessary_fallible_conversions.rs | 119 +++++++++++------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index 4ef26cba468d8..42ad700a574a8 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -10,17 +10,64 @@ use rustc_span::{sym, Span}; use super::UNNECESSARY_FALLIBLE_CONVERSIONS; +#[derive(Copy, Clone)] +enum SpansKind { + TraitFn { trait_span: Span, fn_span: Span }, + Fn { fn_span: Span }, +} + /// What function is being called and whether that call is written as a method call or a function /// call -#[derive(Clone)] +#[derive(Copy, Clone)] #[expect(clippy::enum_variant_names)] enum FunctionKind { /// `T::try_from(U)` - TryFromFunction(Option>), + TryFromFunction(Option), /// `t.try_into()` TryIntoMethod, /// `U::try_into(t)` - TryIntoFunction(Option>), + TryIntoFunction(Option), +} + +impl FunctionKind { + fn applicability(&self, parent_unwrap_call: &Option) -> Applicability { + if parent_unwrap_call.is_none() { + return Applicability::Unspecified; + } + match &self { + FunctionKind::TryFromFunction(None) | FunctionKind::TryIntoFunction(None) => Applicability::Unspecified, + _ => Applicability::MachineApplicable, + } + } + + fn default_sugg(&self, primary_span: Span) -> Vec<(Span, String)> { + match *self { + FunctionKind::TryFromFunction(_) => vec![(primary_span, String::from("From::from"))], + FunctionKind::TryIntoFunction(_) => vec![(primary_span, String::from("Into::into"))], + FunctionKind::TryIntoMethod => vec![(primary_span, String::from("into"))], + } + } + + fn machine_applicable_sugg(&self, primary_span: Span, unwrap_span: Span) -> Vec<(Span, String)> { + let mut sugg = match *self { + FunctionKind::TryFromFunction(Some(spans)) => match spans { + SpansKind::TraitFn { trait_span, fn_span } => { + vec![(trait_span, String::from("From")), (fn_span, String::from("from"))] + }, + SpansKind::Fn { fn_span } => vec![(fn_span, String::from("from"))], + }, + FunctionKind::TryIntoFunction(Some(spans)) => match spans { + SpansKind::TraitFn { trait_span, fn_span } => { + vec![(trait_span, String::from("Into")), (fn_span, String::from("into"))] + }, + SpansKind::Fn { fn_span } => vec![(fn_span, String::from("into"))], + }, + FunctionKind::TryIntoMethod => vec![(primary_span, String::from("into"))], + _ => unreachable!(), + }; + sugg.push((unwrap_span, String::new())); + sugg + } } fn check<'tcx>( @@ -69,47 +116,17 @@ fn check<'tcx>( primary_span }; - let (source_ty, target_ty, sugg, applicability) = match (kind, parent_unwrap_call) { - (FunctionKind::TryIntoMethod, Some(unwrap_span)) => { - let sugg = vec![(primary_span, String::from("into")), (unwrap_span, String::new())]; - (self_ty, other_ty, sugg, Applicability::MachineApplicable) - }, - (FunctionKind::TryFromFunction(Some(spans)), Some(unwrap_span)) => { - let sugg = match spans.len() { - 1 => vec![(spans[0], String::from("from")), (unwrap_span, String::new())], - 2 => vec![ - (spans[0], String::from("From")), - (spans[1], String::from("from")), - (unwrap_span, String::new()), - ], - _ => unreachable!(), - }; - (other_ty, self_ty, sugg, Applicability::MachineApplicable) - }, - (FunctionKind::TryIntoFunction(Some(spans)), Some(unwrap_span)) => { - let sugg = match spans.len() { - 1 => vec![(spans[0], String::from("into")), (unwrap_span, String::new())], - 2 => vec![ - (spans[0], String::from("Into")), - (spans[1], String::from("into")), - (unwrap_span, String::new()), - ], - _ => unreachable!(), - }; - (self_ty, other_ty, sugg, Applicability::MachineApplicable) - }, - (FunctionKind::TryFromFunction(_), _) => { - let sugg = vec![(primary_span, String::from("From::from"))]; - (other_ty, self_ty, sugg, Applicability::Unspecified) - }, - (FunctionKind::TryIntoFunction(_), _) => { - let sugg = vec![(primary_span, String::from("Into::into"))]; - (self_ty, other_ty, sugg, Applicability::Unspecified) - }, - (FunctionKind::TryIntoMethod, _) => { - let sugg = vec![(primary_span, String::from("into"))]; - (self_ty, other_ty, sugg, Applicability::Unspecified) - }, + let (source_ty, target_ty) = match kind { + FunctionKind::TryIntoMethod | FunctionKind::TryIntoFunction(_) => (self_ty, other_ty), + FunctionKind::TryFromFunction(_) => (other_ty, self_ty), + }; + + let applicability = kind.applicability(&parent_unwrap_call); + + let sugg = if applicability == Applicability::MachineApplicable { + kind.machine_applicable_sugg(primary_span, parent_unwrap_call.unwrap()) + } else { + kind.default_sugg(primary_span) }; span_lint_and_then( @@ -151,10 +168,18 @@ pub(super) fn check_function(cx: &LateContext<'_>, expr: &Expr<'_>, callee: &Exp { let qpath_spans = match qpath { QPath::Resolved(_, path) => { - let segments = path.segments.iter().map(|seg| seg.ident).collect::>(); - (segments.len() == 2).then(|| vec![segments[0].span, segments[1].span]) + if let [trait_seg, fn_seg] = path.segments { + Some(SpansKind::TraitFn { + trait_span: trait_seg.ident.span, + fn_span: fn_seg.ident.span, + }) + } else { + None + } }, - QPath::TypeRelative(_, seg) => Some(vec![seg.ident.span]), + QPath::TypeRelative(_, seg) => Some(SpansKind::Fn { + fn_span: seg.ident.span, + }), QPath::LangItem(_, _) => unreachable!("`TryFrom` and `TryInto` are not lang items"), }; From 015ac1095417a61f293ca46b7f320ac935176c83 Mon Sep 17 00:00:00 2001 From: roife Date: Sat, 3 Feb 2024 00:50:20 +0800 Subject: [PATCH 020/417] Refactor machine_applicable_sugg in unnecessary_fallible_conversions --- .../unnecessary_fallible_conversions.rs | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index 42ad700a574a8..72bd8f7e000ca 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -34,6 +34,7 @@ impl FunctionKind { if parent_unwrap_call.is_none() { return Applicability::Unspecified; } + match &self { FunctionKind::TryFromFunction(None) | FunctionKind::TryIntoFunction(None) => Applicability::Unspecified, _ => Applicability::MachineApplicable, @@ -41,30 +42,36 @@ impl FunctionKind { } fn default_sugg(&self, primary_span: Span) -> Vec<(Span, String)> { - match *self { - FunctionKind::TryFromFunction(_) => vec![(primary_span, String::from("From::from"))], - FunctionKind::TryIntoFunction(_) => vec![(primary_span, String::from("Into::into"))], - FunctionKind::TryIntoMethod => vec![(primary_span, String::from("into"))], - } + let replacement = match *self { + FunctionKind::TryFromFunction(_) => "From::from", + FunctionKind::TryIntoFunction(_) => "Into::into", + FunctionKind::TryIntoMethod => "into", + }; + + vec![(primary_span, String::from(replacement))] } fn machine_applicable_sugg(&self, primary_span: Span, unwrap_span: Span) -> Vec<(Span, String)> { + use FunctionKind::*; + use SpansKind::*; + + let (trait_name, fn_name) = { + let (a, b) = match self { + TryFromFunction(_) => ("From", "from"), + TryIntoFunction(_) | TryIntoMethod => ("Into", "into"), + }; + (a.to_string(), b.to_string()) + }; + let mut sugg = match *self { - FunctionKind::TryFromFunction(Some(spans)) => match spans { - SpansKind::TraitFn { trait_span, fn_span } => { - vec![(trait_span, String::from("From")), (fn_span, String::from("from"))] - }, - SpansKind::Fn { fn_span } => vec![(fn_span, String::from("from"))], + TryFromFunction(Some(spans)) | TryIntoFunction(Some(spans)) => match spans { + TraitFn { trait_span, fn_span } => vec![(trait_span, trait_name), (fn_span, fn_name)], + Fn { fn_span } => vec![(fn_span, fn_name)], }, - FunctionKind::TryIntoFunction(Some(spans)) => match spans { - SpansKind::TraitFn { trait_span, fn_span } => { - vec![(trait_span, String::from("Into")), (fn_span, String::from("into"))] - }, - SpansKind::Fn { fn_span } => vec![(fn_span, String::from("into"))], - }, - FunctionKind::TryIntoMethod => vec![(primary_span, String::from("into"))], + TryIntoMethod => vec![(primary_span, fn_name)], _ => unreachable!(), }; + sugg.push((unwrap_span, String::new())); sugg } From fb9fd513f57ea6939c20829286b2c44398c35d2d Mon Sep 17 00:00:00 2001 From: roife Date: Sat, 3 Feb 2024 13:46:16 +0800 Subject: [PATCH 021/417] Remove wildcard usage for patterns --- .../unnecessary_fallible_conversions.rs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index 72bd8f7e000ca..bb23ae5f8437a 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -52,23 +52,18 @@ impl FunctionKind { } fn machine_applicable_sugg(&self, primary_span: Span, unwrap_span: Span) -> Vec<(Span, String)> { - use FunctionKind::*; - use SpansKind::*; - - let (trait_name, fn_name) = { - let (a, b) = match self { - TryFromFunction(_) => ("From", "from"), - TryIntoFunction(_) | TryIntoMethod => ("Into", "into"), - }; - (a.to_string(), b.to_string()) + let (trait_name, fn_name) = match self { + FunctionKind::TryFromFunction(_) => ("From".to_owned(), "from".to_owned()), + FunctionKind::TryIntoFunction(_) | FunctionKind::TryIntoMethod => ("Into".to_owned(), "into".to_owned()), }; let mut sugg = match *self { - TryFromFunction(Some(spans)) | TryIntoFunction(Some(spans)) => match spans { - TraitFn { trait_span, fn_span } => vec![(trait_span, trait_name), (fn_span, fn_name)], - Fn { fn_span } => vec![(fn_span, fn_name)], + FunctionKind::TryFromFunction(Some(spans)) | FunctionKind::TryIntoFunction(Some(spans)) => match spans { + SpansKind::TraitFn { trait_span, fn_span } => vec![(trait_span, trait_name), (fn_span, fn_name)], + SpansKind::Fn { fn_span } => vec![(fn_span, fn_name)], }, - TryIntoMethod => vec![(primary_span, fn_name)], + FunctionKind::TryIntoMethod => vec![(primary_span, fn_name)], + // Or the suggestion is not machine-applicable _ => unreachable!(), }; From 68f6dd41cefd3bb67f867c09cc9238528efd8229 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Mon, 5 Feb 2024 22:52:32 +0000 Subject: [PATCH 022/417] Add y21 to the review rotation --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index 3eadc66f544f3..303a4ca900ca6 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -32,4 +32,5 @@ contributing_url = "https://github.com/rust-lang/rust-clippy/blob/master/CONTRIB "@dswij", "@Jarcho", "@blyxyas", + "@y21", ] From 998c72293f44ab0862afb943d229725764e083e9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 6 Feb 2024 09:51:39 +1100 Subject: [PATCH 023/417] Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. --- clippy_config/src/lib.rs | 4 +++- clippy_lints/src/lib.rs | 7 ++++++- clippy_utils/src/lib.rs | 8 +++++++- src/driver.rs | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/clippy_config/src/lib.rs b/clippy_config/src/lib.rs index 533e375a3104c..5449feed090a9 100644 --- a/clippy_config/src/lib.rs +++ b/clippy_config/src/lib.rs @@ -4,7 +4,9 @@ #![allow( clippy::must_use_candidate, clippy::missing_panics_doc, - rustc::untranslatable_diagnostic_trivial + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, + rustc::untranslatable_diagnostic_trivial, )] extern crate rustc_ast; diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index feb4d188f3978..f6608b229539a 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -10,7 +10,12 @@ #![feature(stmt_expr_attributes)] #![recursion_limit = "512"] #![cfg_attr(feature = "deny-warnings", deny(warnings))] -#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)] +#![allow( + clippy::missing_docs_in_private_items, + clippy::must_use_candidate, + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, +)] #![warn(trivial_casts, trivial_numeric_casts)] // warn on lints, that are included in `rust-lang/rust`s bootstrap #![warn(rust_2018_idioms, unused_lifetimes)] diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 4e499ff4cc612..36034861df5b9 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -8,7 +8,13 @@ #![feature(assert_matches)] #![recursion_limit = "512"] #![cfg_attr(feature = "deny-warnings", deny(warnings))] -#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)] +#![allow( + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::must_use_candidate, + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, +)] // warn on the same lints as `clippy_lints` #![warn(trivial_casts, trivial_numeric_casts)] // warn on lints, that are included in `rust-lang/rust`s bootstrap diff --git a/src/driver.rs b/src/driver.rs index b944a299256c2..1b159f5937a28 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1,3 +1,5 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(rustc_private)] #![feature(let_chains)] #![feature(lazy_cell)] From b168c20951d602872eb89f4b78aaa4cf7f6e2563 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 20 Jan 2024 15:21:27 +0300 Subject: [PATCH 024/417] hir: Make sure all `HirId`s have corresponding HIR `Node`s --- clippy_lints/src/min_ident_chars.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 41168230752a8..2f9f04832a750 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -94,7 +94,7 @@ impl Visitor<'_> for IdentVisitor<'_, '_> { cx.tcx.opt_hir_node(hir_id) } else { let owner = cx.tcx.hir_owner_nodes(hir_id.owner); - owner.nodes.get(hir_id.local_id).copied().flatten().map(|p| p.node) + owner.nodes.get(hir_id.local_id).copied().map(|p| p.node) }; let Some(node) = node else { return; From b247f41596bdc5f904ff9af482bac414655ac567 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 21 Jan 2024 21:13:15 +0300 Subject: [PATCH 025/417] hir: Remove `fn opt_hir_id` and `fn opt_span` --- clippy_lints/src/absolute_paths.rs | 2 +- clippy_lints/src/casts/cast_slice_different_sizes.rs | 5 ++--- clippy_lints/src/casts/unnecessary_cast.rs | 3 +-- clippy_lints/src/derivable_impls.rs | 2 +- clippy_lints/src/empty_drop.rs | 2 +- clippy_lints/src/escape.rs | 6 +++--- clippy_lints/src/explicit_write.rs | 2 +- clippy_lints/src/index_refutable_slice.rs | 4 ++-- clippy_lints/src/len_zero.rs | 6 +++--- clippy_lints/src/loops/same_item_push.rs | 2 +- clippy_lints/src/manual_rem_euclid.rs | 2 +- clippy_lints/src/methods/filter_next.rs | 2 +- clippy_lints/src/methods/option_map_unwrap_or.rs | 4 ++-- clippy_lints/src/min_ident_chars.rs | 2 +- clippy_lints/src/mixed_read_write_in_expression.rs | 5 +---- clippy_lints/src/non_copy_const.rs | 2 +- clippy_lints/src/same_name_method.rs | 4 ++-- clippy_lints/src/self_named_constructors.rs | 2 +- clippy_utils/src/lib.rs | 10 +++++----- 19 files changed, 31 insertions(+), 36 deletions(-) diff --git a/clippy_lints/src/absolute_paths.rs b/clippy_lints/src/absolute_paths.rs index 3822b83b4bc64..8ba661afeeb6f 100644 --- a/clippy_lints/src/absolute_paths.rs +++ b/clippy_lints/src/absolute_paths.rs @@ -62,7 +62,7 @@ impl LateLintPass<'_> for AbsolutePaths { } = self; if !path.span.from_expansion() - && let Some(node) = cx.tcx.opt_hir_node(hir_id) + && let node = cx.tcx.hir_node(hir_id) && !matches!(node, Node::Item(item) if matches!(item.kind, ItemKind::Use(_, _))) && let [first, rest @ ..] = path.segments // Handle `::std` diff --git a/clippy_lints/src/casts/cast_slice_different_sizes.rs b/clippy_lints/src/casts/cast_slice_different_sizes.rs index 91bad8256ecb1..0f29743856ac9 100644 --- a/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -68,9 +68,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { let map = cx.tcx.hir(); - if let Some(parent_id) = map.opt_parent_id(expr.hir_id) - && let Some(parent) = cx.tcx.opt_hir_node(parent_id) - { + if let Some(parent_id) = map.opt_parent_id(expr.hir_id) { + let parent = cx.tcx.hir_node(parent_id); let expr = match parent { Node::Block(block) => { if let Some(parent_expr) = block.expr { diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index bb86b6f30759c..81d0def4322d3 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -144,8 +144,7 @@ pub(super) fn check<'tcx>( if cast_from.kind() == cast_to.kind() && !in_external_macro(cx.sess(), expr.span) { if let Some(id) = path_to_local(cast_expr) - && let Some(span) = cx.tcx.hir().opt_span(id) - && !span.eq_ctxt(cast_expr.span) + && !cx.tcx.hir().span(id).eq_ctxt(cast_expr.span) { // Binding context is different than the identifiers context. // Weird macro wizardry could be involved here. diff --git a/clippy_lints/src/derivable_impls.rs b/clippy_lints/src/derivable_impls.rs index 6b0423200d765..b0f46f5c646cf 100644 --- a/clippy_lints/src/derivable_impls.rs +++ b/clippy_lints/src/derivable_impls.rs @@ -195,7 +195,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls { && let Some(def_id) = trait_ref.trait_def_id() && cx.tcx.is_diagnostic_item(sym::Default, def_id) && let impl_item_hir = child.id.hir_id() - && let Some(Node::ImplItem(impl_item)) = cx.tcx.opt_hir_node(impl_item_hir) + && let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir) && let ImplItemKind::Fn(_, b) = &impl_item.kind && let Body { value: func_expr, .. } = cx.tcx.hir().body(*b) && let &Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind() diff --git a/clippy_lints/src/empty_drop.rs b/clippy_lints/src/empty_drop.rs index 1d2b907b94821..74db250b3ae92 100644 --- a/clippy_lints/src/empty_drop.rs +++ b/clippy_lints/src/empty_drop.rs @@ -42,7 +42,7 @@ impl LateLintPass<'_> for EmptyDrop { }) = item.kind && trait_ref.trait_def_id() == cx.tcx.lang_items().drop_trait() && let impl_item_hir = child.id.hir_id() - && let Some(Node::ImplItem(impl_item)) = cx.tcx.opt_hir_node(impl_item_hir) + && let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir) && let ImplItemKind::Fn(_, b) = &impl_item.kind && let Body { value: func_expr, .. } = cx.tcx.hir().body(*b) && let func_expr = peel_blocks(func_expr) diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index b7776263060be..218d7c6c01ae1 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -123,11 +123,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal { // TODO: Replace with Map::is_argument(..) when it's fixed fn is_argument(tcx: TyCtxt<'_>, id: HirId) -> bool { - match tcx.opt_hir_node(id) { - Some(Node::Pat(Pat { + match tcx.hir_node(id) { + Node::Pat(Pat { kind: PatKind::Binding(..), .. - })) => (), + }) => (), _ => return false, } diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index e8c1e5db35e00..de048fef5f224 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -111,7 +111,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>) // Find id of the local that expr_end_of_block resolves to && let ExprKind::Path(QPath::Resolved(None, expr_path)) = expr_end_of_block.kind && let Res::Local(expr_res) = expr_path.res - && let Some(Node::Pat(res_pat)) = cx.tcx.opt_hir_node(expr_res) + && let Node::Pat(res_pat) = cx.tcx.hir_node(expr_res) // Find id of the local we found in the block && let PatKind::Binding(BindingAnnotation::NONE, local_hir_id, _ident, None) = local.pat.kind diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 5417c13d07967..252be30c4e27d 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -248,7 +248,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { // Checking for slice indexing && let parent_id = map.parent_id(expr.hir_id) - && let Some(hir::Node::Expr(parent_expr)) = cx.tcx.opt_hir_node(parent_id) + && let hir::Node::Expr(parent_expr) = cx.tcx.hir_node(parent_id) && let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind && let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr) && let Ok(index_value) = index_value.try_into() @@ -256,7 +256,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { // Make sure that this slice index is read only && let maybe_addrof_id = map.parent_id(parent_id) - && let Some(hir::Node::Expr(maybe_addrof_expr)) = cx.tcx.opt_hir_node(maybe_addrof_id) + && let hir::Node::Expr(maybe_addrof_expr) = cx.tcx.hir_node(maybe_addrof_id) && let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind { use_info.index_use.push((index_value, map.span(parent_expr.hir_id))); diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index c1ab020117ca6..27d85cde5320a 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -147,9 +147,9 @@ impl<'tcx> LateLintPass<'tcx> for LenZero { && let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder()) { - let (name, kind) = match cx.tcx.opt_hir_node(ty_hir_id) { - Some(Node::ForeignItem(x)) => (x.ident.name, "extern type"), - Some(Node::Item(x)) => match x.kind { + let (name, kind) = match cx.tcx.hir_node(ty_hir_id) { + Node::ForeignItem(x) => (x.ident.name, "extern type"), + Node::Item(x) => match x.kind { ItemKind::Struct(..) => (x.ident.name, "struct"), ItemKind::Enum(..) => (x.ident.name, "enum"), ItemKind::Union(..) => (x.ident.name, "union"), diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index 920a887a6fd1b..5f015db2b33bf 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -63,7 +63,7 @@ pub(super) fn check<'tcx>( && let PatKind::Binding(bind_ann, ..) = pat.kind && !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut)) && let parent_node = cx.tcx.hir().parent_id(hir_id) - && let Some(Node::Local(parent_let_expr)) = cx.tcx.opt_hir_node(parent_node) + && let Node::Local(parent_let_expr) = cx.tcx.hir_node(parent_node) && let Some(init) = parent_let_expr.init { match init.kind { diff --git a/clippy_lints/src/manual_rem_euclid.rs b/clippy_lints/src/manual_rem_euclid.rs index 71a83a68db933..e1768c6d97641 100644 --- a/clippy_lints/src/manual_rem_euclid.rs +++ b/clippy_lints/src/manual_rem_euclid.rs @@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid { // Also ensures the const is nonzero since zero can't be a divisor && const1 == const2 && const2 == const3 && let Some(hir_id) = path_to_local(expr3) - && let Some(Node::Pat(_)) = cx.tcx.opt_hir_node(hir_id) + && let Node::Pat(_) = cx.tcx.hir_node(hir_id) { // Apply only to params or locals with annotated types match cx.tcx.hir().find_parent(hir_id) { diff --git a/clippy_lints/src/methods/filter_next.rs b/clippy_lints/src/methods/filter_next.rs index 9251130a30549..7339362193e54 100644 --- a/clippy_lints/src/methods/filter_next.rs +++ b/clippy_lints/src/methods/filter_next.rs @@ -44,7 +44,7 @@ pub(super) fn check<'tcx>( // add note if not multi-line span_lint_and_then(cx, FILTER_NEXT, expr.span, msg, |diag| { let (applicability, pat) = if let Some(id) = path_to_local(recv) - && let Some(hir::Node::Pat(pat)) = cx.tcx.opt_hir_node(id) + && let hir::Node::Pat(pat) = cx.tcx.hir_node(id) && let hir::PatKind::Binding(BindingAnnotation(_, Mutability::Not), _, ident, _) = pat.kind { (Applicability::Unspecified, Some((pat.span, ident))) diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index 624597ffca949..ab36f854fcb1d 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> { fn visit_path(&mut self, path: &Path<'tcx>, _: HirId) { if let Res::Local(local_id) = path.res - && let Some(Node::Pat(pat)) = self.cx.tcx.opt_hir_node(local_id) + && let Node::Pat(pat) = self.cx.tcx.hir_node(local_id) && let PatKind::Binding(_, local_id, ..) = pat.kind { self.identifiers.insert(local_id); @@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReferenceVisitor<'a, 'tcx> { && let ExprKind::Path(ref path) = expr.kind && let QPath::Resolved(_, path) = path && let Res::Local(local_id) = path.res - && let Some(Node::Pat(pat)) = self.cx.tcx.opt_hir_node(local_id) + && let Node::Pat(pat) = self.cx.tcx.hir_node(local_id) && let PatKind::Binding(_, local_id, ..) = pat.kind && self.identifiers.contains(&local_id) { diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 2f9f04832a750..70cc43e266c6d 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -91,7 +91,7 @@ impl Visitor<'_> for IdentVisitor<'_, '_> { let node = if hir_id.local_id == ItemLocalId::from_u32(0) { // In this case, we can just use `find`, `Owner`'s `node` field is private anyway so we can't // reimplement it even if we wanted to - cx.tcx.opt_hir_node(hir_id) + Some(cx.tcx.hir_node(hir_id)) } else { let owner = cx.tcx.hir_owner_nodes(hir_id.owner); owner.nodes.get(hir_id.local_id).copied().map(|p| p.node) diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index 195ce17629a71..b593e48ae2e16 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -213,11 +213,8 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) { if parent_id == cur_id { break; } - let Some(parent_node) = vis.cx.tcx.opt_hir_node(parent_id) else { - break; - }; - let stop_early = match parent_node { + let stop_early = match vis.cx.tcx.hir_node(parent_id) { Node::Expr(expr) => check_expr(vis, expr), Node::Stmt(stmt) => check_stmt(vis, stmt), Node::Item(_) => { diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index f8365deebd46e..10ab380ba1bc5 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -453,7 +453,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst { if parent_id == cur_expr.hir_id { break; } - if let Some(Node::Expr(parent_expr)) = cx.tcx.opt_hir_node(parent_id) { + if let Node::Expr(parent_expr) = cx.tcx.hir_node(parent_id) { match &parent_expr.kind { ExprKind::AddrOf(..) => { // `&e` => `e` must be referenced. diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 7a351dab2d458..07806b182f22b 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -76,8 +76,8 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { match of_trait { Some(trait_ref) => { let mut methods_in_trait: BTreeSet = - if let Some(Node::TraitRef(TraitRef { path, .. })) = - cx.tcx.opt_hir_node(trait_ref.hir_ref_id) + if let Node::TraitRef(TraitRef { path, .. }) = + cx.tcx.hir_node(trait_ref.hir_ref_id) && let Res::Def(DefKind::Trait, did) = path.res { // FIXME: if diff --git a/clippy_lints/src/self_named_constructors.rs b/clippy_lints/src/self_named_constructors.rs index 98f3235af10a0..fc5a45dd56d6b 100644 --- a/clippy_lints/src/self_named_constructors.rs +++ b/clippy_lints/src/self_named_constructors.rs @@ -73,7 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors { if let Some(self_def) = self_ty.ty_adt_def() && let Some(self_local_did) = self_def.did().as_local() && let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did) - && let Some(Node::Item(x)) = cx.tcx.opt_hir_node(self_id) + && let Node::Item(x) = cx.tcx.hir_node(self_id) && let type_name = x.ident.name.as_str().to_lowercase() && (impl_item.ident.name.as_str() == type_name || impl_item.ident.name.as_str().replace('_', "") == type_name) diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 4e499ff4cc612..3f936009e44ec 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -177,10 +177,10 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr /// canonical binding `HirId`. pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> { let hir = cx.tcx.hir(); - if let Some(Node::Pat(pat)) = cx.tcx.opt_hir_node(hir_id) + if let Node::Pat(pat) = cx.tcx.hir_node(hir_id) && matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..)) && let parent = hir.parent_id(hir_id) - && let Some(Node::Local(local)) = cx.tcx.opt_hir_node(parent) + && let Node::Local(local) = cx.tcx.hir_node(parent) { return local.init; } @@ -1327,7 +1327,7 @@ pub fn get_enclosing_block<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Optio let map = &cx.tcx.hir(); let enclosing_node = map .get_enclosing_scope(hir_id) - .and_then(|enclosing_id| cx.tcx.opt_hir_node(enclosing_id)); + .map(|enclosing_id| cx.tcx.hir_node(enclosing_id)); enclosing_node.and_then(|node| match node { Node::Block(block) => Some(block), Node::Item(&Item { @@ -2696,10 +2696,10 @@ impl<'tcx> ExprUseNode<'tcx> { )), Self::Return(id) => { let hir_id = cx.tcx.local_def_id_to_hir_id(id.def_id); - if let Some(Node::Expr(Expr { + if let Node::Expr(Expr { kind: ExprKind::Closure(c), .. - })) = cx.tcx.opt_hir_node(hir_id) + }) = cx.tcx.hir_node(hir_id) { match c.fn_decl.output { FnRetTy::DefaultReturn(_) => None, From c8d57e8aa4435551ac394d0762515a93d77251e5 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 7 Feb 2024 17:17:52 +0000 Subject: [PATCH 026/417] Use correct param env in clippy --- clippy_lints/src/default.rs | 4 ++-- clippy_lints/src/useless_conversion.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index d8a070b785d5d..8789efcc99444 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { // only when assigning `... = Default::default()` && is_expr_default(expr, cx) && let binding_type = cx.typeck_results().node_type(binding_id) - && let Some(adt) = binding_type.ty_adt_def() + && let ty::Adt(adt, args) = *binding_type.kind() && adt.is_struct() && let variant = adt.non_enum_variant() && (adt.did().is_local() || !variant.is_field_list_non_exhaustive()) @@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { .fields .iter() .all(|field| { - is_copy(cx, cx.tcx.type_of(field.did).instantiate_identity()) + is_copy(cx, cx.tcx.type_of(field.did).instantiate(cx.tcx, args)) }) && (!has_drop(cx, binding_type) || all_fields_are_copy) { diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 2e0a0f6cb3e45..f7a455977facd 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -86,7 +86,6 @@ fn into_iter_bound<'tcx>( param_index: u32, node_args: GenericArgsRef<'tcx>, ) -> Option { - let param_env = cx.tcx.param_env(fn_did); let mut into_iter_span = None; for (pred, span) in cx.tcx.explicit_predicates_of(fn_did).predicates { @@ -111,7 +110,7 @@ fn into_iter_bound<'tcx>( })); let predicate = EarlyBinder::bind(tr).instantiate(cx.tcx, args); - let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), param_env, predicate); + let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate); if !cx .tcx .infer_ctxt() From 3c76b2ceff3526b2d46abb1bbd38180131578808 Mon Sep 17 00:00:00 2001 From: roife Date: Thu, 8 Feb 2024 13:45:57 +0800 Subject: [PATCH 027/417] Merging the calculation of sugg and applicability --- .../unnecessary_fallible_conversions.rs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index bb23ae5f8437a..d46b584f8f444 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -30,14 +30,19 @@ enum FunctionKind { } impl FunctionKind { - fn applicability(&self, parent_unwrap_call: &Option) -> Applicability { - if parent_unwrap_call.is_none() { - return Applicability::Unspecified; - } + fn appl_sugg(&self, parent_unwrap_call: Option, primary_span: Span) -> (Applicability, Vec<(Span, String)>) { + let Some(unwrap_span) = parent_unwrap_call else { + return (Applicability::Unspecified, self.default_sugg(primary_span)); + }; match &self { - FunctionKind::TryFromFunction(None) | FunctionKind::TryIntoFunction(None) => Applicability::Unspecified, - _ => Applicability::MachineApplicable, + FunctionKind::TryFromFunction(None) | FunctionKind::TryIntoFunction(None) => { + (Applicability::Unspecified, self.default_sugg(primary_span)) + }, + _ => ( + Applicability::MachineApplicable, + self.machine_applicable_sugg(primary_span, unwrap_span), + ), } } @@ -123,13 +128,7 @@ fn check<'tcx>( FunctionKind::TryFromFunction(_) => (other_ty, self_ty), }; - let applicability = kind.applicability(&parent_unwrap_call); - - let sugg = if applicability == Applicability::MachineApplicable { - kind.machine_applicable_sugg(primary_span, parent_unwrap_call.unwrap()) - } else { - kind.default_sugg(primary_span) - }; + let (applicability, sugg) = kind.appl_sugg(parent_unwrap_call, primary_span); span_lint_and_then( cx, From 96ff004a683e8b33bd41e31316dfc5d7e51d14d2 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 1 Feb 2024 08:35:37 +0000 Subject: [PATCH 028/417] inline a function that is only used in clippy --- clippy_lints/src/lifetimes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index ffef84d1fadec..f5636945f2037 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -176,7 +176,7 @@ fn check_fn_inner<'tcx>( _ => None, }); for bound in lifetimes { - if !bound.is_static() && !bound.is_elided() { + if bound.res != LifetimeName::Static && !bound.is_elided() { return; } } From 6ca819f202dc8c449d40f04edd81ea87f1e4ee6c Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 7 Feb 2024 10:26:00 -0500 Subject: [PATCH 029/417] Add a new debug_assertions instrinsic (compiler) And in clippy --- clippy_utils/src/qualify_min_const_fn.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 81f4fcc2133d1..8d5bcd665ad25 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -174,7 +174,7 @@ fn check_rvalue<'tcx>( )) } }, - Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(_), _) | Rvalue::ShallowInitBox(_, _) => { + Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(_) | NullOp::DebugAssertions, _) | Rvalue::ShallowInitBox(_, _) => { Ok(()) }, Rvalue::UnaryOp(_, operand) => { From f3b3d23416f1da77103bb74788f23b4f9c78ee7e Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Thu, 8 Feb 2024 20:24:42 +0100 Subject: [PATCH 030/417] Merge commit '60cb29c5e4f9772685c9873752196725c946a849' into clippyup --- .github/driver.sh | 15 + CHANGELOG.md | 66 +++- Cargo.toml | 2 +- book/src/lint_configuration.md | 33 ++ clippy_config/Cargo.toml | 2 +- clippy_config/src/conf.rs | 22 +- clippy_config/src/msrvs.rs | 13 + clippy_lints/Cargo.toml | 2 +- clippy_lints/src/booleans.rs | 1 + .../src/cargo/lint_groups_priority.rs | 168 ++++++++ clippy_lints/src/cargo/mod.rs | 43 ++- clippy_lints/src/casts/mod.rs | 30 +- clippy_lints/src/casts/ref_as_ptr.rs | 55 +++ clippy_lints/src/declared_lints.rs | 6 + clippy_lints/src/doc/mod.rs | 2 +- clippy_lints/src/eta_reduction.rs | 50 +-- clippy_lints/src/incompatible_msrv.rs | 133 +++++++ clippy_lints/src/iter_over_hash_type.rs | 2 +- clippy_lints/src/lib.rs | 21 +- clippy_lints/src/loops/mod.rs | 2 +- clippy_lints/src/loops/never_loop.rs | 6 +- clippy_lints/src/manual_retain.rs | 141 +++++-- .../src/methods/manual_c_str_literals.rs | 197 ++++++++++ clippy_lints/src/methods/map_unwrap_or.rs | 2 +- clippy_lints/src/methods/mod.rs | 65 ++++ clippy_lints/src/methods/unnecessary_fold.rs | 1 - .../methods/unnecessary_result_map_or_else.rs | 95 +++++ clippy_lints/src/no_effect.rs | 2 +- clippy_lints/src/only_used_in_recursion.rs | 5 +- clippy_lints/src/operators/mod.rs | 15 +- .../src/operators/modulo_arithmetic.rs | 27 +- clippy_lints/src/redundant_closure_call.rs | 14 +- clippy_lints/src/redundant_locals.rs | 26 ++ .../src/redundant_type_annotations.rs | 11 +- clippy_lints/src/repeat_vec_with_capacity.rs | 2 +- clippy_lints/src/returns.rs | 31 +- clippy_lints/src/to_string_trait_impl.rs | 67 ++++ clippy_lints/src/unconditional_recursion.rs | 86 +++-- clippy_lints/src/unused_io_amount.rs | 101 +++-- clippy_lints/src/utils/author.rs | 6 +- clippy_lints/src/wildcard_imports.rs | 16 +- clippy_utils/Cargo.toml | 2 +- clippy_utils/src/lib.rs | 359 ++++++++++-------- clippy_utils/src/ty.rs | 29 -- declare_clippy_lint/Cargo.toml | 2 +- rust-toolchain | 2 +- src/driver.rs | 25 +- .../lint_groups_priority/fail/Cargo.stderr | 45 +++ .../lint_groups_priority/fail/Cargo.toml | 20 + .../lint_groups_priority/fail/src/lib.rs | 1 + .../lint_groups_priority/pass/Cargo.toml | 10 + .../lint_groups_priority/pass/src/lib.rs | 1 + .../min_rust_version/min_rust_version.fixed | 2 +- .../min_rust_version/min_rust_version.rs | 2 +- tests/ui-toml/modulo_arithmetic/clippy.toml | 1 + .../modulo_arithmetic/modulo_arithmetic.rs | 10 + .../modulo_arithmetic.stderr | 40 ++ .../toml_unknown_key/conf_unknown_key.stderr | 6 + tests/ui-toml/wildcard_imports/clippy.toml | 3 + .../wildcard_imports/wildcard_imports.fixed | 19 + .../wildcard_imports/wildcard_imports.rs | 19 + .../wildcard_imports/wildcard_imports.stderr | 20 +- .../wildcard_imports_whitelist/clippy.toml | 1 + .../wildcard_imports.fixed | 26 ++ .../wildcard_imports.rs | 26 ++ .../wildcard_imports.stderr | 11 + tests/ui/borrow_as_ptr.fixed | 1 + tests/ui/borrow_as_ptr.rs | 1 + tests/ui/borrow_as_ptr.stderr | 4 +- tests/ui/borrow_as_ptr_no_std.fixed | 1 + tests/ui/borrow_as_ptr_no_std.rs | 1 + tests/ui/borrow_as_ptr_no_std.stderr | 4 +- tests/ui/eta.fixed | 71 ++++ tests/ui/eta.rs | 71 ++++ tests/ui/eta.stderr | 28 +- tests/ui/format_args.fixed | 1 + tests/ui/format_args.rs | 1 + tests/ui/format_args.stderr | 50 +-- tests/ui/ignored_unit_patterns.fixed | 7 +- tests/ui/ignored_unit_patterns.rs | 7 +- tests/ui/ignored_unit_patterns.stderr | 18 +- tests/ui/incompatible_msrv.rs | 23 ++ tests/ui/incompatible_msrv.stderr | 23 ++ tests/ui/manual_c_str_literals.fixed | 60 +++ tests/ui/manual_c_str_literals.rs | 60 +++ tests/ui/manual_c_str_literals.stderr | 83 ++++ tests/ui/manual_retain.fixed | 63 +++ tests/ui/manual_retain.rs | 63 +++ tests/ui/manual_retain.stderr | 142 +++++-- tests/ui/modulo_arithmetic_integral.rs | 8 + tests/ui/needless_borrow.fixed | 3 + tests/ui/needless_borrow.rs | 3 + tests/ui/needless_borrow.stderr | 20 +- .../needless_return_with_question_mark.fixed | 50 +++ .../ui/needless_return_with_question_mark.rs | 50 +++ tests/ui/never_loop.rs | 11 +- tests/ui/nonminimal_bool.rs | 11 + tests/ui/redundant_closure_call_fixable.fixed | 9 + tests/ui/redundant_closure_call_fixable.rs | 9 + tests/ui/redundant_locals.rs | 46 +++ tests/ui/redundant_locals.stderr | 56 +-- tests/ui/redundant_type_annotations.rs | 7 +- tests/ui/redundant_type_annotations.stderr | 4 +- tests/ui/ref_as_ptr.fixed | 110 ++++++ tests/ui/ref_as_ptr.rs | 110 ++++++ tests/ui/ref_as_ptr.stderr | 269 +++++++++++++ tests/ui/strlen_on_c_strings.fixed | 2 +- tests/ui/strlen_on_c_strings.rs | 2 +- tests/ui/to_string_trait_impl.rs | 31 ++ tests/ui/to_string_trait_impl.stderr | 16 + tests/ui/unconditional_recursion.rs | 62 +++ tests/ui/unconditional_recursion.stderr | 14 +- tests/ui/unnecessary_fold.fixed | 6 + tests/ui/unnecessary_fold.rs | 6 + tests/ui/unnecessary_fold.stderr | 41 +- tests/ui/unnecessary_operation.fixed | 7 + tests/ui/unnecessary_operation.rs | 7 + tests/ui/unnecessary_result_map_or_else.fixed | 61 +++ tests/ui/unnecessary_result_map_or_else.rs | 69 ++++ .../ui/unnecessary_result_map_or_else.stderr | 35 ++ tests/ui/unnecessary_to_owned.fixed | 3 + tests/ui/unnecessary_to_owned.rs | 3 + tests/ui/unnecessary_to_owned.stderr | 170 ++++----- tests/ui/unnecessary_to_owned_on_split.fixed | 1 + tests/ui/unnecessary_to_owned_on_split.rs | 1 + tests/ui/unnecessary_to_owned_on_split.stderr | 18 +- tests/ui/unused_io_amount.rs | 43 +++ tests/ui/unused_io_amount.stderr | 8 +- tests/ui/while_let_on_iterator.fixed | 16 +- tests/ui/while_let_on_iterator.rs | 14 +- tests/ui/while_let_on_iterator.stderr | 12 +- 131 files changed, 3869 insertions(+), 604 deletions(-) mode change 100644 => 100755 .github/driver.sh create mode 100644 clippy_lints/src/cargo/lint_groups_priority.rs create mode 100644 clippy_lints/src/casts/ref_as_ptr.rs create mode 100644 clippy_lints/src/incompatible_msrv.rs create mode 100644 clippy_lints/src/methods/manual_c_str_literals.rs create mode 100644 clippy_lints/src/methods/unnecessary_result_map_or_else.rs create mode 100644 clippy_lints/src/to_string_trait_impl.rs create mode 100644 tests/ui-cargo/lint_groups_priority/fail/Cargo.stderr create mode 100644 tests/ui-cargo/lint_groups_priority/fail/Cargo.toml create mode 100644 tests/ui-cargo/lint_groups_priority/fail/src/lib.rs create mode 100644 tests/ui-cargo/lint_groups_priority/pass/Cargo.toml create mode 100644 tests/ui-cargo/lint_groups_priority/pass/src/lib.rs create mode 100644 tests/ui-toml/modulo_arithmetic/clippy.toml create mode 100644 tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs create mode 100644 tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr create mode 100644 tests/ui-toml/wildcard_imports_whitelist/clippy.toml create mode 100644 tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.fixed create mode 100644 tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.rs create mode 100644 tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr create mode 100644 tests/ui/incompatible_msrv.rs create mode 100644 tests/ui/incompatible_msrv.stderr create mode 100644 tests/ui/manual_c_str_literals.fixed create mode 100644 tests/ui/manual_c_str_literals.rs create mode 100644 tests/ui/manual_c_str_literals.stderr create mode 100644 tests/ui/ref_as_ptr.fixed create mode 100644 tests/ui/ref_as_ptr.rs create mode 100644 tests/ui/ref_as_ptr.stderr create mode 100644 tests/ui/to_string_trait_impl.rs create mode 100644 tests/ui/to_string_trait_impl.stderr create mode 100644 tests/ui/unnecessary_result_map_or_else.fixed create mode 100644 tests/ui/unnecessary_result_map_or_else.rs create mode 100644 tests/ui/unnecessary_result_map_or_else.stderr diff --git a/.github/driver.sh b/.github/driver.sh old mode 100644 new mode 100755 index c05c6ecc1151c..40a2aad0f5379 --- a/.github/driver.sh +++ b/.github/driver.sh @@ -11,9 +11,16 @@ if [[ ${OS} == "Windows" ]]; then else desired_sysroot=/tmp fi +# Set --sysroot in command line sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) test "$sysroot" = $desired_sysroot +# Set --sysroot in arg_file.txt and pass @arg_file.txt to command line +echo "--sysroot=$desired_sysroot" > arg_file.txt +sysroot=$(./target/debug/clippy-driver @arg_file.txt --print sysroot) +test "$sysroot" = $desired_sysroot + +# Setting SYSROOT in command line sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) test "$sysroot" = $desired_sysroot @@ -24,6 +31,14 @@ test "$sysroot" = $desired_sysroot SYSROOT=/tmp RUSTFLAGS="--sysroot=$(rustc --print sysroot)" ../target/debug/cargo-clippy clippy --verbose ) +# Check that the --sysroot argument is only passed once via arg_file.txt (SYSROOT is ignored) +( + echo "fn main() {}" > target/driver_test.rs + echo "--sysroot="$(./target/debug/clippy-driver --print sysroot)"" > arg_file.txt + echo "--verbose" >> arg_file.txt + SYSROOT=/tmp ./target/debug/clippy-driver @arg_file.txt ./target/driver_test.rs +) + # Make sure this isn't set - clippy-driver should cope without it unset CARGO_MANIFEST_DIR diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fa45ceeb39be..9b853567219c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,65 @@ document. ## Unreleased / Beta / In Rust Nightly -[09ac14c9...master](https://github.com/rust-lang/rust-clippy/compare/09ac14c9...master) +[a859e5cc...master](https://github.com/rust-lang/rust-clippy/compare/a859e5cc...master) + +## Rust 1.76 + +Current stable, released 2024-02-08 + +[View all 85 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-11-02T20%3A23%3A40Z..2023-12-16T13%3A11%3A08Z+base%3Amaster) + +### New Lints + +- [`infinite_loop`] + [#11829](https://github.com/rust-lang/rust-clippy/pull/11829) +- [`ineffective_open_options`] + [#11902](https://github.com/rust-lang/rust-clippy/pull/11902) +- [`uninhabited_references`] + [#11878](https://github.com/rust-lang/rust-clippy/pull/11878) +- [`repeat_vec_with_capacity`] + [#11597](https://github.com/rust-lang/rust-clippy/pull/11597) +- [`test_attr_in_doctest`] + [#11872](https://github.com/rust-lang/rust-clippy/pull/11872) +- [`option_map_or_err_ok`] + [#11864](https://github.com/rust-lang/rust-clippy/pull/11864) +- [`join_absolute_paths`] + [#11453](https://github.com/rust-lang/rust-clippy/pull/11453) +- [`impl_hash_borrow_with_str_and_bytes`] + [#11781](https://github.com/rust-lang/rust-clippy/pull/11781) +- [`iter_over_hash_type`] + [#11791](https://github.com/rust-lang/rust-clippy/pull/11791) + +### Moves and Deprecations + +- Renamed `blocks_in_if_conditions` to [`blocks_in_conditions`] + [#11853](https://github.com/rust-lang/rust-clippy/pull/11853) +- Moved [`implied_bounds_in_impls`] to `complexity` (Now warn-by-default) + [#11867](https://github.com/rust-lang/rust-clippy/pull/11867) +- Moved [`if_same_then_else`] to `style` (Now warn-by-default) + [#11809](https://github.com/rust-lang/rust-clippy/pull/11809) + +### Enhancements + +- [`missing_safety_doc`], [`unnecessary_safety_doc`], [`missing_panics_doc`], [`missing_errors_doc`]: + Added the [`check-private-items`] configuration to enable lints on private items + [#11842](https://github.com/rust-lang/rust-clippy/pull/11842) + +### ICE Fixes + +- [`impl_trait_in_params`]: No longer crashes when a function has generics but no function parameters + [#11804](https://github.com/rust-lang/rust-clippy/pull/11804) +- [`unused_enumerate_index`]: No longer crashes on empty tuples + [#11756](https://github.com/rust-lang/rust-clippy/pull/11756) + +### Others + +- Clippy now respects the `CARGO` environment value + [#11944](https://github.com/rust-lang/rust-clippy/pull/11944) ## Rust 1.75 -Current stable, released 2023-12-28 +Released 2023-12-28 [View all 69 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-09-25T11%3A47%3A47Z..2023-11-02T16%3A41%3A59Z+base%3Amaster) @@ -5198,6 +5252,7 @@ Released 2018-09-13 [`implied_bounds_in_impls`]: https://rust-lang.github.io/rust-clippy/master/index.html#implied_bounds_in_impls [`impossible_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#impossible_comparisons [`imprecise_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops +[`incompatible_msrv`]: https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv [`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping [`inconsistent_struct_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor [`incorrect_clone_impl_on_copy_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_clone_impl_on_copy_type @@ -5276,6 +5331,7 @@ Released 2018-09-13 [`let_with_type_underscore`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_with_type_underscore [`lines_filter_map_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok [`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist +[`lint_groups_priority`]: https://rust-lang.github.io/rust-clippy/master/index.html#lint_groups_priority [`little_endian_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#little_endian_bytes [`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug [`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal @@ -5284,6 +5340,7 @@ Released 2018-09-13 [`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert [`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn [`manual_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits +[`manual_c_str_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals [`manual_clamp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp [`manual_filter`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter [`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map @@ -5523,6 +5580,7 @@ Released 2018-09-13 [`redundant_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_slicing [`redundant_static_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes [`redundant_type_annotations`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_type_annotations +[`ref_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr [`ref_binding_to_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_binding_to_reference [`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref [`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref @@ -5622,6 +5680,7 @@ Released 2018-09-13 [`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some [`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display [`to_string_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args +[`to_string_trait_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl [`todo`]: https://rust-lang.github.io/rust-clippy/master/index.html#todo [`too_many_arguments`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments [`too_many_lines`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines @@ -5677,6 +5736,7 @@ Released 2018-09-13 [`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed [`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation [`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings +[`unnecessary_result_map_or_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_result_map_or_else [`unnecessary_safety_comment`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_comment [`unnecessary_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_doc [`unnecessary_self_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports @@ -5819,4 +5879,6 @@ Released 2018-09-13 [`enforce-iter-loop-reborrow`]: https://doc.rust-lang.org/clippy/lint_configuration.html#enforce-iter-loop-reborrow [`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items [`pub-underscore-fields-behavior`]: https://doc.rust-lang.org/clippy/lint_configuration.html#pub-underscore-fields-behavior +[`allow-comparison-to-zero`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-comparison-to-zero +[`allowed-wildcard-imports`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-wildcard-imports diff --git a/Cargo.toml b/Cargo.toml index eda20531e40f3..321424880d1e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.1.77" +version = "0.1.78" description = "A bunch of helpful lints to avoid common pitfalls in Rust" repository = "https://github.com/rust-lang/rust-clippy" readme = "README.md" diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index 7f7aff92bf19b..f2357e2b5de92 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -151,6 +151,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio * [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold) * [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one) * [`iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map) +* [`manual_c_str_literals`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals) ## `cognitive-complexity-threshold` @@ -828,3 +829,35 @@ exported visibility, or whether they are marked as "pub". * [`pub_underscore_fields`](https://rust-lang.github.io/rust-clippy/master/index.html#pub_underscore_fields) +## `allow-comparison-to-zero` +Don't lint when comparing the result of a modulo operation to zero. + +**Default Value:** `true` + +--- +**Affected lints:** +* [`modulo_arithmetic`](https://rust-lang.github.io/rust-clippy/master/index.html#modulo_arithmetic) + + +## `allowed-wildcard-imports` +List of path segments allowed to have wildcard imports. + +#### Example + +```toml +allowed-wildcard-imports = [ "utils", "common" ] +``` + +#### Noteworthy + +1. This configuration has no effects if used with `warn_on_all_wildcard_imports = true`. +2. Paths with any segment that containing the word 'prelude' +are already allowed by default. + +**Default Value:** `[]` + +--- +**Affected lints:** +* [`wildcard_imports`](https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports) + + diff --git a/clippy_config/Cargo.toml b/clippy_config/Cargo.toml index 74b8e5eaa1c41..2edc5ed592cb0 100644 --- a/clippy_config/Cargo.toml +++ b/clippy_config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy_config" -version = "0.1.77" +version = "0.1.78" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs index 4e9ddbf8259d3..9741b94d50413 100644 --- a/clippy_config/src/conf.rs +++ b/clippy_config/src/conf.rs @@ -260,7 +260,7 @@ define_Conf! { /// /// Suppress lints whenever the suggested change would cause breakage for other crates. (avoid_breaking_exported_api: bool = true), - /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP. + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS. /// /// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml` #[default_text = ""] @@ -567,6 +567,26 @@ define_Conf! { /// Lint "public" fields in a struct that are prefixed with an underscore based on their /// exported visibility, or whether they are marked as "pub". (pub_underscore_fields_behavior: PubUnderscoreFieldsBehaviour = PubUnderscoreFieldsBehaviour::PubliclyExported), + /// Lint: MODULO_ARITHMETIC. + /// + /// Don't lint when comparing the result of a modulo operation to zero. + (allow_comparison_to_zero: bool = true), + /// Lint: WILDCARD_IMPORTS. + /// + /// List of path segments allowed to have wildcard imports. + /// + /// #### Example + /// + /// ```toml + /// allowed-wildcard-imports = [ "utils", "common" ] + /// ``` + /// + /// #### Noteworthy + /// + /// 1. This configuration has no effects if used with `warn_on_all_wildcard_imports = true`. + /// 2. Paths with any segment that containing the word 'prelude' + /// are already allowed by default. + (allowed_wildcard_imports: FxHashSet = FxHashSet::default()), } /// Search for the configuration file. diff --git a/clippy_config/src/msrvs.rs b/clippy_config/src/msrvs.rs index 72d5b9aff28df..f4389db627d8b 100644 --- a/clippy_config/src/msrvs.rs +++ b/clippy_config/src/msrvs.rs @@ -3,6 +3,7 @@ use rustc_semver::RustcVersion; use rustc_session::Session; use rustc_span::{sym, Symbol}; use serde::Deserialize; +use std::fmt; macro_rules! msrv_aliases { ($($major:literal,$minor:literal,$patch:literal { @@ -16,6 +17,8 @@ macro_rules! msrv_aliases { // names may refer to stabilized feature flags or library items msrv_aliases! { + 1,77,0 { C_STR_LITERALS } + 1,76,0 { PTR_FROM_REF } 1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE } 1,70,0 { OPTION_RESULT_IS_VARIANT_AND, BINARY_HEAP_RETAIN } 1,68,0 { PATH_MAIN_SEPARATOR_STR } @@ -58,6 +61,16 @@ pub struct Msrv { stack: Vec, } +impl fmt::Display for Msrv { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(msrv) = self.current() { + write!(f, "{msrv}") + } else { + f.write_str("1.0.0") + } + } +} + impl<'de> Deserialize<'de> for Msrv { fn deserialize(deserializer: D) -> Result where diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 416e9a680dd73..6e6e315bb6561 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy_lints" -version = "0.1.77" +version = "0.1.78" description = "A bunch of helpful lints to avoid common pitfalls in Rust" repository = "https://github.com/rust-lang/rust-clippy" readme = "README.md" diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index e11f83f226034..2d1c250ace905 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -499,6 +499,7 @@ struct NotSimplificationVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind + && !expr.span.from_expansion() && !inner.span.from_expansion() && let Some(suggestion) = simplify_not(self.cx, inner) && self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, expr.hir_id).0 != Level::Allow diff --git a/clippy_lints/src/cargo/lint_groups_priority.rs b/clippy_lints/src/cargo/lint_groups_priority.rs new file mode 100644 index 0000000000000..a39b972b56a23 --- /dev/null +++ b/clippy_lints/src/cargo/lint_groups_priority.rs @@ -0,0 +1,168 @@ +use super::LINT_GROUPS_PRIORITY; +use clippy_utils::diagnostics::span_lint_and_then; +use rustc_data_structures::fx::FxHashSet; +use rustc_errors::Applicability; +use rustc_lint::{unerased_lint_store, LateContext}; +use rustc_span::{BytePos, Pos, SourceFile, Span, SyntaxContext}; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; +use std::ops::Range; +use std::path::Path; +use toml::Spanned; + +#[derive(Deserialize, Serialize, Debug)] +struct LintConfigTable { + level: String, + priority: Option, +} + +#[derive(Deserialize, Debug)] +#[serde(untagged)] +enum LintConfig { + Level(String), + Table(LintConfigTable), +} + +impl LintConfig { + fn level(&self) -> &str { + match self { + LintConfig::Level(level) => level, + LintConfig::Table(table) => &table.level, + } + } + + fn priority(&self) -> i64 { + match self { + LintConfig::Level(_) => 0, + LintConfig::Table(table) => table.priority.unwrap_or(0), + } + } + + fn is_implicit(&self) -> bool { + if let LintConfig::Table(table) = self { + table.priority.is_none() + } else { + true + } + } +} + +type LintTable = BTreeMap, Spanned>; + +#[derive(Deserialize, Debug)] +struct Lints { + #[serde(default)] + rust: LintTable, + #[serde(default)] + clippy: LintTable, +} + +#[derive(Deserialize, Debug)] +struct CargoToml { + lints: Lints, +} + +#[derive(Default, Debug)] +struct LintsAndGroups { + lints: Vec>, + groups: Vec<(Spanned, Spanned)>, +} + +fn toml_span(range: Range, file: &SourceFile) -> Span { + Span::new( + file.start_pos + BytePos::from_usize(range.start), + file.start_pos + BytePos::from_usize(range.end), + SyntaxContext::root(), + None, + ) +} + +fn check_table(cx: &LateContext<'_>, table: LintTable, groups: &FxHashSet<&str>, file: &SourceFile) { + let mut by_priority = BTreeMap::<_, LintsAndGroups>::new(); + for (name, config) in table { + let lints_and_groups = by_priority.entry(config.as_ref().priority()).or_default(); + if groups.contains(name.get_ref().as_str()) { + lints_and_groups.groups.push((name, config)); + } else { + lints_and_groups.lints.push(name); + } + } + let low_priority = by_priority + .iter() + .find(|(_, lints_and_groups)| !lints_and_groups.lints.is_empty()) + .map_or(-1, |(&lowest_lint_priority, _)| lowest_lint_priority - 1); + + for (priority, LintsAndGroups { lints, groups }) in by_priority { + let Some(last_lint_alphabetically) = lints.last() else { + continue; + }; + + for (group, config) in groups { + span_lint_and_then( + cx, + LINT_GROUPS_PRIORITY, + toml_span(group.span(), file), + &format!( + "lint group `{}` has the same priority ({priority}) as a lint", + group.as_ref() + ), + |diag| { + let config_span = toml_span(config.span(), file); + if config.as_ref().is_implicit() { + diag.span_label(config_span, "has an implicit priority of 0"); + } + // add the label to next lint after this group that has the same priority + let lint = lints + .iter() + .filter(|lint| lint.span().start > group.span().start) + .min_by_key(|lint| lint.span().start) + .unwrap_or(last_lint_alphabetically); + diag.span_label(toml_span(lint.span(), file), "has the same priority as this lint"); + diag.note("the order of the lints in the table is ignored by Cargo"); + let mut suggestion = String::new(); + Serialize::serialize( + &LintConfigTable { + level: config.as_ref().level().into(), + priority: Some(low_priority), + }, + toml::ser::ValueSerializer::new(&mut suggestion), + ) + .unwrap(); + diag.span_suggestion_verbose( + config_span, + format!( + "to have lints override the group set `{}` to a lower priority", + group.as_ref() + ), + suggestion, + Applicability::MaybeIncorrect, + ); + }, + ); + } + } +} + +pub fn check(cx: &LateContext<'_>) { + if let Ok(file) = cx.tcx.sess.source_map().load_file(Path::new("Cargo.toml")) + && let Some(src) = file.src.as_deref() + && let Ok(cargo_toml) = toml::from_str::(src) + { + let mut rustc_groups = FxHashSet::default(); + let mut clippy_groups = FxHashSet::default(); + for (group, ..) in unerased_lint_store(cx.tcx.sess).get_lint_groups() { + match group.split_once("::") { + None => { + rustc_groups.insert(group); + }, + Some(("clippy", group)) => { + clippy_groups.insert(group); + }, + _ => {}, + } + } + + check_table(cx, cargo_toml.lints.rust, &rustc_groups, &file); + check_table(cx, cargo_toml.lints.clippy, &clippy_groups, &file); + } +} diff --git a/clippy_lints/src/cargo/mod.rs b/clippy_lints/src/cargo/mod.rs index d8107f61f371c..95d5449781b47 100644 --- a/clippy_lints/src/cargo/mod.rs +++ b/clippy_lints/src/cargo/mod.rs @@ -1,5 +1,6 @@ mod common_metadata; mod feature_name; +mod lint_groups_priority; mod multiple_crate_versions; mod wildcard_dependencies; @@ -165,6 +166,43 @@ declare_clippy_lint! { "wildcard dependencies being used" } +declare_clippy_lint! { + /// ### What it does + /// Checks for lint groups with the same priority as lints in the `Cargo.toml` + /// [`[lints]` table](https://doc.rust-lang.org/cargo/reference/manifest.html#the-lints-section). + /// + /// This lint will be removed once [cargo#12918](https://github.com/rust-lang/cargo/issues/12918) + /// is resolved. + /// + /// ### Why is this bad? + /// The order of lints in the `[lints]` is ignored, to have a lint override a group the + /// `priority` field needs to be used, otherwise the sort order is undefined. + /// + /// ### Known problems + /// Does not check lints inherited using `lints.workspace = true` + /// + /// ### Example + /// ```toml + /// # Passed as `--allow=clippy::similar_names --warn=clippy::pedantic` + /// # which results in `similar_names` being `warn` + /// [lints.clippy] + /// pedantic = "warn" + /// similar_names = "allow" + /// ``` + /// Use instead: + /// ```toml + /// # Passed as `--warn=clippy::pedantic --allow=clippy::similar_names` + /// # which results in `similar_names` being `allow` + /// [lints.clippy] + /// pedantic = { level = "warn", priority = -1 } + /// similar_names = "allow" + /// ``` + #[clippy::version = "1.76.0"] + pub LINT_GROUPS_PRIORITY, + correctness, + "a lint group in `Cargo.toml` at the same priority as a lint" +} + pub struct Cargo { pub allowed_duplicate_crates: FxHashSet, pub ignore_publish: bool, @@ -175,7 +213,8 @@ impl_lint_pass!(Cargo => [ REDUNDANT_FEATURE_NAMES, NEGATIVE_FEATURE_NAMES, MULTIPLE_CRATE_VERSIONS, - WILDCARD_DEPENDENCIES + WILDCARD_DEPENDENCIES, + LINT_GROUPS_PRIORITY, ]); impl LateLintPass<'_> for Cargo { @@ -188,6 +227,8 @@ impl LateLintPass<'_> for Cargo { ]; static WITH_DEPS_LINTS: &[&Lint] = &[MULTIPLE_CRATE_VERSIONS]; + lint_groups_priority::check(cx); + if !NO_DEPS_LINTS .iter() .all(|&lint| is_lint_allowed(cx, lint, CRATE_HIR_ID)) diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index e05b8f66d8618..14f2f4a7f59da 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -18,6 +18,7 @@ mod fn_to_numeric_cast_any; mod fn_to_numeric_cast_with_truncation; mod ptr_as_ptr; mod ptr_cast_constness; +mod ref_as_ptr; mod unnecessary_cast; mod utils; mod zero_ptr; @@ -689,6 +690,30 @@ declare_clippy_lint! { "using `0 as *{const, mut} T`" } +declare_clippy_lint! { + /// ### What it does + /// Checks for casts of references to pointer using `as` + /// and suggests `std::ptr::from_ref` and `std::ptr::from_mut` instead. + /// + /// ### Why is this bad? + /// Using `as` casts may result in silently changing mutability or type. + /// + /// ### Example + /// ```no_run + /// let a_ref = &1; + /// let a_ptr = a_ref as *const _; + /// ``` + /// Use instead: + /// ```no_run + /// let a_ref = &1; + /// let a_ptr = std::ptr::from_ref(a_ref); + /// ``` + #[clippy::version = "1.77.0"] + pub REF_AS_PTR, + pedantic, + "using `as` to cast a reference to pointer" +} + pub struct Casts { msrv: Msrv, } @@ -724,6 +749,7 @@ impl_lint_pass!(Casts => [ AS_PTR_CAST_MUT, CAST_NAN_TO_INT, ZERO_PTR, + REF_AS_PTR, ]); impl<'tcx> LateLintPass<'tcx> for Casts { @@ -771,7 +797,9 @@ impl<'tcx> LateLintPass<'tcx> for Casts { as_underscore::check(cx, expr, cast_to_hir); - if self.msrv.meets(msrvs::BORROW_AS_PTR) { + if self.msrv.meets(msrvs::PTR_FROM_REF) { + ref_as_ptr::check(cx, expr, cast_expr, cast_to_hir); + } else if self.msrv.meets(msrvs::BORROW_AS_PTR) { borrow_as_ptr::check(cx, expr, cast_expr, cast_to_hir); } } diff --git a/clippy_lints/src/casts/ref_as_ptr.rs b/clippy_lints/src/casts/ref_as_ptr.rs new file mode 100644 index 0000000000000..d600d2aec1b5e --- /dev/null +++ b/clippy_lints/src/casts/ref_as_ptr.rs @@ -0,0 +1,55 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_no_std_crate; +use clippy_utils::source::snippet_with_applicability; +use clippy_utils::sugg::Sugg; +use rustc_errors::Applicability; +use rustc_hir::{Expr, Mutability, Ty, TyKind}; +use rustc_lint::LateContext; +use rustc_middle::ty::{self, TypeAndMut}; + +use super::REF_AS_PTR; + +pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to_hir_ty: &Ty<'_>) { + let (cast_from, cast_to) = ( + cx.typeck_results().expr_ty(cast_expr), + cx.typeck_results().expr_ty(expr), + ); + + if matches!(cast_from.kind(), ty::Ref(..)) + && let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, .. }) = cast_to.kind() + { + let core_or_std = if is_no_std_crate(cx) { "core" } else { "std" }; + let fn_name = match to_mutbl { + Mutability::Not => "from_ref", + Mutability::Mut => "from_mut", + }; + + let mut app = Applicability::MachineApplicable; + let turbofish = match &cast_to_hir_ty.kind { + TyKind::Infer => String::new(), + TyKind::Ptr(mut_ty) => { + if matches!(mut_ty.ty.kind, TyKind::Infer) { + String::new() + } else { + format!( + "::<{}>", + snippet_with_applicability(cx, mut_ty.ty.span, "/* type */", &mut app) + ) + } + }, + _ => return, + }; + + let cast_expr_sugg = Sugg::hir_with_applicability(cx, cast_expr, "_", &mut app); + + span_lint_and_sugg( + cx, + REF_AS_PTR, + expr.span, + "reference as raw pointer", + "try", + format!("{core_or_std}::ptr::{fn_name}{turbofish}({cast_expr_sugg})"), + app, + ); + } +} diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 639edd8da3012..0a5baabd973ea 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -71,6 +71,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::borrow_deref_ref::BORROW_DEREF_REF_INFO, crate::box_default::BOX_DEFAULT_INFO, crate::cargo::CARGO_COMMON_METADATA_INFO, + crate::cargo::LINT_GROUPS_PRIORITY_INFO, crate::cargo::MULTIPLE_CRATE_VERSIONS_INFO, crate::cargo::NEGATIVE_FEATURE_NAMES_INFO, crate::cargo::REDUNDANT_FEATURE_NAMES_INFO, @@ -96,6 +97,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::casts::FN_TO_NUMERIC_CAST_WITH_TRUNCATION_INFO, crate::casts::PTR_AS_PTR_INFO, crate::casts::PTR_CAST_CONSTNESS_INFO, + crate::casts::REF_AS_PTR_INFO, crate::casts::UNNECESSARY_CAST_INFO, crate::casts::ZERO_PTR_INFO, crate::checked_conversions::CHECKED_CONVERSIONS_INFO, @@ -212,6 +214,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::implicit_saturating_add::IMPLICIT_SATURATING_ADD_INFO, crate::implicit_saturating_sub::IMPLICIT_SATURATING_SUB_INFO, crate::implied_bounds_in_impls::IMPLIED_BOUNDS_IN_IMPLS_INFO, + crate::incompatible_msrv::INCOMPATIBLE_MSRV_INFO, crate::inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR_INFO, crate::index_refutable_slice::INDEX_REFUTABLE_SLICE_INFO, crate::indexing_slicing::INDEXING_SLICING_INFO, @@ -384,6 +387,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::methods::ITER_SKIP_ZERO_INFO, crate::methods::ITER_WITH_DRAIN_INFO, crate::methods::JOIN_ABSOLUTE_PATHS_INFO, + crate::methods::MANUAL_C_STR_LITERALS_INFO, crate::methods::MANUAL_FILTER_MAP_INFO, crate::methods::MANUAL_FIND_MAP_INFO, crate::methods::MANUAL_IS_VARIANT_AND_INFO, @@ -452,6 +456,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::methods::UNNECESSARY_JOIN_INFO, crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO, crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO, + crate::methods::UNNECESSARY_RESULT_MAP_OR_ELSE_INFO, crate::methods::UNNECESSARY_SORT_BY_INFO, crate::methods::UNNECESSARY_TO_OWNED_INFO, crate::methods::UNWRAP_OR_DEFAULT_INFO, @@ -656,6 +661,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::tests_outside_test_module::TESTS_OUTSIDE_TEST_MODULE_INFO, crate::thread_local_initializer_can_be_made_const::THREAD_LOCAL_INITIALIZER_CAN_BE_MADE_CONST_INFO, crate::to_digit_is_some::TO_DIGIT_IS_SOME_INFO, + crate::to_string_trait_impl::TO_STRING_TRAIT_IMPL_INFO, crate::trailing_empty_array::TRAILING_EMPTY_ARRAY_INFO, crate::trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS_INFO, crate::trait_bounds::TYPE_REPETITION_IN_BOUNDS_INFO, diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index ba452775015dd..2b4ce6ddfaaa3 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -226,7 +226,7 @@ declare_clippy_lint! { /// unimplemented!(); /// } /// ``` - #[clippy::version = "1.40.0"] + #[clippy::version = "1.76.0"] pub TEST_ATTR_IN_DOCTEST, suspicious, "presence of `#[test]` in code examples" diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 450cee4007c72..40be71a0e5d61 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -3,15 +3,14 @@ use clippy_utils::higher::VecArgs; use clippy_utils::source::snippet_opt; use clippy_utils::ty::type_diagnostic_name; use clippy_utils::usage::{local_used_after_expr, local_used_in}; -use clippy_utils::{higher, is_adjusted, path_to_local, path_to_local_id}; +use clippy_utils::{get_path_from_caller_to_method_type, higher, is_adjusted, path_to_local, path_to_local_id}; use rustc_errors::Applicability; -use rustc_hir::def_id::DefId; use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{ - self, Binder, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, GenericArgsRef, - ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults, + self, Binder, ClosureArgs, ClosureKind, FnSig, GenericArg, GenericArgKind, ImplPolarity, List, Region, RegionKind, + Ty, TypeVisitableExt, TypeckResults, }; use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; @@ -21,8 +20,8 @@ use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _; declare_clippy_lint! { /// ### What it does /// Checks for closures which just call another function where - /// the function can be called directly. `unsafe` functions or calls where types - /// get adjusted are ignored. + /// the function can be called directly. `unsafe` functions, calls where types + /// get adjusted or where the callee is marked `#[track_caller]` are ignored. /// /// ### Why is this bad? /// Needlessly creating a closure adds code for no benefit @@ -136,7 +135,14 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { .map_or(callee_ty, |a| a.target.peel_refs()); let sig = match callee_ty_adjusted.kind() { - ty::FnDef(def, _) => cx.tcx.fn_sig(def).skip_binder().skip_binder(), + ty::FnDef(def, _) => { + // Rewriting `x(|| f())` to `x(f)` where f is marked `#[track_caller]` moves the `Location` + if cx.tcx.has_attr(*def, sym::track_caller) { + return; + } + + cx.tcx.fn_sig(def).skip_binder().skip_binder() + }, ty::FnPtr(sig) => sig.skip_binder(), ty::Closure(_, subs) => cx .tcx @@ -186,6 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { }, ExprKind::MethodCall(path, self_, args, _) if check_inputs(typeck, body.params, Some(self_), args) => { if let Some(method_def_id) = typeck.type_dependent_def_id(body.value.hir_id) + && !cx.tcx.has_attr(method_def_id, sym::track_caller) && check_sig(cx, closure, cx.tcx.fn_sig(method_def_id).skip_binder().skip_binder()) { span_lint_and_then( @@ -195,11 +202,12 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { "redundant closure", |diag| { let args = typeck.node_args(body.value.hir_id); - let name = get_ufcs_type_name(cx, method_def_id, args); + let caller = self_.hir_id.owner.def_id; + let type_name = get_path_from_caller_to_method_type(cx.tcx, caller, method_def_id, args); diag.span_suggestion( expr.span, "replace the closure with the method itself", - format!("{}::{}", name, path.ident.name), + format!("{}::{}", type_name, path.ident.name), Applicability::MachineApplicable, ); }, @@ -301,27 +309,3 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<' .zip(to_sig.inputs_and_output) .any(|(from_ty, to_ty)| check_ty(from_ty, to_ty)) } - -fn get_ufcs_type_name<'tcx>(cx: &LateContext<'tcx>, method_def_id: DefId, args: GenericArgsRef<'tcx>) -> String { - let assoc_item = cx.tcx.associated_item(method_def_id); - let def_id = assoc_item.container_id(cx.tcx); - match assoc_item.container { - ty::TraitContainer => cx.tcx.def_path_str(def_id), - ty::ImplContainer => { - let ty = cx.tcx.type_of(def_id).instantiate_identity(); - match ty.kind() { - ty::Adt(adt, _) => cx.tcx.def_path_str(adt.did()), - ty::Array(..) - | ty::Dynamic(..) - | ty::Never - | ty::RawPtr(_) - | ty::Ref(..) - | ty::Slice(_) - | ty::Tuple(_) => { - format!("<{}>", EarlyBinder::bind(ty).instantiate(cx.tcx, args)) - }, - _ => ty.to_string(), - } - }, - } -} diff --git a/clippy_lints/src/incompatible_msrv.rs b/clippy_lints/src/incompatible_msrv.rs new file mode 100644 index 0000000000000..f2f0e7d426628 --- /dev/null +++ b/clippy_lints/src/incompatible_msrv.rs @@ -0,0 +1,133 @@ +use clippy_config::msrvs::Msrv; +use clippy_utils::diagnostics::span_lint; +use rustc_attr::{StabilityLevel, StableSince}; +use rustc_data_structures::fx::FxHashMap; +use rustc_hir::{Expr, ExprKind}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::TyCtxt; +use rustc_semver::RustcVersion; +use rustc_session::impl_lint_pass; +use rustc_span::def_id::DefId; +use rustc_span::Span; + +declare_clippy_lint! { + /// ### What it does + /// + /// This lint checks that no function newer than the defined MSRV (minimum + /// supported rust version) is used in the crate. + /// + /// ### Why is this bad? + /// + /// It would prevent the crate to be actually used with the specified MSRV. + /// + /// ### Example + /// ```no_run + /// // MSRV of 1.3.0 + /// use std::thread::sleep; + /// use std::time::Duration; + /// + /// // Sleep was defined in `1.4.0`. + /// sleep(Duration::new(1, 0)); + /// ``` + /// + /// To fix this problem, either increase your MSRV or use another item + /// available in your current MSRV. + #[clippy::version = "1.77.0"] + pub INCOMPATIBLE_MSRV, + suspicious, + "ensures that all items used in the crate are available for the current MSRV" +} + +pub struct IncompatibleMsrv { + msrv: Msrv, + is_above_msrv: FxHashMap, +} + +impl_lint_pass!(IncompatibleMsrv => [INCOMPATIBLE_MSRV]); + +impl IncompatibleMsrv { + pub fn new(msrv: Msrv) -> Self { + Self { + msrv, + is_above_msrv: FxHashMap::default(), + } + } + + #[allow(clippy::cast_lossless)] + fn get_def_id_version(&mut self, tcx: TyCtxt<'_>, def_id: DefId) -> RustcVersion { + if let Some(version) = self.is_above_msrv.get(&def_id) { + return *version; + } + let version = if let Some(version) = tcx + .lookup_stability(def_id) + .and_then(|stability| match stability.level { + StabilityLevel::Stable { + since: StableSince::Version(version), + .. + } => Some(RustcVersion::new( + version.major as _, + version.minor as _, + version.patch as _, + )), + _ => None, + }) { + version + } else if let Some(parent_def_id) = tcx.opt_parent(def_id) { + self.get_def_id_version(tcx, parent_def_id) + } else { + RustcVersion::new(1, 0, 0) + }; + self.is_above_msrv.insert(def_id, version); + version + } + + fn emit_lint_if_under_msrv(&mut self, cx: &LateContext<'_>, def_id: DefId, span: Span) { + if def_id.is_local() { + // We don't check local items since their MSRV is supposed to always be valid. + return; + } + let version = self.get_def_id_version(cx.tcx, def_id); + if self.msrv.meets(version) { + return; + } + self.emit_lint_for(cx, span, version); + } + + fn emit_lint_for(&self, cx: &LateContext<'_>, span: Span, version: RustcVersion) { + span_lint( + cx, + INCOMPATIBLE_MSRV, + span, + &format!( + "current MSRV (Minimum Supported Rust Version) is `{}` but this item is stable since `{version}`", + self.msrv + ), + ); + } +} + +impl<'tcx> LateLintPass<'tcx> for IncompatibleMsrv { + extract_msrv_attr!(LateContext); + + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + if self.msrv.current().is_none() { + // If there is no MSRV, then no need to check anything... + return; + } + match expr.kind { + ExprKind::MethodCall(_, _, _, span) => { + if let Some(method_did) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { + self.emit_lint_if_under_msrv(cx, method_did, span); + } + }, + ExprKind::Call(call, [_]) => { + if let ExprKind::Path(qpath) = call.kind + && let Some(path_def_id) = cx.qpath_res(&qpath, call.hir_id).opt_def_id() + { + self.emit_lint_if_under_msrv(cx, path_def_id, call.span); + } + }, + _ => {}, + } + } +} diff --git a/clippy_lints/src/iter_over_hash_type.rs b/clippy_lints/src/iter_over_hash_type.rs index 8110c1970d9b1..6c6eff9ba48bd 100644 --- a/clippy_lints/src/iter_over_hash_type.rs +++ b/clippy_lints/src/iter_over_hash_type.rs @@ -34,7 +34,7 @@ declare_clippy_lint! { /// let value = &my_map[key]; /// } /// ``` - #[clippy::version = "1.75.0"] + #[clippy::version = "1.76.0"] pub ITER_OVER_HASH_TYPE, restriction, "iterating over unordered hash-based types (`HashMap` and `HashSet`)" diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index feb4d188f3978..5636f46b22fee 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -26,6 +26,7 @@ extern crate rustc_abi; extern crate rustc_arena; extern crate rustc_ast; extern crate rustc_ast_pretty; +extern crate rustc_attr; extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_errors; @@ -153,6 +154,7 @@ mod implicit_return; mod implicit_saturating_add; mod implicit_saturating_sub; mod implied_bounds_in_impls; +mod incompatible_msrv; mod inconsistent_struct_constructor; mod index_refutable_slice; mod indexing_slicing; @@ -325,6 +327,7 @@ mod temporary_assignment; mod tests_outside_test_module; mod thread_local_initializer_can_be_made_const; mod to_digit_is_some; +mod to_string_trait_impl; mod trailing_empty_array; mod trait_bounds; mod transmute; @@ -521,6 +524,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { ref allowed_dotfiles, ref allowed_idents_below_min_chars, ref allowed_scripts, + ref allowed_wildcard_imports, ref arithmetic_side_effects_allowed_binary, ref arithmetic_side_effects_allowed_unary, ref arithmetic_side_effects_allowed, @@ -575,6 +579,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { check_private_items, pub_underscore_fields_behavior, ref allowed_duplicate_crates, + allow_comparison_to_zero, blacklisted_names: _, cyclomatic_complexity_threshold: _, @@ -872,7 +877,12 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { )) }); store.register_early_pass(|| Box::new(option_env_unwrap::OptionEnvUnwrap)); - store.register_late_pass(move |_| Box::new(wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports))); + store.register_late_pass(move |_| { + Box::new(wildcard_imports::WildcardImports::new( + warn_on_all_wildcard_imports, + allowed_wildcard_imports.clone(), + )) + }); store.register_late_pass(|_| Box::::default()); store.register_late_pass(|_| Box::new(unnamed_address::UnnamedAddress)); store.register_late_pass(|_| Box::>::default()); @@ -968,7 +978,12 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { store.register_late_pass(|_| Box::new(default_instead_of_iter_empty::DefaultIterEmpty)); store.register_late_pass(move |_| Box::new(manual_rem_euclid::ManualRemEuclid::new(msrv()))); store.register_late_pass(move |_| Box::new(manual_retain::ManualRetain::new(msrv()))); - store.register_late_pass(move |_| Box::new(operators::Operators::new(verbose_bit_mask_threshold))); + store.register_late_pass(move |_| { + Box::new(operators::Operators::new( + verbose_bit_mask_threshold, + allow_comparison_to_zero, + )) + }); store.register_late_pass(|_| Box::::default()); store.register_late_pass(move |_| Box::new(instant_subtraction::InstantSubtraction::new(msrv()))); store.register_late_pass(|_| Box::new(partialeq_to_none::PartialeqToNone)); @@ -1094,6 +1109,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { store.register_late_pass(move |_| { Box::new(thread_local_initializer_can_be_made_const::ThreadLocalInitializerCanBeMadeConst::new(msrv())) }); + store.register_late_pass(move |_| Box::new(incompatible_msrv::IncompatibleMsrv::new(msrv()))); + store.register_late_pass(|_| Box::new(to_string_trait_impl::ToStringTraitImpl)); // add lints here, do not remove this comment, it's used in `new_lint` } diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 3c9bde86bb6f8..b5e39b33c6a15 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -672,7 +672,7 @@ declare_clippy_lint! { /// } /// } /// ``` - #[clippy::version = "1.75.0"] + #[clippy::version = "1.76.0"] pub INFINITE_LOOP, restriction, "possibly unintended infinite loop" diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index 62bc663191f60..245a903f99826 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -201,12 +201,12 @@ fn never_loop_expr<'tcx>( }) }) }, - ExprKind::Block(b, l) => { - if l.is_some() { + ExprKind::Block(b, _) => { + if b.targeted_by_break { local_labels.push((b.hir_id, false)); } let ret = never_loop_block(cx, b, local_labels, main_loop_id); - let jumped_to = l.is_some() && local_labels.pop().unwrap().1; + let jumped_to = b.targeted_by_break && local_labels.pop().unwrap().1; match ret { NeverLoopResult::Diverging if jumped_to => NeverLoopResult::Normal, _ => ret, diff --git a/clippy_lints/src/manual_retain.rs b/clippy_lints/src/manual_retain.rs index 1fe247dacb932..6f15fca089eba 100644 --- a/clippy_lints/src/manual_retain.rs +++ b/clippy_lints/src/manual_retain.rs @@ -11,6 +11,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_semver::RustcVersion; use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; +use rustc_span::Span; const ACCEPTABLE_METHODS: [&[&str]; 5] = [ &paths::BINARYHEAP_ITER, @@ -28,6 +29,7 @@ const ACCEPTABLE_TYPES: [(rustc_span::Symbol, Option); 7] = [ (sym::Vec, None), (sym::VecDeque, None), ]; +const MAP_TYPES: [rustc_span::Symbol; 2] = [sym::BTreeMap, sym::HashMap]; declare_clippy_lint! { /// ### What it does @@ -44,6 +46,7 @@ declare_clippy_lint! { /// ```no_run /// let mut vec = vec![0, 1, 2]; /// vec.retain(|x| x % 2 == 0); + /// vec.retain(|x| x % 2 == 0); /// ``` #[clippy::version = "1.64.0"] pub MANUAL_RETAIN, @@ -74,9 +77,9 @@ impl<'tcx> LateLintPass<'tcx> for ManualRetain { && let Some(collect_def_id) = cx.typeck_results().type_dependent_def_id(collect_expr.hir_id) && cx.tcx.is_diagnostic_item(sym::iterator_collect_fn, collect_def_id) { - check_into_iter(cx, parent_expr, left_expr, target_expr, &self.msrv); - check_iter(cx, parent_expr, left_expr, target_expr, &self.msrv); - check_to_owned(cx, parent_expr, left_expr, target_expr, &self.msrv); + check_into_iter(cx, left_expr, target_expr, parent_expr.span, &self.msrv); + check_iter(cx, left_expr, target_expr, parent_expr.span, &self.msrv); + check_to_owned(cx, left_expr, target_expr, parent_expr.span, &self.msrv); } } @@ -85,9 +88,9 @@ impl<'tcx> LateLintPass<'tcx> for ManualRetain { fn check_into_iter( cx: &LateContext<'_>, - parent_expr: &hir::Expr<'_>, left_expr: &hir::Expr<'_>, target_expr: &hir::Expr<'_>, + parent_expr_span: Span, msrv: &Msrv, ) { if let hir::ExprKind::MethodCall(_, into_iter_expr, [_], _) = &target_expr.kind @@ -98,16 +101,39 @@ fn check_into_iter( && Some(into_iter_def_id) == cx.tcx.lang_items().into_iter_fn() && match_acceptable_type(cx, left_expr, msrv) && SpanlessEq::new(cx).eq_expr(left_expr, struct_expr) + && let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = target_expr.kind + && let hir::ExprKind::Closure(closure) = closure_expr.kind + && let filter_body = cx.tcx.hir().body(closure.body) + && let [filter_params] = filter_body.params { - suggest(cx, parent_expr, left_expr, target_expr); + if match_map_type(cx, left_expr) { + if let hir::PatKind::Tuple([key_pat, value_pat], _) = filter_params.pat.kind { + if let Some(sugg) = make_sugg(cx, key_pat, value_pat, left_expr, filter_body) { + make_span_lint_and_sugg(cx, parent_expr_span, sugg); + } + } + // Cannot lint other cases because `retain` requires two parameters + } else { + // Can always move because `retain` and `filter` have the same bound on the predicate + // for other types + make_span_lint_and_sugg( + cx, + parent_expr_span, + format!( + "{}.retain({})", + snippet(cx, left_expr.span, ".."), + snippet(cx, closure_expr.span, "..") + ), + ); + } } } fn check_iter( cx: &LateContext<'_>, - parent_expr: &hir::Expr<'_>, left_expr: &hir::Expr<'_>, target_expr: &hir::Expr<'_>, + parent_expr_span: Span, msrv: &Msrv, ) { if let hir::ExprKind::MethodCall(_, filter_expr, [], _) = &target_expr.kind @@ -122,16 +148,50 @@ fn check_iter( && match_acceptable_def_path(cx, iter_expr_def_id) && match_acceptable_type(cx, left_expr, msrv) && SpanlessEq::new(cx).eq_expr(left_expr, struct_expr) + && let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind + && let hir::ExprKind::Closure(closure) = closure_expr.kind + && let filter_body = cx.tcx.hir().body(closure.body) + && let [filter_params] = filter_body.params { - suggest(cx, parent_expr, left_expr, filter_expr); + match filter_params.pat.kind { + // hir::PatKind::Binding(_, _, _, None) => { + // // Be conservative now. Do nothing here. + // // TODO: Ideally, we can rewrite the lambda by stripping one level of reference + // }, + hir::PatKind::Tuple([_, _], _) => { + // the `&&` reference for the `filter` method will be auto derefed to `ref` + // so, we can directly use the lambda + // https://doc.rust-lang.org/reference/patterns.html#binding-modes + make_span_lint_and_sugg( + cx, + parent_expr_span, + format!( + "{}.retain({})", + snippet(cx, left_expr.span, ".."), + snippet(cx, closure_expr.span, "..") + ), + ); + }, + hir::PatKind::Ref(pat, _) => make_span_lint_and_sugg( + cx, + parent_expr_span, + format!( + "{}.retain(|{}| {})", + snippet(cx, left_expr.span, ".."), + snippet(cx, pat.span, ".."), + snippet(cx, filter_body.value.span, "..") + ), + ), + _ => {}, + } } } fn check_to_owned( cx: &LateContext<'_>, - parent_expr: &hir::Expr<'_>, left_expr: &hir::Expr<'_>, target_expr: &hir::Expr<'_>, + parent_expr_span: Span, msrv: &Msrv, ) { if msrv.meets(msrvs::STRING_RETAIN) @@ -147,43 +207,25 @@ fn check_to_owned( && let ty = cx.typeck_results().expr_ty(str_expr).peel_refs() && is_type_lang_item(cx, ty, hir::LangItem::String) && SpanlessEq::new(cx).eq_expr(left_expr, str_expr) - { - suggest(cx, parent_expr, left_expr, filter_expr); - } -} - -fn suggest(cx: &LateContext<'_>, parent_expr: &hir::Expr<'_>, left_expr: &hir::Expr<'_>, filter_expr: &hir::Expr<'_>) { - if let hir::ExprKind::MethodCall(_, _, [closure], _) = filter_expr.kind - && let hir::ExprKind::Closure(&hir::Closure { body, .. }) = closure.kind - && let filter_body = cx.tcx.hir().body(body) + && let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind + && let hir::ExprKind::Closure(closure) = closure_expr.kind + && let filter_body = cx.tcx.hir().body(closure.body) && let [filter_params] = filter_body.params - && let Some(sugg) = match filter_params.pat.kind { - hir::PatKind::Binding(_, _, filter_param_ident, None) => Some(format!( - "{}.retain(|{filter_param_ident}| {})", - snippet(cx, left_expr.span, ".."), - snippet(cx, filter_body.value.span, "..") - )), - hir::PatKind::Tuple([key_pat, value_pat], _) => make_sugg(cx, key_pat, value_pat, left_expr, filter_body), - hir::PatKind::Ref(pat, _) => match pat.kind { - hir::PatKind::Binding(_, _, filter_param_ident, None) => Some(format!( - "{}.retain(|{filter_param_ident}| {})", + { + if let hir::PatKind::Ref(pat, _) = filter_params.pat.kind { + make_span_lint_and_sugg( + cx, + parent_expr_span, + format!( + "{}.retain(|{}| {})", snippet(cx, left_expr.span, ".."), + snippet(cx, pat.span, ".."), snippet(cx, filter_body.value.span, "..") - )), - _ => None, - }, - _ => None, + ), + ); } - { - span_lint_and_sugg( - cx, - MANUAL_RETAIN, - parent_expr.span, - "this expression can be written more simply using `.retain()`", - "consider calling `.retain()` instead", - sugg, - Applicability::MachineApplicable, - ); + // Be conservative now. Do nothing for the `Binding` case. + // TODO: Ideally, we can rewrite the lambda by stripping one level of reference } } @@ -229,3 +271,20 @@ fn match_acceptable_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>, msrv: &Msrv && acceptable_msrv.map_or(true, |acceptable_msrv| msrv.meets(acceptable_msrv)) }) } + +fn match_map_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { + let expr_ty = cx.typeck_results().expr_ty(expr).peel_refs(); + MAP_TYPES.iter().any(|ty| is_type_diagnostic_item(cx, expr_ty, *ty)) +} + +fn make_span_lint_and_sugg(cx: &LateContext<'_>, span: Span, sugg: String) { + span_lint_and_sugg( + cx, + MANUAL_RETAIN, + span, + "this expression can be written more simply using `.retain()`", + "consider calling `.retain()` instead", + sugg, + Applicability::MachineApplicable, + ); +} diff --git a/clippy_lints/src/methods/manual_c_str_literals.rs b/clippy_lints/src/methods/manual_c_str_literals.rs new file mode 100644 index 0000000000000..cb9fb373c10a6 --- /dev/null +++ b/clippy_lints/src/methods/manual_c_str_literals.rs @@ -0,0 +1,197 @@ +use clippy_config::msrvs::{self, Msrv}; +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::get_parent_expr; +use clippy_utils::source::snippet; +use rustc_ast::{LitKind, StrStyle}; +use rustc_errors::Applicability; +use rustc_hir::{Expr, ExprKind, Node, QPath, TyKind}; +use rustc_lint::LateContext; +use rustc_span::{sym, Span, Symbol}; + +use super::MANUAL_C_STR_LITERALS; + +/// Checks: +/// - `b"...".as_ptr()` +/// - `b"...".as_ptr().cast()` +/// - `"...".as_ptr()` +/// - `"...".as_ptr().cast()` +/// +/// Iff the parent call of `.cast()` isn't `CStr::from_ptr`, to avoid linting twice. +pub(super) fn check_as_ptr<'tcx>( + cx: &LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, + receiver: &'tcx Expr<'tcx>, + msrv: &Msrv, +) { + if let ExprKind::Lit(lit) = receiver.kind + && let LitKind::ByteStr(_, StrStyle::Cooked) | LitKind::Str(_, StrStyle::Cooked) = lit.node + && let casts_removed = peel_ptr_cast_ancestors(cx, expr) + && !get_parent_expr(cx, casts_removed).is_some_and( + |parent| matches!(parent.kind, ExprKind::Call(func, _) if is_c_str_function(cx, func).is_some()), + ) + && let Some(sugg) = rewrite_as_cstr(cx, lit.span) + && msrv.meets(msrvs::C_STR_LITERALS) + { + span_lint_and_sugg( + cx, + MANUAL_C_STR_LITERALS, + receiver.span, + "manually constructing a nul-terminated string", + r#"use a `c""` literal"#, + sugg, + // an additional cast may be needed, since the type of `CStr::as_ptr` and + // `"".as_ptr()` can differ and is platform dependent + Applicability::HasPlaceholders, + ); + } +} + +/// Checks if the callee is a "relevant" `CStr` function considered by this lint. +/// Returns the function name. +fn is_c_str_function(cx: &LateContext<'_>, func: &Expr<'_>) -> Option { + if let ExprKind::Path(QPath::TypeRelative(cstr, fn_name)) = &func.kind + && let TyKind::Path(QPath::Resolved(_, ty_path)) = &cstr.kind + && cx.tcx.lang_items().c_str() == ty_path.res.opt_def_id() + { + Some(fn_name.ident.name) + } else { + None + } +} + +/// Checks calls to the `CStr` constructor functions: +/// - `CStr::from_bytes_with_nul(..)` +/// - `CStr::from_bytes_with_nul_unchecked(..)` +/// - `CStr::from_ptr(..)` +pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, func: &Expr<'_>, args: &[Expr<'_>], msrv: &Msrv) { + if let Some(fn_name) = is_c_str_function(cx, func) + && let [arg] = args + && msrv.meets(msrvs::C_STR_LITERALS) + { + match fn_name.as_str() { + name @ ("from_bytes_with_nul" | "from_bytes_with_nul_unchecked") + if !arg.span.from_expansion() + && let ExprKind::Lit(lit) = arg.kind + && let LitKind::ByteStr(_, StrStyle::Cooked) | LitKind::Str(_, StrStyle::Cooked) = lit.node => + { + check_from_bytes(cx, expr, arg, name); + }, + "from_ptr" => check_from_ptr(cx, expr, arg), + _ => {}, + } + } +} + +/// Checks `CStr::from_ptr(b"foo\0".as_ptr().cast())` +fn check_from_ptr(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>) { + if let ExprKind::MethodCall(method, lit, ..) = peel_ptr_cast(arg).kind + && method.ident.name == sym::as_ptr + && !lit.span.from_expansion() + && let ExprKind::Lit(lit) = lit.kind + && let LitKind::ByteStr(_, StrStyle::Cooked) = lit.node + && let Some(sugg) = rewrite_as_cstr(cx, lit.span) + { + span_lint_and_sugg( + cx, + MANUAL_C_STR_LITERALS, + expr.span, + "calling `CStr::from_ptr` with a byte string literal", + r#"use a `c""` literal"#, + sugg, + Applicability::MachineApplicable, + ); + } +} +/// Checks `CStr::from_bytes_with_nul(b"foo\0")` +fn check_from_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, method: &str) { + let (span, applicability) = if let Some(parent) = get_parent_expr(cx, expr) + && let ExprKind::MethodCall(method, ..) = parent.kind + && [sym::unwrap, sym::expect].contains(&method.ident.name) + { + (parent.span, Applicability::MachineApplicable) + } else if method == "from_bytes_with_nul_unchecked" { + // `*_unchecked` returns `&CStr` directly, nothing needs to be changed + (expr.span, Applicability::MachineApplicable) + } else { + // User needs to remove error handling, can't be machine applicable + (expr.span, Applicability::HasPlaceholders) + }; + + let Some(sugg) = rewrite_as_cstr(cx, arg.span) else { + return; + }; + + span_lint_and_sugg( + cx, + MANUAL_C_STR_LITERALS, + span, + "calling `CStr::new` with a byte string literal", + r#"use a `c""` literal"#, + sugg, + applicability, + ); +} + +/// Rewrites a byte string literal to a c-str literal. +/// `b"foo\0"` -> `c"foo"` +/// +/// Returns `None` if it doesn't end in a NUL byte. +fn rewrite_as_cstr(cx: &LateContext<'_>, span: Span) -> Option { + let mut sugg = String::from("c") + snippet(cx, span.source_callsite(), "..").trim_start_matches('b'); + + // NUL byte should always be right before the closing quote. + if let Some(quote_pos) = sugg.rfind('"') { + // Possible values right before the quote: + // - literal NUL value + if sugg.as_bytes()[quote_pos - 1] == b'\0' { + sugg.remove(quote_pos - 1); + } + // - \x00 + else if sugg[..quote_pos].ends_with("\\x00") { + sugg.replace_range(quote_pos - 4..quote_pos, ""); + } + // - \0 + else if sugg[..quote_pos].ends_with("\\0") { + sugg.replace_range(quote_pos - 2..quote_pos, ""); + } + // No known suffix, so assume it's not a C-string. + else { + return None; + } + } + + Some(sugg) +} + +fn get_cast_target<'tcx>(e: &'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> { + match &e.kind { + ExprKind::MethodCall(method, receiver, [], _) if method.ident.as_str() == "cast" => Some(receiver), + ExprKind::Cast(expr, _) => Some(expr), + _ => None, + } +} + +/// `x.cast()` -> `x` +/// `x as *const _` -> `x` +/// `x` -> `x` (returns the same expression for non-cast exprs) +fn peel_ptr_cast<'tcx>(e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> { + get_cast_target(e).map_or(e, peel_ptr_cast) +} + +/// Same as `peel_ptr_cast`, but the other way around, by walking up the ancestor cast expressions: +/// +/// `foo(x.cast() as *const _)` +/// ^ given this `x` expression, returns the `foo(...)` expression +fn peel_ptr_cast_ancestors<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> { + let mut prev = e; + for (_, node) in cx.tcx.hir().parent_iter(e.hir_id) { + if let Node::Expr(e) = node + && get_cast_target(e).is_some() + { + prev = e; + } else { + break; + } + } + prev +} diff --git a/clippy_lints/src/methods/map_unwrap_or.rs b/clippy_lints/src/methods/map_unwrap_or.rs index 52ea584a2c8cb..3226fa9cd3fa4 100644 --- a/clippy_lints/src/methods/map_unwrap_or.rs +++ b/clippy_lints/src/methods/map_unwrap_or.rs @@ -21,7 +21,7 @@ pub(super) fn check<'tcx>( unwrap_arg: &'tcx hir::Expr<'_>, msrv: &Msrv, ) -> bool { - // lint if the caller of `map()` is an `Option` + // lint if the caller of `map()` is an `Option` or a `Result`. let is_option = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Option); let is_result = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Result); diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 03bcf108914a0..e8a7a321bf4b7 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -51,6 +51,7 @@ mod iter_skip_zero; mod iter_with_drain; mod iterator_step_by_zero; mod join_absolute_paths; +mod manual_c_str_literals; mod manual_is_variant_and; mod manual_next_back; mod manual_ok_or; @@ -113,6 +114,7 @@ mod unnecessary_iter_cloned; mod unnecessary_join; mod unnecessary_lazy_eval; mod unnecessary_literal_unwrap; +mod unnecessary_result_map_or_else; mod unnecessary_sort_by; mod unnecessary_to_owned; mod unwrap_expect_used; @@ -3951,6 +3953,64 @@ declare_clippy_lint! { "cloning an `Option` via `as_ref().cloned()`" } +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of `.map_or_else()` "map closure" for `Result` type. + /// + /// ### Why is this bad? + /// This can be written more concisely by using `unwrap_or_else()`. + /// + /// ### Example + /// ```no_run + /// # fn handle_error(_: ()) -> u32 { 0 } + /// let x: Result = Ok(0); + /// let y = x.map_or_else(|err| handle_error(err), |n| n); + /// ``` + /// Use instead: + /// ```no_run + /// # fn handle_error(_: ()) -> u32 { 0 } + /// let x: Result = Ok(0); + /// let y = x.unwrap_or_else(|err| handle_error(err)); + /// ``` + #[clippy::version = "1.77.0"] + pub UNNECESSARY_RESULT_MAP_OR_ELSE, + suspicious, + "making no use of the \"map closure\" when calling `.map_or_else(|err| handle_error(err), |n| n)`" +} + +declare_clippy_lint! { + /// Checks for the manual creation of C strings (a string with a `NUL` byte at the end), either + /// through one of the `CStr` constructor functions, or more plainly by calling `.as_ptr()` + /// on a (byte) string literal with a hardcoded `\0` byte at the end. + /// + /// ### Why is this bad? + /// This can be written more concisely using `c"str"` literals and is also less error-prone, + /// because the compiler checks for interior `NUL` bytes and the terminating `NUL` byte is inserted automatically. + /// + /// ### Example + /// ```no_run + /// # use std::ffi::CStr; + /// # mod libc { pub unsafe fn puts(_: *const i8) {} } + /// fn needs_cstr(_: &CStr) {} + /// + /// needs_cstr(CStr::from_bytes_with_nul(b"Hello\0").unwrap()); + /// unsafe { libc::puts("World\0".as_ptr().cast()) } + /// ``` + /// Use instead: + /// ```no_run + /// # use std::ffi::CStr; + /// # mod libc { pub unsafe fn puts(_: *const i8) {} } + /// fn needs_cstr(_: &CStr) {} + /// + /// needs_cstr(c"Hello"); + /// unsafe { libc::puts(c"World".as_ptr()) } + /// ``` + #[clippy::version = "1.76.0"] + pub MANUAL_C_STR_LITERALS, + pedantic, + r#"creating a `CStr` through functions when `c""` literals can be used"# +} + pub struct Methods { avoid_breaking_exported_api: bool, msrv: Msrv, @@ -4109,6 +4169,8 @@ impl_lint_pass!(Methods => [ MANUAL_IS_VARIANT_AND, STR_SPLIT_AT_NEWLINE, OPTION_AS_REF_CLONED, + UNNECESSARY_RESULT_MAP_OR_ELSE, + MANUAL_C_STR_LITERALS, ]); /// Extracts a method call name, args, and `Span` of the method name. @@ -4136,6 +4198,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods { hir::ExprKind::Call(func, args) => { from_iter_instead_of_collect::check(cx, expr, args, func); unnecessary_fallible_conversions::check_function(cx, expr, func); + manual_c_str_literals::check(cx, expr, func, args, &self.msrv); }, hir::ExprKind::MethodCall(method_call, receiver, args, _) => { let method_span = method_call.ident.span; @@ -4354,6 +4417,7 @@ impl Methods { } }, ("as_mut", []) => useless_asref::check(cx, expr, "as_mut", recv), + ("as_ptr", []) => manual_c_str_literals::check_as_ptr(cx, expr, recv, &self.msrv), ("as_ref", []) => useless_asref::check(cx, expr, "as_ref", recv), ("assume_init", []) => uninit_assumed_init::check(cx, expr, recv), ("cloned", []) => { @@ -4592,6 +4656,7 @@ impl Methods { }, ("map_or_else", [def, map]) => { result_map_or_else_none::check(cx, expr, recv, def, map); + unnecessary_result_map_or_else::check(cx, expr, recv, def, map); }, ("next", []) => { if let Some((name2, recv2, args2, _, _)) = method_call(recv) { diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index f3577ef6082bf..2046692bbd0bd 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -99,7 +99,6 @@ fn check_fold_with_op( cx, UNNECESSARY_FOLD, fold_span.with_hi(expr.span.hi()), - // TODO #2371 don't suggest e.g., .any(|x| f(x)) if we can suggest .any(f) "this `.fold` can be written more succinctly using another method", "try", sugg, diff --git a/clippy_lints/src/methods/unnecessary_result_map_or_else.rs b/clippy_lints/src/methods/unnecessary_result_map_or_else.rs new file mode 100644 index 0000000000000..7b0cf48ac43be --- /dev/null +++ b/clippy_lints/src/methods/unnecessary_result_map_or_else.rs @@ -0,0 +1,95 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::peel_blocks; +use clippy_utils::source::snippet; +use clippy_utils::ty::is_type_diagnostic_item; +use rustc_errors::Applicability; +use rustc_hir as hir; +use rustc_hir::{Closure, Expr, ExprKind, HirId, QPath, Stmt, StmtKind}; +use rustc_lint::LateContext; +use rustc_span::symbol::sym; + +use super::UNNECESSARY_RESULT_MAP_OR_ELSE; + +fn emit_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, def_arg: &Expr<'_>) { + let msg = "unused \"map closure\" when calling `Result::map_or_else` value"; + let self_snippet = snippet(cx, recv.span, ".."); + let err_snippet = snippet(cx, def_arg.span, ".."); + span_lint_and_sugg( + cx, + UNNECESSARY_RESULT_MAP_OR_ELSE, + expr.span, + msg, + "consider using `unwrap_or_else`", + format!("{self_snippet}.unwrap_or_else({err_snippet})"), + Applicability::MachineApplicable, + ); +} + +fn get_last_chain_binding_hir_id(mut hir_id: HirId, statements: &[Stmt<'_>]) -> Option { + for stmt in statements { + if let StmtKind::Local(local) = stmt.kind + && let Some(init) = local.init + && let ExprKind::Path(QPath::Resolved(_, path)) = init.kind + && let hir::def::Res::Local(local_hir_id) = path.res + && local_hir_id == hir_id + { + hir_id = local.pat.hir_id; + } else { + return None; + } + } + Some(hir_id) +} + +fn handle_qpath( + cx: &LateContext<'_>, + expr: &Expr<'_>, + recv: &Expr<'_>, + def_arg: &Expr<'_>, + expected_hir_id: HirId, + qpath: QPath<'_>, +) { + if let QPath::Resolved(_, path) = qpath + && let hir::def::Res::Local(hir_id) = path.res + && expected_hir_id == hir_id + { + emit_lint(cx, expr, recv, def_arg); + } +} + +/// lint use of `_.map_or_else(|err| err, |n| n)` for `Result`s. +pub(super) fn check<'tcx>( + cx: &LateContext<'tcx>, + expr: &'tcx Expr<'_>, + recv: &'tcx Expr<'_>, + def_arg: &'tcx Expr<'_>, + map_arg: &'tcx Expr<'_>, +) { + // lint if the caller of `map_or_else()` is a `Result` + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Result) + && let ExprKind::Closure(&Closure { body, .. }) = map_arg.kind + && let body = cx.tcx.hir().body(body) + && let Some(first_param) = body.params.first() + { + let body_expr = peel_blocks(body.value); + + match body_expr.kind { + ExprKind::Path(qpath) => { + handle_qpath(cx, expr, recv, def_arg, first_param.pat.hir_id, qpath); + }, + // If this is a block (that wasn't peeled off), then it means there are statements. + ExprKind::Block(block, _) => { + if let Some(block_expr) = block.expr + // First we ensure that this is a "binding chain" (each statement is a binding + // of the previous one) and that it is a binding of the closure argument. + && let Some(last_chain_binding_id) = + get_last_chain_binding_hir_id(first_param.pat.hir_id, block.stmts) + && let ExprKind::Path(qpath) = block_expr.kind + { + handle_qpath(cx, expr, recv, def_arg, last_chain_binding_id, qpath); + } + }, + _ => {}, + } + } +} diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 0d234f7f9b52c..580160efeb701 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -357,7 +357,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option { - if block.stmts.is_empty() { + if block.stmts.is_empty() && !block.targeted_by_break { block.expr.as_ref().and_then(|e| { match block.rules { BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None, diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index d621051ef1653..ae14016f4823a 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -252,7 +252,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion { { ( trait_item_id, - FnKind::ImplTraitFn(cx.tcx.erase_regions(trait_ref.args) as *const _ as usize), + FnKind::ImplTraitFn(std::ptr::from_ref(cx.tcx.erase_regions(trait_ref.args)) as usize), usize::from(sig.decl.implicit_self.has_implicit_self()), ) } else { @@ -390,7 +390,6 @@ fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool { GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx), GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx), }), - #[allow(trivial_casts)] - FnKind::ImplTraitFn(expected_args) => args as *const _ as usize == expected_args, + FnKind::ImplTraitFn(expected_args) => std::ptr::from_ref(args) as usize == expected_args, } } diff --git a/clippy_lints/src/operators/mod.rs b/clippy_lints/src/operators/mod.rs index 4c09c4eea581f..e002429e3a47a 100644 --- a/clippy_lints/src/operators/mod.rs +++ b/clippy_lints/src/operators/mod.rs @@ -771,6 +771,7 @@ declare_clippy_lint! { pub struct Operators { arithmetic_context: numeric_arithmetic::Context, verbose_bit_mask_threshold: u64, + modulo_arithmetic_allow_comparison_to_zero: bool, } impl_lint_pass!(Operators => [ ABSURD_EXTREME_COMPARISONS, @@ -801,10 +802,11 @@ impl_lint_pass!(Operators => [ SELF_ASSIGNMENT, ]); impl Operators { - pub fn new(verbose_bit_mask_threshold: u64) -> Self { + pub fn new(verbose_bit_mask_threshold: u64, modulo_arithmetic_allow_comparison_to_zero: bool) -> Self { Self { arithmetic_context: numeric_arithmetic::Context::default(), verbose_bit_mask_threshold, + modulo_arithmetic_allow_comparison_to_zero, } } } @@ -835,12 +837,19 @@ impl<'tcx> LateLintPass<'tcx> for Operators { cmp_owned::check(cx, op.node, lhs, rhs); float_cmp::check(cx, e, op.node, lhs, rhs); modulo_one::check(cx, e, op.node, rhs); - modulo_arithmetic::check(cx, e, op.node, lhs, rhs); + modulo_arithmetic::check( + cx, + e, + op.node, + lhs, + rhs, + self.modulo_arithmetic_allow_comparison_to_zero, + ); }, ExprKind::AssignOp(op, lhs, rhs) => { self.arithmetic_context.check_binary(cx, e, op.node, lhs, rhs); misrefactored_assign_op::check(cx, e, op.node, lhs, rhs); - modulo_arithmetic::check(cx, e, op.node, lhs, rhs); + modulo_arithmetic::check(cx, e, op.node, lhs, rhs, false); }, ExprKind::Assign(lhs, rhs, _) => { assign_op_pattern::check(cx, e, lhs, rhs); diff --git a/clippy_lints/src/operators/modulo_arithmetic.rs b/clippy_lints/src/operators/modulo_arithmetic.rs index cb3916484c1d5..40d4a842befb8 100644 --- a/clippy_lints/src/operators/modulo_arithmetic.rs +++ b/clippy_lints/src/operators/modulo_arithmetic.rs @@ -1,7 +1,7 @@ use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::sext; -use rustc_hir::{BinOpKind, Expr}; +use rustc_hir::{BinOpKind, Expr, ExprKind, Node}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use std::fmt::Display; @@ -14,8 +14,13 @@ pub(super) fn check<'tcx>( op: BinOpKind, lhs: &'tcx Expr<'_>, rhs: &'tcx Expr<'_>, + allow_comparison_to_zero: bool, ) { if op == BinOpKind::Rem { + if allow_comparison_to_zero && used_in_comparison_with_zero(cx, e) { + return; + } + let lhs_operand = analyze_operand(lhs, cx, e); let rhs_operand = analyze_operand(rhs, cx, e); if let Some(lhs_operand) = lhs_operand @@ -28,6 +33,26 @@ pub(super) fn check<'tcx>( }; } +fn used_in_comparison_with_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { + let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find_parent(expr.hir_id) else { + return false; + }; + let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind else { + return false; + }; + + if op.node == BinOpKind::Eq || op.node == BinOpKind::Ne { + if let Some(Constant::Int(0)) = constant(cx, cx.typeck_results(), rhs) { + return true; + } + if let Some(Constant::Int(0)) = constant(cx, cx.typeck_results(), lhs) { + return true; + } + } + + false +} + struct OperandInfo { string_representation: Option, is_negative: bool, diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 334e6770ae407..915da18aafe2e 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -2,6 +2,7 @@ use crate::rustc_lint::LintContext; use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use clippy_utils::get_parent_expr; use clippy_utils::sugg::Sugg; +use hir::Param; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::intravisit::{Visitor as HirVisitor, Visitor}; @@ -13,6 +14,7 @@ use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::declare_lint_pass; +use rustc_span::ExpnKind; declare_clippy_lint! { /// ### What it does @@ -89,7 +91,12 @@ fn find_innermost_closure<'tcx>( cx: &LateContext<'tcx>, mut expr: &'tcx hir::Expr<'tcx>, mut steps: usize, -) -> Option<(&'tcx hir::Expr<'tcx>, &'tcx hir::FnDecl<'tcx>, ty::Asyncness)> { +) -> Option<( + &'tcx hir::Expr<'tcx>, + &'tcx hir::FnDecl<'tcx>, + ty::Asyncness, + &'tcx [Param<'tcx>], +)> { let mut data = None; while let hir::ExprKind::Closure(closure) = expr.kind @@ -110,6 +117,7 @@ fn find_innermost_closure<'tcx>( } else { ty::Asyncness::No }, + body.params, )); steps -= 1; } @@ -152,7 +160,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall { // without this check, we'd end up linting twice. && !matches!(recv.kind, hir::ExprKind::Call(..)) && let (full_expr, call_depth) = get_parent_call_exprs(cx, expr) - && let Some((body, fn_decl, coroutine_kind)) = find_innermost_closure(cx, recv, call_depth) + && let Some((body, fn_decl, coroutine_kind, params)) = find_innermost_closure(cx, recv, call_depth) + // outside macros we lint properly. Inside macros, we lint only ||() style closures. + && (!matches!(expr.span.ctxt().outer_expn_data().kind, ExpnKind::Macro(_, _)) || params.is_empty()) { span_lint_and_then( cx, diff --git a/clippy_lints/src/redundant_locals.rs b/clippy_lints/src/redundant_locals.rs index 2c511ee0bc029..700a5dd4a8511 100644 --- a/clippy_lints/src/redundant_locals.rs +++ b/clippy_lints/src/redundant_locals.rs @@ -4,8 +4,10 @@ use clippy_utils::ty::needs_ordered_drop; use rustc_ast::Mutability; use rustc_hir::def::Res; use rustc_hir::{BindingAnnotation, ByRef, ExprKind, HirId, Local, Node, Pat, PatKind, QPath}; +use rustc_hir_typeck::expr_use_visitor::PlaceBase; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; +use rustc_middle::ty::UpvarCapture; use rustc_session::declare_lint_pass; use rustc_span::symbol::Ident; use rustc_span::DesugaringKind; @@ -69,6 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals { // the local is user-controlled && !in_external_macro(cx.sess(), local.span) && !is_from_proc_macro(cx, expr) + && !is_by_value_closure_capture(cx, local.hir_id, binding_id) { span_lint_and_help( cx, @@ -82,6 +85,29 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals { } } +/// Checks if the enclosing body is a closure and if the given local is captured by value. +/// +/// In those cases, the redefinition may be necessary to force a move: +/// ``` +/// fn assert_static(_: T) {} +/// +/// let v = String::new(); +/// let closure = || { +/// let v = v; // <- removing this redefinition makes `closure` no longer `'static` +/// dbg!(&v); +/// }; +/// assert_static(closure); +/// ``` +fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_variable: HirId) -> bool { + let closure_def_id = cx.tcx.hir().enclosing_body_owner(redefinition); + + cx.tcx.is_closure_or_coroutine(closure_def_id.to_def_id()) + && cx.tcx.closure_captures(closure_def_id).iter().any(|c| { + matches!(c.info.capture_kind, UpvarCapture::ByValue) + && matches!(c.place.base, PlaceBase::Upvar(upvar) if upvar.var_path.hir_id == root_variable) + }) +} + /// Find the annotation of a binding introduced by a pattern, or `None` if it's not introduced. fn find_binding(pat: &Pat<'_>, name: Ident) -> Option { let mut ret = None; diff --git a/clippy_lints/src/redundant_type_annotations.rs b/clippy_lints/src/redundant_type_annotations.rs index 07fcb69afbc4c..c8352c052659b 100644 --- a/clippy_lints/src/redundant_type_annotations.rs +++ b/clippy_lints/src/redundant_type_annotations.rs @@ -188,7 +188,6 @@ impl LateLintPass<'_> for RedundantTypeAnnotations { match init_lit.node { // In these cases the annotation is redundant LitKind::Str(..) - | LitKind::ByteStr(..) | LitKind::Byte(..) | LitKind::Char(..) | LitKind::Bool(..) @@ -202,6 +201,16 @@ impl LateLintPass<'_> for RedundantTypeAnnotations { } }, LitKind::Err => (), + LitKind::ByteStr(..) => { + // We only lint if the type annotation is an array type (e.g. &[u8; 4]). + // If instead it is a slice (e.g. &[u8]) it may not be redundant, so we + // don't lint. + if let hir::TyKind::Ref(_, mut_ty) = ty.kind + && matches!(mut_ty.ty.kind, hir::TyKind::Array(..)) + { + span_lint(cx, REDUNDANT_TYPE_ANNOTATIONS, local.span, "redundant type annotation"); + } + }, } }, _ => (), diff --git a/clippy_lints/src/repeat_vec_with_capacity.rs b/clippy_lints/src/repeat_vec_with_capacity.rs index 5a4933a3fceb6..fcb79f6d694ee 100644 --- a/clippy_lints/src/repeat_vec_with_capacity.rs +++ b/clippy_lints/src/repeat_vec_with_capacity.rs @@ -42,7 +42,7 @@ declare_clippy_lint! { /// // ^^^ this closure executes 123 times /// // and the vecs will have the expected capacity /// ``` - #[clippy::version = "1.74.0"] + #[clippy::version = "1.76.0"] pub REPEAT_VEC_WITH_CAPACITY, suspicious, "repeating a `Vec::with_capacity` expression which does not retain capacity" diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index e01750465873d..2af466d3f51e3 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -2,10 +2,14 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then, span_lin use clippy_utils::source::{snippet_opt, snippet_with_context}; use clippy_utils::sugg::has_enclosing_paren; use clippy_utils::visitors::{for_each_expr_with_closures, Descend}; -use clippy_utils::{fn_def_id, is_from_proc_macro, is_inside_let_else, path_to_local_id, span_find_starting_semi}; +use clippy_utils::{ + fn_def_id, is_from_proc_macro, is_inside_let_else, is_res_lang_ctor, path_res, path_to_local_id, + span_find_starting_semi, +}; use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; +use rustc_hir::LangItem::ResultErr; use rustc_hir::{ Block, Body, Expr, ExprKind, FnDecl, HirId, ItemKind, LangItem, MatchSource, Node, OwnerNode, PatKind, QPath, Stmt, StmtKind, @@ -18,6 +22,7 @@ use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{BytePos, Pos, Span}; use std::borrow::Cow; +use std::fmt::Display; declare_clippy_lint! { /// ### What it does @@ -146,14 +151,14 @@ impl<'tcx> RetReplacement<'tcx> { } } -impl<'tcx> ToString for RetReplacement<'tcx> { - fn to_string(&self) -> String { +impl<'tcx> Display for RetReplacement<'tcx> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Empty => String::new(), - Self::Block => "{}".to_string(), - Self::Unit => "()".to_string(), - Self::IfSequence(inner, _) => format!("({inner})"), - Self::Expr(inner, _) => inner.to_string(), + Self::Empty => write!(f, ""), + Self::Block => write!(f, "{{}}"), + Self::Unit => write!(f, "()"), + Self::IfSequence(inner, _) => write!(f, "({inner})"), + Self::Expr(inner, _) => write!(f, "{inner}"), } } } @@ -181,7 +186,15 @@ impl<'tcx> LateLintPass<'tcx> for Return { if !in_external_macro(cx.sess(), stmt.span) && let StmtKind::Semi(expr) = stmt.kind && let ExprKind::Ret(Some(ret)) = expr.kind - && let ExprKind::Match(.., MatchSource::TryDesugar(_)) = ret.kind + // return Err(...)? desugars to a match + // over a Err(...).branch() + // which breaks down to a branch call, with the callee being + // the constructor of the Err variant + && let ExprKind::Match(maybe_cons, _, MatchSource::TryDesugar(_)) = ret.kind + && let ExprKind::Call(_, [maybe_result_err]) = maybe_cons.kind + && let ExprKind::Call(maybe_constr, _) = maybe_result_err.kind + && is_res_lang_ctor(cx, path_res(cx, maybe_constr), ResultErr) + // Ensure this is not the final stmt, otherwise removing it would cause a compile error && let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id)) && let ItemKind::Fn(_, _, body) = item.kind diff --git a/clippy_lints/src/to_string_trait_impl.rs b/clippy_lints/src/to_string_trait_impl.rs new file mode 100644 index 0000000000000..e1cea99085fde --- /dev/null +++ b/clippy_lints/src/to_string_trait_impl.rs @@ -0,0 +1,67 @@ +use clippy_utils::diagnostics::span_lint_and_help; +use rustc_hir::{Impl, Item, ItemKind}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_session::declare_lint_pass; +use rustc_span::sym; + +declare_clippy_lint! { + /// ### What it does + /// Checks for direct implementations of `ToString`. + /// ### Why is this bad? + /// This trait is automatically implemented for any type which implements the `Display` trait. + /// As such, `ToString` shouldn’t be implemented directly: `Display` should be implemented instead, + /// and you get the `ToString` implementation for free. + /// ### Example + /// ```no_run + /// struct Point { + /// x: usize, + /// y: usize, + /// } + /// + /// impl ToString for Point { + /// fn to_string(&self) -> String { + /// format!("({}, {})", self.x, self.y) + /// } + /// } + /// ``` + /// Use instead: + /// ```no_run + /// struct Point { + /// x: usize, + /// y: usize, + /// } + /// + /// impl std::fmt::Display for Point { + /// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + /// write!(f, "({}, {})", self.x, self.y) + /// } + /// } + /// ``` + #[clippy::version = "1.77.0"] + pub TO_STRING_TRAIT_IMPL, + style, + "check for direct implementations of `ToString`" +} + +declare_lint_pass!(ToStringTraitImpl => [TO_STRING_TRAIT_IMPL]); + +impl<'tcx> LateLintPass<'tcx> for ToStringTraitImpl { + fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx Item<'tcx>) { + if let ItemKind::Impl(Impl { + of_trait: Some(trait_ref), + .. + }) = it.kind + && let Some(trait_did) = trait_ref.trait_def_id() + && cx.tcx.is_diagnostic_item(sym::ToString, trait_did) + { + span_lint_and_help( + cx, + TO_STRING_TRAIT_IMPL, + it.span, + "direct implementation of `ToString`", + None, + "prefer implementing `Display` instead", + ); + } + } +} diff --git a/clippy_lints/src/unconditional_recursion.rs b/clippy_lints/src/unconditional_recursion.rs index 209035804e43e..224ec475c5107 100644 --- a/clippy_lints/src/unconditional_recursion.rs +++ b/clippy_lints/src/unconditional_recursion.rs @@ -69,14 +69,6 @@ fn span_error(cx: &LateContext<'_>, method_span: Span, expr: &Expr<'_>) { ); } -fn get_ty_def_id(ty: Ty<'_>) -> Option { - match ty.peel_refs().kind() { - ty::Adt(adt, _) => Some(adt.did()), - ty::Foreign(def_id) => Some(*def_id), - _ => None, - } -} - fn get_hir_ty_def_id<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: rustc_hir::Ty<'tcx>) -> Option { let TyKind::Path(qpath) = hir_ty.kind else { return None }; match qpath { @@ -131,21 +123,49 @@ fn get_impl_trait_def_id(cx: &LateContext<'_>, method_def_id: LocalDefId) -> Opt } } -#[allow(clippy::unnecessary_def_path)] +/// When we have `x == y` where `x = &T` and `y = &T`, then that resolves to +/// `<&T as PartialEq<&T>>::eq`, which is not the same as `>::eq`, +/// however we still would want to treat it the same, because we know that it's a blanket impl +/// that simply delegates to the `PartialEq` impl with one reference removed. +/// +/// Still, we can't just do `lty.peel_refs() == rty.peel_refs()` because when we have `x = &T` and +/// `y = &&T`, this is not necessarily the same as `>::eq` +/// +/// So to avoid these FNs and FPs, we keep removing a layer of references from *both* sides +/// until both sides match the expected LHS and RHS type (or they don't). +fn matches_ty<'tcx>( + mut left: Ty<'tcx>, + mut right: Ty<'tcx>, + expected_left: Ty<'tcx>, + expected_right: Ty<'tcx>, +) -> bool { + while let (&ty::Ref(_, lty, _), &ty::Ref(_, rty, _)) = (left.kind(), right.kind()) { + if lty == expected_left && rty == expected_right { + return true; + } + left = lty; + right = rty; + } + false +} + fn check_partial_eq(cx: &LateContext<'_>, method_span: Span, method_def_id: LocalDefId, name: Ident, expr: &Expr<'_>) { - let args = cx - .tcx - .instantiate_bound_regions_with_erased(cx.tcx.fn_sig(method_def_id).skip_binder()) - .inputs(); + let Some(sig) = cx + .typeck_results() + .liberated_fn_sigs() + .get(cx.tcx.local_def_id_to_hir_id(method_def_id)) + else { + return; + }; + // That has two arguments. - if let [self_arg, other_arg] = args - && let Some(self_arg) = get_ty_def_id(*self_arg) - && let Some(other_arg) = get_ty_def_id(*other_arg) + if let [self_arg, other_arg] = sig.inputs() + && let &ty::Ref(_, self_arg, _) = self_arg.kind() + && let &ty::Ref(_, other_arg, _) = other_arg.kind() // The two arguments are of the same type. - && self_arg == other_arg && let Some(trait_def_id) = get_impl_trait_def_id(cx, method_def_id) // The trait is `PartialEq`. - && Some(trait_def_id) == get_trait_def_id(cx, &["core", "cmp", "PartialEq"]) + && cx.tcx.is_diagnostic_item(sym::PartialEq, trait_def_id) { let to_check_op = if name.name == sym::eq { BinOpKind::Eq @@ -154,31 +174,19 @@ fn check_partial_eq(cx: &LateContext<'_>, method_span: Span, method_def_id: Loca }; let is_bad = match expr.kind { ExprKind::Binary(op, left, right) if op.node == to_check_op => { - // Then we check if the left-hand element is of the same type as `self`. - if let Some(left_ty) = cx.typeck_results().expr_ty_opt(left) - && let Some(left_id) = get_ty_def_id(left_ty) - && self_arg == left_id - && let Some(right_ty) = cx.typeck_results().expr_ty_opt(right) - && let Some(right_id) = get_ty_def_id(right_ty) - && other_arg == right_id - { - true - } else { - false - } + // Then we check if the LHS matches self_arg and RHS matches other_arg + let left_ty = cx.typeck_results().expr_ty_adjusted(left); + let right_ty = cx.typeck_results().expr_ty_adjusted(right); + matches_ty(left_ty, right_ty, self_arg, other_arg) }, - ExprKind::MethodCall(segment, receiver, &[_arg], _) if segment.ident.name == name.name => { - if let Some(ty) = cx.typeck_results().expr_ty_opt(receiver) - && let Some(ty_id) = get_ty_def_id(ty) - && self_arg != ty_id - { - // Since this called on a different type, the lint should not be - // triggered here. - return; - } + ExprKind::MethodCall(segment, receiver, [arg], _) if segment.ident.name == name.name => { + let receiver_ty = cx.typeck_results().expr_ty_adjusted(receiver); + let arg_ty = cx.typeck_results().expr_ty_adjusted(arg); + if let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) && let Some(trait_id) = cx.tcx.trait_of_item(fn_id) && trait_id == trait_def_id + && matches_ty(receiver_ty, arg_ty, self_arg, other_arg) { true } else { diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index adc66e15ff501..6b3ea7700b735 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,5 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{is_res_lang_ctor, is_trait_method, match_trait_method, paths}; +use clippy_utils::macros::{is_panic, root_macro_call_first_node}; +use clippy_utils::{is_res_lang_ctor, is_trait_method, match_trait_method, paths, peel_blocks}; use hir::{ExprKind, PatKind}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; @@ -82,37 +83,72 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount { } if let Some(exp) = block.expr - && matches!(exp.kind, hir::ExprKind::If(_, _, _) | hir::ExprKind::Match(_, _, _)) + && matches!( + exp.kind, + hir::ExprKind::If(_, _, _) | hir::ExprKind::Match(_, _, hir::MatchSource::Normal) + ) { check_expr(cx, exp); } } } +fn non_consuming_err_arm<'a>(cx: &LateContext<'a>, arm: &hir::Arm<'a>) -> bool { + // if there is a guard, we consider the result to be consumed + if arm.guard.is_some() { + return false; + } + if is_unreachable_or_panic(cx, arm.body) { + // if the body is unreachable or there is a panic, + // we consider the result to be consumed + return false; + } + + if let PatKind::TupleStruct(ref path, [inner_pat], _) = arm.pat.kind { + return is_res_lang_ctor(cx, cx.qpath_res(path, inner_pat.hir_id), hir::LangItem::ResultErr); + } + + false +} + +fn non_consuming_ok_arm<'a>(cx: &LateContext<'a>, arm: &hir::Arm<'a>) -> bool { + // if there is a guard, we consider the result to be consumed + if arm.guard.is_some() { + return false; + } + if is_unreachable_or_panic(cx, arm.body) { + // if the body is unreachable or there is a panic, + // we consider the result to be consumed + return false; + } + + if is_ok_wild_or_dotdot_pattern(cx, arm.pat) { + return true; + } + false +} + fn check_expr<'a>(cx: &LateContext<'a>, expr: &'a hir::Expr<'a>) { match expr.kind { hir::ExprKind::If(cond, _, _) if let ExprKind::Let(hir::Let { pat, init, .. }) = cond.kind - && pattern_is_ignored_ok(cx, pat) + && is_ok_wild_or_dotdot_pattern(cx, pat) && let Some(op) = should_lint(cx, init) => { emit_lint(cx, cond.span, op, &[pat.span]); }, - hir::ExprKind::Match(expr, arms, hir::MatchSource::Normal) if let Some(op) = should_lint(cx, expr) => { - let found_arms: Vec<_> = arms - .iter() - .filter_map(|arm| { - if pattern_is_ignored_ok(cx, arm.pat) { - Some(arm.span) - } else { - None - } - }) - .collect(); - if !found_arms.is_empty() { - emit_lint(cx, expr.span, op, found_arms.as_slice()); + // we will capture only the case where the match is Ok( ) or Err( ) + // prefer to match the minimum possible, and expand later if needed + // to avoid false positives on something as used as this + hir::ExprKind::Match(expr, [arm1, arm2], hir::MatchSource::Normal) if let Some(op) = should_lint(cx, expr) => { + if non_consuming_ok_arm(cx, arm1) && non_consuming_err_arm(cx, arm2) { + emit_lint(cx, expr.span, op, &[arm1.pat.span]); + } + if non_consuming_ok_arm(cx, arm2) && non_consuming_err_arm(cx, arm1) { + emit_lint(cx, expr.span, op, &[arm2.pat.span]); } }, + hir::ExprKind::Match(_, _, hir::MatchSource::Normal) => {}, _ if let Some(op) = should_lint(cx, expr) => { emit_lint(cx, expr.span, op, &[]); }, @@ -130,25 +166,40 @@ fn should_lint<'a>(cx: &LateContext<'a>, mut inner: &'a hir::Expr<'a>) -> Option check_io_mode(cx, inner) } -fn pattern_is_ignored_ok(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> bool { +fn is_ok_wild_or_dotdot_pattern<'a>(cx: &LateContext<'a>, pat: &hir::Pat<'a>) -> bool { // the if checks whether we are in a result Ok( ) pattern // and the return checks whether it is unhandled - if let PatKind::TupleStruct(ref path, inner_pat, ddp) = pat.kind + if let PatKind::TupleStruct(ref path, inner_pat, _) = pat.kind // we check against Result::Ok to avoid linting on Err(_) or something else. && is_res_lang_ctor(cx, cx.qpath_res(path, pat.hir_id), hir::LangItem::ResultOk) { - return match (inner_pat, ddp.as_opt_usize()) { - // Ok(_) pattern - ([inner_pat], None) if matches!(inner_pat.kind, PatKind::Wild) => true, - // Ok(..) pattern - ([], Some(0)) => true, - _ => false, - }; + if matches!(inner_pat, []) { + return true; + } + + if let [cons_pat] = inner_pat + && matches!(cons_pat.kind, PatKind::Wild) + { + return true; + } + return false; } false } +// this is partially taken from panic_unimplemented +fn is_unreachable_or_panic(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { + let expr = peel_blocks(expr); + let Some(macro_call) = root_macro_call_first_node(cx, expr) else { + return false; + }; + if is_panic(cx, macro_call.def_id) { + return !cx.tcx.hir().is_inside_const_context(expr.hir_id); + } + matches!(cx.tcx.item_name(macro_call.def_id).as_str(), "unreachable") +} + fn unpack_call_chain<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> { while let hir::ExprKind::MethodCall(path, receiver, ..) = expr.kind { if matches!( diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 288df0fd663f0..29c67341a467c 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -490,9 +490,9 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { format!("ClosureKind::Coroutine(CoroutineKind::Coroutine(Movability::{movability:?})") }, }, - ClosureKind::CoroutineClosure(desugaring) => format!( - "ClosureKind::CoroutineClosure(CoroutineDesugaring::{desugaring:?})" - ), + ClosureKind::CoroutineClosure(desugaring) => { + format!("ClosureKind::CoroutineClosure(CoroutineDesugaring::{desugaring:?})") + }, }; let ret_ty = match fn_decl.output { diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index b82bd1d7e7c89..5410e8ac11781 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -1,6 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::is_test_module_or_function; use clippy_utils::source::{snippet, snippet_with_applicability}; +use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Item, ItemKind, PathSegment, UseKind}; @@ -100,13 +101,15 @@ declare_clippy_lint! { pub struct WildcardImports { warn_on_all: bool, test_modules_deep: u32, + allowed_segments: FxHashSet, } impl WildcardImports { - pub fn new(warn_on_all: bool) -> Self { + pub fn new(warn_on_all: bool, allowed_wildcard_imports: FxHashSet) -> Self { Self { warn_on_all, test_modules_deep: 0, + allowed_segments: allowed_wildcard_imports, } } } @@ -190,6 +193,7 @@ impl WildcardImports { item.span.from_expansion() || is_prelude_import(segments) || (is_super_only_import(segments) && self.test_modules_deep > 0) + || is_allowed_via_config(segments, &self.allowed_segments) } } @@ -198,10 +202,18 @@ impl WildcardImports { fn is_prelude_import(segments: &[PathSegment<'_>]) -> bool { segments .iter() - .any(|ps| ps.ident.name.as_str().contains(sym::prelude.as_str())) + .any(|ps| ps.ident.as_str().contains(sym::prelude.as_str())) } // Allow "super::*" imports in tests. fn is_super_only_import(segments: &[PathSegment<'_>]) -> bool { segments.len() == 1 && segments[0].ident.name == kw::Super } + +// Allow skipping imports containing user configured segments, +// i.e. "...::utils::...::*" if user put `allowed-wildcard-imports = ["utils"]` in `Clippy.toml` +fn is_allowed_via_config(segments: &[PathSegment<'_>], allowed_segments: &FxHashSet) -> bool { + // segment matching need to be exact instead of using 'contains', in case user unintentionaly put + // a single character in the config thus skipping most of the warnings. + segments.iter().any(|seg| allowed_segments.contains(seg.ident.as_str())) +} diff --git a/clippy_utils/Cargo.toml b/clippy_utils/Cargo.toml index b8869eedf52c2..c7454fa3328b8 100644 --- a/clippy_utils/Cargo.toml +++ b/clippy_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy_utils" -version = "0.1.77" +version = "0.1.78" edition = "2021" publish = false diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 3f936009e44ec..79bf0551506d7 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1,5 +1,6 @@ #![feature(array_chunks)] #![feature(box_patterns)] +#![feature(control_flow_enum)] #![feature(if_let_guard)] #![feature(let_chains)] #![feature(lint_reasons)] @@ -75,6 +76,7 @@ use core::mem; use core::ops::ControlFlow; use std::collections::hash_map::Entry; use std::hash::BuildHasherDefault; +use std::iter::{once, repeat}; use std::sync::{Mutex, MutexGuard, OnceLock}; use itertools::Itertools; @@ -84,6 +86,7 @@ use rustc_data_structures::packed::Pu128; use rustc_data_structures::unhash::UnhashMap; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, LOCAL_CRATE}; +use rustc_hir::definitions::{DefPath, DefPathData}; use rustc_hir::hir_id::{HirIdMap, HirIdSet}; use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; @@ -102,8 +105,8 @@ use rustc_middle::ty::binding::BindingMode; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::{ - self as rustc_ty, Binder, BorrowKind, ClosureKind, FloatTy, IntTy, ParamEnv, ParamEnvAnd, Ty, TyCtxt, TypeAndMut, - TypeVisitableExt, UintTy, UpvarCapture, + self as rustc_ty, Binder, BorrowKind, ClosureKind, EarlyBinder, FloatTy, GenericArgsRef, IntTy, ParamEnv, + ParamEnvAnd, Ty, TyCtxt, TypeAndMut, TypeVisitableExt, UintTy, UpvarCapture, }; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::source_map::SourceMap; @@ -114,10 +117,7 @@ use visitors::Visitable; use crate::consts::{constant, mir_to_const, Constant}; use crate::higher::Range; -use crate::ty::{ - adt_and_variant_of_res, can_partially_move_ty, expr_sig, is_copy, is_recursively_primitive_type, - ty_is_fn_once_param, -}; +use crate::ty::{adt_and_variant_of_res, can_partially_move_ty, expr_sig, is_copy, is_recursively_primitive_type}; use crate::visitors::for_each_expr; use rustc_middle::hir::nested_filter; @@ -1353,46 +1353,12 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>( for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) { match node { Node::Expr(e) => match e.kind { - ExprKind::Closure { .. } => { + ExprKind::Closure { .. } if let rustc_ty::Closure(_, subs) = cx.typeck_results().expr_ty(e).kind() - && subs.as_closure().kind() == ClosureKind::FnOnce - { - continue; - } - let is_once = walk_to_expr_usage(cx, e, |node, id| { - let Node::Expr(e) = node else { - return None; - }; - match e.kind { - ExprKind::Call(f, _) if f.hir_id == id => Some(()), - ExprKind::Call(f, args) => { - let i = args.iter().position(|arg| arg.hir_id == id)?; - let sig = expr_sig(cx, f)?; - let predicates = sig - .predicates_id() - .map_or(cx.param_env, |id| cx.tcx.param_env(id)) - .caller_bounds(); - sig.input(i).and_then(|ty| { - ty_is_fn_once_param(cx.tcx, ty.skip_binder(), predicates).then_some(()) - }) - }, - ExprKind::MethodCall(_, receiver, args, _) => { - let i = std::iter::once(receiver) - .chain(args.iter()) - .position(|arg| arg.hir_id == id)?; - let id = cx.typeck_results().type_dependent_def_id(e.hir_id)?; - let ty = cx.tcx.fn_sig(id).instantiate_identity().skip_binder().inputs()[i]; - ty_is_fn_once_param(cx.tcx, ty, cx.tcx.param_env(id).caller_bounds()).then_some(()) - }, - _ => None, - } - }) - .is_some(); - if !is_once { - return Some(e); - } - }, - ExprKind::Loop(..) => return Some(e), + && subs.as_closure().kind() == ClosureKind::FnOnce => {}, + + // Note: A closure's kind is determined by how it's used, not it's captures. + ExprKind::Closure { .. } | ExprKind::Loop(..) => return Some(e), _ => (), }, Node::Stmt(_) | Node::Block(_) | Node::Local(_) | Node::Arm(_) => (), @@ -2590,26 +2556,30 @@ pub fn is_test_module_or_function(tcx: TyCtxt<'_>, item: &Item<'_>) -> bool { && item.ident.name.as_str().split('_').any(|a| a == "test" || a == "tests") } -/// Walks the HIR tree from the given expression, up to the node where the value produced by the -/// expression is consumed. Calls the function for every node encountered this way until it returns -/// `Some`. +/// Walks up the HIR tree from the given expression in an attempt to find where the value is +/// consumed. +/// +/// Termination has three conditions: +/// - The given function returns `Break`. This function will return the value. +/// - The consuming node is found. This function will return `Continue(use_node, child_id)`. +/// - No further parent nodes are found. This will trigger a debug assert or return `None`. /// -/// This allows walking through `if`, `match`, `break`, block expressions to find where the value -/// produced by the expression is consumed. +/// This allows walking through `if`, `match`, `break`, and block expressions to find where the +/// value produced by the expression is consumed. pub fn walk_to_expr_usage<'tcx, T>( cx: &LateContext<'tcx>, e: &Expr<'tcx>, - mut f: impl FnMut(Node<'tcx>, HirId) -> Option, -) -> Option { + mut f: impl FnMut(HirId, Node<'tcx>, HirId) -> ControlFlow, +) -> Option, HirId)>> { let map = cx.tcx.hir(); let mut iter = map.parent_iter(e.hir_id); let mut child_id = e.hir_id; while let Some((parent_id, parent)) = iter.next() { - if let Some(x) = f(parent, child_id) { - return Some(x); + if let ControlFlow::Break(x) = f(parent_id, parent, child_id) { + return Some(ControlFlow::Break(x)); } - let parent = match parent { + let parent_expr = match parent { Node::Expr(e) => e, Node::Block(Block { expr: Some(body), .. }) | Node::Arm(Arm { body, .. }) if body.hir_id == child_id => { child_id = parent_id; @@ -2619,18 +2589,19 @@ pub fn walk_to_expr_usage<'tcx, T>( child_id = parent_id; continue; }, - _ => return None, + _ => return Some(ControlFlow::Continue((parent, child_id))), }; - match parent.kind { + match parent_expr.kind { ExprKind::If(child, ..) | ExprKind::Match(child, ..) if child.hir_id != child_id => child_id = parent_id, ExprKind::Break(Destination { target_id: Ok(id), .. }, _) => { child_id = id; iter = map.parent_iter(id); }, - ExprKind::Block(..) => child_id = parent_id, - _ => return None, + ExprKind::Block(..) | ExprKind::DropTemps(_) => child_id = parent_id, + _ => return Some(ControlFlow::Continue((parent, child_id))), } } + debug_assert!(false, "no parent node found for `{child_id:?}`"); None } @@ -2674,6 +2645,8 @@ pub enum ExprUseNode<'tcx> { Callee, /// Access of a field. FieldAccess(Ident), + Expr, + Other, } impl<'tcx> ExprUseNode<'tcx> { /// Checks if the value is returned from the function. @@ -2750,144 +2723,104 @@ impl<'tcx> ExprUseNode<'tcx> { let sig = cx.tcx.fn_sig(id).skip_binder(); Some(DefinedTy::Mir(cx.tcx.param_env(id).and(sig.input(i)))) }, - Self::Local(_) | Self::FieldAccess(..) | Self::Callee => None, + Self::Local(_) | Self::FieldAccess(..) | Self::Callee | Self::Expr | Self::Other => None, } } } /// Gets the context an expression's value is used in. -#[expect(clippy::too_many_lines)] pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> Option> { let mut adjustments = [].as_slice(); let mut is_ty_unified = false; let mut moved_before_use = false; let ctxt = e.span.ctxt(); - walk_to_expr_usage(cx, e, &mut |parent, child_id| { - // LocalTableInContext returns the wrong lifetime, so go use `expr_adjustments` instead. + walk_to_expr_usage(cx, e, &mut |parent_id, parent, child_id| { if adjustments.is_empty() && let Node::Expr(e) = cx.tcx.hir_node(child_id) { adjustments = cx.typeck_results().expr_adjustments(e); } - match parent { - Node::Local(l) if l.span.ctxt() == ctxt => Some(ExprUseCtxt { - node: ExprUseNode::Local(l), - adjustments, - is_ty_unified, - moved_before_use, - }), + if cx.tcx.hir().span(parent_id).ctxt() != ctxt { + return ControlFlow::Break(()); + } + if let Node::Expr(e) = parent { + match e.kind { + ExprKind::If(e, _, _) | ExprKind::Match(e, _, _) if e.hir_id != child_id => { + is_ty_unified = true; + moved_before_use = true; + }, + ExprKind::Block(_, Some(_)) | ExprKind::Break(..) => { + is_ty_unified = true; + moved_before_use = true; + }, + ExprKind::Block(..) => moved_before_use = true, + _ => {}, + } + } + ControlFlow::Continue(()) + })? + .continue_value() + .map(|(use_node, child_id)| { + let node = match use_node { + Node::Local(l) => ExprUseNode::Local(l), + Node::ExprField(field) => ExprUseNode::Field(field), + Node::Item(&Item { kind: ItemKind::Static(..) | ItemKind::Const(..), owner_id, - span, .. }) | Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), owner_id, - span, .. }) | Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), owner_id, - span, .. - }) if span.ctxt() == ctxt => Some(ExprUseCtxt { - node: ExprUseNode::ConstStatic(owner_id), - adjustments, - is_ty_unified, - moved_before_use, - }), + }) => ExprUseNode::ConstStatic(owner_id), Node::Item(&Item { kind: ItemKind::Fn(..), owner_id, - span, .. }) | Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), owner_id, - span, .. }) | Node::ImplItem(&ImplItem { kind: ImplItemKind::Fn(..), owner_id, - span, .. - }) if span.ctxt() == ctxt => Some(ExprUseCtxt { - node: ExprUseNode::Return(owner_id), - adjustments, - is_ty_unified, - moved_before_use, - }), - - Node::ExprField(field) if field.span.ctxt() == ctxt => Some(ExprUseCtxt { - node: ExprUseNode::Field(field), - adjustments, - is_ty_unified, - moved_before_use, - }), + }) => ExprUseNode::Return(owner_id), - Node::Expr(parent) if parent.span.ctxt() == ctxt => match parent.kind { - ExprKind::Ret(_) => Some(ExprUseCtxt { - node: ExprUseNode::Return(OwnerId { - def_id: cx.tcx.hir().body_owner_def_id(cx.enclosing_body.unwrap()), - }), - adjustments, - is_ty_unified, - moved_before_use, - }), - ExprKind::Closure(closure) => Some(ExprUseCtxt { - node: ExprUseNode::Return(OwnerId { def_id: closure.def_id }), - adjustments, - is_ty_unified, - moved_before_use, - }), - ExprKind::Call(func, args) => Some(ExprUseCtxt { - node: match args.iter().position(|arg| arg.hir_id == child_id) { - Some(i) => ExprUseNode::FnArg(func, i), - None => ExprUseNode::Callee, - }, - adjustments, - is_ty_unified, - moved_before_use, - }), - ExprKind::MethodCall(name, _, args, _) => Some(ExprUseCtxt { - node: ExprUseNode::MethodArg( - parent.hir_id, - name.args, - args.iter().position(|arg| arg.hir_id == child_id).map_or(0, |i| i + 1), - ), - adjustments, - is_ty_unified, - moved_before_use, - }), - ExprKind::Field(child, name) if child.hir_id == e.hir_id => Some(ExprUseCtxt { - node: ExprUseNode::FieldAccess(name), - adjustments, - is_ty_unified, - moved_before_use, + Node::Expr(use_expr) => match use_expr.kind { + ExprKind::Ret(_) => ExprUseNode::Return(OwnerId { + def_id: cx.tcx.hir().body_owner_def_id(cx.enclosing_body.unwrap()), }), - ExprKind::If(e, _, _) | ExprKind::Match(e, _, _) if e.hir_id != child_id => { - is_ty_unified = true; - moved_before_use = true; - None - }, - ExprKind::Block(_, Some(_)) | ExprKind::Break(..) => { - is_ty_unified = true; - moved_before_use = true; - None + ExprKind::Closure(closure) => ExprUseNode::Return(OwnerId { def_id: closure.def_id }), + ExprKind::Call(func, args) => match args.iter().position(|arg| arg.hir_id == child_id) { + Some(i) => ExprUseNode::FnArg(func, i), + None => ExprUseNode::Callee, }, - ExprKind::Block(..) => { - moved_before_use = true; - None - }, - _ => None, + ExprKind::MethodCall(name, _, args, _) => ExprUseNode::MethodArg( + use_expr.hir_id, + name.args, + args.iter().position(|arg| arg.hir_id == child_id).map_or(0, |i| i + 1), + ), + ExprKind::Field(child, name) if child.hir_id == e.hir_id => ExprUseNode::FieldAccess(name), + _ => ExprUseNode::Expr, }, - _ => None, + _ => ExprUseNode::Other, + }; + ExprUseCtxt { + node, + adjustments, + is_ty_unified, + moved_before_use, } }) } @@ -3264,3 +3197,131 @@ pub fn is_never_expr<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> Option< }) } } + +/// Produces a path from a local caller to the type of the called method. Suitable for user +/// output/suggestions. +/// +/// Returned path can be either absolute (for methods defined non-locally), or relative (for local +/// methods). +pub fn get_path_from_caller_to_method_type<'tcx>( + tcx: TyCtxt<'tcx>, + from: LocalDefId, + method: DefId, + args: GenericArgsRef<'tcx>, +) -> String { + let assoc_item = tcx.associated_item(method); + let def_id = assoc_item.container_id(tcx); + match assoc_item.container { + rustc_ty::TraitContainer => get_path_to_callee(tcx, from, def_id), + rustc_ty::ImplContainer => { + let ty = tcx.type_of(def_id).instantiate_identity(); + get_path_to_ty(tcx, from, ty, args) + }, + } +} + +fn get_path_to_ty<'tcx>(tcx: TyCtxt<'tcx>, from: LocalDefId, ty: Ty<'tcx>, args: GenericArgsRef<'tcx>) -> String { + match ty.kind() { + rustc_ty::Adt(adt, _) => get_path_to_callee(tcx, from, adt.did()), + // TODO these types need to be recursively resolved as well + rustc_ty::Array(..) + | rustc_ty::Dynamic(..) + | rustc_ty::Never + | rustc_ty::RawPtr(_) + | rustc_ty::Ref(..) + | rustc_ty::Slice(_) + | rustc_ty::Tuple(_) => format!("<{}>", EarlyBinder::bind(ty).instantiate(tcx, args)), + _ => ty.to_string(), + } +} + +/// Produce a path from some local caller to the callee. Suitable for user output/suggestions. +fn get_path_to_callee(tcx: TyCtxt<'_>, from: LocalDefId, callee: DefId) -> String { + // only search for a relative path if the call is fully local + if callee.is_local() { + let callee_path = tcx.def_path(callee); + let caller_path = tcx.def_path(from.to_def_id()); + maybe_get_relative_path(&caller_path, &callee_path, 2) + } else { + tcx.def_path_str(callee) + } +} + +/// Tries to produce a relative path from `from` to `to`; if such a path would contain more than +/// `max_super` `super` items, produces an absolute path instead. Both `from` and `to` should be in +/// the local crate. +/// +/// Suitable for user output/suggestions. +/// +/// This ignores use items, and assumes that the target path is visible from the source +/// path (which _should_ be a reasonable assumption since we in order to be able to use an object of +/// certain type T, T is required to be visible). +/// +/// TODO make use of `use` items. Maybe we should have something more sophisticated like +/// rust-analyzer does? +fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> String { + use itertools::EitherOrBoth::{Both, Left, Right}; + + // 1. skip the segments common for both paths (regardless of their type) + let unique_parts = to + .data + .iter() + .zip_longest(from.data.iter()) + .skip_while(|el| matches!(el, Both(l, r) if l == r)) + .map(|el| match el { + Both(l, r) => Both(l.data, r.data), + Left(l) => Left(l.data), + Right(r) => Right(r.data), + }); + + // 2. for the remaning segments, construct relative path using only mod names and `super` + let mut go_up_by = 0; + let mut path = Vec::new(); + for el in unique_parts { + match el { + Both(l, r) => { + // consider: + // a::b::sym:: :: refers to + // c::d::e ::f::sym + // result should be super::super::c::d::e::f + // + // alternatively: + // a::b::c ::d::sym refers to + // e::f::sym:: :: + // result should be super::super::super::super::e::f + if let DefPathData::TypeNs(s) = l { + path.push(s.to_string()); + } + if let DefPathData::TypeNs(_) = r { + go_up_by += 1; + } + }, + // consider: + // a::b::sym:: :: refers to + // c::d::e ::f::sym + // when looking at `f` + Left(DefPathData::TypeNs(sym)) => path.push(sym.to_string()), + // consider: + // a::b::c ::d::sym refers to + // e::f::sym:: :: + // when looking at `d` + Right(DefPathData::TypeNs(_)) => go_up_by += 1, + _ => {}, + } + } + + if go_up_by > max_super { + // `super` chain would be too long, just use the absolute path instead + once(String::from("crate")) + .chain(to.data.iter().filter_map(|el| { + if let DefPathData::TypeNs(sym) = el.data { + Some(sym.to_string()) + } else { + None + } + })) + .join("::") + } else { + repeat(String::from("super")).take(go_up_by).chain(path).join("::") + } +} diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 11bb16ff6c5bf..6762c88300503 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -1000,35 +1000,6 @@ pub fn adt_and_variant_of_res<'tcx>(cx: &LateContext<'tcx>, res: Res) -> Option< } } -/// Checks if the type is a type parameter implementing `FnOnce`, but not `FnMut`. -pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tcx [ty::Clause<'_>]) -> bool { - let ty::Param(ty) = *ty.kind() else { - return false; - }; - let lang = tcx.lang_items(); - let (Some(fn_once_id), Some(fn_mut_id), Some(fn_id)) = (lang.fn_once_trait(), lang.fn_mut_trait(), lang.fn_trait()) - else { - return false; - }; - predicates - .iter() - .try_fold(false, |found, p| { - if let ty::ClauseKind::Trait(p) = p.kind().skip_binder() - && let ty::Param(self_ty) = p.trait_ref.self_ty().kind() - && ty.index == self_ty.index - { - // This should use `super_traits_of`, but that's a private function. - if p.trait_ref.def_id == fn_once_id { - return Some(true); - } else if p.trait_ref.def_id == fn_mut_id || p.trait_ref.def_id == fn_id { - return None; - } - } - Some(found) - }) - .unwrap_or(false) -} - /// Comes up with an "at least" guesstimate for the type's size, not taking into /// account the layout of type parameters. pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 { diff --git a/declare_clippy_lint/Cargo.toml b/declare_clippy_lint/Cargo.toml index 5aaafb4172144..0f90cef5cdd2b 100644 --- a/declare_clippy_lint/Cargo.toml +++ b/declare_clippy_lint/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "declare_clippy_lint" -version = "0.1.77" +version = "0.1.78" edition = "2021" publish = false diff --git a/rust-toolchain b/rust-toolchain index d2d56e59ee3fb..fcf5c456270cd 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-01-25" +channel = "nightly-2024-02-08" components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] diff --git a/src/driver.rs b/src/driver.rs index b944a299256c2..f5e52f787ab41 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -22,9 +22,11 @@ use rustc_session::EarlyDiagCtxt; use rustc_span::symbol::Symbol; use std::env; +use std::fs::read_to_string; use std::ops::Deref; use std::path::Path; use std::process::exit; +use std::string::ToString; use anstream::println; @@ -188,12 +190,31 @@ pub fn main() { exit(rustc_driver::catch_with_exit_code(move || { let mut orig_args: Vec = env::args().collect(); - let has_sysroot_arg = arg_value(&orig_args, "--sysroot", |_| true).is_some(); + + let has_sysroot_arg = |args: &mut [String]| -> bool { + if arg_value(args, "--sysroot", |_| true).is_some() { + return true; + } + // https://doc.rust-lang.org/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path + // Beside checking for existence of `--sysroot` on the command line, we need to + // check for the arg files that are prefixed with @ as well to be consistent with rustc + for arg in args.iter() { + if let Some(arg_file_path) = arg.strip_prefix('@') { + if let Ok(arg_file) = read_to_string(arg_file_path) { + let split_arg_file: Vec = arg_file.lines().map(ToString::to_string).collect(); + if arg_value(&split_arg_file, "--sysroot", |_| true).is_some() { + return true; + } + } + } + } + false + }; let sys_root_env = std::env::var("SYSROOT").ok(); let pass_sysroot_env_if_given = |args: &mut Vec, sys_root_env| { if let Some(sys_root) = sys_root_env { - if !has_sysroot_arg { + if !has_sysroot_arg(args) { args.extend(vec!["--sysroot".into(), sys_root]); } }; diff --git a/tests/ui-cargo/lint_groups_priority/fail/Cargo.stderr b/tests/ui-cargo/lint_groups_priority/fail/Cargo.stderr new file mode 100644 index 0000000000000..103e60d84844c --- /dev/null +++ b/tests/ui-cargo/lint_groups_priority/fail/Cargo.stderr @@ -0,0 +1,45 @@ +error: lint group `rust_2018_idioms` has the same priority (0) as a lint + --> Cargo.toml:7:1 + | +7 | rust_2018_idioms = "warn" + | ^^^^^^^^^^^^^^^^ ------ has an implicit priority of 0 +8 | bare_trait_objects = "allow" + | ------------------ has the same priority as this lint + | + = note: the order of the lints in the table is ignored by Cargo + = note: `#[deny(clippy::lint_groups_priority)]` on by default +help: to have lints override the group set `rust_2018_idioms` to a lower priority + | +7 | rust_2018_idioms = { level = "warn", priority = -1 } + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: lint group `unused` has the same priority (0) as a lint + --> Cargo.toml:10:1 + | +10 | unused = { level = "deny" } + | ^^^^^^ ------------------ has an implicit priority of 0 +11 | unused_braces = { level = "allow", priority = 1 } +12 | unused_attributes = { level = "allow" } + | ----------------- has the same priority as this lint + | + = note: the order of the lints in the table is ignored by Cargo +help: to have lints override the group set `unused` to a lower priority + | +10 | unused = { level = "deny", priority = -1 } + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: lint group `pedantic` has the same priority (-1) as a lint + --> Cargo.toml:19:1 + | +19 | pedantic = { level = "warn", priority = -1 } + | ^^^^^^^^ +20 | similar_names = { level = "allow", priority = -1 } + | ------------- has the same priority as this lint + | + = note: the order of the lints in the table is ignored by Cargo +help: to have lints override the group set `pedantic` to a lower priority + | +19 | pedantic = { level = "warn", priority = -2 } + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: could not compile `fail` (lib) due to 3 previous errors diff --git a/tests/ui-cargo/lint_groups_priority/fail/Cargo.toml b/tests/ui-cargo/lint_groups_priority/fail/Cargo.toml new file mode 100644 index 0000000000000..4ce41f7817118 --- /dev/null +++ b/tests/ui-cargo/lint_groups_priority/fail/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "fail" +version = "0.1.0" +publish = false + +[lints.rust] +rust_2018_idioms = "warn" +bare_trait_objects = "allow" + +unused = { level = "deny" } +unused_braces = { level = "allow", priority = 1 } +unused_attributes = { level = "allow" } + +# `warnings` is not a group so the order it is passed does not matter +warnings = "deny" +deprecated = "allow" + +[lints.clippy] +pedantic = { level = "warn", priority = -1 } +similar_names = { level = "allow", priority = -1 } diff --git a/tests/ui-cargo/lint_groups_priority/fail/src/lib.rs b/tests/ui-cargo/lint_groups_priority/fail/src/lib.rs new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/tests/ui-cargo/lint_groups_priority/fail/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/ui-cargo/lint_groups_priority/pass/Cargo.toml b/tests/ui-cargo/lint_groups_priority/pass/Cargo.toml new file mode 100644 index 0000000000000..e9fcf803d9369 --- /dev/null +++ b/tests/ui-cargo/lint_groups_priority/pass/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "pass" +version = "0.1.0" +publish = false + +[lints.clippy] +pedantic = { level = "warn", priority = -1 } +style = { level = "warn", priority = 1 } +similar_names = "allow" +dbg_macro = { level = "warn", priority = 2 } diff --git a/tests/ui-cargo/lint_groups_priority/pass/src/lib.rs b/tests/ui-cargo/lint_groups_priority/pass/src/lib.rs new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/tests/ui-cargo/lint_groups_priority/pass/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/ui-toml/min_rust_version/min_rust_version.fixed b/tests/ui-toml/min_rust_version/min_rust_version.fixed index 6c58e07d846ea..497f783087a10 100644 --- a/tests/ui-toml/min_rust_version/min_rust_version.fixed +++ b/tests/ui-toml/min_rust_version/min_rust_version.fixed @@ -1,4 +1,4 @@ -#![allow(clippy::redundant_clone, clippy::unnecessary_operation)] +#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)] #![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)] use std::mem::{size_of, size_of_val}; diff --git a/tests/ui-toml/min_rust_version/min_rust_version.rs b/tests/ui-toml/min_rust_version/min_rust_version.rs index e1dc3f4389c0b..6e7874108a34c 100644 --- a/tests/ui-toml/min_rust_version/min_rust_version.rs +++ b/tests/ui-toml/min_rust_version/min_rust_version.rs @@ -1,4 +1,4 @@ -#![allow(clippy::redundant_clone, clippy::unnecessary_operation)] +#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)] #![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)] use std::mem::{size_of, size_of_val}; diff --git a/tests/ui-toml/modulo_arithmetic/clippy.toml b/tests/ui-toml/modulo_arithmetic/clippy.toml new file mode 100644 index 0000000000000..de80f4ae59838 --- /dev/null +++ b/tests/ui-toml/modulo_arithmetic/clippy.toml @@ -0,0 +1 @@ +allow-comparison-to-zero = false diff --git a/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs new file mode 100644 index 0000000000000..27d27564baf34 --- /dev/null +++ b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs @@ -0,0 +1,10 @@ +#![warn(clippy::modulo_arithmetic)] + +fn main() { + let a = -1; + let b = 2; + let c = a % b == 0; + let c = a % b != 0; + let c = 0 == a % b; + let c = 0 != a % b; +} diff --git a/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr new file mode 100644 index 0000000000000..da644b05a113d --- /dev/null +++ b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr @@ -0,0 +1,40 @@ +error: you are using modulo operator on types that might have different signs + --> $DIR/modulo_arithmetic.rs:6:13 + | +LL | let c = a % b == 0; + | ^^^^^ + | + = note: double check for expected result especially when interoperating with different languages + = note: or consider using `rem_euclid` or similar function + = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` + +error: you are using modulo operator on types that might have different signs + --> $DIR/modulo_arithmetic.rs:7:13 + | +LL | let c = a % b != 0; + | ^^^^^ + | + = note: double check for expected result especially when interoperating with different languages + = note: or consider using `rem_euclid` or similar function + +error: you are using modulo operator on types that might have different signs + --> $DIR/modulo_arithmetic.rs:8:18 + | +LL | let c = 0 == a % b; + | ^^^^^ + | + = note: double check for expected result especially when interoperating with different languages + = note: or consider using `rem_euclid` or similar function + +error: you are using modulo operator on types that might have different signs + --> $DIR/modulo_arithmetic.rs:9:18 + | +LL | let c = 0 != a % b; + | ^^^^^ + | + = note: double check for expected result especially when interoperating with different languages + = note: or consider using `rem_euclid` or similar function + +error: aborting due to 4 previous errors + diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index fc683e514ba40..f097d2503e163 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -3,6 +3,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect absolute-paths-max-segments accept-comment-above-attributes accept-comment-above-statement + allow-comparison-to-zero allow-dbg-in-tests allow-expect-in-tests allow-mixed-uninlined-format-args @@ -14,6 +15,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect allowed-duplicate-crates allowed-idents-below-min-chars allowed-scripts + allowed-wildcard-imports arithmetic-side-effects-allowed arithmetic-side-effects-allowed-binary arithmetic-side-effects-allowed-unary @@ -80,6 +82,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect absolute-paths-max-segments accept-comment-above-attributes accept-comment-above-statement + allow-comparison-to-zero allow-dbg-in-tests allow-expect-in-tests allow-mixed-uninlined-format-args @@ -91,6 +94,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect allowed-duplicate-crates allowed-idents-below-min-chars allowed-scripts + allowed-wildcard-imports arithmetic-side-effects-allowed arithmetic-side-effects-allowed-binary arithmetic-side-effects-allowed-unary @@ -157,6 +161,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni absolute-paths-max-segments accept-comment-above-attributes accept-comment-above-statement + allow-comparison-to-zero allow-dbg-in-tests allow-expect-in-tests allow-mixed-uninlined-format-args @@ -168,6 +173,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni allowed-duplicate-crates allowed-idents-below-min-chars allowed-scripts + allowed-wildcard-imports arithmetic-side-effects-allowed arithmetic-side-effects-allowed-binary arithmetic-side-effects-allowed-unary diff --git a/tests/ui-toml/wildcard_imports/clippy.toml b/tests/ui-toml/wildcard_imports/clippy.toml index 875aaeef6c935..68815c1756ac2 100644 --- a/tests/ui-toml/wildcard_imports/clippy.toml +++ b/tests/ui-toml/wildcard_imports/clippy.toml @@ -1 +1,4 @@ warn-on-all-wildcard-imports = true + +# This should be ignored since `warn-on-all-wildcard-imports` has higher precedence +allowed-wildcard-imports = ["utils"] diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.fixed b/tests/ui-toml/wildcard_imports/wildcard_imports.fixed index 1752f48856c2b..af72d6be0e096 100644 --- a/tests/ui-toml/wildcard_imports/wildcard_imports.fixed +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.fixed @@ -3,9 +3,28 @@ mod prelude { pub const FOO: u8 = 1; } + +mod utils { + pub const BAR: u8 = 1; + pub fn print() {} +} + +mod my_crate { + pub mod utils { + pub fn my_util_fn() {} + } +} + +use utils::{BAR, print}; +//~^ ERROR: usage of wildcard import +use my_crate::utils::my_util_fn; +//~^ ERROR: usage of wildcard import use prelude::FOO; //~^ ERROR: usage of wildcard import fn main() { let _ = FOO; + let _ = BAR; + print(); + my_util_fn(); } diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.rs b/tests/ui-toml/wildcard_imports/wildcard_imports.rs index 331c2c59c222f..91009dd8835f8 100644 --- a/tests/ui-toml/wildcard_imports/wildcard_imports.rs +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.rs @@ -3,9 +3,28 @@ mod prelude { pub const FOO: u8 = 1; } + +mod utils { + pub const BAR: u8 = 1; + pub fn print() {} +} + +mod my_crate { + pub mod utils { + pub fn my_util_fn() {} + } +} + +use utils::*; +//~^ ERROR: usage of wildcard import +use my_crate::utils::*; +//~^ ERROR: usage of wildcard import use prelude::*; //~^ ERROR: usage of wildcard import fn main() { let _ = FOO; + let _ = BAR; + print(); + my_util_fn(); } diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr index f11fda6a0c6e1..a733d786d0e64 100644 --- a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr @@ -1,11 +1,23 @@ error: usage of wildcard import - --> $DIR/wildcard_imports.rs:6:5 + --> $DIR/wildcard_imports.rs:18:5 | -LL | use prelude::*; - | ^^^^^^^^^^ help: try: `prelude::FOO` +LL | use utils::*; + | ^^^^^^^^ help: try: `utils::{BAR, print}` | = note: `-D clippy::wildcard-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` -error: aborting due to 1 previous error +error: usage of wildcard import + --> $DIR/wildcard_imports.rs:20:5 + | +LL | use my_crate::utils::*; + | ^^^^^^^^^^^^^^^^^^ help: try: `my_crate::utils::my_util_fn` + +error: usage of wildcard import + --> $DIR/wildcard_imports.rs:22:5 + | +LL | use prelude::*; + | ^^^^^^^^^^ help: try: `prelude::FOO` + +error: aborting due to 3 previous errors diff --git a/tests/ui-toml/wildcard_imports_whitelist/clippy.toml b/tests/ui-toml/wildcard_imports_whitelist/clippy.toml new file mode 100644 index 0000000000000..6b7882e64a8bb --- /dev/null +++ b/tests/ui-toml/wildcard_imports_whitelist/clippy.toml @@ -0,0 +1 @@ +allowed-wildcard-imports = ["utils"] diff --git a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.fixed b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.fixed new file mode 100644 index 0000000000000..d539525c45ed6 --- /dev/null +++ b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.fixed @@ -0,0 +1,26 @@ +#![warn(clippy::wildcard_imports)] + +mod utils { + pub fn print() {} +} + +mod utils_plus { + pub fn do_something() {} +} + +mod my_crate { + pub mod utils { + pub fn my_util_fn() {} + } +} + +use my_crate::utils::*; +use utils::*; +use utils_plus::do_something; +//~^ ERROR: usage of wildcard import + +fn main() { + print(); + my_util_fn(); + do_something(); +} diff --git a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.rs b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.rs new file mode 100644 index 0000000000000..9169d16a08be1 --- /dev/null +++ b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.rs @@ -0,0 +1,26 @@ +#![warn(clippy::wildcard_imports)] + +mod utils { + pub fn print() {} +} + +mod utils_plus { + pub fn do_something() {} +} + +mod my_crate { + pub mod utils { + pub fn my_util_fn() {} + } +} + +use my_crate::utils::*; +use utils::*; +use utils_plus::*; +//~^ ERROR: usage of wildcard import + +fn main() { + print(); + my_util_fn(); + do_something(); +} diff --git a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr new file mode 100644 index 0000000000000..12c2f9cbada70 --- /dev/null +++ b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr @@ -0,0 +1,11 @@ +error: usage of wildcard import + --> $DIR/wildcard_imports.rs:19:5 + | +LL | use utils_plus::*; + | ^^^^^^^^^^^^^ help: try: `utils_plus::do_something` + | + = note: `-D clippy::wildcard-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/borrow_as_ptr.fixed b/tests/ui/borrow_as_ptr.fixed index 6c0de96d65e36..289a5ef38b8dd 100644 --- a/tests/ui/borrow_as_ptr.fixed +++ b/tests/ui/borrow_as_ptr.fixed @@ -5,6 +5,7 @@ fn a() -> i32 { 0 } +#[clippy::msrv = "1.75"] fn main() { let val = 1; let _p = std::ptr::addr_of!(val); diff --git a/tests/ui/borrow_as_ptr.rs b/tests/ui/borrow_as_ptr.rs index c37c5357c82c0..b5328cb22dcdb 100644 --- a/tests/ui/borrow_as_ptr.rs +++ b/tests/ui/borrow_as_ptr.rs @@ -5,6 +5,7 @@ fn a() -> i32 { 0 } +#[clippy::msrv = "1.75"] fn main() { let val = 1; let _p = &val as *const i32; diff --git a/tests/ui/borrow_as_ptr.stderr b/tests/ui/borrow_as_ptr.stderr index 43a7a6bf5b57e..b98618059050c 100644 --- a/tests/ui/borrow_as_ptr.stderr +++ b/tests/ui/borrow_as_ptr.stderr @@ -1,5 +1,5 @@ error: borrow as raw pointer - --> $DIR/borrow_as_ptr.rs:10:14 + --> $DIR/borrow_as_ptr.rs:11:14 | LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)` @@ -8,7 +8,7 @@ LL | let _p = &val as *const i32; = help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]` error: borrow as raw pointer - --> $DIR/borrow_as_ptr.rs:17:18 + --> $DIR/borrow_as_ptr.rs:18:18 | LL | let _p_mut = &mut val_mut as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)` diff --git a/tests/ui/borrow_as_ptr_no_std.fixed b/tests/ui/borrow_as_ptr_no_std.fixed index a361a36474de5..f66554de30005 100644 --- a/tests/ui/borrow_as_ptr_no_std.fixed +++ b/tests/ui/borrow_as_ptr_no_std.fixed @@ -2,6 +2,7 @@ #![feature(lang_items, start, libc)] #![no_std] +#[clippy::msrv = "1.75"] #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { let val = 1; diff --git a/tests/ui/borrow_as_ptr_no_std.rs b/tests/ui/borrow_as_ptr_no_std.rs index b3fe01442b745..1fc254aafa775 100644 --- a/tests/ui/borrow_as_ptr_no_std.rs +++ b/tests/ui/borrow_as_ptr_no_std.rs @@ -2,6 +2,7 @@ #![feature(lang_items, start, libc)] #![no_std] +#[clippy::msrv = "1.75"] #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { let val = 1; diff --git a/tests/ui/borrow_as_ptr_no_std.stderr b/tests/ui/borrow_as_ptr_no_std.stderr index 2f258bcf966ad..1ef0a948a32a1 100644 --- a/tests/ui/borrow_as_ptr_no_std.stderr +++ b/tests/ui/borrow_as_ptr_no_std.stderr @@ -1,5 +1,5 @@ error: borrow as raw pointer - --> $DIR/borrow_as_ptr_no_std.rs:8:14 + --> $DIR/borrow_as_ptr_no_std.rs:9:14 | LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of!(val)` @@ -8,7 +8,7 @@ LL | let _p = &val as *const i32; = help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]` error: borrow as raw pointer - --> $DIR/borrow_as_ptr_no_std.rs:11:18 + --> $DIR/borrow_as_ptr_no_std.rs:12:18 | LL | let _p_mut = &mut val_mut as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of_mut!(val_mut)` diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed index 32c7499bf73f6..da28ec2e653a7 100644 --- a/tests/ui/eta.fixed +++ b/tests/ui/eta.fixed @@ -346,6 +346,23 @@ fn angle_brackets_and_args() { dyn_opt.map(::method_on_dyn); } +// https://github.com/rust-lang/rust-clippy/issues/12199 +fn track_caller_fp() { + struct S; + impl S { + #[track_caller] + fn add_location(self) {} + } + + #[track_caller] + fn add_location() {} + + fn foo(_: fn()) {} + fn foo2(_: fn(S)) {} + foo(|| add_location()); + foo2(|s| s.add_location()); +} + fn _late_bound_to_early_bound_regions() { struct Foo<'a>(&'a u32); impl<'a> Foo<'a> { @@ -400,3 +417,57 @@ fn _closure_with_types() { let _ = f2(|x: u32| f(x)); let _ = f2(|x| -> u32 { f(x) }); } + +/// https://github.com/rust-lang/rust-clippy/issues/10854 +/// This is to verify that redundant_closure_for_method_calls resolves suggested paths to relative. +mod issue_10854 { + pub mod test_mod { + pub struct Test; + + impl Test { + pub fn method(self) -> i32 { + 0 + } + } + + pub fn calls_test(test: Option) -> Option { + test.map(Test::method) + } + + pub fn calls_outer(test: Option) -> Option { + test.map(super::Outer::method) + } + } + + pub struct Outer; + + impl Outer { + pub fn method(self) -> i32 { + 0 + } + } + + pub fn calls_into_mod(test: Option) -> Option { + test.map(test_mod::Test::method) + } + + mod a { + pub mod b { + pub mod c { + pub fn extreme_nesting(test: Option) -> Option { + test.map(crate::issue_10854::d::Test::method) + } + } + } + } + + mod d { + pub struct Test; + + impl Test { + pub fn method(self) -> i32 { + 0 + } + } + } +} diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index 25b7431ba8cd7..f924100f8f419 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -346,6 +346,23 @@ fn angle_brackets_and_args() { dyn_opt.map(|d| d.method_on_dyn()); } +// https://github.com/rust-lang/rust-clippy/issues/12199 +fn track_caller_fp() { + struct S; + impl S { + #[track_caller] + fn add_location(self) {} + } + + #[track_caller] + fn add_location() {} + + fn foo(_: fn()) {} + fn foo2(_: fn(S)) {} + foo(|| add_location()); + foo2(|s| s.add_location()); +} + fn _late_bound_to_early_bound_regions() { struct Foo<'a>(&'a u32); impl<'a> Foo<'a> { @@ -400,3 +417,57 @@ fn _closure_with_types() { let _ = f2(|x: u32| f(x)); let _ = f2(|x| -> u32 { f(x) }); } + +/// https://github.com/rust-lang/rust-clippy/issues/10854 +/// This is to verify that redundant_closure_for_method_calls resolves suggested paths to relative. +mod issue_10854 { + pub mod test_mod { + pub struct Test; + + impl Test { + pub fn method(self) -> i32 { + 0 + } + } + + pub fn calls_test(test: Option) -> Option { + test.map(|t| t.method()) + } + + pub fn calls_outer(test: Option) -> Option { + test.map(|t| t.method()) + } + } + + pub struct Outer; + + impl Outer { + pub fn method(self) -> i32 { + 0 + } + } + + pub fn calls_into_mod(test: Option) -> Option { + test.map(|t| t.method()) + } + + mod a { + pub mod b { + pub mod c { + pub fn extreme_nesting(test: Option) -> Option { + test.map(|t| t.method()) + } + } + } + } + + mod d { + pub struct Test; + + impl Test { + pub fn method(self) -> i32 { + 0 + } + } + } +} diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 951e4ac749c25..945de466d8322 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -161,10 +161,34 @@ LL | dyn_opt.map(|d| d.method_on_dyn()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `::method_on_dyn` error: redundant closure - --> $DIR/eta.rs:389:19 + --> $DIR/eta.rs:406:19 | LL | let _ = f(&0, |x, y| f2(x, y)); | ^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `f2` -error: aborting due to 27 previous errors +error: redundant closure + --> $DIR/eta.rs:434:22 + | +LL | test.map(|t| t.method()) + | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `Test::method` + +error: redundant closure + --> $DIR/eta.rs:438:22 + | +LL | test.map(|t| t.method()) + | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `super::Outer::method` + +error: redundant closure + --> $DIR/eta.rs:451:18 + | +LL | test.map(|t| t.method()) + | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `test_mod::Test::method` + +error: redundant closure + --> $DIR/eta.rs:458:30 + | +LL | test.map(|t| t.method()) + | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `crate::issue_10854::d::Test::method` + +error: aborting due to 31 previous errors diff --git a/tests/ui/format_args.fixed b/tests/ui/format_args.fixed index ddd5976c408a3..cab20b11e0731 100644 --- a/tests/ui/format_args.fixed +++ b/tests/ui/format_args.fixed @@ -14,6 +14,7 @@ use std::panic::Location; struct Somewhere; +#[allow(clippy::to_string_trait_impl)] impl ToString for Somewhere { fn to_string(&self) -> String { String::from("somewhere") diff --git a/tests/ui/format_args.rs b/tests/ui/format_args.rs index 18e1bc1af67f1..bc3645cb2c2bc 100644 --- a/tests/ui/format_args.rs +++ b/tests/ui/format_args.rs @@ -14,6 +14,7 @@ use std::panic::Location; struct Somewhere; +#[allow(clippy::to_string_trait_impl)] impl ToString for Somewhere { fn to_string(&self) -> String { String::from("somewhere") diff --git a/tests/ui/format_args.stderr b/tests/ui/format_args.stderr index dcdfa668aff30..2f1714296d6c8 100644 --- a/tests/ui/format_args.stderr +++ b/tests/ui/format_args.stderr @@ -1,5 +1,5 @@ error: `to_string` applied to a type that implements `Display` in `format!` args - --> $DIR/format_args.rs:76:72 + --> $DIR/format_args.rs:77:72 | LL | let _ = format!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this @@ -8,145 +8,145 @@ LL | let _ = format!("error: something failed at {}", Location::caller().to_ = help: to override `-D warnings` add `#[allow(clippy::to_string_in_format_args)]` error: `to_string` applied to a type that implements `Display` in `write!` args - --> $DIR/format_args.rs:80:27 + --> $DIR/format_args.rs:81:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `writeln!` args - --> $DIR/format_args.rs:85:27 + --> $DIR/format_args.rs:86:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:87:63 + --> $DIR/format_args.rs:88:63 | LL | print!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:88:65 + --> $DIR/format_args.rs:89:65 | LL | println!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `eprint!` args - --> $DIR/format_args.rs:89:64 + --> $DIR/format_args.rs:90:64 | LL | eprint!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `eprintln!` args - --> $DIR/format_args.rs:90:66 + --> $DIR/format_args.rs:91:66 | LL | eprintln!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `format_args!` args - --> $DIR/format_args.rs:91:77 + --> $DIR/format_args.rs:92:77 | LL | let _ = format_args!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert!` args - --> $DIR/format_args.rs:92:70 + --> $DIR/format_args.rs:93:70 | LL | assert!(true, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert_eq!` args - --> $DIR/format_args.rs:93:73 + --> $DIR/format_args.rs:94:73 | LL | assert_eq!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert_ne!` args - --> $DIR/format_args.rs:94:73 + --> $DIR/format_args.rs:95:73 | LL | assert_ne!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `panic!` args - --> $DIR/format_args.rs:95:63 + --> $DIR/format_args.rs:96:63 | LL | panic!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:96:20 + --> $DIR/format_args.rs:97:20 | LL | println!("{}", X(1).to_string()); | ^^^^^^^^^^^^^^^^ help: use this: `*X(1)` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:97:20 + --> $DIR/format_args.rs:98:20 | LL | println!("{}", Y(&X(1)).to_string()); | ^^^^^^^^^^^^^^^^^^^^ help: use this: `***Y(&X(1))` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:98:24 + --> $DIR/format_args.rs:99:24 | LL | println!("{}", Z(1).to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:99:20 + --> $DIR/format_args.rs:100:20 | LL | println!("{}", x.to_string()); | ^^^^^^^^^^^^^ help: use this: `**x` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:100:20 + --> $DIR/format_args.rs:101:20 | LL | println!("{}", x_ref.to_string()); | ^^^^^^^^^^^^^^^^^ help: use this: `***x_ref` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:102:39 + --> $DIR/format_args.rs:103:39 | LL | println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:103:52 + --> $DIR/format_args.rs:104:52 | LL | println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:104:39 + --> $DIR/format_args.rs:105:39 | LL | println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:105:52 + --> $DIR/format_args.rs:106:52 | LL | println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:117:37 + --> $DIR/format_args.rs:118:37 | LL | print!("{}", (Location::caller().to_string())); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:118:39 + --> $DIR/format_args.rs:119:39 | LL | print!("{}", ((Location::caller()).to_string())); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `format!` args - --> $DIR/format_args.rs:146:38 + --> $DIR/format_args.rs:147:38 | LL | let x = format!("{} {}", a, b.to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:160:24 + --> $DIR/format_args.rs:161:24 | LL | println!("{}", original[..10].to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use this: `&original[..10]` diff --git a/tests/ui/ignored_unit_patterns.fixed b/tests/ui/ignored_unit_patterns.fixed index 707a0e76e4ebc..118f0b4889529 100644 --- a/tests/ui/ignored_unit_patterns.fixed +++ b/tests/ui/ignored_unit_patterns.fixed @@ -1,6 +1,11 @@ //@aux-build:proc_macro_derive.rs #![warn(clippy::ignored_unit_patterns)] -#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)] +#![allow( + clippy::let_unit_value, + clippy::redundant_pattern_matching, + clippy::single_match, + clippy::needless_borrow +)] fn foo() -> Result<(), ()> { unimplemented!() diff --git a/tests/ui/ignored_unit_patterns.rs b/tests/ui/ignored_unit_patterns.rs index 544f2b8f6929c..92feb9e6c2814 100644 --- a/tests/ui/ignored_unit_patterns.rs +++ b/tests/ui/ignored_unit_patterns.rs @@ -1,6 +1,11 @@ //@aux-build:proc_macro_derive.rs #![warn(clippy::ignored_unit_patterns)] -#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)] +#![allow( + clippy::let_unit_value, + clippy::redundant_pattern_matching, + clippy::single_match, + clippy::needless_borrow +)] fn foo() -> Result<(), ()> { unimplemented!() diff --git a/tests/ui/ignored_unit_patterns.stderr b/tests/ui/ignored_unit_patterns.stderr index 05c8f281e554d..18ca7ebbcf2c4 100644 --- a/tests/ui/ignored_unit_patterns.stderr +++ b/tests/ui/ignored_unit_patterns.stderr @@ -1,5 +1,5 @@ error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:11:12 + --> $DIR/ignored_unit_patterns.rs:16:12 | LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` @@ -8,49 +8,49 @@ LL | Ok(_) => {}, = help: to override `-D warnings` add `#[allow(clippy::ignored_unit_patterns)]` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:12:13 + --> $DIR/ignored_unit_patterns.rs:17:13 | LL | Err(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:14:15 + --> $DIR/ignored_unit_patterns.rs:19:15 | LL | if let Ok(_) = foo() {} | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:16:28 + --> $DIR/ignored_unit_patterns.rs:21:28 | LL | let _ = foo().map_err(|_| todo!()); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:22:16 + --> $DIR/ignored_unit_patterns.rs:27:16 | LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:24:17 + --> $DIR/ignored_unit_patterns.rs:29:17 | LL | Err(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:36:9 + --> $DIR/ignored_unit_patterns.rs:41:9 | LL | let _ = foo().unwrap(); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:45:13 + --> $DIR/ignored_unit_patterns.rs:50:13 | LL | (1, _) => unimplemented!(), | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:52:13 + --> $DIR/ignored_unit_patterns.rs:57:13 | LL | for (x, _) in v { | ^ help: use `()` instead of `_`: `()` diff --git a/tests/ui/incompatible_msrv.rs b/tests/ui/incompatible_msrv.rs new file mode 100644 index 0000000000000..a92017fb0f626 --- /dev/null +++ b/tests/ui/incompatible_msrv.rs @@ -0,0 +1,23 @@ +#![warn(clippy::incompatible_msrv)] +#![feature(custom_inner_attributes)] +#![clippy::msrv = "1.3.0"] + +use std::collections::hash_map::Entry; +use std::collections::HashMap; +use std::thread::sleep; +use std::time::Duration; + +fn foo() { + let mut map: HashMap<&str, u32> = HashMap::new(); + assert_eq!(map.entry("poneyland").key(), &"poneyland"); + //~^ ERROR: is `1.3.0` but this item is stable since `1.10.0` + if let Entry::Vacant(v) = map.entry("poneyland") { + v.into_key(); + //~^ ERROR: is `1.3.0` but this item is stable since `1.12.0` + } + // Should warn for `sleep` but not for `Duration` (which was added in `1.3.0`). + sleep(Duration::new(1, 0)); + //~^ ERROR: is `1.3.0` but this item is stable since `1.4.0` +} + +fn main() {} diff --git a/tests/ui/incompatible_msrv.stderr b/tests/ui/incompatible_msrv.stderr new file mode 100644 index 0000000000000..bd5ecd6ed2ffb --- /dev/null +++ b/tests/ui/incompatible_msrv.stderr @@ -0,0 +1,23 @@ +error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.10.0` + --> $DIR/incompatible_msrv.rs:12:39 + | +LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); + | ^^^^^ + | + = note: `-D clippy::incompatible-msrv` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]` + +error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.12.0` + --> $DIR/incompatible_msrv.rs:15:11 + | +LL | v.into_key(); + | ^^^^^^^^^^ + +error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.4.0` + --> $DIR/incompatible_msrv.rs:19:5 + | +LL | sleep(Duration::new(1, 0)); + | ^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/manual_c_str_literals.fixed b/tests/ui/manual_c_str_literals.fixed new file mode 100644 index 0000000000000..a24d7088c882a --- /dev/null +++ b/tests/ui/manual_c_str_literals.fixed @@ -0,0 +1,60 @@ +#![warn(clippy::manual_c_str_literals)] +#![allow(clippy::no_effect)] + +use std::ffi::CStr; + +macro_rules! cstr { + ($s:literal) => { + CStr::from_bytes_with_nul(concat!($s, "\0").as_bytes()).unwrap() + }; +} + +macro_rules! macro_returns_c_str { + () => { + CStr::from_bytes_with_nul(b"foo\0").unwrap(); + }; +} + +macro_rules! macro_returns_byte_string { + () => { + b"foo\0" + }; +} + +#[clippy::msrv = "1.76.0"] +fn pre_stabilization() { + CStr::from_bytes_with_nul(b"foo\0"); +} + +#[clippy::msrv = "1.77.0"] +fn post_stabilization() { + c"foo"; +} + +fn main() { + c"foo"; + c"foo"; + c"foo"; + c"foo\\0sdsd"; + CStr::from_bytes_with_nul(br"foo\\0sdsd\0").unwrap(); + CStr::from_bytes_with_nul(br"foo\x00").unwrap(); + CStr::from_bytes_with_nul(br##"foo#a\0"##).unwrap(); + + unsafe { c"foo" }; + unsafe { c"foo" }; + let _: *const _ = c"foo".as_ptr(); + let _: *const _ = c"foo".as_ptr(); + let _: *const _ = "foo".as_ptr(); // not a C-string + let _: *const _ = "".as_ptr(); + let _: *const _ = c"foo".as_ptr().cast::(); + let _ = "电脑".as_ptr(); + let _ = "电脑\\".as_ptr(); + let _ = c"电脑\\".as_ptr(); + let _ = c"电脑".as_ptr(); + let _ = c"电脑".as_ptr(); + + // Macro cases, don't lint: + cstr!("foo"); + macro_returns_c_str!(); + CStr::from_bytes_with_nul(macro_returns_byte_string!()).unwrap(); +} diff --git a/tests/ui/manual_c_str_literals.rs b/tests/ui/manual_c_str_literals.rs new file mode 100644 index 0000000000000..0a007786720f7 --- /dev/null +++ b/tests/ui/manual_c_str_literals.rs @@ -0,0 +1,60 @@ +#![warn(clippy::manual_c_str_literals)] +#![allow(clippy::no_effect)] + +use std::ffi::CStr; + +macro_rules! cstr { + ($s:literal) => { + CStr::from_bytes_with_nul(concat!($s, "\0").as_bytes()).unwrap() + }; +} + +macro_rules! macro_returns_c_str { + () => { + CStr::from_bytes_with_nul(b"foo\0").unwrap(); + }; +} + +macro_rules! macro_returns_byte_string { + () => { + b"foo\0" + }; +} + +#[clippy::msrv = "1.76.0"] +fn pre_stabilization() { + CStr::from_bytes_with_nul(b"foo\0"); +} + +#[clippy::msrv = "1.77.0"] +fn post_stabilization() { + CStr::from_bytes_with_nul(b"foo\0"); +} + +fn main() { + CStr::from_bytes_with_nul(b"foo\0"); + CStr::from_bytes_with_nul(b"foo\x00"); + CStr::from_bytes_with_nul(b"foo\0").unwrap(); + CStr::from_bytes_with_nul(b"foo\\0sdsd\0").unwrap(); + CStr::from_bytes_with_nul(br"foo\\0sdsd\0").unwrap(); + CStr::from_bytes_with_nul(br"foo\x00").unwrap(); + CStr::from_bytes_with_nul(br##"foo#a\0"##).unwrap(); + + unsafe { CStr::from_ptr(b"foo\0".as_ptr().cast()) }; + unsafe { CStr::from_ptr(b"foo\0".as_ptr() as *const _) }; + let _: *const _ = b"foo\0".as_ptr(); + let _: *const _ = "foo\0".as_ptr(); + let _: *const _ = "foo".as_ptr(); // not a C-string + let _: *const _ = "".as_ptr(); + let _: *const _ = b"foo\0".as_ptr().cast::(); + let _ = "电脑".as_ptr(); + let _ = "电脑\\".as_ptr(); + let _ = "电脑\\\0".as_ptr(); + let _ = "电脑\0".as_ptr(); + let _ = "电脑\x00".as_ptr(); + + // Macro cases, don't lint: + cstr!("foo"); + macro_returns_c_str!(); + CStr::from_bytes_with_nul(macro_returns_byte_string!()).unwrap(); +} diff --git a/tests/ui/manual_c_str_literals.stderr b/tests/ui/manual_c_str_literals.stderr new file mode 100644 index 0000000000000..8de4e16f010d6 --- /dev/null +++ b/tests/ui/manual_c_str_literals.stderr @@ -0,0 +1,83 @@ +error: calling `CStr::new` with a byte string literal + --> $DIR/manual_c_str_literals.rs:31:5 + | +LL | CStr::from_bytes_with_nul(b"foo\0"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` + | + = note: `-D clippy::manual-c-str-literals` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_c_str_literals)]` + +error: calling `CStr::new` with a byte string literal + --> $DIR/manual_c_str_literals.rs:35:5 + | +LL | CStr::from_bytes_with_nul(b"foo\0"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: calling `CStr::new` with a byte string literal + --> $DIR/manual_c_str_literals.rs:36:5 + | +LL | CStr::from_bytes_with_nul(b"foo\x00"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: calling `CStr::new` with a byte string literal + --> $DIR/manual_c_str_literals.rs:37:5 + | +LL | CStr::from_bytes_with_nul(b"foo\0").unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: calling `CStr::new` with a byte string literal + --> $DIR/manual_c_str_literals.rs:38:5 + | +LL | CStr::from_bytes_with_nul(b"foo\\0sdsd\0").unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo\\0sdsd"` + +error: calling `CStr::from_ptr` with a byte string literal + --> $DIR/manual_c_str_literals.rs:43:14 + | +LL | unsafe { CStr::from_ptr(b"foo\0".as_ptr().cast()) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: calling `CStr::from_ptr` with a byte string literal + --> $DIR/manual_c_str_literals.rs:44:14 + | +LL | unsafe { CStr::from_ptr(b"foo\0".as_ptr() as *const _) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: manually constructing a nul-terminated string + --> $DIR/manual_c_str_literals.rs:45:23 + | +LL | let _: *const _ = b"foo\0".as_ptr(); + | ^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: manually constructing a nul-terminated string + --> $DIR/manual_c_str_literals.rs:46:23 + | +LL | let _: *const _ = "foo\0".as_ptr(); + | ^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: manually constructing a nul-terminated string + --> $DIR/manual_c_str_literals.rs:49:23 + | +LL | let _: *const _ = b"foo\0".as_ptr().cast::(); + | ^^^^^^^^ help: use a `c""` literal: `c"foo"` + +error: manually constructing a nul-terminated string + --> $DIR/manual_c_str_literals.rs:52:13 + | +LL | let _ = "电脑\\\0".as_ptr(); + | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑\\"` + +error: manually constructing a nul-terminated string + --> $DIR/manual_c_str_literals.rs:53:13 + | +LL | let _ = "电脑\0".as_ptr(); + | ^^^^^^^^ help: use a `c""` literal: `c"电脑"` + +error: manually constructing a nul-terminated string + --> $DIR/manual_c_str_literals.rs:54:13 + | +LL | let _ = "电脑\x00".as_ptr(); + | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑"` + +error: aborting due to 13 previous errors + diff --git a/tests/ui/manual_retain.fixed b/tests/ui/manual_retain.fixed index 4dea3e8bfe68a..5540029bf6b1f 100644 --- a/tests/ui/manual_retain.fixed +++ b/tests/ui/manual_retain.fixed @@ -14,6 +14,9 @@ fn main() { _msrv_153(); _msrv_126(); _msrv_118(); + + issue_10393(); + issue_12081(); } fn binary_heap_retain() { @@ -23,6 +26,11 @@ fn binary_heap_retain() { binary_heap.retain(|x| x % 2 == 0); binary_heap.retain(|x| x % 2 == 0); + // Do lint, because we use pattern matching + let mut tuples = BinaryHeap::from([(0, 1), (1, 2), (2, 3)]); + tuples.retain(|(ref x, ref y)| *x == 0); + tuples.retain(|(x, y)| *x == 0); + // Do not lint, because type conversion is performed binary_heap = binary_heap .into_iter() @@ -55,6 +63,9 @@ fn btree_map_retain() { btree_map.retain(|_, &mut v| v % 2 == 0); btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0)); + // Do not lint, because the parameters are not matched in tuple pattern + btree_map = btree_map.into_iter().filter(|t| t.0 % 2 == 0).collect(); + // Do not lint. btree_map = btree_map .into_iter() @@ -76,6 +87,11 @@ fn btree_set_retain() { btree_set.retain(|x| x % 2 == 0); btree_set.retain(|x| x % 2 == 0); + // Do lint, because we use pattern matching + let mut tuples = BTreeSet::from([(0, 1), (1, 2), (2, 3)]); + tuples.retain(|(ref x, ref y)| *x == 0); + tuples.retain(|(x, y)| *x == 0); + // Do not lint, because type conversion is performed btree_set = btree_set .iter() @@ -108,6 +124,9 @@ fn hash_map_retain() { hash_map.retain(|_, &mut v| v % 2 == 0); hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0)); + // Do not lint, because the parameters are not matched in tuple pattern + hash_map = hash_map.into_iter().filter(|t| t.0 % 2 == 0).collect(); + // Do not lint. hash_map = hash_map .into_iter() @@ -128,6 +147,11 @@ fn hash_set_retain() { hash_set.retain(|x| x % 2 == 0); hash_set.retain(|x| x % 2 == 0); + // Do lint, because we use pattern matching + let mut tuples = HashSet::from([(0, 1), (1, 2), (2, 3)]); + tuples.retain(|(ref x, ref y)| *x == 0); + tuples.retain(|(x, y)| *x == 0); + // Do not lint, because type conversion is performed hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect::>(); hash_set = hash_set @@ -171,6 +195,11 @@ fn vec_retain() { vec.retain(|x| x % 2 == 0); vec.retain(|x| x % 2 == 0); + // Do lint, because we use pattern matching + let mut tuples = vec![(0, 1), (1, 2), (2, 3)]; + tuples.retain(|(ref x, ref y)| *x == 0); + tuples.retain(|(x, y)| *x == 0); + // Do not lint, because type conversion is performed vec = vec.into_iter().filter(|x| x % 2 == 0).collect::>(); vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect::>(); @@ -246,3 +275,37 @@ fn _msrv_118() { let mut hash_map: HashMap = (0..8).map(|x| (x, x * 10)).collect(); hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); } + +fn issue_10393() { + // Do lint + let mut vec = vec![(0, 1), (1, 2), (2, 3)]; + vec.retain(|(x, y)| *x == 0); + + // Do lint + let mut tuples = vec![(true, -2), (false, 3)]; + tuples.retain(|(_, n)| *n > 0); +} + +fn issue_11457() { + // Do not lint, as we need to modify the closure + let mut vals = vec![1, 2, 3, 4]; + vals = vals.iter().filter(|v| **v != 1).cloned().collect(); + + // Do not lint, as we need to modify the closure + let mut s = String::from("foobar"); + s = s.chars().filter(|c| *c != 'o').to_owned().collect(); +} + +fn issue_12081() { + let mut vec = vec![0, 1, 2]; + + // Do lint + vec.retain(|&x| x == 0); + vec.retain(|&x| x == 0); + vec.retain(|&x| x == 0); + + // Do lint + vec.retain(|x| *x == 0); + vec.retain(|x| *x == 0); + vec.retain(|x| *x == 0); +} diff --git a/tests/ui/manual_retain.rs b/tests/ui/manual_retain.rs index d839550f33a22..cee641d9d65f9 100644 --- a/tests/ui/manual_retain.rs +++ b/tests/ui/manual_retain.rs @@ -14,6 +14,9 @@ fn main() { _msrv_153(); _msrv_126(); _msrv_118(); + + issue_10393(); + issue_12081(); } fn binary_heap_retain() { @@ -23,6 +26,11 @@ fn binary_heap_retain() { binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).copied().collect(); binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).cloned().collect(); + // Do lint, because we use pattern matching + let mut tuples = BinaryHeap::from([(0, 1), (1, 2), (2, 3)]); + tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + // Do not lint, because type conversion is performed binary_heap = binary_heap .into_iter() @@ -58,6 +66,9 @@ fn btree_map_retain() { .filter(|(k, v)| (k % 2 == 0) && (v % 2 == 0)) .collect(); + // Do not lint, because the parameters are not matched in tuple pattern + btree_map = btree_map.into_iter().filter(|t| t.0 % 2 == 0).collect(); + // Do not lint. btree_map = btree_map .into_iter() @@ -79,6 +90,11 @@ fn btree_set_retain() { btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect(); + // Do lint, because we use pattern matching + let mut tuples = BTreeSet::from([(0, 1), (1, 2), (2, 3)]); + tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + // Do not lint, because type conversion is performed btree_set = btree_set .iter() @@ -114,6 +130,9 @@ fn hash_map_retain() { .filter(|(k, v)| (k % 2 == 0) && (v % 2 == 0)) .collect(); + // Do not lint, because the parameters are not matched in tuple pattern + hash_map = hash_map.into_iter().filter(|t| t.0 % 2 == 0).collect(); + // Do not lint. hash_map = hash_map .into_iter() @@ -134,6 +153,11 @@ fn hash_set_retain() { hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect(); hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); + // Do lint, because we use pattern matching + let mut tuples = HashSet::from([(0, 1), (1, 2), (2, 3)]); + tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + // Do not lint, because type conversion is performed hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect::>(); hash_set = hash_set @@ -177,6 +201,11 @@ fn vec_retain() { vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect(); vec = vec.into_iter().filter(|x| x % 2 == 0).collect(); + // Do lint, because we use pattern matching + let mut tuples = vec![(0, 1), (1, 2), (2, 3)]; + tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + // Do not lint, because type conversion is performed vec = vec.into_iter().filter(|x| x % 2 == 0).collect::>(); vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect::>(); @@ -252,3 +281,37 @@ fn _msrv_118() { let mut hash_map: HashMap = (0..8).map(|x| (x, x * 10)).collect(); hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); } + +fn issue_10393() { + // Do lint + let mut vec = vec![(0, 1), (1, 2), (2, 3)]; + vec = vec.into_iter().filter(|(x, y)| *x == 0).collect(); + + // Do lint + let mut tuples = vec![(true, -2), (false, 3)]; + tuples = tuples.into_iter().filter(|(_, n)| *n > 0).collect(); +} + +fn issue_11457() { + // Do not lint, as we need to modify the closure + let mut vals = vec![1, 2, 3, 4]; + vals = vals.iter().filter(|v| **v != 1).cloned().collect(); + + // Do not lint, as we need to modify the closure + let mut s = String::from("foobar"); + s = s.chars().filter(|c| *c != 'o').to_owned().collect(); +} + +fn issue_12081() { + let mut vec = vec![0, 1, 2]; + + // Do lint + vec = vec.iter().filter(|&&x| x == 0).copied().collect(); + vec = vec.iter().filter(|&&x| x == 0).cloned().collect(); + vec = vec.into_iter().filter(|&x| x == 0).collect(); + + // Do lint + vec = vec.iter().filter(|&x| *x == 0).copied().collect(); + vec = vec.iter().filter(|&x| *x == 0).cloned().collect(); + vec = vec.into_iter().filter(|x| *x == 0).collect(); +} diff --git a/tests/ui/manual_retain.stderr b/tests/ui/manual_retain.stderr index 0c5b1383b6aed..2c872f3b430e8 100644 --- a/tests/ui/manual_retain.stderr +++ b/tests/ui/manual_retain.stderr @@ -1,5 +1,5 @@ error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:22:5 + --> $DIR/manual_retain.rs:25:5 | LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` @@ -8,31 +8,43 @@ LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect(); = help: to override `-D warnings` add `#[allow(clippy::manual_retain)]` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:23:5 + --> $DIR/manual_retain.rs:26:5 | LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:24:5 + --> $DIR/manual_retain.rs:27:5 | LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:54:5 + --> $DIR/manual_retain.rs:31:5 + | +LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:32:5 + | +LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:62:5 | LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:55:5 + --> $DIR/manual_retain.rs:63:5 | LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:56:5 + --> $DIR/manual_retain.rs:64:5 | LL | / btree_map = btree_map LL | | .into_iter() @@ -41,37 +53,49 @@ LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:78:5 + --> $DIR/manual_retain.rs:89:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:79:5 + --> $DIR/manual_retain.rs:90:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:80:5 + --> $DIR/manual_retain.rs:91:5 | LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:110:5 + --> $DIR/manual_retain.rs:95:5 + | +LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:96:5 + | +LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:126:5 | LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:111:5 + --> $DIR/manual_retain.rs:127:5 | LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:112:5 + --> $DIR/manual_retain.rs:128:5 | LL | / hash_map = hash_map LL | | .into_iter() @@ -80,64 +104,136 @@ LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:133:5 + --> $DIR/manual_retain.rs:152:5 | LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:134:5 + --> $DIR/manual_retain.rs:153:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:135:5 + --> $DIR/manual_retain.rs:154:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:164:5 + --> $DIR/manual_retain.rs:158:5 + | +LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:159:5 + | +LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:188:5 | LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:176:5 + --> $DIR/manual_retain.rs:200:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:177:5 + --> $DIR/manual_retain.rs:201:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:178:5 + --> $DIR/manual_retain.rs:202:5 | LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:200:5 + --> $DIR/manual_retain.rs:206:5 + | +LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:207:5 + | +LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:229:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:201:5 + --> $DIR/manual_retain.rs:230:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:202:5 + --> $DIR/manual_retain.rs:231:5 | LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` -error: aborting due to 22 previous errors +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:288:5 + | +LL | vec = vec.into_iter().filter(|(x, y)| *x == 0).collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|(x, y)| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:292:5 + | +LL | tuples = tuples.into_iter().filter(|(_, n)| *n > 0).collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(_, n)| *n > 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:309:5 + | +LL | vec = vec.iter().filter(|&&x| x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:310:5 + | +LL | vec = vec.iter().filter(|&&x| x == 0).cloned().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:311:5 + | +LL | vec = vec.into_iter().filter(|&x| x == 0).collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:314:5 + | +LL | vec = vec.iter().filter(|&x| *x == 0).copied().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:315:5 + | +LL | vec = vec.iter().filter(|&x| *x == 0).cloned().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` + +error: this expression can be written more simply using `.retain()` + --> $DIR/manual_retain.rs:316:5 + | +LL | vec = vec.into_iter().filter(|x| *x == 0).collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` + +error: aborting due to 38 previous errors diff --git a/tests/ui/modulo_arithmetic_integral.rs b/tests/ui/modulo_arithmetic_integral.rs index 4dbed24026cf5..c427b8580e17a 100644 --- a/tests/ui/modulo_arithmetic_integral.rs +++ b/tests/ui/modulo_arithmetic_integral.rs @@ -114,4 +114,12 @@ fn main() { a_usize % b_usize; let mut a_usize: usize = 1; a_usize %= 2; + + // No lint when comparing to zero + let a = -1; + let mut b = 2; + let c = a % b == 0; + let c = 0 == a % b; + let c = a % b != 0; + let c = 0 != a % b; } diff --git a/tests/ui/needless_borrow.fixed b/tests/ui/needless_borrow.fixed index ff1e2dc88756b..23e8bf8a468fd 100644 --- a/tests/ui/needless_borrow.fixed +++ b/tests/ui/needless_borrow.fixed @@ -131,6 +131,9 @@ fn main() { 0 } } + + // issue #11786 + let x: (&str,) = ("",); } #[allow(clippy::needless_borrowed_reference)] diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index 597021539acfa..27771a8f15b30 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -131,6 +131,9 @@ fn main() { 0 } } + + // issue #11786 + let x: (&str,) = (&"",); } #[allow(clippy::needless_borrowed_reference)] diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index 44552ee6abea1..a21ed8382c14e 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -121,41 +121,47 @@ error: this expression creates a reference which is immediately dereferenced by LL | (&&5).foo(); | ^^^^^ help: change this to: `(&5)` +error: this expression creates a reference which is immediately dereferenced by the compiler + --> $DIR/needless_borrow.rs:136:23 + | +LL | let x: (&str,) = (&"",); + | ^^^ help: change this to: `""` + error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:175:13 + --> $DIR/needless_borrow.rs:178:13 | LL | (&self.f)() | ^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:184:13 + --> $DIR/needless_borrow.rs:187:13 | LL | (&mut self.f)() | ^^^^^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:221:22 + --> $DIR/needless_borrow.rs:224:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:228:22 + --> $DIR/needless_borrow.rs:231:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:232:22 + --> $DIR/needless_borrow.rs:235:22 | LL | let _ = &mut (&mut x.u).x; | ^^^^^^^^^^ help: change this to: `x.u` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:233:22 + --> $DIR/needless_borrow.rs:236:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` -error: aborting due to 26 previous errors +error: aborting due to 27 previous errors diff --git a/tests/ui/needless_return_with_question_mark.fixed b/tests/ui/needless_return_with_question_mark.fixed index 0147c73a94b24..9b7da85266316 100644 --- a/tests/ui/needless_return_with_question_mark.fixed +++ b/tests/ui/needless_return_with_question_mark.fixed @@ -77,3 +77,53 @@ fn issue11616() -> Result<(), ()> { }; Ok(()) } + +fn issue11982() { + mod bar { + pub struct Error; + pub fn foo(_: bool) -> Result<(), Error> { + Ok(()) + } + } + + pub struct Error; + + impl From for Error { + fn from(_: bar::Error) -> Self { + Error + } + } + + fn foo(ok: bool) -> Result<(), Error> { + if !ok { + return bar::foo(ok).map(|_| Ok::<(), Error>(()))?; + }; + Ok(()) + } +} + +fn issue11982_no_conversion() { + mod bar { + pub struct Error; + pub fn foo(_: bool) -> Result<(), Error> { + Ok(()) + } + } + + fn foo(ok: bool) -> Result<(), bar::Error> { + if !ok { + return bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?; + }; + Ok(()) + } +} + +fn general_return() { + fn foo(ok: bool) -> Result<(), ()> { + let bar = Result::Ok(Result::<(), ()>::Ok(())); + if !ok { + return bar?; + }; + Ok(()) + } +} diff --git a/tests/ui/needless_return_with_question_mark.rs b/tests/ui/needless_return_with_question_mark.rs index 66e1f438f8ce0..68e76d2b6402e 100644 --- a/tests/ui/needless_return_with_question_mark.rs +++ b/tests/ui/needless_return_with_question_mark.rs @@ -77,3 +77,53 @@ fn issue11616() -> Result<(), ()> { }; Ok(()) } + +fn issue11982() { + mod bar { + pub struct Error; + pub fn foo(_: bool) -> Result<(), Error> { + Ok(()) + } + } + + pub struct Error; + + impl From for Error { + fn from(_: bar::Error) -> Self { + Error + } + } + + fn foo(ok: bool) -> Result<(), Error> { + if !ok { + return bar::foo(ok).map(|_| Ok::<(), Error>(()))?; + }; + Ok(()) + } +} + +fn issue11982_no_conversion() { + mod bar { + pub struct Error; + pub fn foo(_: bool) -> Result<(), Error> { + Ok(()) + } + } + + fn foo(ok: bool) -> Result<(), bar::Error> { + if !ok { + return bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?; + }; + Ok(()) + } +} + +fn general_return() { + fn foo(ok: bool) -> Result<(), ()> { + let bar = Result::Ok(Result::<(), ()>::Ok(())); + if !ok { + return bar?; + }; + Ok(()) + } +} diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index c67a6d4494e05..92f173d9db4a3 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -1,4 +1,4 @@ -#![feature(inline_const)] +#![feature(inline_const, try_blocks)] #![allow( clippy::eq_op, clippy::single_match, @@ -400,6 +400,15 @@ pub fn test32() { } } +pub fn issue12205() -> Option<()> { + loop { + let _: Option<_> = try { + None?; + return Some(()); + }; + } +} + fn main() { test1(); test2(); diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs index 4d48ef14d31ce..f7c3df7066f7d 100644 --- a/tests/ui/nonminimal_bool.rs +++ b/tests/ui/nonminimal_bool.rs @@ -145,3 +145,14 @@ fn issue10836() { // Should not lint let _: bool = !!Foo(true); } + +fn issue11932() { + let x: i32 = unimplemented!(); + + #[allow(clippy::nonminimal_bool)] + let _ = x % 2 == 0 || { + // Should not lint + assert!(x > 0); + x % 3 == 0 + }; +} diff --git a/tests/ui/redundant_closure_call_fixable.fixed b/tests/ui/redundant_closure_call_fixable.fixed index f272d8359a388..ce5c7f2600be7 100644 --- a/tests/ui/redundant_closure_call_fixable.fixed +++ b/tests/ui/redundant_closure_call_fixable.fixed @@ -102,3 +102,12 @@ mod issue11707 { fn avoid_double_parens() { std::convert::identity(13_i32 + 36_i32).leading_zeros(); } + +fn fp_11274() { + macro_rules! m { + ($closure:expr) => { + $closure(1) + }; + } + m!(|x| println!("{x}")); +} diff --git a/tests/ui/redundant_closure_call_fixable.rs b/tests/ui/redundant_closure_call_fixable.rs index f45db8c9cff5d..ac09390e6eaeb 100644 --- a/tests/ui/redundant_closure_call_fixable.rs +++ b/tests/ui/redundant_closure_call_fixable.rs @@ -102,3 +102,12 @@ mod issue11707 { fn avoid_double_parens() { std::convert::identity((|| 13_i32 + 36_i32)()).leading_zeros(); } + +fn fp_11274() { + macro_rules! m { + ($closure:expr) => { + $closure(1) + }; + } + m!(|x| println!("{x}")); +} diff --git a/tests/ui/redundant_locals.rs b/tests/ui/redundant_locals.rs index 182d067a5e9fa..f6909828aa9a7 100644 --- a/tests/ui/redundant_locals.rs +++ b/tests/ui/redundant_locals.rs @@ -1,6 +1,7 @@ //@aux-build:proc_macros.rs #![allow(unused, clippy::no_effect, clippy::needless_pass_by_ref_mut)] #![warn(clippy::redundant_locals)] +#![feature(async_closure, coroutines)] extern crate proc_macros; use proc_macros::{external, with_span}; @@ -163,3 +164,48 @@ fn drop_compose() { let b = ComposeDrop { d: WithDrop(1) }; let a = a; } + +fn issue12225() { + fn assert_static(_: T) {} + + let v1 = String::new(); + let v2 = String::new(); + let v3 = String::new(); + let v4 = String::new(); + let v5 = String::new(); + let v6 = String::new(); + + assert_static(|| { + let v1 = v1; + dbg!(&v1); + }); + assert_static(async { + let v2 = v2; + dbg!(&v2); + }); + assert_static(|| async { + let v3 = v3; + dbg!(&v3); + }); + assert_static(async || { + let v4 = v4; + dbg!(&v4); + }); + assert_static(static || { + let v5 = v5; + yield; + }); + assert_static(|| { + let v6 = v6; + yield; + }); + + fn foo(a: &str, b: &str) {} + + let do_not_move = String::new(); + let things_to_move = vec!["a".to_string(), "b".to_string()]; + let futures = things_to_move.into_iter().map(|move_me| async { + let move_me = move_me; + foo(&do_not_move, &move_me) + }); +} diff --git a/tests/ui/redundant_locals.stderr b/tests/ui/redundant_locals.stderr index 30ab4aa2ea915..610d587ddadce 100644 --- a/tests/ui/redundant_locals.stderr +++ b/tests/ui/redundant_locals.stderr @@ -1,11 +1,11 @@ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:12:5 + --> $DIR/redundant_locals.rs:13:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:11:9 + --> $DIR/redundant_locals.rs:12:9 | LL | let x = 1; | ^ @@ -13,157 +13,157 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::redundant_locals)]` error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:17:5 + --> $DIR/redundant_locals.rs:18:5 | LL | let mut x = x; | ^^^^^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:16:9 + --> $DIR/redundant_locals.rs:17:9 | LL | let mut x = 1; | ^^^^^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:47:5 + --> $DIR/redundant_locals.rs:48:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:46:14 + --> $DIR/redundant_locals.rs:47:14 | LL | fn parameter(x: i32) { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:52:5 + --> $DIR/redundant_locals.rs:53:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:51:9 + --> $DIR/redundant_locals.rs:52:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:53:5 + --> $DIR/redundant_locals.rs:54:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:52:9 + --> $DIR/redundant_locals.rs:53:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:54:5 + --> $DIR/redundant_locals.rs:55:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:53:9 + --> $DIR/redundant_locals.rs:54:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:55:5 + --> $DIR/redundant_locals.rs:56:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:54:9 + --> $DIR/redundant_locals.rs:55:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:61:5 + --> $DIR/redundant_locals.rs:62:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:59:9 + --> $DIR/redundant_locals.rs:60:9 | LL | let a = 1; | ^ error: redundant redefinition of a binding `b` - --> $DIR/redundant_locals.rs:62:5 + --> $DIR/redundant_locals.rs:63:5 | LL | let b = b; | ^^^^^^^^^^ | help: `b` is initially defined here - --> $DIR/redundant_locals.rs:60:9 + --> $DIR/redundant_locals.rs:61:9 | LL | let b = 2; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:68:9 + --> $DIR/redundant_locals.rs:69:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:67:13 + --> $DIR/redundant_locals.rs:68:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:75:9 + --> $DIR/redundant_locals.rs:76:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:74:13 + --> $DIR/redundant_locals.rs:75:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:78:9 + --> $DIR/redundant_locals.rs:79:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:77:6 + --> $DIR/redundant_locals.rs:78:6 | LL | |x: i32| { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:97:9 + --> $DIR/redundant_locals.rs:98:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:94:9 + --> $DIR/redundant_locals.rs:95:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:152:5 + --> $DIR/redundant_locals.rs:153:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:150:9 + --> $DIR/redundant_locals.rs:151:9 | LL | let a = WithoutDrop(1); | ^ diff --git a/tests/ui/redundant_type_annotations.rs b/tests/ui/redundant_type_annotations.rs index acf53fea2bb2c..dc9b073ffba85 100644 --- a/tests/ui/redundant_type_annotations.rs +++ b/tests/ui/redundant_type_annotations.rs @@ -196,13 +196,18 @@ fn test_simple_types() { let _var: &str = "test"; //~^ ERROR: redundant type annotation - let _var: &[u8] = b"test"; + let _var: &[u8; 4] = b"test"; //~^ ERROR: redundant type annotation let _var: bool = false; //~^ ERROR: redundant type annotation } +fn issue12212() { + // This should not be linted + let _var: &[u8] = b"test"; +} + fn issue11190() {} fn main() {} diff --git a/tests/ui/redundant_type_annotations.stderr b/tests/ui/redundant_type_annotations.stderr index d1f26f1832e39..48df465ad4971 100644 --- a/tests/ui/redundant_type_annotations.stderr +++ b/tests/ui/redundant_type_annotations.stderr @@ -94,8 +94,8 @@ LL | let _var: &str = "test"; error: redundant type annotation --> $DIR/redundant_type_annotations.rs:199:5 | -LL | let _var: &[u8] = b"test"; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _var: &[u8; 4] = b"test"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation --> $DIR/redundant_type_annotations.rs:202:5 diff --git a/tests/ui/ref_as_ptr.fixed b/tests/ui/ref_as_ptr.fixed new file mode 100644 index 0000000000000..7a946393f259b --- /dev/null +++ b/tests/ui/ref_as_ptr.fixed @@ -0,0 +1,110 @@ +#![warn(clippy::ref_as_ptr)] +#![allow(clippy::unnecessary_mut_passed)] + +fn main() { + let _ = std::ptr::from_ref(&1u8); + let _ = std::ptr::from_ref::(&2u32); + let _ = std::ptr::from_ref::(&3.0f64); + + let _ = std::ptr::from_ref(&4) as *const f32; + let _ = std::ptr::from_ref::(&5.0f32) as *const u32; + + let _ = std::ptr::from_ref(&mut 6u8); + let _ = std::ptr::from_ref::(&mut 7u32); + let _ = std::ptr::from_ref::(&mut 8.0f64); + + let _ = std::ptr::from_ref(&mut 9) as *const f32; + let _ = std::ptr::from_ref::(&mut 10.0f32) as *const u32; + + let _ = std::ptr::from_mut(&mut 11u8); + let _ = std::ptr::from_mut::(&mut 12u32); + let _ = std::ptr::from_mut::(&mut 13.0f64); + + let _ = std::ptr::from_mut(&mut 14) as *const f32; + let _ = std::ptr::from_mut::(&mut 15.0f32) as *const u32; + + let _ = std::ptr::from_ref(&1u8); + let _ = std::ptr::from_ref::(&2u32); + let _ = std::ptr::from_ref::(&3.0f64); + + let _ = std::ptr::from_ref(&4) as *const f32; + let _ = std::ptr::from_ref::(&5.0f32) as *const u32; + + let val = 1; + let _ = std::ptr::from_ref(&val); + let _ = std::ptr::from_ref::(&val); + + let _ = std::ptr::from_ref(&val) as *const f32; + let _ = std::ptr::from_ref::(&val) as *const f64; + + let mut val: u8 = 2; + let _ = std::ptr::from_mut::(&mut val); + let _ = std::ptr::from_mut(&mut val); + + let _ = std::ptr::from_ref::(&mut val); + let _ = std::ptr::from_ref(&mut val); + + let _ = std::ptr::from_ref::(&mut val) as *const f64; + let _: *const Option = std::ptr::from_ref(&mut val) as *const _; + + let _ = std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i)); + let _ = std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i)); + let _ = std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i)); +} + +#[clippy::msrv = "1.75"] +fn _msrv_1_75() { + let val = &42_i32; + let mut_val = &mut 42_i32; + + // `std::ptr::from_{ref, mut}` was stabilized in 1.76. Do not lint this + let _ = val as *const i32; + let _ = mut_val as *mut i32; +} + +#[clippy::msrv = "1.76"] +fn _msrv_1_76() { + let val = &42_i32; + let mut_val = &mut 42_i32; + + let _ = std::ptr::from_ref::(val); + let _ = std::ptr::from_mut::(mut_val); +} + +fn foo(val: &[u8]) { + let _ = std::ptr::from_ref(val); + let _ = std::ptr::from_ref::<[u8]>(val); +} + +fn bar(val: &mut str) { + let _ = std::ptr::from_mut(val); + let _ = std::ptr::from_mut::(val); +} + +struct X<'a>(&'a i32); + +impl<'a> X<'a> { + fn foo(&self) -> *const i64 { + std::ptr::from_ref(self.0) as *const _ + } + + fn bar(&mut self) -> *const i64 { + std::ptr::from_ref(self.0) as *const _ + } +} + +struct Y<'a>(&'a mut i32); + +impl<'a> Y<'a> { + fn foo(&self) -> *const i64 { + std::ptr::from_ref(self.0) as *const _ + } + + fn bar(&mut self) -> *const i64 { + std::ptr::from_ref(self.0) as *const _ + } + + fn baz(&mut self) -> *const i64 { + std::ptr::from_mut(self.0) as *mut _ + } +} diff --git a/tests/ui/ref_as_ptr.rs b/tests/ui/ref_as_ptr.rs new file mode 100644 index 0000000000000..6f745505b4695 --- /dev/null +++ b/tests/ui/ref_as_ptr.rs @@ -0,0 +1,110 @@ +#![warn(clippy::ref_as_ptr)] +#![allow(clippy::unnecessary_mut_passed)] + +fn main() { + let _ = &1u8 as *const _; + let _ = &2u32 as *const u32; + let _ = &3.0f64 as *const f64; + + let _ = &4 as *const _ as *const f32; + let _ = &5.0f32 as *const f32 as *const u32; + + let _ = &mut 6u8 as *const _; + let _ = &mut 7u32 as *const u32; + let _ = &mut 8.0f64 as *const f64; + + let _ = &mut 9 as *const _ as *const f32; + let _ = &mut 10.0f32 as *const f32 as *const u32; + + let _ = &mut 11u8 as *mut _; + let _ = &mut 12u32 as *mut u32; + let _ = &mut 13.0f64 as *mut f64; + + let _ = &mut 14 as *mut _ as *const f32; + let _ = &mut 15.0f32 as *mut f32 as *const u32; + + let _ = &1u8 as *const _; + let _ = &2u32 as *const u32; + let _ = &3.0f64 as *const f64; + + let _ = &4 as *const _ as *const f32; + let _ = &5.0f32 as *const f32 as *const u32; + + let val = 1; + let _ = &val as *const _; + let _ = &val as *const i32; + + let _ = &val as *const _ as *const f32; + let _ = &val as *const i32 as *const f64; + + let mut val: u8 = 2; + let _ = &mut val as *mut u8; + let _ = &mut val as *mut _; + + let _ = &mut val as *const u8; + let _ = &mut val as *const _; + + let _ = &mut val as *const u8 as *const f64; + let _: *const Option = &mut val as *const _ as *const _; + + let _ = &std::array::from_fn(|i| i * i) as *const [usize; 7]; + let _ = &mut std::array::from_fn(|i| i * i) as *const [usize; 8]; + let _ = &mut std::array::from_fn(|i| i * i) as *mut [usize; 9]; +} + +#[clippy::msrv = "1.75"] +fn _msrv_1_75() { + let val = &42_i32; + let mut_val = &mut 42_i32; + + // `std::ptr::from_{ref, mut}` was stabilized in 1.76. Do not lint this + let _ = val as *const i32; + let _ = mut_val as *mut i32; +} + +#[clippy::msrv = "1.76"] +fn _msrv_1_76() { + let val = &42_i32; + let mut_val = &mut 42_i32; + + let _ = val as *const i32; + let _ = mut_val as *mut i32; +} + +fn foo(val: &[u8]) { + let _ = val as *const _; + let _ = val as *const [u8]; +} + +fn bar(val: &mut str) { + let _ = val as *mut _; + let _ = val as *mut str; +} + +struct X<'a>(&'a i32); + +impl<'a> X<'a> { + fn foo(&self) -> *const i64 { + self.0 as *const _ as *const _ + } + + fn bar(&mut self) -> *const i64 { + self.0 as *const _ as *const _ + } +} + +struct Y<'a>(&'a mut i32); + +impl<'a> Y<'a> { + fn foo(&self) -> *const i64 { + self.0 as *const _ as *const _ + } + + fn bar(&mut self) -> *const i64 { + self.0 as *const _ as *const _ + } + + fn baz(&mut self) -> *const i64 { + self.0 as *mut _ as *mut _ + } +} diff --git a/tests/ui/ref_as_ptr.stderr b/tests/ui/ref_as_ptr.stderr new file mode 100644 index 0000000000000..371d42df528b9 --- /dev/null +++ b/tests/ui/ref_as_ptr.stderr @@ -0,0 +1,269 @@ +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:5:13 + | +LL | let _ = &1u8 as *const _; + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` + | + = note: `-D clippy::ref-as-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ref_as_ptr)]` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:6:13 + | +LL | let _ = &2u32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:7:13 + | +LL | let _ = &3.0f64 as *const f64; + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:9:13 + | +LL | let _ = &4 as *const _ as *const f32; + | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:10:13 + | +LL | let _ = &5.0f32 as *const f32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:12:13 + | +LL | let _ = &mut 6u8 as *const _; + | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 6u8)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:13:13 + | +LL | let _ = &mut 7u32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 7u32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:14:13 + | +LL | let _ = &mut 8.0f64 as *const f64; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 8.0f64)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:16:13 + | +LL | let _ = &mut 9 as *const _ as *const f32; + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 9)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:17:13 + | +LL | let _ = &mut 10.0f32 as *const f32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 10.0f32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:19:13 + | +LL | let _ = &mut 11u8 as *mut _; + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 11u8)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:20:13 + | +LL | let _ = &mut 12u32 as *mut u32; + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 12u32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:21:13 + | +LL | let _ = &mut 13.0f64 as *mut f64; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 13.0f64)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:23:13 + | +LL | let _ = &mut 14 as *mut _ as *const f32; + | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 14)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:24:13 + | +LL | let _ = &mut 15.0f32 as *mut f32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 15.0f32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:26:13 + | +LL | let _ = &1u8 as *const _; + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:27:13 + | +LL | let _ = &2u32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:28:13 + | +LL | let _ = &3.0f64 as *const f64; + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:30:13 + | +LL | let _ = &4 as *const _ as *const f32; + | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:31:13 + | +LL | let _ = &5.0f32 as *const f32 as *const u32; + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:34:13 + | +LL | let _ = &val as *const _; + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:35:13 + | +LL | let _ = &val as *const i32; + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:37:13 + | +LL | let _ = &val as *const _ as *const f32; + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:38:13 + | +LL | let _ = &val as *const i32 as *const f64; + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:41:13 + | +LL | let _ = &mut val as *mut u8; + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:42:13 + | +LL | let _ = &mut val as *mut _; + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:44:13 + | +LL | let _ = &mut val as *const u8; + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:45:13 + | +LL | let _ = &mut val as *const _; + | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:47:13 + | +LL | let _ = &mut val as *const u8 as *const f64; + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:48:32 + | +LL | let _: *const Option = &mut val as *const _ as *const _; + | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:50:13 + | +LL | let _ = &std::array::from_fn(|i| i * i) as *const [usize; 7]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i))` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:51:13 + | +LL | let _ = &mut std::array::from_fn(|i| i * i) as *const [usize; 8]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i))` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:52:13 + | +LL | let _ = &mut std::array::from_fn(|i| i * i) as *mut [usize; 9]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:70:13 + | +LL | let _ = val as *const i32; + | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:71:13 + | +LL | let _ = mut_val as *mut i32; + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(mut_val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:75:13 + | +LL | let _ = val as *const _; + | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:76:13 + | +LL | let _ = val as *const [u8]; + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[u8]>(val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:80:13 + | +LL | let _ = val as *mut _; + | ^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:81:13 + | +LL | let _ = val as *mut str; + | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(val)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:88:9 + | +LL | self.0 as *const _ as *const _ + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:92:9 + | +LL | self.0 as *const _ as *const _ + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:100:9 + | +LL | self.0 as *const _ as *const _ + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:104:9 + | +LL | self.0 as *const _ as *const _ + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` + +error: reference as raw pointer + --> $DIR/ref_as_ptr.rs:108:9 + | +LL | self.0 as *mut _ as *mut _ + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(self.0)` + +error: aborting due to 44 previous errors + diff --git a/tests/ui/strlen_on_c_strings.fixed b/tests/ui/strlen_on_c_strings.fixed index 8304e2afd8b6b..1e7d04ffb9df9 100644 --- a/tests/ui/strlen_on_c_strings.fixed +++ b/tests/ui/strlen_on_c_strings.fixed @@ -1,5 +1,5 @@ #![warn(clippy::strlen_on_c_strings)] -#![allow(dead_code)] +#![allow(dead_code, clippy::manual_c_str_literals)] #![feature(rustc_private)] extern crate libc; diff --git a/tests/ui/strlen_on_c_strings.rs b/tests/ui/strlen_on_c_strings.rs index deba40a9ea5e6..c3ad03591d4ec 100644 --- a/tests/ui/strlen_on_c_strings.rs +++ b/tests/ui/strlen_on_c_strings.rs @@ -1,5 +1,5 @@ #![warn(clippy::strlen_on_c_strings)] -#![allow(dead_code)] +#![allow(dead_code, clippy::manual_c_str_literals)] #![feature(rustc_private)] extern crate libc; diff --git a/tests/ui/to_string_trait_impl.rs b/tests/ui/to_string_trait_impl.rs new file mode 100644 index 0000000000000..b0731632d4504 --- /dev/null +++ b/tests/ui/to_string_trait_impl.rs @@ -0,0 +1,31 @@ +#![warn(clippy::to_string_trait_impl)] + +use std::fmt::{self, Display}; + +struct Point { + x: usize, + y: usize, +} + +impl ToString for Point { + fn to_string(&self) -> String { + format!("({}, {})", self.x, self.y) + } +} + +struct Foo; + +impl Display for Foo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Foo") + } +} + +struct Bar; + +impl Bar { + #[allow(clippy::inherent_to_string)] + fn to_string(&self) -> String { + String::from("Bar") + } +} diff --git a/tests/ui/to_string_trait_impl.stderr b/tests/ui/to_string_trait_impl.stderr new file mode 100644 index 0000000000000..55fa9f12c0e65 --- /dev/null +++ b/tests/ui/to_string_trait_impl.stderr @@ -0,0 +1,16 @@ +error: direct implementation of `ToString` + --> $DIR/to_string_trait_impl.rs:10:1 + | +LL | / impl ToString for Point { +LL | | fn to_string(&self) -> String { +LL | | format!("({}, {})", self.x, self.y) +LL | | } +LL | | } + | |_^ + | + = help: prefer implementing `Display` instead + = note: `-D clippy::to-string-trait-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::to_string_trait_impl)]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/unconditional_recursion.rs b/tests/ui/unconditional_recursion.rs index 7b898a6e0e784..6ad3bde51cde0 100644 --- a/tests/ui/unconditional_recursion.rs +++ b/tests/ui/unconditional_recursion.rs @@ -206,6 +206,7 @@ impl PartialEq for S8 { struct S9; +#[allow(clippy::to_string_trait_impl)] impl std::string::ToString for S9 { fn to_string(&self) -> String { //~^ ERROR: function cannot return without recursing @@ -215,6 +216,7 @@ impl std::string::ToString for S9 { struct S10; +#[allow(clippy::to_string_trait_impl)] impl std::string::ToString for S10 { fn to_string(&self) -> String { //~^ ERROR: function cannot return without recursing @@ -225,6 +227,7 @@ impl std::string::ToString for S10 { struct S11; +#[allow(clippy::to_string_trait_impl)] impl std::string::ToString for S11 { fn to_string(&self) -> String { //~^ ERROR: function cannot return without recursing @@ -288,4 +291,63 @@ impl PartialEq for S15<'_> { } } +mod issue12154 { + struct MyBox(T); + + impl std::ops::Deref for MyBox { + type Target = T; + fn deref(&self) -> &T { + &self.0 + } + } + + impl PartialEq for MyBox { + fn eq(&self, other: &Self) -> bool { + (**self).eq(&**other) + } + } + + // Not necessarily related to the issue but another FP from the http crate that was fixed with it: + // https://docs.rs/http/latest/src/http/header/name.rs.html#1424 + // We used to simply peel refs from the LHS and RHS, so we couldn't differentiate + // between `PartialEq for &T` and `PartialEq<&T> for T` impls. + #[derive(PartialEq)] + struct HeaderName; + impl<'a> PartialEq<&'a HeaderName> for HeaderName { + fn eq(&self, other: &&'a HeaderName) -> bool { + *self == **other + } + } + + impl<'a> PartialEq for &'a HeaderName { + fn eq(&self, other: &HeaderName) -> bool { + *other == *self + } + } + + // Issue #12181 but also fixed by the same PR + struct Foo; + + impl Foo { + fn as_str(&self) -> &str { + "Foo" + } + } + + impl PartialEq for Foo { + fn eq(&self, other: &Self) -> bool { + self.as_str().eq(other.as_str()) + } + } + + impl PartialEq for Foo + where + for<'a> &'a str: PartialEq, + { + fn eq(&self, other: &T) -> bool { + (&self.as_str()).eq(other) + } + } +} + fn main() {} diff --git a/tests/ui/unconditional_recursion.stderr b/tests/ui/unconditional_recursion.stderr index 094b80d4586c8..93a5eac91d8e3 100644 --- a/tests/ui/unconditional_recursion.stderr +++ b/tests/ui/unconditional_recursion.stderr @@ -23,7 +23,7 @@ LL | self.eq(other) = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:210:5 + --> $DIR/unconditional_recursion.rs:211:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -34,7 +34,7 @@ LL | self.to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:219:5 + --> $DIR/unconditional_recursion.rs:221:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -45,7 +45,7 @@ LL | x.to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:229:5 + --> $DIR/unconditional_recursion.rs:232:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -326,7 +326,7 @@ LL | mine == theirs | ^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:244:5 + --> $DIR/unconditional_recursion.rs:247:5 | LL | / fn new() -> Self { LL | | @@ -335,13 +335,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:246:9 + --> $DIR/unconditional_recursion.rs:249:9 | LL | Self::default() | ^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:283:5 + --> $DIR/unconditional_recursion.rs:286:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -352,7 +352,7 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:287:9 + --> $DIR/unconditional_recursion.rs:290:9 | LL | mine.eq(theirs) | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_fold.fixed b/tests/ui/unnecessary_fold.fixed index c884d26eb6176..c5bc11b55ab5c 100644 --- a/tests/ui/unnecessary_fold.fixed +++ b/tests/ui/unnecessary_fold.fixed @@ -1,9 +1,15 @@ #![allow(dead_code)] +fn is_any(acc: bool, x: usize) -> bool { + acc || x > 2 +} + /// Calls which should trigger the `UNNECESSARY_FOLD` lint fn unnecessary_fold() { // Can be replaced by .any let _ = (0..3).any(|x| x > 2); + // Can be replaced by .any (checking suggestion) + let _ = (0..3).fold(false, is_any); // Can be replaced by .all let _ = (0..3).all(|x| x > 2); // Can be replaced by .sum diff --git a/tests/ui/unnecessary_fold.rs b/tests/ui/unnecessary_fold.rs index 2e6d6ba52eb91..3a5136eeeaeb7 100644 --- a/tests/ui/unnecessary_fold.rs +++ b/tests/ui/unnecessary_fold.rs @@ -1,9 +1,15 @@ #![allow(dead_code)] +fn is_any(acc: bool, x: usize) -> bool { + acc || x > 2 +} + /// Calls which should trigger the `UNNECESSARY_FOLD` lint fn unnecessary_fold() { // Can be replaced by .any let _ = (0..3).fold(false, |acc, x| acc || x > 2); + // Can be replaced by .any (checking suggestion) + let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); // Can be replaced by .all let _ = (0..3).fold(true, |acc, x| acc && x > 2); // Can be replaced by .sum diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index f0d0396384214..123d4a3be7557 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,5 +1,5 @@ error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:6:20 + --> $DIR/unnecessary_fold.rs:10:20 | LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` @@ -7,89 +7,98 @@ LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); = note: `-D clippy::unnecessary-fold` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fold)]` +error: redundant closure + --> $DIR/unnecessary_fold.rs:12:32 + | +LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `is_any` + | + = note: `-D clippy::redundant-closure` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` + error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:8:20 + --> $DIR/unnecessary_fold.rs:14:20 | LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:10:25 + --> $DIR/unnecessary_fold.rs:16:25 | LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:12:25 + --> $DIR/unnecessary_fold.rs:18:25 | LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:17:41 + --> $DIR/unnecessary_fold.rs:23:41 | LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:47:10 + --> $DIR/unnecessary_fold.rs:53:10 | LL | .fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:58:33 + --> $DIR/unnecessary_fold.rs:64:33 | LL | assert_eq!(map.values().fold(0, |x, y| x + y), 0); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:61:30 + --> $DIR/unnecessary_fold.rs:67:30 | LL | let _ = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:62:30 + --> $DIR/unnecessary_fold.rs:68:30 | LL | let _ = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:63:35 + --> $DIR/unnecessary_fold.rs:69:35 | LL | let _: i32 = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:64:35 + --> $DIR/unnecessary_fold.rs:70:35 | LL | let _: i32 = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:65:31 + --> $DIR/unnecessary_fold.rs:71:31 | LL | anything(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:66:31 + --> $DIR/unnecessary_fold.rs:72:31 | LL | anything(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:67:26 + --> $DIR/unnecessary_fold.rs:73:26 | LL | num(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:68:26 + --> $DIR/unnecessary_fold.rs:74:26 | LL | num(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` -error: aborting due to 15 previous errors +error: aborting due to 16 previous errors diff --git a/tests/ui/unnecessary_operation.fixed b/tests/ui/unnecessary_operation.fixed index 463412daec08d..11761c6c90e36 100644 --- a/tests/ui/unnecessary_operation.fixed +++ b/tests/ui/unnecessary_operation.fixed @@ -106,4 +106,11 @@ fn main() { // Issue #11885 Cout << 16; + + // Issue #11575 + // Bad formatting is required to trigger the bug + #[rustfmt::skip] + 'label: { + break 'label + }; } diff --git a/tests/ui/unnecessary_operation.rs b/tests/ui/unnecessary_operation.rs index f0d28e2890291..de0081289ac3d 100644 --- a/tests/ui/unnecessary_operation.rs +++ b/tests/ui/unnecessary_operation.rs @@ -110,4 +110,11 @@ fn main() { // Issue #11885 Cout << 16; + + // Issue #11575 + // Bad formatting is required to trigger the bug + #[rustfmt::skip] + 'label: { + break 'label + }; } diff --git a/tests/ui/unnecessary_result_map_or_else.fixed b/tests/ui/unnecessary_result_map_or_else.fixed new file mode 100644 index 0000000000000..224e0b52d75df --- /dev/null +++ b/tests/ui/unnecessary_result_map_or_else.fixed @@ -0,0 +1,61 @@ +#![warn(clippy::unnecessary_result_map_or_else)] +#![allow(clippy::unnecessary_literal_unwrap, clippy::let_and_return, clippy::let_unit_value)] + +fn main() { + let x: Result<(), ()> = Ok(()); + x.unwrap_or_else(|err| err); //~ ERROR: unused "map closure" when calling + + // Type ascribtion. + let x: Result<(), ()> = Ok(()); + x.unwrap_or_else(|err: ()| err); //~ ERROR: unused "map closure" when calling + + // Auto-deref. + let y = String::new(); + let x: Result<&String, &String> = Ok(&y); + let y: &str = x.unwrap_or_else(|err| err); //~ ERROR: unused "map closure" when calling + + // Temporary variable. + let x: Result<(), ()> = Ok(()); + x.unwrap_or_else(|err| err); + + // Should not warn. + let x: Result = Ok(0); + x.map_or_else(|err| err, |n| n + 1); + + // Should not warn. + let y = (); + let x: Result<(), ()> = Ok(()); + x.map_or_else(|err| err, |_| y); + + // Should not warn. + let y = (); + let x: Result<(), ()> = Ok(()); + x.map_or_else( + |err| err, + |_| { + let tmp = y; + tmp + }, + ); + + // Should not warn. + let x: Result = Ok(1); + x.map_or_else( + |err| err, + |n| { + let tmp = n + 1; + tmp + }, + ); + + // Should not warn. + let y = 0; + let x: Result = Ok(1); + x.map_or_else( + |err| err, + |n| { + let tmp = n; + y + }, + ); +} diff --git a/tests/ui/unnecessary_result_map_or_else.rs b/tests/ui/unnecessary_result_map_or_else.rs new file mode 100644 index 0000000000000..4fe950a4cfa6b --- /dev/null +++ b/tests/ui/unnecessary_result_map_or_else.rs @@ -0,0 +1,69 @@ +#![warn(clippy::unnecessary_result_map_or_else)] +#![allow(clippy::unnecessary_literal_unwrap, clippy::let_and_return, clippy::let_unit_value)] + +fn main() { + let x: Result<(), ()> = Ok(()); + x.map_or_else(|err| err, |n| n); //~ ERROR: unused "map closure" when calling + + // Type ascribtion. + let x: Result<(), ()> = Ok(()); + x.map_or_else(|err: ()| err, |n: ()| n); //~ ERROR: unused "map closure" when calling + + // Auto-deref. + let y = String::new(); + let x: Result<&String, &String> = Ok(&y); + let y: &str = x.map_or_else(|err| err, |n| n); //~ ERROR: unused "map closure" when calling + + // Temporary variable. + let x: Result<(), ()> = Ok(()); + x.map_or_else( + //~^ ERROR: unused "map closure" when calling + |err| err, + |n| { + let tmp = n; + let tmp2 = tmp; + tmp2 + }, + ); + + // Should not warn. + let x: Result = Ok(0); + x.map_or_else(|err| err, |n| n + 1); + + // Should not warn. + let y = (); + let x: Result<(), ()> = Ok(()); + x.map_or_else(|err| err, |_| y); + + // Should not warn. + let y = (); + let x: Result<(), ()> = Ok(()); + x.map_or_else( + |err| err, + |_| { + let tmp = y; + tmp + }, + ); + + // Should not warn. + let x: Result = Ok(1); + x.map_or_else( + |err| err, + |n| { + let tmp = n + 1; + tmp + }, + ); + + // Should not warn. + let y = 0; + let x: Result = Ok(1); + x.map_or_else( + |err| err, + |n| { + let tmp = n; + y + }, + ); +} diff --git a/tests/ui/unnecessary_result_map_or_else.stderr b/tests/ui/unnecessary_result_map_or_else.stderr new file mode 100644 index 0000000000000..0f83be5d55661 --- /dev/null +++ b/tests/ui/unnecessary_result_map_or_else.stderr @@ -0,0 +1,35 @@ +error: unused "map closure" when calling `Result::map_or_else` value + --> $DIR/unnecessary_result_map_or_else.rs:6:5 + | +LL | x.map_or_else(|err| err, |n| n); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` + | + = note: `-D clippy::unnecessary-result-map-or-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_result_map_or_else)]` + +error: unused "map closure" when calling `Result::map_or_else` value + --> $DIR/unnecessary_result_map_or_else.rs:10:5 + | +LL | x.map_or_else(|err: ()| err, |n: ()| n); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err: ()| err)` + +error: unused "map closure" when calling `Result::map_or_else` value + --> $DIR/unnecessary_result_map_or_else.rs:15:19 + | +LL | let y: &str = x.map_or_else(|err| err, |n| n); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` + +error: unused "map closure" when calling `Result::map_or_else` value + --> $DIR/unnecessary_result_map_or_else.rs:19:5 + | +LL | / x.map_or_else( +LL | | +LL | | |err| err, +LL | | |n| { +... | +LL | | }, +LL | | ); + | |_____^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` + +error: aborting due to 4 previous errors + diff --git a/tests/ui/unnecessary_to_owned.fixed b/tests/ui/unnecessary_to_owned.fixed index 2dd1d746626f3..7f01c981a9380 100644 --- a/tests/ui/unnecessary_to_owned.fixed +++ b/tests/ui/unnecessary_to_owned.fixed @@ -27,6 +27,7 @@ impl AsRef for X { } } +#[allow(clippy::to_string_trait_impl)] impl ToString for X { fn to_string(&self) -> String { self.0.to_string() @@ -265,6 +266,7 @@ mod issue_8507 { } } + #[allow(clippy::to_string_trait_impl)] impl ToString for Y { fn to_string(&self) -> String { self.0.to_string() @@ -338,6 +340,7 @@ mod issue_9317 { struct Bytes {} + #[allow(clippy::to_string_trait_impl)] impl ToString for Bytes { fn to_string(&self) -> String { "123".to_string() diff --git a/tests/ui/unnecessary_to_owned.rs b/tests/ui/unnecessary_to_owned.rs index 17fad33402b58..a270ed1e1c21e 100644 --- a/tests/ui/unnecessary_to_owned.rs +++ b/tests/ui/unnecessary_to_owned.rs @@ -27,6 +27,7 @@ impl AsRef for X { } } +#[allow(clippy::to_string_trait_impl)] impl ToString for X { fn to_string(&self) -> String { self.0.to_string() @@ -265,6 +266,7 @@ mod issue_8507 { } } + #[allow(clippy::to_string_trait_impl)] impl ToString for Y { fn to_string(&self) -> String { self.0.to_string() @@ -338,6 +340,7 @@ mod issue_9317 { struct Bytes {} + #[allow(clippy::to_string_trait_impl)] impl ToString for Bytes { fn to_string(&self) -> String { "123".to_string() diff --git a/tests/ui/unnecessary_to_owned.stderr b/tests/ui/unnecessary_to_owned.stderr index ad6fa422b8cd2..95ff5f2ec2cff 100644 --- a/tests/ui/unnecessary_to_owned.stderr +++ b/tests/ui/unnecessary_to_owned.stderr @@ -1,11 +1,11 @@ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:154:64 + --> $DIR/unnecessary_to_owned.rs:155:64 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:154:20 + --> $DIR/unnecessary_to_owned.rs:155:20 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,55 +13,55 @@ LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()) = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone - --> $DIR/unnecessary_to_owned.rs:155:40 + --> $DIR/unnecessary_to_owned.rs:156:40 | LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:155:21 + --> $DIR/unnecessary_to_owned.rs:156:21 | LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:156:48 + --> $DIR/unnecessary_to_owned.rs:157:48 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:156:19 + --> $DIR/unnecessary_to_owned.rs:157:19 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:157:35 + --> $DIR/unnecessary_to_owned.rs:158:35 | LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:157:18 + --> $DIR/unnecessary_to_owned.rs:158:18 | LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:158:39 + --> $DIR/unnecessary_to_owned.rs:159:39 | LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:158:20 + --> $DIR/unnecessary_to_owned.rs:159:20 | LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^^^^^^^^^ error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:63:36 + --> $DIR/unnecessary_to_owned.rs:64:36 | LL | require_c_str(&Cow::from(c_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this @@ -70,415 +70,415 @@ LL | require_c_str(&Cow::from(c_str).into_owned()); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:64:19 + --> $DIR/unnecessary_to_owned.rs:65:19 | LL | require_c_str(&c_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_os_string` - --> $DIR/unnecessary_to_owned.rs:66:20 + --> $DIR/unnecessary_to_owned.rs:67:20 | LL | require_os_str(&os_str.to_os_string()); | ^^^^^^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:67:38 + --> $DIR/unnecessary_to_owned.rs:68:38 | LL | require_os_str(&Cow::from(os_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:68:20 + --> $DIR/unnecessary_to_owned.rs:69:20 | LL | require_os_str(&os_str.to_owned()); | ^^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_path_buf` - --> $DIR/unnecessary_to_owned.rs:70:18 + --> $DIR/unnecessary_to_owned.rs:71:18 | LL | require_path(&path.to_path_buf()); | ^^^^^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:71:34 + --> $DIR/unnecessary_to_owned.rs:72:34 | LL | require_path(&Cow::from(path).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:72:18 + --> $DIR/unnecessary_to_owned.rs:73:18 | LL | require_path(&path.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:74:17 + --> $DIR/unnecessary_to_owned.rs:75:17 | LL | require_str(&s.to_string()); | ^^^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:75:30 + --> $DIR/unnecessary_to_owned.rs:76:30 | LL | require_str(&Cow::from(s).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:76:17 + --> $DIR/unnecessary_to_owned.rs:77:17 | LL | require_str(&s.to_owned()); | ^^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:77:17 + --> $DIR/unnecessary_to_owned.rs:78:17 | LL | require_str(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref.as_ref()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:79:19 + --> $DIR/unnecessary_to_owned.rs:80:19 | LL | require_slice(&slice.to_vec()); | ^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:80:36 + --> $DIR/unnecessary_to_owned.rs:81:36 | LL | require_slice(&Cow::from(slice).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:81:19 + --> $DIR/unnecessary_to_owned.rs:82:19 | LL | require_slice(&array.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `array.as_ref()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:82:19 + --> $DIR/unnecessary_to_owned.rs:83:19 | LL | require_slice(&array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref.as_ref()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:83:19 + --> $DIR/unnecessary_to_owned.rs:84:19 | LL | require_slice(&slice.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:86:42 + --> $DIR/unnecessary_to_owned.rs:87:42 | LL | require_x(&Cow::::Owned(x.clone()).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:89:25 + --> $DIR/unnecessary_to_owned.rs:90:25 | LL | require_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:90:26 + --> $DIR/unnecessary_to_owned.rs:91:26 | LL | require_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:91:24 + --> $DIR/unnecessary_to_owned.rs:92:24 | LL | require_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:92:23 + --> $DIR/unnecessary_to_owned.rs:93:23 | LL | require_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:93:25 + --> $DIR/unnecessary_to_owned.rs:94:25 | LL | require_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:95:30 + --> $DIR/unnecessary_to_owned.rs:96:30 | LL | require_impl_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:96:31 + --> $DIR/unnecessary_to_owned.rs:97:31 | LL | require_impl_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:97:29 + --> $DIR/unnecessary_to_owned.rs:98:29 | LL | require_impl_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:98:28 + --> $DIR/unnecessary_to_owned.rs:99:28 | LL | require_impl_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:99:30 + --> $DIR/unnecessary_to_owned.rs:100:30 | LL | require_impl_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:101:29 + --> $DIR/unnecessary_to_owned.rs:102:29 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:101:43 + --> $DIR/unnecessary_to_owned.rs:102:43 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:102:29 + --> $DIR/unnecessary_to_owned.rs:103:29 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:102:47 + --> $DIR/unnecessary_to_owned.rs:103:47 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:104:26 + --> $DIR/unnecessary_to_owned.rs:105:26 | LL | require_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:105:27 + --> $DIR/unnecessary_to_owned.rs:106:27 | LL | require_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:106:25 + --> $DIR/unnecessary_to_owned.rs:107:25 | LL | require_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:107:24 + --> $DIR/unnecessary_to_owned.rs:108:24 | LL | require_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:108:24 + --> $DIR/unnecessary_to_owned.rs:109:24 | LL | require_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:109:26 + --> $DIR/unnecessary_to_owned.rs:110:26 | LL | require_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:110:26 + --> $DIR/unnecessary_to_owned.rs:111:26 | LL | require_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:111:26 + --> $DIR/unnecessary_to_owned.rs:112:26 | LL | require_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:113:31 + --> $DIR/unnecessary_to_owned.rs:114:31 | LL | require_impl_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:114:32 + --> $DIR/unnecessary_to_owned.rs:115:32 | LL | require_impl_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:115:30 + --> $DIR/unnecessary_to_owned.rs:116:30 | LL | require_impl_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:116:29 + --> $DIR/unnecessary_to_owned.rs:117:29 | LL | require_impl_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:117:29 + --> $DIR/unnecessary_to_owned.rs:118:29 | LL | require_impl_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:118:31 + --> $DIR/unnecessary_to_owned.rs:119:31 | LL | require_impl_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:119:31 + --> $DIR/unnecessary_to_owned.rs:120:31 | LL | require_impl_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:120:31 + --> $DIR/unnecessary_to_owned.rs:121:31 | LL | require_impl_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:122:30 + --> $DIR/unnecessary_to_owned.rs:123:30 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:122:44 + --> $DIR/unnecessary_to_owned.rs:123:44 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:123:30 + --> $DIR/unnecessary_to_owned.rs:124:30 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:123:44 + --> $DIR/unnecessary_to_owned.rs:124:44 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:124:30 + --> $DIR/unnecessary_to_owned.rs:125:30 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:124:44 + --> $DIR/unnecessary_to_owned.rs:125:44 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:125:30 + --> $DIR/unnecessary_to_owned.rs:126:30 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:125:48 + --> $DIR/unnecessary_to_owned.rs:126:48 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:126:30 + --> $DIR/unnecessary_to_owned.rs:127:30 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:126:52 + --> $DIR/unnecessary_to_owned.rs:127:52 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:127:30 + --> $DIR/unnecessary_to_owned.rs:128:30 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:127:48 + --> $DIR/unnecessary_to_owned.rs:128:48 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:129:20 + --> $DIR/unnecessary_to_owned.rs:130:20 | LL | let _ = x.join(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:131:13 + --> $DIR/unnecessary_to_owned.rs:132:13 | LL | let _ = slice.to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:132:13 + --> $DIR/unnecessary_to_owned.rs:133:13 | LL | let _ = slice.to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:133:13 + --> $DIR/unnecessary_to_owned.rs:134:13 | LL | let _ = [std::path::PathBuf::new()][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:134:13 + --> $DIR/unnecessary_to_owned.rs:135:13 | LL | let _ = [std::path::PathBuf::new()][..].to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:136:13 + --> $DIR/unnecessary_to_owned.rs:137:13 | LL | let _ = IntoIterator::into_iter(slice.to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:137:13 + --> $DIR/unnecessary_to_owned.rs:138:13 | LL | let _ = IntoIterator::into_iter(slice.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:138:13 + --> $DIR/unnecessary_to_owned.rs:139:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:139:13 + --> $DIR/unnecessary_to_owned.rs:140:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:201:14 + --> $DIR/unnecessary_to_owned.rs:202:14 | LL | for t in file_types.to_vec() { | ^^^^^^^^^^^^^^^^^^^ @@ -494,31 +494,31 @@ LL + let path = match get_file_path(t) { | error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:224:14 + --> $DIR/unnecessary_to_owned.rs:225:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:229:14 + --> $DIR/unnecessary_to_owned.rs:230:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:276:24 + --> $DIR/unnecessary_to_owned.rs:278:24 | LL | Box::new(build(y.to_string())) | ^^^^^^^^^^^^^ help: use: `y` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:384:12 + --> $DIR/unnecessary_to_owned.rs:387:12 | LL | id("abc".to_string()) | ^^^^^^^^^^^^^^^^^ help: use: `"abc"` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:527:37 + --> $DIR/unnecessary_to_owned.rs:530:37 | LL | IntoFuture::into_future(foo([].to_vec(), &0)); | ^^^^^^^^^^^ help: use: `[]` diff --git a/tests/ui/unnecessary_to_owned_on_split.fixed b/tests/ui/unnecessary_to_owned_on_split.fixed index f87c898f9b79a..e0ba216f41bfc 100644 --- a/tests/ui/unnecessary_to_owned_on_split.fixed +++ b/tests/ui/unnecessary_to_owned_on_split.fixed @@ -8,6 +8,7 @@ impl AsRef for Issue12068 { } } +#[allow(clippy::to_string_trait_impl)] impl ToString for Issue12068 { fn to_string(&self) -> String { String::new() diff --git a/tests/ui/unnecessary_to_owned_on_split.rs b/tests/ui/unnecessary_to_owned_on_split.rs index db5719e588095..70efc6ebba5da 100644 --- a/tests/ui/unnecessary_to_owned_on_split.rs +++ b/tests/ui/unnecessary_to_owned_on_split.rs @@ -8,6 +8,7 @@ impl AsRef for Issue12068 { } } +#[allow(clippy::to_string_trait_impl)] impl ToString for Issue12068 { fn to_string(&self) -> String { String::new() diff --git a/tests/ui/unnecessary_to_owned_on_split.stderr b/tests/ui/unnecessary_to_owned_on_split.stderr index 4cfaeed3384ab..9aea15b48bfbd 100644 --- a/tests/ui/unnecessary_to_owned_on_split.stderr +++ b/tests/ui/unnecessary_to_owned_on_split.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:18:13 + --> $DIR/unnecessary_to_owned_on_split.rs:19:13 | LL | let _ = "a".to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` @@ -8,49 +8,49 @@ LL | let _ = "a".to_string().split('a').next().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:20:13 + --> $DIR/unnecessary_to_owned_on_split.rs:21:13 | LL | let _ = "a".to_string().split("a").next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split("a")` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:22:13 + --> $DIR/unnecessary_to_owned_on_split.rs:23:13 | LL | let _ = "a".to_owned().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:24:13 + --> $DIR/unnecessary_to_owned_on_split.rs:25:13 | LL | let _ = "a".to_owned().split("a").next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split("a")` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:26:13 + --> $DIR/unnecessary_to_owned_on_split.rs:27:13 | LL | let _ = Issue12068.to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Issue12068.as_ref().split('a')` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned_on_split.rs:29:13 + --> $DIR/unnecessary_to_owned_on_split.rs:30:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned_on_split.rs:31:13 + --> $DIR/unnecessary_to_owned_on_split.rs:32:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:33:13 + --> $DIR/unnecessary_to_owned_on_split.rs:34:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:35:13 + --> $DIR/unnecessary_to_owned_on_split.rs:36:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index 9974600dad5be..7e5a10c911bf1 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -229,4 +229,47 @@ fn on_return_should_not_raise(s: &mut T) -> io::Result< s.read(&mut buf) } +pub fn unwrap_in_block(rdr: &mut dyn std::io::Read) -> std::io::Result { + let read = { rdr.read(&mut [0])? }; + Ok(read) +} + +pub fn consumed_example(rdr: &mut dyn std::io::Read) { + match rdr.read(&mut [0]) { + Ok(0) => println!("EOF"), + Ok(_) => println!("fully read"), + Err(_) => println!("fail"), + }; + match rdr.read(&mut [0]) { + Ok(0) => println!("EOF"), + Ok(_) => println!("fully read"), + Err(_) => println!("fail"), + } +} + +pub fn unreachable_or_panic(rdr: &mut dyn std::io::Read) { + { + match rdr.read(&mut [0]) { + Ok(_) => unreachable!(), + Err(_) => println!("expected"), + } + } + + { + match rdr.read(&mut [0]) { + Ok(_) => panic!(), + Err(_) => println!("expected"), + } + } +} + +pub fn wildcards(rdr: &mut dyn std::io::Read) { + { + match rdr.read(&mut [0]) { + Ok(1) => todo!(), + _ => todo!(), + } + } +} + fn main() {} diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 4af56d264bfa1..1aab56966a88c 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -180,7 +180,7 @@ note: the result is consumed here, but the amount of I/O bytes remains unhandled --> $DIR/unused_io_amount.rs:149:9 | LL | Ok(_) => todo!(), - | ^^^^^^^^^^^^^^^^ + | ^^^^^ error: read amount is not handled --> $DIR/unused_io_amount.rs:155:11 @@ -193,7 +193,7 @@ note: the result is consumed here, but the amount of I/O bytes remains unhandled --> $DIR/unused_io_amount.rs:157:9 | LL | Ok(_) => todo!(), - | ^^^^^^^^^^^^^^^^ + | ^^^^^ error: read amount is not handled --> $DIR/unused_io_amount.rs:164:11 @@ -206,7 +206,7 @@ note: the result is consumed here, but the amount of I/O bytes remains unhandled --> $DIR/unused_io_amount.rs:166:9 | LL | Ok(_) => todo!(), - | ^^^^^^^^^^^^^^^^ + | ^^^^^ error: written amount is not handled --> $DIR/unused_io_amount.rs:173:11 @@ -219,7 +219,7 @@ note: the result is consumed here, but the amount of I/O bytes remains unhandled --> $DIR/unused_io_amount.rs:175:9 | LL | Ok(_) => todo!(), - | ^^^^^^^^^^^^^^^^ + | ^^^^^ error: read amount is not handled --> $DIR/unused_io_amount.rs:186:8 diff --git a/tests/ui/while_let_on_iterator.fixed b/tests/ui/while_let_on_iterator.fixed index d628d2227b719..59b5c858d0460 100644 --- a/tests/ui/while_let_on_iterator.fixed +++ b/tests/ui/while_let_on_iterator.fixed @@ -406,7 +406,7 @@ fn issue_8113() { fn fn_once_closure() { let mut it = 0..10; (|| { - for x in it { + for x in it.by_ref() { if x % 2 == 0 { break; } @@ -441,7 +441,19 @@ fn fn_once_closure() { break; } } - }) + }); + + trait MySpecialFnMut: FnOnce() {} + impl MySpecialFnMut for T {} + fn f4(_: impl MySpecialFnMut) {} + let mut it = 0..10; + f4(|| { + for x in it { + if x % 2 == 0 { + break; + } + } + }); } fn main() { diff --git a/tests/ui/while_let_on_iterator.rs b/tests/ui/while_let_on_iterator.rs index 525dbbaaab66f..559513d56946d 100644 --- a/tests/ui/while_let_on_iterator.rs +++ b/tests/ui/while_let_on_iterator.rs @@ -441,7 +441,19 @@ fn fn_once_closure() { break; } } - }) + }); + + trait MySpecialFnMut: FnOnce() {} + impl MySpecialFnMut for T {} + fn f4(_: impl MySpecialFnMut) {} + let mut it = 0..10; + f4(|| { + while let Some(x) = it.next() { + if x % 2 == 0 { + break; + } + } + }); } fn main() { diff --git a/tests/ui/while_let_on_iterator.stderr b/tests/ui/while_let_on_iterator.stderr index cdc83b8166707..7b9a9dc049a28 100644 --- a/tests/ui/while_let_on_iterator.stderr +++ b/tests/ui/while_let_on_iterator.stderr @@ -131,7 +131,7 @@ error: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:409:9 | LL | while let Some(x) = it.next() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:419:9 @@ -152,10 +152,16 @@ LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:449:5 + --> $DIR/while_let_on_iterator.rs:451:9 + | +LL | while let Some(x) = it.next() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` + +error: this loop could be written as a `for` loop + --> $DIR/while_let_on_iterator.rs:461:5 | LL | while let Some(..) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in it` -error: aborting due to 26 previous errors +error: aborting due to 27 previous errors From 0d696023c4ae02da2b86ba5e5adbdb024845e48b Mon Sep 17 00:00:00 2001 From: blyxyas Date: Fri, 9 Feb 2024 09:29:34 +0100 Subject: [PATCH 031/417] (NOT INCLUDE IN RUST-SYNC) Temporary vacation to focus on performance --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index 3eadc66f544f3..a05765b398133 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -19,6 +19,7 @@ new_pr = true [assign] contributing_url = "https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md" +users_on_vacation = ["blyxyas"] [assign.owners] "/.github" = ["@flip1995"] From 4a5e30dca7ce6271f34ca8c88c5733aa6969b5ab Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 9 Feb 2024 22:56:07 -0600 Subject: [PATCH 032/417] Refactor a portion of 'non_expressive_names.rs' for clarity --- clippy_lints/src/non_expressive_names.rs | 128 +++++++++++------------ 1 file changed, 62 insertions(+), 66 deletions(-) diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index ba9230dab7aee..66b0a53fdd747 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -119,7 +119,6 @@ impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> { // this list contains lists of names that are allowed to be similar // the assumption is that no name is ever contained in multiple lists. -#[rustfmt::skip] const ALLOWED_TO_BE_SIMILAR: &[&[&str]] = &[ &["parsed", "parser"], &["lhs", "rhs"], @@ -189,7 +188,6 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { } } - #[expect(clippy::too_many_lines)] fn check_ident(&mut self, ident: Ident) { let interned_name = ident.name.as_str(); if interned_name.chars().any(char::is_uppercase) { @@ -219,71 +217,18 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { if allowed_to_be_similar(interned_name, existing_name.exemptions) { continue; } - match existing_name.len.cmp(&count) { - Ordering::Greater => { - if existing_name.len - count != 1 - || levenstein_not_1(interned_name, existing_name.interned.as_str()) - { - continue; - } - }, - Ordering::Less => { - if count - existing_name.len != 1 - || levenstein_not_1(existing_name.interned.as_str(), interned_name) - { - continue; - } - }, - Ordering::Equal => { - let mut interned_chars = interned_name.chars(); - let interned_str = existing_name.interned.as_str(); - let mut existing_chars = interned_str.chars(); - let first_i = interned_chars.next().expect("we know we have at least one char"); - let first_e = existing_chars.next().expect("we know we have at least one char"); - let eq_or_numeric = |(a, b): (char, char)| a == b || a.is_numeric() && b.is_numeric(); - - if eq_or_numeric((first_i, first_e)) { - let last_i = interned_chars.next_back().expect("we know we have at least two chars"); - let last_e = existing_chars.next_back().expect("we know we have at least two chars"); - if eq_or_numeric((last_i, last_e)) { - if interned_chars - .zip(existing_chars) - .filter(|&ie| !eq_or_numeric(ie)) - .count() - != 1 - { - continue; - } - } else { - let second_last_i = interned_chars - .next_back() - .expect("we know we have at least three chars"); - let second_last_e = existing_chars - .next_back() - .expect("we know we have at least three chars"); - if !eq_or_numeric((second_last_i, second_last_e)) - || second_last_i == '_' - || !interned_chars.zip(existing_chars).all(eq_or_numeric) - { - // allowed similarity foo_x, foo_y - // or too many chars differ (foo_x, boo_y) or (foox, booy) - continue; - } - } - } else { - let second_i = interned_chars.next().expect("we know we have at least two chars"); - let second_e = existing_chars.next().expect("we know we have at least two chars"); - if !eq_or_numeric((second_i, second_e)) - || second_i == '_' - || !interned_chars.zip(existing_chars).all(eq_or_numeric) - { - // allowed similarity x_foo, y_foo - // or too many chars differ (x_foo, y_boo) or (xfoo, yboo) - continue; - } - } - }, + + let existing_str = existing_name.interned.as_str(); + let dissimilar = match existing_name.len.cmp(&count) { + Ordering::Greater => existing_name.len - count != 1 || levenstein_not_1(interned_name, existing_str), + Ordering::Less => count - existing_name.len != 1 || levenstein_not_1(existing_str, interned_name), + Ordering::Equal => Self::equal_length_strs_not_similar(interned_name, existing_str), + }; + + if dissimilar { + continue; } + span_lint_and_then( self.0.cx, SIMILAR_NAMES, @@ -302,6 +247,57 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { len: count, }); } + + fn equal_length_strs_not_similar(interned_name: &str, existing_name: &str) -> bool { + let mut interned_chars = interned_name.chars(); + let mut existing_chars = existing_name.chars(); + let first_i = interned_chars.next().expect("we know we have at least one char"); + let first_e = existing_chars.next().expect("we know we have at least one char"); + let eq_or_numeric = |(a, b): (char, char)| a == b || a.is_numeric() && b.is_numeric(); + + if eq_or_numeric((first_i, first_e)) { + let last_i = interned_chars.next_back().expect("we know we have at least two chars"); + let last_e = existing_chars.next_back().expect("we know we have at least two chars"); + if eq_or_numeric((last_i, last_e)) { + if interned_chars + .zip(existing_chars) + .filter(|&ie| !eq_or_numeric(ie)) + .count() + != 1 + { + return true; + } + } else { + let second_last_i = interned_chars + .next_back() + .expect("we know we have at least three chars"); + let second_last_e = existing_chars + .next_back() + .expect("we know we have at least three chars"); + if !eq_or_numeric((second_last_i, second_last_e)) + || second_last_i == '_' + || !interned_chars.zip(existing_chars).all(eq_or_numeric) + { + // allowed similarity foo_x, foo_y + // or too many chars differ (foo_x, boo_y) or (foox, booy) + return true; + } + } + } else { + let second_i = interned_chars.next().expect("we know we have at least two chars"); + let second_e = existing_chars.next().expect("we know we have at least two chars"); + if !eq_or_numeric((second_i, second_e)) + || second_i == '_' + || !interned_chars.zip(existing_chars).all(eq_or_numeric) + { + // allowed similarity x_foo, y_foo + // or too many chars differ (x_foo, y_boo) or (xfoo, yboo) + return true; + } + } + + false + } } impl<'a, 'b> SimilarNamesLocalVisitor<'a, 'b> { From 09f18f61c6111674244471d49d7f82d826913022 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 9 Feb 2024 23:19:27 -0600 Subject: [PATCH 033/417] [similar_names] don't raise if the first character is different A lot of cases of the "noise" cases of `similar_names` come from two idents with a different first letter, which is easy enough to differentiate visually but causes this lint to be raised. Do not raise the lint in these cases, as long as the first character does not have a lookalike. Link: https://github.com/rust-lang/rust-clippy/issues/10926 --- clippy_lints/src/non_expressive_names.rs | 18 +++++++++ tests/ui/similar_names.rs | 5 +-- tests/ui/similar_names.stderr | 50 ++++++------------------ 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 66b0a53fdd747..b8c3c7fa65aee 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -131,6 +131,14 @@ const ALLOWED_TO_BE_SIMILAR: &[&[&str]] = &[ &["iter", "item"], ]; +/// Characters that look visually similar +const SIMILAR_CHARS: &[(char, char)] = &[('l', 'i'), ('l', '1'), ('i', '1'), ('u', 'v')]; + +/// Return true if two characters are visually similar +fn chars_are_similar(a: char, b: char) -> bool { + a == b || SIMILAR_CHARS.contains(&(a, b)) || SIMILAR_CHARS.contains(&(b, a)) +} + struct SimilarNamesNameVisitor<'a, 'tcx, 'b>(&'b mut SimilarNamesLocalVisitor<'a, 'tcx>); impl<'a, 'tcx, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> { @@ -219,6 +227,16 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { } let existing_str = existing_name.interned.as_str(); + + // The first char being different is usually enough to set identifiers apart, as long + // as the characters aren't too similar. + if !chars_are_similar( + interned_name.chars().next().expect("len >= 1"), + existing_str.chars().next().expect("len >= 1"), + ) { + continue; + } + let dissimilar = match existing_name.len.cmp(&count) { Ordering::Greater => existing_name.len - count != 1 || levenstein_not_1(interned_name, existing_str), Ordering::Less => count - existing_name.len != 1 || levenstein_not_1(existing_str, interned_name), diff --git a/tests/ui/similar_names.rs b/tests/ui/similar_names.rs index f46af56c6e2b0..f09693344915b 100644 --- a/tests/ui/similar_names.rs +++ b/tests/ui/similar_names.rs @@ -17,13 +17,10 @@ fn main() { let specter: i32; let spectre: i32; + // ok; first letter is different enough let apple: i32; - let bpple: i32; - //~^ ERROR: binding's name is too similar to existing binding - let cpple: i32; - //~^ ERROR: binding's name is too similar to existing binding let a_bar: i32; let b_bar: i32; diff --git a/tests/ui/similar_names.stderr b/tests/ui/similar_names.stderr index 44ae3532a4862..0cadb44ecf159 100644 --- a/tests/ui/similar_names.stderr +++ b/tests/ui/similar_names.stderr @@ -1,88 +1,64 @@ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:22:9 - | -LL | let bpple: i32; - | ^^^^^ - | -note: existing binding defined here - --> $DIR/similar_names.rs:20:9 - | -LL | let apple: i32; - | ^^^^^ - = note: `-D clippy::similar-names` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::similar_names)]` - -error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:25:9 - | -LL | let cpple: i32; - | ^^^^^ - | -note: existing binding defined here - --> $DIR/similar_names.rs:20:9 - | -LL | let apple: i32; - | ^^^^^ - -error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:50:9 + --> $DIR/similar_names.rs:47:9 | LL | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:49:9 + --> $DIR/similar_names.rs:46:9 | LL | let blubx: i32; | ^^^^^ + = note: `-D clippy::similar-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::similar_names)]` error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:55:9 + --> $DIR/similar_names.rs:52:9 | LL | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:53:9 + --> $DIR/similar_names.rs:50:9 | LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:74:9 + --> $DIR/similar_names.rs:71:9 | LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:72:9 + --> $DIR/similar_names.rs:69:9 | LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:79:9 + --> $DIR/similar_names.rs:76:9 | LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:77:9 + --> $DIR/similar_names.rs:74:9 | LL | let parser: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:101:16 + --> $DIR/similar_names.rs:98:16 | LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:100:16 + --> $DIR/similar_names.rs:97:16 | LL | apple: spring, | ^^^^^^ -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors From 5250afb77d5f14a82539fef4bfbb96d6d56f639a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 9 Feb 2024 23:36:31 -0600 Subject: [PATCH 034/417] Remove '#[expect(clippy::similar_names)]' where needed to pass dogfood tests --- clippy_lints/src/item_name_repetitions.rs | 1 - .../src/operators/double_comparison.rs | 1 - clippy_lints/src/operators/op_ref.rs | 2 +- clippy_utils/src/ast_utils.rs | 4 +- clippy_utils/src/hir_utils.rs | 5 +- clippy_utils/src/qualify_min_const_fn.rs | 1 - tests/ui/approx_const.rs | 1 - tests/ui/approx_const.stderr | 46 +++++++++---------- 8 files changed, 27 insertions(+), 34 deletions(-) diff --git a/clippy_lints/src/item_name_repetitions.rs b/clippy_lints/src/item_name_repetitions.rs index 276c1abb60cd5..0b4c416d94db0 100644 --- a/clippy_lints/src/item_name_repetitions.rs +++ b/clippy_lints/src/item_name_repetitions.rs @@ -385,7 +385,6 @@ impl LateLintPass<'_> for ItemNameRepetitions { assert!(last.is_some()); } - #[expect(clippy::similar_names)] fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { let item_name = item.ident.name.as_str(); let item_camel = to_camel_case(item_name); diff --git a/clippy_lints/src/operators/double_comparison.rs b/clippy_lints/src/operators/double_comparison.rs index d48e8286f2cae..d72a2fc3b1ab5 100644 --- a/clippy_lints/src/operators/double_comparison.rs +++ b/clippy_lints/src/operators/double_comparison.rs @@ -8,7 +8,6 @@ use rustc_span::Span; use super::DOUBLE_COMPARISONS; -#[expect(clippy::similar_names)] pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, op: BinOpKind, lhs: &'tcx Expr<'_>, rhs: &'tcx Expr<'_>, span: Span) { let (lkind, llhs, lrhs, rkind, rlhs, rrhs) = match (&lhs.kind, &rhs.kind) { (ExprKind::Binary(lb, llhs, lrhs), ExprKind::Binary(rb, rlhs, rrhs)) => { diff --git a/clippy_lints/src/operators/op_ref.rs b/clippy_lints/src/operators/op_ref.rs index 7d8aa3f56fed2..c2b27c9b2298a 100644 --- a/clippy_lints/src/operators/op_ref.rs +++ b/clippy_lints/src/operators/op_ref.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::{self, Ty}; use super::OP_REF; -#[expect(clippy::similar_names, clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] pub(crate) fn check<'tcx>( cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, diff --git a/clippy_utils/src/ast_utils.rs b/clippy_utils/src/ast_utils.rs index adc35bd82ae39..63f7d58af2607 100644 --- a/clippy_utils/src/ast_utils.rs +++ b/clippy_utils/src/ast_utils.rs @@ -2,7 +2,7 @@ //! //! - The `eq_foobar` functions test for semantic equality but ignores `NodeId`s and `Span`s. -#![allow(clippy::similar_names, clippy::wildcard_imports, clippy::enum_glob_use)] +#![allow(clippy::wildcard_imports, clippy::enum_glob_use)] use crate::{both, over}; use rustc_ast::ptr::P; @@ -296,7 +296,7 @@ pub fn eq_item(l: &Item, r: &Item, mut eq_kind: impl FnMut(&K, &K) -> b eq_id(l.ident, r.ident) && over(&l.attrs, &r.attrs, eq_attr) && eq_vis(&l.vis, &r.vis) && eq_kind(&l.kind, &r.kind) } -#[expect(clippy::too_many_lines)] // Just a big match statement +#[expect(clippy::similar_names, clippy::too_many_lines)] // Just a big match statement pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { use ItemKind::*; match (l, r) { diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index 4fa93ad23c369..36013ae0c1f2f 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -132,7 +132,6 @@ impl HirEqInterExpr<'_, '_, '_> { } /// Checks whether two blocks are the same. - #[expect(clippy::similar_names)] fn eq_block(&mut self, left: &Block<'_>, right: &Block<'_>) -> bool { use TokenKind::{Semi, Whitespace}; if left.stmts.len() != right.stmts.len() { @@ -247,7 +246,7 @@ impl HirEqInterExpr<'_, '_, '_> { res } - #[expect(clippy::similar_names, clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn eq_expr(&mut self, left: &Expr<'_>, right: &Expr<'_>) -> bool { if !self.check_ctxt(left.span.ctxt(), right.span.ctxt()) { return false; @@ -463,7 +462,6 @@ impl HirEqInterExpr<'_, '_, '_> { } } - #[expect(clippy::similar_names)] fn eq_qpath(&mut self, left: &QPath<'_>, right: &QPath<'_>) -> bool { match (left, right) { (&QPath::Resolved(ref lty, lpath), &QPath::Resolved(ref rty, rpath)) => { @@ -1158,7 +1156,6 @@ pub fn hash_expr(cx: &LateContext<'_>, e: &Expr<'_>) -> u64 { h.finish() } -#[expect(clippy::similar_names)] fn eq_span_tokens( cx: &LateContext<'_>, left: impl SpanRange, diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 81f4fcc2133d1..41f52ce8895f7 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -389,7 +389,6 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool { }) } -#[expect(clippy::similar_names)] // bit too pedantic fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool { // FIXME(effects, fee1-dead) revert to const destruct once it works again #[expect(unused)] diff --git a/tests/ui/approx_const.rs b/tests/ui/approx_const.rs index 2c3e0978c528e..3c4ed03678941 100644 --- a/tests/ui/approx_const.rs +++ b/tests/ui/approx_const.rs @@ -1,5 +1,4 @@ #[warn(clippy::approx_constant)] -#[allow(clippy::similar_names)] fn main() { let my_e = 2.7182; //~^ ERROR: approximate value of `f{32, 64}::consts::E` found diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index 4b5cd2a7a62f1..cb530eaf734a2 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::E` found - --> $DIR/approx_const.rs:4:16 + --> $DIR/approx_const.rs:3:16 | LL | let my_e = 2.7182; | ^^^^^^ @@ -9,7 +9,7 @@ LL | let my_e = 2.7182; = help: to override `-D warnings` add `#[allow(clippy::approx_constant)]` error: approximate value of `f{32, 64}::consts::E` found - --> $DIR/approx_const.rs:6:20 + --> $DIR/approx_const.rs:5:20 | LL | let almost_e = 2.718; | ^^^^^ @@ -17,7 +17,7 @@ LL | let almost_e = 2.718; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found - --> $DIR/approx_const.rs:10:24 + --> $DIR/approx_const.rs:9:24 | LL | let my_1_frac_pi = 0.3183; | ^^^^^^ @@ -25,7 +25,7 @@ LL | let my_1_frac_pi = 0.3183; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found - --> $DIR/approx_const.rs:14:28 + --> $DIR/approx_const.rs:13:28 | LL | let my_frac_1_sqrt_2 = 0.70710678; | ^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let my_frac_1_sqrt_2 = 0.70710678; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found - --> $DIR/approx_const.rs:16:32 + --> $DIR/approx_const.rs:15:32 | LL | let almost_frac_1_sqrt_2 = 0.70711; | ^^^^^^^ @@ -41,7 +41,7 @@ LL | let almost_frac_1_sqrt_2 = 0.70711; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found - --> $DIR/approx_const.rs:20:24 + --> $DIR/approx_const.rs:19:24 | LL | let my_frac_2_pi = 0.63661977; | ^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let my_frac_2_pi = 0.63661977; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found - --> $DIR/approx_const.rs:24:27 + --> $DIR/approx_const.rs:23:27 | LL | let my_frac_2_sq_pi = 1.128379; | ^^^^^^^^ @@ -57,7 +57,7 @@ LL | let my_frac_2_sq_pi = 1.128379; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found - --> $DIR/approx_const.rs:28:24 + --> $DIR/approx_const.rs:27:24 | LL | let my_frac_pi_2 = 1.57079632679; | ^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let my_frac_pi_2 = 1.57079632679; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found - --> $DIR/approx_const.rs:32:24 + --> $DIR/approx_const.rs:31:24 | LL | let my_frac_pi_3 = 1.04719755119; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let my_frac_pi_3 = 1.04719755119; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found - --> $DIR/approx_const.rs:36:24 + --> $DIR/approx_const.rs:35:24 | LL | let my_frac_pi_4 = 0.785398163397; | ^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let my_frac_pi_4 = 0.785398163397; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found - --> $DIR/approx_const.rs:40:24 + --> $DIR/approx_const.rs:39:24 | LL | let my_frac_pi_6 = 0.523598775598; | ^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let my_frac_pi_6 = 0.523598775598; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found - --> $DIR/approx_const.rs:44:24 + --> $DIR/approx_const.rs:43:24 | LL | let my_frac_pi_8 = 0.3926990816987; | ^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let my_frac_pi_8 = 0.3926990816987; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LN_10` found - --> $DIR/approx_const.rs:48:20 + --> $DIR/approx_const.rs:47:20 | LL | let my_ln_10 = 2.302585092994046; | ^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | let my_ln_10 = 2.302585092994046; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LN_2` found - --> $DIR/approx_const.rs:52:19 + --> $DIR/approx_const.rs:51:19 | LL | let my_ln_2 = 0.6931471805599453; | ^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | let my_ln_2 = 0.6931471805599453; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG10_E` found - --> $DIR/approx_const.rs:56:22 + --> $DIR/approx_const.rs:55:22 | LL | let my_log10_e = 0.4342944819032518; | ^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | let my_log10_e = 0.4342944819032518; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_E` found - --> $DIR/approx_const.rs:60:21 + --> $DIR/approx_const.rs:59:21 | LL | let my_log2_e = 1.4426950408889634; | ^^^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | let my_log2_e = 1.4426950408889634; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/approx_const.rs:64:19 + --> $DIR/approx_const.rs:63:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG10_2` found - --> $DIR/approx_const.rs:68:19 + --> $DIR/approx_const.rs:67:19 | LL | let log10_2 = 0.301029995663981; | ^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | let log10_2 = 0.301029995663981; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::PI` found - --> $DIR/approx_const.rs:72:17 + --> $DIR/approx_const.rs:71:17 | LL | let my_pi = 3.1415; | ^^^^^^ @@ -153,7 +153,7 @@ LL | let my_pi = 3.1415; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::PI` found - --> $DIR/approx_const.rs:74:21 + --> $DIR/approx_const.rs:73:21 | LL | let almost_pi = 3.14; | ^^^^ @@ -161,7 +161,7 @@ LL | let almost_pi = 3.14; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::SQRT_2` found - --> $DIR/approx_const.rs:78:18 + --> $DIR/approx_const.rs:77:18 | LL | let my_sq2 = 1.4142; | ^^^^^^ @@ -169,7 +169,7 @@ LL | let my_sq2 = 1.4142; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::TAU` found - --> $DIR/approx_const.rs:82:18 + --> $DIR/approx_const.rs:81:18 | LL | let my_tau = 6.2832; | ^^^^^^ @@ -177,7 +177,7 @@ LL | let my_tau = 6.2832; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::TAU` found - --> $DIR/approx_const.rs:84:22 + --> $DIR/approx_const.rs:83:22 | LL | let almost_tau = 6.28; | ^^^^ From fc8f6628ab945fc1b8586d6a83d78f247eaf512c Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 9 Feb 2024 23:58:36 +0300 Subject: [PATCH 035/417] hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}` --- clippy_lints/src/assertions_on_constants.rs | 3 +- .../src/casts/cast_slice_different_sizes.rs | 31 ++++++++----------- clippy_lints/src/casts/unnecessary_cast.rs | 2 +- clippy_lints/src/dbg_macro.rs | 2 +- clippy_lints/src/default_numeric_fallback.rs | 3 +- clippy_lints/src/dereference.rs | 2 +- clippy_lints/src/escape.rs | 6 ++-- .../src/functions/impl_trait_in_params.rs | 4 +-- clippy_lints/src/ignored_unit_patterns.rs | 4 +-- clippy_lints/src/index_refutable_slice.rs | 11 ++----- clippy_lints/src/iter_without_into_iter.rs | 2 +- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/loops/same_item_push.rs | 3 +- clippy_lints/src/manual_hash_one.rs | 6 ++-- clippy_lints/src/manual_rem_euclid.rs | 6 ++-- .../src/matches/match_single_binding.rs | 16 +++++----- clippy_lints/src/matches/redundant_guards.rs | 2 +- clippy_lints/src/methods/mod.rs | 2 +- .../src/methods/readonly_write_lock.rs | 4 +-- clippy_lints/src/methods/unnecessary_fold.rs | 2 +- .../src/methods/unnecessary_literal_unwrap.rs | 2 +- .../src/mixed_read_write_in_expression.rs | 3 +- clippy_lints/src/needless_pass_by_ref_mut.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/non_copy_const.rs | 2 +- .../src/operators/modulo_arithmetic.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 2 +- .../transmutes_expressible_as_ptr_casts.rs | 2 +- clippy_lints/src/tuple_array_conversions.rs | 9 ++---- clippy_lints/src/unit_types/unit_arg.rs | 8 ++--- clippy_lints/src/unnecessary_box_returns.rs | 2 +- clippy_lints/src/unnecessary_wraps.rs | 2 +- clippy_lints/src/unused_async.rs | 2 +- clippy_lints/src/unwrap.rs | 2 +- .../internal_lints/metadata_collector.rs | 6 ++-- .../internal_lints/unnecessary_def_path.rs | 3 +- clippy_lints/src/vec.rs | 4 +-- clippy_utils/src/lib.rs | 10 +++--- clippy_utils/src/ty/type_certainty/mod.rs | 2 +- 39 files changed, 78 insertions(+), 102 deletions(-) diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 1e327f7a6dfb8..9365fbfaed088 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -46,11 +46,10 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { return; }; if let ConstantSource::Constant = source - && let Some(node) = cx.tcx.hir().find_parent(e.hir_id) && let Node::Item(Item { kind: ItemKind::Const(..), .. - }) = node + }) = cx.tcx.parent_hir_node(e.hir_id) { return; } diff --git a/clippy_lints/src/casts/cast_slice_different_sizes.rs b/clippy_lints/src/casts/cast_slice_different_sizes.rs index 0f29743856ac9..a31943f002180 100644 --- a/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -67,25 +67,20 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv } fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let map = cx.tcx.hir(); - if let Some(parent_id) = map.opt_parent_id(expr.hir_id) { - let parent = cx.tcx.hir_node(parent_id); - let expr = match parent { - Node::Block(block) => { - if let Some(parent_expr) = block.expr { - parent_expr - } else { - return false; - } - }, - Node::Expr(expr) => expr, - _ => return false, - }; + let parent = cx.tcx.parent_hir_node(expr.hir_id); + let expr = match parent { + Node::Block(block) => { + if let Some(parent_expr) = block.expr { + parent_expr + } else { + return false; + } + }, + Node::Expr(expr) => expr, + _ => return false, + }; - matches!(expr.kind, ExprKind::Cast(..)) - } else { - false - } + matches!(expr.kind, ExprKind::Cast(..)) } /// Returns the type T of the pointed to *const [T] or *mut [T] and the mutability of the slice if diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index 81d0def4322d3..b4a23d0d4db41 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -65,7 +65,7 @@ pub(super) fn check<'tcx>( && let ExprKind::Path(qpath) = inner.kind && let QPath::Resolved(None, Path { res, .. }) = qpath && let Res::Local(hir_id) = res - && let parent = cx.tcx.hir().get_parent(*hir_id) + && let parent = cx.tcx.parent_hir_node(*hir_id) && let Node::Local(local) = parent { if let Some(ty) = local.ty diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 9424a9103db83..ec66556cebffa 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -63,7 +63,7 @@ impl LateLintPass<'_> for DbgMacro { ExprKind::Block(..) => { // If the `dbg!` macro is a "free" statement and not contained within other expressions, // remove the whole statement. - if let Some(Node::Stmt(_)) = cx.tcx.hir().find_parent(expr.hir_id) + if let Node::Stmt(_) = cx.tcx.parent_hir_node(expr.hir_id) && let Some(semi_span) = cx.sess().source_map().mac_call_stmt_semi_span(macro_call.span) { (macro_call.span.to(semi_span), String::new()) diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index c4437a3c4b339..59d2df0295fb4 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -128,8 +128,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { }, _, ) => { - if let Some(parent) = self.cx.tcx.hir().find_parent(expr.hir_id) - && let Some(fn_sig) = parent.fn_sig() + if let Some(fn_sig) = self.cx.tcx.parent_hir_node(expr.hir_id).fn_sig() && let FnRetTy::Return(_ty) = fn_sig.decl.output { // We cannot check the exact type since it's a `hir::Ty`` which does not implement `is_numeric` diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index 194cf69ea7ed0..cdbb52f497b36 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1088,7 +1088,7 @@ fn report<'tcx>( // // e.g. `&mut x.y.z` where `x` is a union, and accessing `z` requires a // deref through `ManuallyDrop<_>` will not compile. - let parent_id = cx.tcx.hir().parent_id(expr.hir_id); + let parent_id = cx.tcx.parent_hir_id(expr.hir_id); if parent_id == data.first_expr.hir_id { return; } diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 218d7c6c01ae1..064bac2e7dc74 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -131,7 +131,7 @@ fn is_argument(tcx: TyCtxt<'_>, id: HirId) -> bool { _ => return false, } - matches!(tcx.hir().find_parent(id), Some(Node::Param(_))) + matches!(tcx.parent_hir_node(id), Node::Param(_)) } impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { @@ -156,8 +156,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { let map = &self.cx.tcx.hir(); if is_argument(self.cx.tcx, cmt.hir_id) { // Skip closure arguments - let parent_id = map.parent_id(cmt.hir_id); - if let Some(Node::Expr(..)) = map.find_parent(parent_id) { + let parent_id = self.cx.tcx.parent_hir_id(cmt.hir_id); + if let Node::Expr(..) = self.cx.tcx.parent_hir_node(parent_id) { return; } diff --git a/clippy_lints/src/functions/impl_trait_in_params.rs b/clippy_lints/src/functions/impl_trait_in_params.rs index 8fba41c0e24d5..6fb38a0d6dd84 100644 --- a/clippy_lints/src/functions/impl_trait_in_params.rs +++ b/clippy_lints/src/functions/impl_trait_in_params.rs @@ -53,7 +53,7 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body: pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) { if let ImplItemKind::Fn(_, body_id) = impl_item.kind - && let hir::Node::Item(item) = cx.tcx.hir().get_parent(impl_item.hir_id()) + && let hir::Node::Item(item) = cx.tcx.parent_hir_node(impl_item.hir_id()) && let hir::ItemKind::Impl(impl_) = item.kind && let hir::Impl { of_trait, .. } = *impl_ && of_trait.is_none() @@ -72,7 +72,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) { pub(super) fn check_trait_item(cx: &LateContext<'_>, trait_item: &TraitItem<'_>, avoid_breaking_exported_api: bool) { if !avoid_breaking_exported_api && let TraitItemKind::Fn(_, _) = trait_item.kind - && let hir::Node::Item(item) = cx.tcx.hir().get_parent(trait_item.hir_id()) + && let hir::Node::Item(item) = cx.tcx.parent_hir_node(trait_item.hir_id()) // ^^ (Will always be a trait) && !item.vis_span.is_empty() // Is public && !is_in_test_function(cx.tcx, trait_item.hir_id()) diff --git a/clippy_lints/src/ignored_unit_patterns.rs b/clippy_lints/src/ignored_unit_patterns.rs index 0a2fd0c663e54..80a537b9f9413 100644 --- a/clippy_lints/src/ignored_unit_patterns.rs +++ b/clippy_lints/src/ignored_unit_patterns.rs @@ -41,8 +41,8 @@ impl<'tcx> LateLintPass<'tcx> for IgnoredUnitPatterns { return; } - match cx.tcx.hir().get_parent(pat.hir_id) { - Node::Param(param) if matches!(cx.tcx.hir().get_parent(param.hir_id), Node::Item(_)) => { + match cx.tcx.parent_hir_node(pat.hir_id) { + Node::Param(param) if matches!(cx.tcx.parent_hir_node(param.hir_id), Node::Item(_)) => { // Ignore function parameters return; }, diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 252be30c4e27d..51b4f26b6d131 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -242,12 +242,8 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { } = *self; if let Some(use_info) = slice_lint_info.get_mut(&local_id) - // Check if this is even a local we're interested in - - && let map = cx.tcx.hir() - // Checking for slice indexing - && let parent_id = map.parent_id(expr.hir_id) + && let parent_id = cx.tcx.parent_hir_id(expr.hir_id) && let hir::Node::Expr(parent_expr) = cx.tcx.hir_node(parent_id) && let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind && let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr) @@ -255,11 +251,10 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { && index_value < max_suggested_slice // Make sure that this slice index is read only - && let maybe_addrof_id = map.parent_id(parent_id) - && let hir::Node::Expr(maybe_addrof_expr) = cx.tcx.hir_node(maybe_addrof_id) + && let hir::Node::Expr(maybe_addrof_expr) = cx.tcx.parent_hir_node(parent_id) && let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind { - use_info.index_use.push((index_value, map.span(parent_expr.hir_id))); + use_info.index_use.push((index_value, cx.tcx.hir().span(parent_expr.hir_id))); return; } diff --git a/clippy_lints/src/iter_without_into_iter.rs b/clippy_lints/src/iter_without_into_iter.rs index 82a37bb4f278a..b5821d909f849 100644 --- a/clippy_lints/src/iter_without_into_iter.rs +++ b/clippy_lints/src/iter_without_into_iter.rs @@ -269,7 +269,7 @@ impl {self_ty_without_ref} {{ // } let span_behind_impl = cx .tcx - .def_span(cx.tcx.hir().parent_id(item.hir_id()).owner.def_id) + .def_span(cx.tcx.parent_hir_id(item.hir_id()).owner.def_id) .shrink_to_lo(); let sugg = format!( diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index f5636945f2037..2b73663d229ea 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -285,7 +285,7 @@ fn elision_suggestions( .iter() .filter(|usage| named_lifetime(usage).map_or(false, |id| elidable_lts.contains(&id))) .map(|usage| { - match cx.tcx.hir().get_parent(usage.hir_id) { + match cx.tcx.parent_hir_node(usage.hir_id) { Node::Ty(Ty { kind: TyKind::Ref(..), .. }) => { diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index 5f015db2b33bf..0f35514b8ad66 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -62,8 +62,7 @@ pub(super) fn check<'tcx>( if let Node::Pat(pat) = node && let PatKind::Binding(bind_ann, ..) = pat.kind && !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut)) - && let parent_node = cx.tcx.hir().parent_id(hir_id) - && let Node::Local(parent_let_expr) = cx.tcx.hir_node(parent_node) + && let Node::Local(parent_let_expr) = cx.tcx.parent_hir_node(hir_id) && let Some(init) = parent_let_expr.init { match init.kind { diff --git a/clippy_lints/src/manual_hash_one.rs b/clippy_lints/src/manual_hash_one.rs index 73687fbbe54e1..5cbab0ec977c1 100644 --- a/clippy_lints/src/manual_hash_one.rs +++ b/clippy_lints/src/manual_hash_one.rs @@ -68,8 +68,8 @@ impl LateLintPass<'_> for ManualHashOne { && let ExprKind::MethodCall(seg, build_hasher, [], _) = init.kind && seg.ident.name == sym!(build_hasher) - && let Node::Stmt(local_stmt) = cx.tcx.hir().get_parent(local.hir_id) - && let Node::Block(block) = cx.tcx.hir().get_parent(local_stmt.hir_id) + && let Node::Stmt(local_stmt) = cx.tcx.parent_hir_node(local.hir_id) + && let Node::Block(block) = cx.tcx.parent_hir_node(local_stmt.hir_id) && let mut stmts = block.stmts.iter() .skip_while(|stmt| stmt.hir_id != local_stmt.hir_id) @@ -91,7 +91,7 @@ impl LateLintPass<'_> for ManualHashOne { // `hasher.finish()`, may be anywhere in a statement or the trailing expr of the block && let Some(path_expr) = local_used_once(cx, (maybe_finish_stmt, block.expr), hasher) - && let Node::Expr(finish_expr) = cx.tcx.hir().get_parent(path_expr.hir_id) + && let Node::Expr(finish_expr) = cx.tcx.parent_hir_node(path_expr.hir_id) && !finish_expr.span.from_expansion() && let ExprKind::MethodCall(seg, _, [], _) = finish_expr.kind && seg.ident.name == sym!(finish) diff --git a/clippy_lints/src/manual_rem_euclid.rs b/clippy_lints/src/manual_rem_euclid.rs index e1768c6d97641..0bde62bd55490 100644 --- a/clippy_lints/src/manual_rem_euclid.rs +++ b/clippy_lints/src/manual_rem_euclid.rs @@ -79,9 +79,9 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid { && let Node::Pat(_) = cx.tcx.hir_node(hir_id) { // Apply only to params or locals with annotated types - match cx.tcx.hir().find_parent(hir_id) { - Some(Node::Param(..)) => (), - Some(Node::Local(local)) => { + match cx.tcx.parent_hir_node(hir_id) { + Node::Param(..) => (), + Node::Local(local) => { let Some(ty) = local.ty else { return }; if matches!(ty.kind, TyKind::Infer) { return; diff --git a/clippy_lints/src/matches/match_single_binding.rs b/clippy_lints/src/matches/match_single_binding.rs index 89da7a55cbd5f..61977045fd460 100644 --- a/clippy_lints/src/matches/match_single_binding.rs +++ b/clippy_lints/src/matches/match_single_binding.rs @@ -36,7 +36,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e .to_string(); // Do we need to add ';' to suggestion ? - if let Node::Stmt(stmt) = cx.tcx.hir().get_parent(expr.hir_id) + if let Node::Stmt(stmt) = cx.tcx.parent_hir_node(expr.hir_id) && let StmtKind::Expr(_) = stmt.kind && match match_body.kind { // We don't need to add a ; to blocks, unless that block is from a macro expansion @@ -146,18 +146,16 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e /// Returns true if the `ex` match expression is in a local (`let`) or assign expression fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option { - let map = &cx.tcx.hir(); - - if let Some(Node::Expr(parent_arm_expr)) = map.find_parent(ex.hir_id) { - return match map.find_parent(parent_arm_expr.hir_id) { - Some(Node::Local(parent_let_expr)) => Some(AssignmentExpr::Local { + if let Node::Expr(parent_arm_expr) = cx.tcx.parent_hir_node(ex.hir_id) { + return match cx.tcx.parent_hir_node(parent_arm_expr.hir_id) { + Node::Local(parent_let_expr) => Some(AssignmentExpr::Local { span: parent_let_expr.span, pat_span: parent_let_expr.pat.span(), }), - Some(Node::Expr(Expr { + Node::Expr(Expr { kind: ExprKind::Assign(parent_assign_expr, match_expr, _), .. - })) => Some(AssignmentExpr::Assign { + }) => Some(AssignmentExpr::Assign { span: parent_assign_expr.span, match_span: match_expr.span, }), @@ -191,7 +189,7 @@ fn sugg_with_curlies<'a>( // If the parent is already an arm, and the body is another match statement, // we need curly braces around suggestion - if let Node::Arm(arm) = &cx.tcx.hir().get_parent(match_expr.hir_id) { + if let Node::Arm(arm) = &cx.tcx.parent_hir_node(match_expr.hir_id) { if let ExprKind::Match(..) = arm.body.kind { cbrace_end = format!("\n{indent}}}"); // Fix body indent due to the match diff --git a/clippy_lints/src/matches/redundant_guards.rs b/clippy_lints/src/matches/redundant_guards.rs index dfaaeb14ca3cb..a1b82679f2e2a 100644 --- a/clippy_lints/src/matches/redundant_guards.rs +++ b/clippy_lints/src/matches/redundant_guards.rs @@ -199,7 +199,7 @@ fn get_pat_binding<'tcx>( return span.map(|span| PatBindingInfo { span, byref_ident, - is_field: matches!(cx.tcx.hir().get_parent(local), Node::PatField(_)), + is_field: matches!(cx.tcx.parent_hir_node(local), Node::PatField(_)), }); } } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index e8a7a321bf4b7..1452547807ba2 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -4458,7 +4458,7 @@ impl Methods { _ => {}, }, ("drain", ..) => { - if let Node::Stmt(Stmt { hir_id: _, kind, .. }) = cx.tcx.hir().get_parent(expr.hir_id) + if let Node::Stmt(Stmt { hir_id: _, kind, .. }) = cx.tcx.parent_hir_node(expr.hir_id) && matches!(kind, StmtKind::Semi(_)) && args.len() <= 1 { diff --git a/clippy_lints/src/methods/readonly_write_lock.rs b/clippy_lints/src/methods/readonly_write_lock.rs index 1184dd4525a73..6c6846c4b476c 100644 --- a/clippy_lints/src/methods/readonly_write_lock.rs +++ b/clippy_lints/src/methods/readonly_write_lock.rs @@ -21,9 +21,9 @@ fn is_unwrap_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, receiver: &Expr<'_>) { if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(receiver).peel_refs(), sym::RwLock) - && let Node::Expr(unwrap_call_expr) = cx.tcx.hir().get_parent(expr.hir_id) + && let Node::Expr(unwrap_call_expr) = cx.tcx.parent_hir_node(expr.hir_id) && is_unwrap_call(cx, unwrap_call_expr) - && let parent = cx.tcx.hir().get_parent(unwrap_call_expr.hir_id) + && let parent = cx.tcx.parent_hir_node(unwrap_call_expr.hir_id) && let Node::Local(local) = parent && let Some(mir) = enclosing_mir(cx.tcx, expr.hir_id) && let Some((local, _)) = mir diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index 2046692bbd0bd..988f3e86fcf08 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -16,7 +16,7 @@ use super::UNNECESSARY_FOLD; /// Changing `fold` to `sum` needs it sometimes when the return type can't be /// inferred. This checks for some common cases where it can be safely omitted fn needs_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { - let parent = cx.tcx.hir().get_parent(expr.hir_id); + let parent = cx.tcx.parent_hir_node(expr.hir_id); // some common cases where turbofish isn't needed: // - assigned to a local variable with a type annotation diff --git a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs index a1125d70db39a..1b2bfbf4090ec 100644 --- a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs +++ b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs @@ -76,7 +76,7 @@ pub(super) fn check( (expr.span.with_lo(call_args[0].span.hi()), String::new()), ]; // try to also remove the unsafe block if present - if let hir::Node::Block(block) = cx.tcx.hir().get_parent(expr.hir_id) + if let hir::Node::Block(block) = cx.tcx.parent_hir_node(expr.hir_id) && let hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::UserProvided) = block.rules { suggs.extend([ diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index b593e48ae2e16..a1f7dc7b38c40 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -206,10 +206,9 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { /// /// When such a read is found, the lint is triggered. fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) { - let map = &vis.cx.tcx.hir(); let mut cur_id = vis.write_expr.hir_id; loop { - let parent_id = map.parent_id(cur_id); + let parent_id = vis.cx.tcx.parent_hir_id(cur_id); if parent_id == cur_id { break; } diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index d2eef6ae4338e..149d440ecac49 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> { }; // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { + if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 2c5c3dcaa7528..384a402ce5b01 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { } // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { + if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 10ab380ba1bc5..ea73d9afa2ea0 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -449,7 +449,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst { let mut dereferenced_expr = expr; let mut needs_check_adjustment = true; loop { - let parent_id = cx.tcx.hir().parent_id(cur_expr.hir_id); + let parent_id = cx.tcx.parent_hir_id(cur_expr.hir_id); if parent_id == cur_expr.hir_id { break; } diff --git a/clippy_lints/src/operators/modulo_arithmetic.rs b/clippy_lints/src/operators/modulo_arithmetic.rs index 40d4a842befb8..2a933a11e12c0 100644 --- a/clippy_lints/src/operators/modulo_arithmetic.rs +++ b/clippy_lints/src/operators/modulo_arithmetic.rs @@ -34,7 +34,7 @@ pub(super) fn check<'tcx>( } fn used_in_comparison_with_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find_parent(expr.hir_id) else { + let Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id) else { return false; }; let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind else { diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 57d37067e8f98..ec03ab0e41ab7 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -301,7 +301,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue { } // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { + if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs index 513a913f56adb..bbecc39a8130c 100644 --- a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs +++ b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs @@ -41,7 +41,7 @@ pub(super) fn check<'tcx>( _ => return false, }; - if let Node::Expr(parent) = cx.tcx.hir().get_parent(e.hir_id) + if let Node::Expr(parent) = cx.tcx.parent_hir_node(e.hir_id) && parent.precedence().order() > ExprPrecedence::Cast.order() { sugg = format!("({sugg})"); diff --git a/clippy_lints/src/tuple_array_conversions.rs b/clippy_lints/src/tuple_array_conversions.rs index e1cd82e18d56d..c11504cd2d4f9 100644 --- a/clippy_lints/src/tuple_array_conversions.rs +++ b/clippy_lints/src/tuple_array_conversions.rs @@ -153,13 +153,10 @@ fn all_bindings_are_for_conv<'tcx>( let Some(locals) = locals.iter().map(|e| path_to_local(e)).collect::>>() else { return false; }; - let Some(local_parents) = locals + let local_parents = locals .iter() - .map(|&l| cx.tcx.hir().find_parent(l)) - .collect::>>() - else { - return false; - }; + .map(|l| cx.tcx.parent_hir_node(*l)) + .collect::>(); local_parents .iter() diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs index 44cff78a7936d..eba7fa7b993c2 100644 --- a/clippy_lints/src/unit_types/unit_arg.rs +++ b/clippy_lints/src/unit_types/unit_arg.rs @@ -19,9 +19,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { if is_questionmark_desugar_marked_call(expr) { return; } - let map = &cx.tcx.hir(); - let opt_parent_node = map.find_parent(expr.hir_id); - if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node + if let hir::Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id) && is_questionmark_desugar_marked_call(parent_expr) { return; @@ -183,8 +181,8 @@ fn fmt_stmts_and_call( let mut stmts_and_call_snippet = stmts_and_call.join(&format!("{}{}", ";\n", " ".repeat(call_expr_indent))); // expr is not in a block statement or result expression position, wrap in a block - let parent_node = cx.tcx.hir().find_parent(call_expr.hir_id); - if !matches!(parent_node, Some(Node::Block(_))) && !matches!(parent_node, Some(Node::Stmt(_))) { + let parent_node = cx.tcx.parent_hir_node(call_expr.hir_id); + if !matches!(parent_node, Node::Block(_)) && !matches!(parent_node, Node::Stmt(_)) { let block_indent = call_expr_indent + 4; stmts_and_call_snippet = reindent_multiline(stmts_and_call_snippet.into(), true, Some(block_indent)).into_owned(); diff --git a/clippy_lints/src/unnecessary_box_returns.rs b/clippy_lints/src/unnecessary_box_returns.rs index f5af540fa1486..c332cf076ae7d 100644 --- a/clippy_lints/src/unnecessary_box_returns.rs +++ b/clippy_lints/src/unnecessary_box_returns.rs @@ -116,7 +116,7 @@ impl LateLintPass<'_> for UnnecessaryBoxReturns { fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::ImplItem<'_>) { // Ignore implementations of traits, because the lint should be on the // trait, not on the implementation of it. - let Node::Item(parent) = cx.tcx.hir().get_parent(item.hir_id()) else { + let Node::Item(parent) = cx.tcx.parent_hir_node(item.hir_id()) else { return; }; let ItemKind::Impl(parent) = parent.kind else { return }; diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 446160f8e0fdc..9c8b0ae172763 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -92,7 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps { // Abort if the method is implementing a trait or of it a trait method. let hir_id = cx.tcx.local_def_id_to_hir_id(def_id); - if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { + if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index 1d42375ba8e55..738fba54fa83f 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync { && let Some(local_def_id) = def_id.as_local() && cx.tcx.def_kind(def_id) == DefKind::Fn && cx.tcx.asyncness(def_id).is_async() - && !is_node_func_call(cx.tcx.hir().get_parent(hir_id), path.span) + && !is_node_func_call(cx.tcx.parent_hir_node(hir_id), path.span) { self.async_fns_as_value.insert(local_def_id); } diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index ae2ac38cffe1b..f2eb774b5cbfe 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -208,7 +208,7 @@ struct MutationVisitor<'tcx> { /// (i.e. the `x` in `x.as_mut()`), and that is the reason for why we care about its parent /// expression: that will be where the actual method call is. fn is_option_as_mut_use(tcx: TyCtxt<'_>, expr_id: HirId) -> bool { - if let Node::Expr(mutating_expr) = tcx.hir().get_parent(expr_id) + if let Node::Expr(mutating_expr) = tcx.parent_hir_node(expr_id) && let ExprKind::MethodCall(path, ..) = mutating_expr.kind { path.ident.name.as_str() == "as_mut" diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index fae1b90ace21c..349e0e3e077a8 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -1007,9 +1007,9 @@ fn get_parent_local<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) - fn get_parent_local_hir_id<'hir>(cx: &LateContext<'hir>, hir_id: hir::HirId) -> Option<&'hir hir::Local<'hir>> { let map = cx.tcx.hir(); - match map.find_parent(hir_id) { - Some(hir::Node::Local(local)) => Some(local), - Some(hir::Node::Pat(pattern)) => get_parent_local_hir_id(cx, pattern.hir_id), + match cx.tcx.parent_hir_node(hir_id) { + hir::Node::Local(local) => Some(local), + hir::Node::Pat(pattern) => get_parent_local_hir_id(cx, pattern.hir_id), _ => None, } } diff --git a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs index 6e449dc980630..38c832931fc68 100644 --- a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs +++ b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs @@ -217,8 +217,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option match cx.qpath_res(qpath, expr.hir_id) { Res::Local(hir_id) => { - let parent_id = cx.tcx.hir().parent_id(hir_id); - if let Node::Local(Local { init: Some(init), .. }) = cx.tcx.hir_node(parent_id) { + if let Node::Local(Local { init: Some(init), .. }) = cx.tcx.parent_hir_node(hir_id) { path_to_matched_type(cx, init) } else { None diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 2c33c93412a3d..b3489142558e3 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { if let Some(vec_args) = higher::VecArgs::hir(cx, expr.peel_borrows()) { // search for `let foo = vec![_]` expressions where all uses of `foo` // adjust to slices or call a method that exist on slices (e.g. len) - if let Node::Local(local) = cx.tcx.hir().get_parent(expr.hir_id) + if let Node::Local(local) = cx.tcx.parent_hir_node(expr.hir_id) // for now ignore locals with type annotations. // this is to avoid compile errors when doing the suggestion here: let _: Vec<_> = vec![..]; && local.ty.is_none() @@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { } // if the local pattern has a specified type, do not lint. else if let Some(_) = higher::VecArgs::hir(cx, expr) - && let Node::Local(local) = cx.tcx.hir().get_parent(expr.hir_id) + && let Node::Local(local) = cx.tcx.parent_hir_node(expr.hir_id) && local.ty.is_some() { let span = expr.span.ctxt().outer_expn_data().call_site; diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 6a33e11be465b..67a18caca0e2d 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -182,11 +182,9 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr /// Note: If you have an expression that references a binding `x`, use `path_to_local` to get the /// canonical binding `HirId`. pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> { - let hir = cx.tcx.hir(); if let Node::Pat(pat) = cx.tcx.hir_node(hir_id) && matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..)) - && let parent = hir.parent_id(hir_id) - && let Node::Local(local) = cx.tcx.hir_node(parent) + && let Node::Local(local) = cx.tcx.parent_hir_node(hir_id) { return local.init; } @@ -333,7 +331,7 @@ pub fn is_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, diag_item: Symbol) /// Checks if the `def_id` belongs to a function that is part of a trait impl. pub fn is_def_id_trait_method(cx: &LateContext<'_>, def_id: LocalDefId) -> bool { if let Some(hir_id) = cx.tcx.opt_local_def_id_to_hir_id(def_id) - && let Node::Item(item) = cx.tcx.hir().get_parent(hir_id) + && let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) && let ItemKind::Impl(imp) = item.kind { imp.of_trait.is_some() @@ -1311,7 +1309,7 @@ pub fn contains_return<'tcx>(expr: impl Visitable<'tcx>) -> bool { /// Gets the parent node, if any. pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option> { - tcx.hir().find_parent(id) + Some(tcx.parent_hir_node(id)) } /// Gets the parent expression, if any –- this is useful to constrain a lint. @@ -2227,7 +2225,7 @@ pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool { /// } /// ``` pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool { - if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { + if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) { matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })) } else { false diff --git a/clippy_utils/src/ty/type_certainty/mod.rs b/clippy_utils/src/ty/type_certainty/mod.rs index adca2ca1c3efa..7913926928f2a 100644 --- a/clippy_utils/src/ty/type_certainty/mod.rs +++ b/clippy_utils/src/ty/type_certainty/mod.rs @@ -237,7 +237,7 @@ fn path_segment_certainty( }, // `get_parent` because `hir_id` refers to a `Pat`, and we're interested in the node containing the `Pat`. - Res::Local(hir_id) => match cx.tcx.hir().get_parent(hir_id) { + Res::Local(hir_id) => match cx.tcx.parent_hir_node(hir_id) { // An argument's type is always certain. Node::Param(..) => Certainty::Certain(None), // A local's type is certain if its type annotation is certain or it has an initializer whose From 92537a0e5b73629b7c25061ccff6dc255e53c6b6 Mon Sep 17 00:00:00 2001 From: J-ZhengLi Date: Fri, 29 Dec 2023 10:15:45 +0800 Subject: [PATCH 036/417] add test case with a proc macro `fake_desugar_await` --- tests/ui/auxiliary/proc_macro_attr.rs | 20 ++++++++++++++++++++ tests/ui/blocks_in_conditions.fixed | 13 +++++++++++++ tests/ui/blocks_in_conditions.rs | 13 +++++++++++++ tests/ui/blocks_in_conditions.stderr | 16 +++++++++++----- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/tests/ui/auxiliary/proc_macro_attr.rs b/tests/ui/auxiliary/proc_macro_attr.rs index ac544737099c6..75f7a20f961b6 100644 --- a/tests/ui/auxiliary/proc_macro_attr.rs +++ b/tests/ui/auxiliary/proc_macro_attr.rs @@ -125,3 +125,23 @@ pub fn fake_main(_attr: TokenStream, item: TokenStream) -> TokenStream { } .into() } + +#[proc_macro_attribute] +pub fn fake_desugar_await(_args: TokenStream, input: TokenStream) -> TokenStream { + let mut async_fn = syn::parse_macro_input!(input as syn::ItemFn); + + for stmt in &mut async_fn.block.stmts { + if let syn::Stmt::Expr(syn::Expr::Match(syn::ExprMatch { expr: scrutinee, .. }), _) = stmt { + if let syn::Expr::Await(syn::ExprAwait { base, await_token, .. }) = scrutinee.as_mut() { + let blc = quote_spanned!( await_token.span => { + #[allow(clippy::let_and_return)] + let __pinned = #base; + __pinned + }); + *scrutinee = parse_quote!(#blc); + } + } + } + + quote!(#async_fn).into() +} diff --git a/tests/ui/blocks_in_conditions.fixed b/tests/ui/blocks_in_conditions.fixed index efef60567a979..ac1ad68ffc233 100644 --- a/tests/ui/blocks_in_conditions.fixed +++ b/tests/ui/blocks_in_conditions.fixed @@ -1,3 +1,5 @@ +//@aux-build:proc_macro_attr.rs + #![warn(clippy::blocks_in_conditions)] #![allow(unused, clippy::let_and_return, clippy::needless_if)] #![warn(clippy::nonminimal_bool)] @@ -99,4 +101,15 @@ fn issue_12162() { } } +mod issue_12016 { + #[proc_macro_attr::fake_desugar_await] + pub async fn await_becomes_block() -> i32 { + let res = await; match res { + Some(1) => 2, + Some(2) => 3, + _ => 0, + } + } +} + fn main() {} diff --git a/tests/ui/blocks_in_conditions.rs b/tests/ui/blocks_in_conditions.rs index 8bd8a939eb16e..e72daaa910d43 100644 --- a/tests/ui/blocks_in_conditions.rs +++ b/tests/ui/blocks_in_conditions.rs @@ -1,3 +1,5 @@ +//@aux-build:proc_macro_attr.rs + #![warn(clippy::blocks_in_conditions)] #![allow(unused, clippy::let_and_return, clippy::needless_if)] #![warn(clippy::nonminimal_bool)] @@ -99,4 +101,15 @@ fn issue_12162() { } } +mod issue_12016 { + #[proc_macro_attr::fake_desugar_await] + pub async fn await_becomes_block() -> i32 { + match Some(1).await { + Some(1) => 2, + Some(2) => 3, + _ => 0, + } + } +} + fn main() {} diff --git a/tests/ui/blocks_in_conditions.stderr b/tests/ui/blocks_in_conditions.stderr index b00fe2f632c79..cb2f6da3516c3 100644 --- a/tests/ui/blocks_in_conditions.stderr +++ b/tests/ui/blocks_in_conditions.stderr @@ -1,5 +1,5 @@ error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions.rs:23:5 + --> $DIR/blocks_in_conditions.rs:25:5 | LL | / if { LL | | @@ -20,13 +20,13 @@ LL ~ }; if res { | error: omit braces around single expression condition - --> $DIR/blocks_in_conditions.rs:35:8 + --> $DIR/blocks_in_conditions.rs:37:8 | LL | if { true } { 6 } else { 10 } | ^^^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/blocks_in_conditions.rs:41:8 + --> $DIR/blocks_in_conditions.rs:43:8 | LL | if true && x == 3 { 6 } else { 10 } | ^^^^^^^^^^^^^^ help: try: `x == 3` @@ -35,7 +35,7 @@ LL | if true && x == 3 { 6 } else { 10 } = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions.rs:68:5 + --> $DIR/blocks_in_conditions.rs:70:5 | LL | / match { LL | | @@ -53,5 +53,11 @@ LL + opt LL ~ }; match res { | -error: aborting due to 4 previous errors +error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` + --> $DIR/blocks_in_conditions.rs:107:9 + | +LL | match Some(1).await { + | ^^^^^^^^^^^^^^^^^^^ help: try: `let res = await; match res` + +error: aborting due to 5 previous errors From 9012d55c022e55bc154e023cb802c5083e905369 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sat, 10 Feb 2024 09:35:29 -0500 Subject: [PATCH 037/417] Don't lint `incompatible_msrv` in test code --- clippy_lints/src/incompatible_msrv.rs | 11 ++++++----- tests/ui/incompatible_msrv.rs | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/incompatible_msrv.rs b/clippy_lints/src/incompatible_msrv.rs index f2f0e7d426628..475938d6adf01 100644 --- a/clippy_lints/src/incompatible_msrv.rs +++ b/clippy_lints/src/incompatible_msrv.rs @@ -1,8 +1,9 @@ use clippy_config::msrvs::Msrv; use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_in_test_function; use rustc_attr::{StabilityLevel, StableSince}; use rustc_data_structures::fx::FxHashMap; -use rustc_hir::{Expr, ExprKind}; +use rustc_hir::{Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TyCtxt; use rustc_semver::RustcVersion; @@ -81,13 +82,13 @@ impl IncompatibleMsrv { version } - fn emit_lint_if_under_msrv(&mut self, cx: &LateContext<'_>, def_id: DefId, span: Span) { + fn emit_lint_if_under_msrv(&mut self, cx: &LateContext<'_>, def_id: DefId, node: HirId, span: Span) { if def_id.is_local() { // We don't check local items since their MSRV is supposed to always be valid. return; } let version = self.get_def_id_version(cx.tcx, def_id); - if self.msrv.meets(version) { + if self.msrv.meets(version) || is_in_test_function(cx.tcx, node) { return; } self.emit_lint_for(cx, span, version); @@ -117,14 +118,14 @@ impl<'tcx> LateLintPass<'tcx> for IncompatibleMsrv { match expr.kind { ExprKind::MethodCall(_, _, _, span) => { if let Some(method_did) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { - self.emit_lint_if_under_msrv(cx, method_did, span); + self.emit_lint_if_under_msrv(cx, method_did, expr.hir_id, span); } }, ExprKind::Call(call, [_]) => { if let ExprKind::Path(qpath) = call.kind && let Some(path_def_id) = cx.qpath_res(&qpath, call.hir_id).opt_def_id() { - self.emit_lint_if_under_msrv(cx, path_def_id, call.span); + self.emit_lint_if_under_msrv(cx, path_def_id, expr.hir_id, call.span); } }, _ => {}, diff --git a/tests/ui/incompatible_msrv.rs b/tests/ui/incompatible_msrv.rs index a92017fb0f626..0fa047c7102aa 100644 --- a/tests/ui/incompatible_msrv.rs +++ b/tests/ui/incompatible_msrv.rs @@ -20,4 +20,9 @@ fn foo() { //~^ ERROR: is `1.3.0` but this item is stable since `1.4.0` } +#[test] +fn test() { + sleep(Duration::new(1, 0)); +} + fn main() {} From b3b9919d1b4b321b0a9b7955ee06b9ecb755ce7e Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:37:51 +0100 Subject: [PATCH 038/417] [`to_string_trait_impl`]: take specialization into account --- clippy_lints/src/to_string_trait_impl.rs | 3 ++ tests/ui/to_string_trait_impl.rs | 44 ++++++++++++++++++++++++ tests/ui/to_string_trait_impl.stderr | 16 +++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/to_string_trait_impl.rs b/clippy_lints/src/to_string_trait_impl.rs index e1cea99085fde..59ae185c9de74 100644 --- a/clippy_lints/src/to_string_trait_impl.rs +++ b/clippy_lints/src/to_string_trait_impl.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::ty::implements_trait; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -53,6 +54,8 @@ impl<'tcx> LateLintPass<'tcx> for ToStringTraitImpl { }) = it.kind && let Some(trait_did) = trait_ref.trait_def_id() && cx.tcx.is_diagnostic_item(sym::ToString, trait_did) + && let Some(display_did) = cx.tcx.get_diagnostic_item(sym::Display) + && !implements_trait(cx, cx.tcx.type_of(it.owner_id).instantiate_identity(), display_did, &[]) { span_lint_and_help( cx, diff --git a/tests/ui/to_string_trait_impl.rs b/tests/ui/to_string_trait_impl.rs index b0731632d4504..4c1202d420341 100644 --- a/tests/ui/to_string_trait_impl.rs +++ b/tests/ui/to_string_trait_impl.rs @@ -1,4 +1,5 @@ #![warn(clippy::to_string_trait_impl)] +#![feature(min_specialization)] use std::fmt::{self, Display}; @@ -29,3 +30,46 @@ impl Bar { String::from("Bar") } } + +mod issue12263 { + pub struct MyStringWrapper<'a>(&'a str); + + impl std::fmt::Display for MyStringWrapper<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } + } + + impl ToString for MyStringWrapper<'_> { + fn to_string(&self) -> String { + self.0.to_string() + } + } + + pub struct S(T); + impl std::fmt::Display for S { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + // no specialization if the generics differ, so lint + impl ToString for S { + fn to_string(&self) -> String { + todo!() + } + } + + pub struct S2(T); + impl std::fmt::Display for S2 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + + // also specialization if the generics don't differ + impl ToString for S2 { + fn to_string(&self) -> String { + todo!() + } + } +} diff --git a/tests/ui/to_string_trait_impl.stderr b/tests/ui/to_string_trait_impl.stderr index 55fa9f12c0e65..0051ea25ae00a 100644 --- a/tests/ui/to_string_trait_impl.stderr +++ b/tests/ui/to_string_trait_impl.stderr @@ -1,5 +1,5 @@ error: direct implementation of `ToString` - --> $DIR/to_string_trait_impl.rs:10:1 + --> $DIR/to_string_trait_impl.rs:11:1 | LL | / impl ToString for Point { LL | | fn to_string(&self) -> String { @@ -12,5 +12,17 @@ LL | | } = note: `-D clippy::to-string-trait-impl` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::to_string_trait_impl)]` -error: aborting due to 1 previous error +error: direct implementation of `ToString` + --> $DIR/to_string_trait_impl.rs:56:5 + | +LL | / impl ToString for S { +LL | | fn to_string(&self) -> String { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: prefer implementing `Display` instead + +error: aborting due to 2 previous errors From c4d11083d9ee8efb873cff069b0282be68a37ab2 Mon Sep 17 00:00:00 2001 From: granddaifuku Date: Sun, 11 Feb 2024 03:51:26 +0900 Subject: [PATCH 039/417] fix: ICE when array index exceeds usize --- clippy_lints/src/indexing_slicing.rs | 1 + tests/ui/crashes/ice-12253.rs | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tests/ui/crashes/ice-12253.rs diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 391db0b0df726..35fcd8cdd3547 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -174,6 +174,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { // only `usize` index is legal in rust array index // leave other type to rustc if let Constant::Int(off) = constant + && off <= usize::MAX as u128 && let ty::Uint(utype) = cx.typeck_results().expr_ty(index).kind() && *utype == ty::UintTy::Usize && let ty::Array(_, s) = ty.kind() diff --git a/tests/ui/crashes/ice-12253.rs b/tests/ui/crashes/ice-12253.rs new file mode 100644 index 0000000000000..41f50035144a7 --- /dev/null +++ b/tests/ui/crashes/ice-12253.rs @@ -0,0 +1,5 @@ +#[allow(overflowing_literals, unconditional_panic, clippy::no_effect)] +fn main() { + let arr: [i32; 5] = [0; 5]; + arr[0xfffffe7ffffffffffffffffffffffff]; +} From ac7c6e54176a7e7d987b8c5d48716267a964e839 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sat, 10 Feb 2024 16:10:05 -0500 Subject: [PATCH 040/417] Don't allow derive macros to silence `disallowed_macros` for their own call. --- clippy_lints/src/disallowed_macros.rs | 84 ++++++++++++------- .../auxiliary/proc_macros.rs | 29 +++++++ tests/ui-toml/disallowed_macros/clippy.toml | 1 + .../disallowed_macros/disallowed_macros.rs | 6 ++ .../disallowed_macros.stderr | 38 +++++---- 5 files changed, 112 insertions(+), 46 deletions(-) create mode 100644 tests/ui-toml/disallowed_macros/auxiliary/proc_macros.rs diff --git a/clippy_lints/src/disallowed_macros.rs b/clippy_lints/src/disallowed_macros.rs index 656b3d9bfaf1b..4652cec722edf 100644 --- a/clippy_lints/src/disallowed_macros.rs +++ b/clippy_lints/src/disallowed_macros.rs @@ -1,13 +1,16 @@ use clippy_config::types::DisallowedPath; -use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; use clippy_utils::macros::macro_backtrace; use rustc_ast::Attribute; use rustc_data_structures::fx::FxHashSet; +use rustc_errors::Diagnostic; use rustc_hir::def_id::DefIdMap; -use rustc_hir::{Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, Pat, Path, Stmt, TraitItem, Ty}; +use rustc_hir::{ + Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, ItemKind, OwnerId, Pat, Path, Stmt, TraitItem, Ty, +}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::{ExpnId, Span}; +use rustc_span::{ExpnId, MacroKind, Span}; declare_clippy_lint! { /// ### What it does @@ -57,6 +60,10 @@ pub struct DisallowedMacros { conf_disallowed: Vec, disallowed: DefIdMap, seen: FxHashSet, + + // Track the most recently seen node that can have a `derive` attribute. + // Needed to use the correct lint level. + derive_src: Option, } impl DisallowedMacros { @@ -65,10 +72,11 @@ impl DisallowedMacros { conf_disallowed, disallowed: DefIdMap::default(), seen: FxHashSet::default(), + derive_src: None, } } - fn check(&mut self, cx: &LateContext<'_>, span: Span) { + fn check(&mut self, cx: &LateContext<'_>, span: Span, derive_src: Option) { if self.conf_disallowed.is_empty() { return; } @@ -80,18 +88,26 @@ impl DisallowedMacros { if let Some(&index) = self.disallowed.get(&mac.def_id) { let conf = &self.conf_disallowed[index]; - - span_lint_and_then( - cx, - DISALLOWED_MACROS, - mac.span, - &format!("use of a disallowed macro `{}`", conf.path()), - |diag| { - if let Some(reason) = conf.reason() { - diag.note(reason); - } - }, - ); + let msg = format!("use of a disallowed macro `{}`", conf.path()); + let add_note = |diag: &mut Diagnostic| { + if let Some(reason) = conf.reason() { + diag.note(reason); + } + }; + if matches!(mac.kind, MacroKind::Derive) + && let Some(derive_src) = derive_src + { + span_lint_hir_and_then( + cx, + DISALLOWED_MACROS, + cx.tcx.local_def_id_to_hir_id(derive_src.def_id), + mac.span, + &msg, + add_note, + ); + } else { + span_lint_and_then(cx, DISALLOWED_MACROS, mac.span, &msg, add_note); + } } } } @@ -110,49 +126,57 @@ impl LateLintPass<'_> for DisallowedMacros { } fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { - self.check(cx, expr.span); + self.check(cx, expr.span, None); // `$t + $t` can have the context of $t, check also the span of the binary operator if let ExprKind::Binary(op, ..) = expr.kind { - self.check(cx, op.span); + self.check(cx, op.span, None); } } fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &Stmt<'_>) { - self.check(cx, stmt.span); + self.check(cx, stmt.span, None); } fn check_ty(&mut self, cx: &LateContext<'_>, ty: &Ty<'_>) { - self.check(cx, ty.span); + self.check(cx, ty.span, None); } fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { - self.check(cx, pat.span); + self.check(cx, pat.span, None); } fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { - self.check(cx, item.span); - self.check(cx, item.vis_span); + self.check(cx, item.span, self.derive_src); + self.check(cx, item.vis_span, None); + + if matches!( + item.kind, + ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..) + ) && macro_backtrace(item.span).all(|m| !matches!(m.kind, MacroKind::Derive)) + { + self.derive_src = Some(item.owner_id); + } } fn check_foreign_item(&mut self, cx: &LateContext<'_>, item: &ForeignItem<'_>) { - self.check(cx, item.span); - self.check(cx, item.vis_span); + self.check(cx, item.span, None); + self.check(cx, item.vis_span, None); } fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &ImplItem<'_>) { - self.check(cx, item.span); - self.check(cx, item.vis_span); + self.check(cx, item.span, None); + self.check(cx, item.vis_span, None); } fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) { - self.check(cx, item.span); + self.check(cx, item.span, None); } fn check_path(&mut self, cx: &LateContext<'_>, path: &Path<'_>, _: HirId) { - self.check(cx, path.span); + self.check(cx, path.span, None); } fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &Attribute) { - self.check(cx, attr.span); + self.check(cx, attr.span, self.derive_src); } } diff --git a/tests/ui-toml/disallowed_macros/auxiliary/proc_macros.rs b/tests/ui-toml/disallowed_macros/auxiliary/proc_macros.rs new file mode 100644 index 0000000000000..dbfce16858aca --- /dev/null +++ b/tests/ui-toml/disallowed_macros/auxiliary/proc_macros.rs @@ -0,0 +1,29 @@ +extern crate proc_macro; +use proc_macro::Delimiter::{Brace, Bracket, Parenthesis}; +use proc_macro::Spacing::{Alone, Joint}; +use proc_macro::{Group, Ident, Punct, Span, TokenStream, TokenTree as TT}; + +#[proc_macro_derive(Derive)] +pub fn derive(_: TokenStream) -> TokenStream { + TokenStream::from_iter([ + TT::from(Punct::new('#', Alone)), + TT::from(Group::new( + Bracket, + TokenStream::from_iter([ + TT::from(Ident::new("allow", Span::call_site())), + TT::from(Group::new( + Parenthesis, + TokenStream::from_iter([ + TT::from(Ident::new("clippy", Span::call_site())), + TT::from(Punct::new(':', Joint)), + TT::from(Punct::new(':', Alone)), + TT::from(Ident::new("disallowed_macros", Span::call_site())), + ]), + )), + ]), + )), + TT::from(Ident::new("impl", Span::call_site())), + TT::from(Ident::new("Foo", Span::call_site())), + TT::from(Group::new(Brace, TokenStream::new())), + ]) +} diff --git a/tests/ui-toml/disallowed_macros/clippy.toml b/tests/ui-toml/disallowed_macros/clippy.toml index 85f1b71eb66b9..8b4f3b713bbb5 100644 --- a/tests/ui-toml/disallowed_macros/clippy.toml +++ b/tests/ui-toml/disallowed_macros/clippy.toml @@ -10,4 +10,5 @@ disallowed-macros = [ "macros::item", "macros::binop", "macros::attr", + "proc_macros::Derive", ] diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.rs b/tests/ui-toml/disallowed_macros/disallowed_macros.rs index 4a3d55e13c9dc..e63a99e74cbbe 100644 --- a/tests/ui-toml/disallowed_macros/disallowed_macros.rs +++ b/tests/ui-toml/disallowed_macros/disallowed_macros.rs @@ -1,9 +1,12 @@ //@aux-build:macros.rs +//@aux-build:proc_macros.rs #![allow(unused)] extern crate macros; +extern crate proc_macros; +use proc_macros::Derive; use serde::Serialize; fn main() { @@ -40,3 +43,6 @@ trait Y { impl Y for S { macros::item!(); } + +#[derive(Derive)] +struct Foo; diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr index 3c6f59b16e7c3..986a7b171c4a0 100644 --- a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr +++ b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr @@ -1,5 +1,5 @@ error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros.rs:10:5 + --> $DIR/disallowed_macros.rs:13:5 | LL | println!("one"); | ^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | println!("one"); = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]` error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros.rs:11:5 + --> $DIR/disallowed_macros.rs:14:5 | LL | println!("two"); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `std::cfg` - --> $DIR/disallowed_macros.rs:12:5 + --> $DIR/disallowed_macros.rs:15:5 | LL | cfg!(unix); | ^^^^^^^^^^ error: use of a disallowed macro `std::vec` - --> $DIR/disallowed_macros.rs:13:5 + --> $DIR/disallowed_macros.rs:16:5 | LL | vec![1, 2, 3]; | ^^^^^^^^^^^^^ error: use of a disallowed macro `serde::Serialize` - --> $DIR/disallowed_macros.rs:15:14 + --> $DIR/disallowed_macros.rs:18:14 | LL | #[derive(Serialize)] | ^^^^^^^^^ @@ -34,43 +34,43 @@ LL | #[derive(Serialize)] = note: no serializing (from clippy.toml) error: use of a disallowed macro `macros::expr` - --> $DIR/disallowed_macros.rs:18:13 + --> $DIR/disallowed_macros.rs:21:13 | LL | let _ = macros::expr!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::stmt` - --> $DIR/disallowed_macros.rs:19:5 + --> $DIR/disallowed_macros.rs:22:5 | LL | macros::stmt!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::pat` - --> $DIR/disallowed_macros.rs:20:9 + --> $DIR/disallowed_macros.rs:23:9 | LL | let macros::pat!() = 1; | ^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::ty` - --> $DIR/disallowed_macros.rs:21:12 + --> $DIR/disallowed_macros.rs:24:12 | LL | let _: macros::ty!() = ""; | ^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:22:5 + --> $DIR/disallowed_macros.rs:25:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::binop` - --> $DIR/disallowed_macros.rs:23:13 + --> $DIR/disallowed_macros.rs:26:13 | LL | let _ = macros::binop!(1); | ^^^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::attr` - --> $DIR/disallowed_macros.rs:28:1 + --> $DIR/disallowed_macros.rs:31:1 | LL | / macros::attr! { LL | | struct S; @@ -78,22 +78,28 @@ LL | | } | |_^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:33:5 + --> $DIR/disallowed_macros.rs:36:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:37:5 + --> $DIR/disallowed_macros.rs:40:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:41:5 + --> $DIR/disallowed_macros.rs:44:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ -error: aborting due to 15 previous errors +error: use of a disallowed macro `proc_macros::Derive` + --> $DIR/disallowed_macros.rs:47:10 + | +LL | #[derive(Derive)] + | ^^^^^^ + +error: aborting due to 16 previous errors From d1acbf576e704dca5da757dabfe49248028ff18c Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 11 Feb 2024 00:17:21 +0100 Subject: [PATCH 041/417] extract supertrait collection to separate function --- clippy_lints/src/implied_bounds_in_impls.rs | 156 ++++++++++---------- 1 file changed, 80 insertions(+), 76 deletions(-) diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index fab8ffedb9493..3527a39e2da84 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -1,16 +1,17 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_errors::{Applicability, SuggestionStyle}; -use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::def_id::DefId; use rustc_hir::intravisit::FnKind; use rustc_hir::{ - Body, FnDecl, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind, ItemKind, TraitBoundModifier, TraitItem, - TraitItemKind, TyKind, + Body, FnDecl, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind, ItemKind, OpaqueTy, TraitBoundModifier, + TraitItem, TraitItemKind, TyKind, TypeBinding, }; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, ClauseKind, Generics, Ty, TyCtxt}; use rustc_session::declare_lint_pass; +use rustc_span::def_id::LocalDefId; use rustc_span::Span; declare_clippy_lint! { @@ -50,20 +51,17 @@ declare_clippy_lint! { } declare_lint_pass!(ImpliedBoundsInImpls => [IMPLIED_BOUNDS_IN_IMPLS]); -#[allow(clippy::too_many_arguments)] fn emit_lint( cx: &LateContext<'_>, poly_trait: &rustc_hir::PolyTraitRef<'_>, opaque_ty: &rustc_hir::OpaqueTy<'_>, index: usize, - // The bindings that were implied + // The bindings that were implied, used for suggestion purposes since removing a bound with associated types + // means we might need to then move it to a different bound implied_bindings: &[rustc_hir::TypeBinding<'_>], - // The original bindings that `implied_bindings` are implied from - implied_by_bindings: &[rustc_hir::TypeBinding<'_>], - implied_by_args: &[GenericArg<'_>], - implied_by_span: Span, + bound: &ImplTraitBound<'_>, ) { - let implied_by = snippet(cx, implied_by_span, ".."); + let implied_by = snippet(cx, bound.impl_trait_bound_span, ".."); span_lint_and_then( cx, @@ -93,17 +91,17 @@ fn emit_lint( // If we're going to suggest removing `Deref<..>`, we'll need to put `` on `DerefMut` let omitted_assoc_tys: Vec<_> = implied_bindings .iter() - .filter(|binding| !implied_by_bindings.iter().any(|b| b.ident == binding.ident)) + .filter(|binding| !bound.bindings.iter().any(|b| b.ident == binding.ident)) .collect(); if !omitted_assoc_tys.is_empty() { // `<>` needs to be added if there aren't yet any generic arguments or bindings - let needs_angle_brackets = implied_by_args.is_empty() && implied_by_bindings.is_empty(); - let insert_span = match (implied_by_args, implied_by_bindings) { + let needs_angle_brackets = bound.args.is_empty() && bound.bindings.is_empty(); + let insert_span = match (bound.args, bound.bindings) { ([.., arg], [.., binding]) => arg.span().max(binding.span).shrink_to_hi(), ([.., arg], []) => arg.span().shrink_to_hi(), ([], [.., binding]) => binding.span.shrink_to_hi(), - ([], []) => implied_by_span.shrink_to_hi(), + ([], []) => bound.impl_trait_bound_span.shrink_to_hi(), }; let mut associated_tys_sugg = if needs_angle_brackets { @@ -223,42 +221,64 @@ fn is_same_generics<'tcx>( }) } +struct ImplTraitBound<'tcx> { + /// The span of the bound in the `impl Trait` type + impl_trait_bound_span: Span, + /// The predicates defined in the trait referenced by this bound + predicates: &'tcx [(ty::Clause<'tcx>, Span)], + /// The `DefId` of the trait being referenced by this bound + trait_def_id: DefId, + /// The generic arguments on the `impl Trait` bound + args: &'tcx [GenericArg<'tcx>], + /// The associated types on this bound + bindings: &'tcx [TypeBinding<'tcx>], +} + +/// Given an `impl Trait` type, gets all the supertraits from each bound ("implied bounds"). +/// +/// For `impl Deref + DerefMut + Eq` this returns `[Deref, PartialEq]`. +/// The `Deref` comes from `DerefMut` because `trait DerefMut: Deref {}`, and `PartialEq` comes from +/// `Eq`. +fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, opaque_ty: &OpaqueTy<'tcx>) -> Vec> { + opaque_ty + .bounds + .iter() + .filter_map(|bound| { + if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound + && let [.., path] = poly_trait.trait_ref.path.segments + && poly_trait.bound_generic_params.is_empty() + && let Some(trait_def_id) = path.res.opt_def_id() + && let predicates = cx.tcx.super_predicates_of(trait_def_id).predicates + // If the trait has no supertrait, there is no need to collect anything from that bound + && !predicates.is_empty() + { + Some(ImplTraitBound { + predicates, + args: path.args.map_or([].as_slice(), |p| p.args), + bindings: path.args.map_or([].as_slice(), |p| p.bindings), + trait_def_id, + impl_trait_bound_span: bound.span(), + }) + } else { + None + } + }) + .collect() +} + fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { if let FnRetTy::Return(ty) = decl.output - &&let TyKind::OpaqueDef(item_id, ..) = ty.kind + && let TyKind::OpaqueDef(item_id, ..) = ty.kind && let item = cx.tcx.hir().item(item_id) && let ItemKind::OpaqueTy(opaque_ty) = item.kind // Very often there is only a single bound, e.g. `impl Deref<..>`, in which case // we can avoid doing a bunch of stuff unnecessarily. && opaque_ty.bounds.len() > 1 { - // Get all the (implied) trait predicates in the bounds. - // For `impl Deref + DerefMut` this will contain [`Deref`]. - // The implied `Deref` comes from `DerefMut` because `trait DerefMut: Deref {}`. - // N.B. (G)ATs are fine to disregard, because they must be the same for all of its supertraits. - // Example: - // `impl Deref + DerefMut` is not allowed. - // `DerefMut::Target` needs to match `Deref::Target`. - let implied_bounds: Vec<_> = opaque_ty - .bounds - .iter() - .filter_map(|bound| { - if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound - && let [.., path] = poly_trait.trait_ref.path.segments - && poly_trait.bound_generic_params.is_empty() - && let Some(trait_def_id) = path.res.opt_def_id() - && let predicates = cx.tcx.super_predicates_of(trait_def_id).predicates - && !predicates.is_empty() - // If the trait has no supertrait, there is nothing to add. - { - Some((bound.span(), path, predicates, trait_def_id)) - } else { - None - } - }) - .collect(); + let supertraits = collect_supertrait_bounds(cx, opaque_ty); - // Lint all bounds in the `impl Trait` type that are also in the `implied_bounds` vec. + // Lint all bounds in the `impl Trait` type that we've previously also seen in the set of + // supertraits of each of the bounds. // This involves some extra logic when generic arguments are present, since // simply comparing trait `DefId`s won't be enough. We also need to compare the generics. for (index, bound) in opaque_ty.bounds.iter().enumerate() { @@ -267,42 +287,26 @@ fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { && let implied_args = path.args.map_or([].as_slice(), |a| a.args) && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() - && let Some((implied_by_span, implied_by_args, implied_by_bindings)) = - implied_bounds - .iter() - .find_map(|&(span, implied_by_path, preds, implied_by_def_id)| { - let implied_by_args = implied_by_path.args.map_or([].as_slice(), |a| a.args); - let implied_by_bindings = implied_by_path.args.map_or([].as_slice(), |a| a.bindings); - - preds.iter().find_map(|(clause, _)| { - if let ClauseKind::Trait(tr) = clause.kind().skip_binder() - && tr.def_id() == def_id - && is_same_generics( - cx.tcx, - tr.trait_ref.args, - implied_by_args, - implied_args, - implied_by_def_id, - def_id, - ) - { - Some((span, implied_by_args, implied_by_bindings)) - } else { - None - } - }) - }) + && let Some(bound) = supertraits.iter().find(|bound| { + bound.predicates.iter().any(|(clause, _)| { + if let ClauseKind::Trait(tr) = clause.kind().skip_binder() + && tr.def_id() == def_id + { + is_same_generics( + cx.tcx, + tr.trait_ref.args, + bound.args, + implied_args, + bound.trait_def_id, + def_id, + ) + } else { + false + } + }) + }) { - emit_lint( - cx, - poly_trait, - opaque_ty, - index, - implied_bindings, - implied_by_bindings, - implied_by_args, - implied_by_span, - ); + emit_lint(cx, poly_trait, opaque_ty, index, implied_bindings, bound); } } } From a38f44ca93bc5e77b8d26bd2884c8b1f84281ca6 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 11 Feb 2024 00:19:58 +0100 Subject: [PATCH 042/417] extract finding implied bound to separate function --- clippy_lints/src/implied_bounds_in_impls.rs | 58 +++++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index 3527a39e2da84..cc6ece45fcdba 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -61,7 +61,7 @@ fn emit_lint( implied_bindings: &[rustc_hir::TypeBinding<'_>], bound: &ImplTraitBound<'_>, ) { - let implied_by = snippet(cx, bound.impl_trait_bound_span, ".."); + let implied_by = snippet(cx, bound.span, ".."); span_lint_and_then( cx, @@ -101,7 +101,7 @@ fn emit_lint( ([.., arg], [.., binding]) => arg.span().max(binding.span).shrink_to_hi(), ([.., arg], []) => arg.span().shrink_to_hi(), ([], [.., binding]) => binding.span.shrink_to_hi(), - ([], []) => bound.impl_trait_bound_span.shrink_to_hi(), + ([], []) => bound.span.shrink_to_hi(), }; let mut associated_tys_sugg = if needs_angle_brackets { @@ -223,8 +223,9 @@ fn is_same_generics<'tcx>( struct ImplTraitBound<'tcx> { /// The span of the bound in the `impl Trait` type - impl_trait_bound_span: Span, - /// The predicates defined in the trait referenced by this bound + span: Span, + /// The predicates defined in the trait referenced by this bound. This also contains the actual + /// supertrait bounds predicates: &'tcx [(ty::Clause<'tcx>, Span)], /// The `DefId` of the trait being referenced by this bound trait_def_id: DefId, @@ -257,7 +258,7 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, opaque_ty: &OpaqueTy< args: path.args.map_or([].as_slice(), |p| p.args), bindings: path.args.map_or([].as_slice(), |p| p.bindings), trait_def_id, - impl_trait_bound_span: bound.span(), + span: bound.span(), }) } else { None @@ -266,6 +267,34 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, opaque_ty: &OpaqueTy< .collect() } +/// Given a bound in an `impl Trait` type, looks for a trait in the set of supertraits (previously +/// collected in [`collect_supertrait_bounds`]) that matches (same trait and generic arguments). +fn find_bound_in_supertraits<'a, 'tcx>( + cx: &LateContext<'tcx>, + trait_def_id: DefId, + args: &'tcx [GenericArg<'tcx>], + bounds: &'a [ImplTraitBound<'tcx>], +) -> Option<&'a ImplTraitBound<'tcx>> { + bounds.iter().find(|bound| { + bound.predicates.iter().any(|(clause, _)| { + if let ClauseKind::Trait(tr) = clause.kind().skip_binder() + && tr.def_id() == trait_def_id + { + is_same_generics( + cx.tcx, + tr.trait_ref.args, + bound.args, + args, + bound.trait_def_id, + trait_def_id, + ) + } else { + false + } + }) + }) +} + fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { if let FnRetTy::Return(ty) = decl.output && let TyKind::OpaqueDef(item_id, ..) = ty.kind @@ -287,24 +316,7 @@ fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { && let implied_args = path.args.map_or([].as_slice(), |a| a.args) && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() - && let Some(bound) = supertraits.iter().find(|bound| { - bound.predicates.iter().any(|(clause, _)| { - if let ClauseKind::Trait(tr) = clause.kind().skip_binder() - && tr.def_id() == def_id - { - is_same_generics( - cx.tcx, - tr.trait_ref.args, - bound.args, - implied_args, - bound.trait_def_id, - def_id, - ) - } else { - false - } - }) - }) + && let Some(bound) = find_bound_in_supertraits(cx, def_id, implied_args, &supertraits) { emit_lint(cx, poly_trait, opaque_ty, index, implied_bindings, bound); } From 0de367748c41af843b4989d4039269ac2092c903 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 10 Feb 2024 18:59:47 -0800 Subject: [PATCH 043/417] Fix typo Co-authored-by: Benjamin Peter <145429680+benjamin-nw@users.noreply.github.com> --- library/std/src/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index e662b26316b75..a46ddfd949170 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -451,7 +451,7 @@ pub struct SplitPaths<'a> { /// /// # Panics /// -/// This will panic on systems where theere is no delimited `PATH` variable, +/// This will panic on systems where there is no delimited `PATH` variable, /// such as UEFI. /// /// # Examples From a595a2c98b37e1bf2081841e41942693ab336b4c Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sun, 11 Feb 2024 04:22:32 -0500 Subject: [PATCH 044/417] Minor refactor format-impls * Move all linting logic into a single format implementations struct This should help with the future format-args improvements. TODO: do the same with format_args.rs, perhaps in the same PR --- clippy_lints/src/format_impl.rs | 203 +++++++++++++++++--------------- 1 file changed, 106 insertions(+), 97 deletions(-) diff --git a/clippy_lints/src/format_impl.rs b/clippy_lints/src/format_impl.rs index 9360eb1fa91ad..93517076cda01 100644 --- a/clippy_lints/src/format_impl.rs +++ b/clippy_lints/src/format_impl.rs @@ -7,7 +7,7 @@ use rustc_hir::{Expr, ExprKind, Impl, ImplItem, ImplItemKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{sym, Symbol}; declare_clippy_lint! { /// ### What it does @@ -119,123 +119,132 @@ impl<'tcx> LateLintPass<'tcx> for FormatImpl { } fn check_impl_item_post(&mut self, cx: &LateContext<'_>, impl_item: &ImplItem<'_>) { - // Assume no nested Impl of Debug and Display within eachother + // Assume no nested Impl of Debug and Display within each other if is_format_trait_impl(cx, impl_item).is_some() { self.format_trait_impl = None; } } fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - let Some(format_trait_impl) = self.format_trait_impl else { - return; - }; - - if format_trait_impl.name == sym::Display { - check_to_string_in_display(cx, expr); + if let Some(format_trait_impl) = self.format_trait_impl { + let linter = FormatImplExpr { + cx, + expr, + format_trait_impl, + }; + linter.check_to_string_in_display(); + linter.check_self_in_format_args(); + linter.check_print_in_format_impl(); } - - check_self_in_format_args(cx, expr, format_trait_impl); - check_print_in_format_impl(cx, expr, format_trait_impl); } } -fn check_to_string_in_display(cx: &LateContext<'_>, expr: &Expr<'_>) { - if let ExprKind::MethodCall(path, self_arg, ..) = expr.kind - // Get the hir_id of the object we are calling the method on - // Is the method to_string() ? - && path.ident.name == sym::to_string - // Is the method a part of the ToString trait? (i.e. not to_string() implemented - // separately) - && let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) - && is_diag_trait_item(cx, expr_def_id, sym::ToString) - // Is the method is called on self - && let ExprKind::Path(QPath::Resolved(_, path)) = self_arg.kind - && let [segment] = path.segments - && segment.ident.name == kw::SelfLower - { - span_lint( - cx, - RECURSIVE_FORMAT_IMPL, - expr.span, - "using `self.to_string` in `fmt::Display` implementation will cause infinite recursion", - ); - } +struct FormatImplExpr<'a, 'tcx> { + cx: &'a LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, + format_trait_impl: FormatTraitNames, } -fn check_self_in_format_args<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, impl_trait: FormatTraitNames) { - // Check each arg in format calls - do we ever use Display on self (directly or via deref)? - if let Some(outer_macro) = root_macro_call_first_node(cx, expr) - && let macro_def_id = outer_macro.def_id - && is_format_macro(cx, macro_def_id) - && let Some(format_args) = find_format_args(cx, expr, outer_macro.expn) - { - for piece in &format_args.template { - if let FormatArgsPiece::Placeholder(placeholder) = piece - && let trait_name = match placeholder.format_trait { - FormatTrait::Display => sym::Display, - FormatTrait::Debug => sym::Debug, - FormatTrait::LowerExp => sym!(LowerExp), - FormatTrait::UpperExp => sym!(UpperExp), - FormatTrait::Octal => sym!(Octal), - FormatTrait::Pointer => sym::Pointer, - FormatTrait::Binary => sym!(Binary), - FormatTrait::LowerHex => sym!(LowerHex), - FormatTrait::UpperHex => sym!(UpperHex), +impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> { + fn check_to_string_in_display(&self) { + if self.format_trait_impl.name == sym::Display + && let ExprKind::MethodCall(path, self_arg, ..) = self.expr.kind + // Get the hir_id of the object we are calling the method on + // Is the method to_string() ? + && path.ident.name == sym::to_string + // Is the method a part of the ToString trait? (i.e. not to_string() implemented + // separately) + && let Some(expr_def_id) = self.cx.typeck_results().type_dependent_def_id(self.expr.hir_id) + && is_diag_trait_item(self.cx, expr_def_id, sym::ToString) + // Is the method is called on self + && let ExprKind::Path(QPath::Resolved(_, path)) = self_arg.kind + && let [segment] = path.segments + && segment.ident.name == kw::SelfLower + { + span_lint( + self.cx, + RECURSIVE_FORMAT_IMPL, + self.expr.span, + "using `self.to_string` in `fmt::Display` implementation will cause infinite recursion", + ); + } + } + + fn check_self_in_format_args(&self) { + // Check each arg in format calls - do we ever use Display on self (directly or via deref)? + if let Some(outer_macro) = root_macro_call_first_node(self.cx, self.expr) + && let macro_def_id = outer_macro.def_id + && is_format_macro(self.cx, macro_def_id) + && let Some(format_args) = find_format_args(self.cx, self.expr, outer_macro.expn) + { + for piece in &format_args.template { + if let FormatArgsPiece::Placeholder(placeholder) = piece + && let trait_name = match placeholder.format_trait { + FormatTrait::Display => sym::Display, + FormatTrait::Debug => sym::Debug, + FormatTrait::LowerExp => sym!(LowerExp), + FormatTrait::UpperExp => sym!(UpperExp), + FormatTrait::Octal => sym!(Octal), + FormatTrait::Pointer => sym::Pointer, + FormatTrait::Binary => sym!(Binary), + FormatTrait::LowerHex => sym!(LowerHex), + FormatTrait::UpperHex => sym!(UpperHex), + } + && trait_name == self.format_trait_impl.name + && let Ok(index) = placeholder.argument.index + && let Some(arg) = format_args.arguments.all_args().get(index) + && let Ok(arg_expr) = find_format_arg_expr(self.expr, arg) + { + self.check_format_arg_self(arg_expr); } - && trait_name == impl_trait.name - && let Ok(index) = placeholder.argument.index - && let Some(arg) = format_args.arguments.all_args().get(index) - && let Ok(arg_expr) = find_format_arg_expr(expr, arg) - { - check_format_arg_self(cx, expr.span, arg_expr, impl_trait); } } } -} -fn check_format_arg_self(cx: &LateContext<'_>, span: Span, arg: &Expr<'_>, impl_trait: FormatTraitNames) { - // Handle multiple dereferencing of references e.g. &&self - // Handle dereference of &self -> self that is equivalent (i.e. via *self in fmt() impl) - // Since the argument to fmt is itself a reference: &self - let reference = peel_ref_operators(cx, arg); - let map = cx.tcx.hir(); - // Is the reference self? - if path_to_local(reference).map(|x| map.name(x)) == Some(kw::SelfLower) { - let FormatTraitNames { name, .. } = impl_trait; - span_lint( - cx, - RECURSIVE_FORMAT_IMPL, - span, - &format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"), - ); + fn check_format_arg_self(&self, arg: &Expr<'_>) { + // Handle multiple dereferencing of references e.g. &&self + // Handle dereference of &self -> self that is equivalent (i.e. via *self in fmt() impl) + // Since the argument to fmt is itself a reference: &self + let reference = peel_ref_operators(self.cx, arg); + let map = self.cx.tcx.hir(); + // Is the reference self? + if path_to_local(reference).map(|x| map.name(x)) == Some(kw::SelfLower) { + let FormatTraitNames { name, .. } = self.format_trait_impl; + span_lint( + self.cx, + RECURSIVE_FORMAT_IMPL, + self.expr.span, + &format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"), + ); + } } -} -fn check_print_in_format_impl(cx: &LateContext<'_>, expr: &Expr<'_>, impl_trait: FormatTraitNames) { - if let Some(macro_call) = root_macro_call_first_node(cx, expr) - && let Some(name) = cx.tcx.get_diagnostic_name(macro_call.def_id) - { - let replacement = match name { - sym::print_macro | sym::eprint_macro => "write", - sym::println_macro | sym::eprintln_macro => "writeln", - _ => return, - }; + fn check_print_in_format_impl(&self) { + if let Some(macro_call) = root_macro_call_first_node(self.cx, self.expr) + && let Some(name) = self.cx.tcx.get_diagnostic_name(macro_call.def_id) + { + let replacement = match name { + sym::print_macro | sym::eprint_macro => "write", + sym::println_macro | sym::eprintln_macro => "writeln", + _ => return, + }; - let name = name.as_str().strip_suffix("_macro").unwrap(); + let name = name.as_str().strip_suffix("_macro").unwrap(); - span_lint_and_sugg( - cx, - PRINT_IN_FORMAT_IMPL, - macro_call.span, - &format!("use of `{name}!` in `{}` impl", impl_trait.name), - "replace with", - if let Some(formatter_name) = impl_trait.formatter_name { - format!("{replacement}!({formatter_name}, ..)") - } else { - format!("{replacement}!(..)") - }, - Applicability::HasPlaceholders, - ); + span_lint_and_sugg( + self.cx, + PRINT_IN_FORMAT_IMPL, + macro_call.span, + &format!("use of `{name}!` in `{}` impl", self.format_trait_impl.name), + "replace with", + if let Some(formatter_name) = self.format_trait_impl.formatter_name { + format!("{replacement}!({formatter_name}, ..)") + } else { + format!("{replacement}!(..)") + }, + Applicability::HasPlaceholders, + ); + } } } From 67bdb0e11c27df7c8f089976141a1a7526903743 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:57:26 +0100 Subject: [PATCH 045/417] [`incompatible_msrv`]: allow expressions that come from desugaring --- clippy_lints/src/incompatible_msrv.rs | 7 ++++++- tests/ui/incompatible_msrv.rs | 8 ++++++++ tests/ui/incompatible_msrv.stderr | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/incompatible_msrv.rs b/clippy_lints/src/incompatible_msrv.rs index 475938d6adf01..cd000fcd18449 100644 --- a/clippy_lints/src/incompatible_msrv.rs +++ b/clippy_lints/src/incompatible_msrv.rs @@ -9,7 +9,7 @@ use rustc_middle::ty::TyCtxt; use rustc_semver::RustcVersion; use rustc_session::impl_lint_pass; use rustc_span::def_id::DefId; -use rustc_span::Span; +use rustc_span::{ExpnKind, Span}; declare_clippy_lint! { /// ### What it does @@ -91,6 +91,11 @@ impl IncompatibleMsrv { if self.msrv.meets(version) || is_in_test_function(cx.tcx, node) { return; } + if let ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) = span.ctxt().outer_expn_data().kind { + // Desugared expressions get to cheat and stability is ignored. + // Intentionally not using `.from_expansion()`, since we do still care about macro expansions + return; + } self.emit_lint_for(cx, span, version); } diff --git a/tests/ui/incompatible_msrv.rs b/tests/ui/incompatible_msrv.rs index 0fa047c7102aa..8ef1f554bc35d 100644 --- a/tests/ui/incompatible_msrv.rs +++ b/tests/ui/incompatible_msrv.rs @@ -4,6 +4,7 @@ use std::collections::hash_map::Entry; use std::collections::HashMap; +use std::future::Future; use std::thread::sleep; use std::time::Duration; @@ -25,4 +26,11 @@ fn test() { sleep(Duration::new(1, 0)); } +#[clippy::msrv = "1.63.0"] +async fn issue12273(v: impl Future) { + // `.await` desugaring has a call to `IntoFuture::into_future` marked #[stable(since = "1.64.0")], + // but its stability is ignored + v.await; +} + fn main() {} diff --git a/tests/ui/incompatible_msrv.stderr b/tests/ui/incompatible_msrv.stderr index bd5ecd6ed2ffb..9e1c81b82bcd0 100644 --- a/tests/ui/incompatible_msrv.stderr +++ b/tests/ui/incompatible_msrv.stderr @@ -1,5 +1,5 @@ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.10.0` - --> $DIR/incompatible_msrv.rs:12:39 + --> $DIR/incompatible_msrv.rs:13:39 | LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); | ^^^^^ @@ -8,13 +8,13 @@ LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); = help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]` error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.12.0` - --> $DIR/incompatible_msrv.rs:15:11 + --> $DIR/incompatible_msrv.rs:16:11 | LL | v.into_key(); | ^^^^^^^^^^ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.4.0` - --> $DIR/incompatible_msrv.rs:19:5 + --> $DIR/incompatible_msrv.rs:20:5 | LL | sleep(Duration::new(1, 0)); | ^^^^^ From 2b89cd4bf6f47a6d7724c17dd270fa6a93db8ea7 Mon Sep 17 00:00:00 2001 From: Lukas Eschbacher Date: Sun, 11 Feb 2024 06:49:11 +0100 Subject: [PATCH 046/417] fix broken URL in `Lint Configuration` Signed-off-by: Lukas Eschbacher --- book/src/lint_configuration.md | 2 +- clippy_config/src/conf.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index f2357e2b5de92..214a60d3bfdf7 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -278,7 +278,7 @@ The minimum number of struct fields for the lints about field names to trigger --- **Affected lints:** -* [`struct_variant_names`](https://rust-lang.github.io/rust-clippy/master/index.html#struct_variant_names) +* [`struct_field_names`](https://rust-lang.github.io/rust-clippy/master/index.html#struct_field_names) ## `enum-variant-size-threshold` diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs index 9741b94d50413..6a1d7cb852a2a 100644 --- a/clippy_config/src/conf.rs +++ b/clippy_config/src/conf.rs @@ -325,7 +325,7 @@ define_Conf! { /// /// The minimum number of enum variants for the lints about variant names to trigger (enum_variant_name_threshold: u64 = 3), - /// Lint: STRUCT_VARIANT_NAMES. + /// Lint: STRUCT_FIELD_NAMES. /// /// The minimum number of struct fields for the lints about field names to trigger (struct_field_name_threshold: u64 = 3), From 4cc7b7e09287c1a4908d73c1104b222858193e85 Mon Sep 17 00:00:00 2001 From: J-ZhengLi Date: Mon, 12 Feb 2024 04:16:11 +0800 Subject: [PATCH 047/417] stop linting [`blocks_in_conditions`] on `match` on proc macros --- clippy_lints/src/blocks_in_conditions.rs | 4 ++-- tests/ui/blocks_in_conditions.fixed | 2 +- tests/ui/blocks_in_conditions.stderr | 8 +------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/blocks_in_conditions.rs b/clippy_lints/src/blocks_in_conditions.rs index ff4dffd06079f..eae87db26c6fd 100644 --- a/clippy_lints/src/blocks_in_conditions.rs +++ b/clippy_lints/src/blocks_in_conditions.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_block_with_applicability; use clippy_utils::ty::implements_trait; use clippy_utils::visitors::{for_each_expr, Descend}; -use clippy_utils::{get_parent_expr, higher}; +use clippy_utils::{get_parent_expr, higher, is_from_proc_macro}; use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::{BlockCheckMode, Expr, ExprKind, MatchSource}; @@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions { } } else { let span = block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span); - if span.from_expansion() || expr.span.from_expansion() { + if span.from_expansion() || expr.span.from_expansion() || is_from_proc_macro(cx, cond) { return; } // move block higher diff --git a/tests/ui/blocks_in_conditions.fixed b/tests/ui/blocks_in_conditions.fixed index ac1ad68ffc233..caf29e23d5450 100644 --- a/tests/ui/blocks_in_conditions.fixed +++ b/tests/ui/blocks_in_conditions.fixed @@ -104,7 +104,7 @@ fn issue_12162() { mod issue_12016 { #[proc_macro_attr::fake_desugar_await] pub async fn await_becomes_block() -> i32 { - let res = await; match res { + match Some(1).await { Some(1) => 2, Some(2) => 3, _ => 0, diff --git a/tests/ui/blocks_in_conditions.stderr b/tests/ui/blocks_in_conditions.stderr index cb2f6da3516c3..4d3efb4ffd1fe 100644 --- a/tests/ui/blocks_in_conditions.stderr +++ b/tests/ui/blocks_in_conditions.stderr @@ -53,11 +53,5 @@ LL + opt LL ~ }; match res { | -error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions.rs:107:9 - | -LL | match Some(1).await { - | ^^^^^^^^^^^^^^^^^^^ help: try: `let res = await; match res` - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors From 92616c0aaac07bf589a2d40502dd5dec804e8318 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Mon, 27 Nov 2023 00:43:47 +0100 Subject: [PATCH 048/417] [`implied_bounds_in_impls`]: avoid linting on overlapping associated types --- clippy_lints/src/implied_bounds_in_impls.rs | 9 +++++ tests/ui/implied_bounds_in_impls.fixed | 29 ++++++++++++++++ tests/ui/implied_bounds_in_impls.rs | 29 ++++++++++++++++ tests/ui/implied_bounds_in_impls.stderr | 38 ++++++++++++++++++++- 4 files changed, 104 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index cc6ece45fcdba..174db30a7cd49 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -317,6 +317,15 @@ fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() && let Some(bound) = find_bound_in_supertraits(cx, def_id, implied_args, &supertraits) + // If the implied bound has a type binding that also exists in the implied-by trait, + // then we shouldn't lint. See #11880 for an example. + && let assocs = cx.tcx.associated_items(bound.trait_def_id) + && !implied_bindings.iter().any(|binding| { + assocs + .filter_by_name_unhygienic(binding.ident.name) + .next() + .is_some_and(|assoc| assoc.kind == ty::AssocKind::Type) + }) { emit_lint(cx, poly_trait, opaque_ty, index, implied_bindings, bound); } diff --git a/tests/ui/implied_bounds_in_impls.fixed b/tests/ui/implied_bounds_in_impls.fixed index fa117aaddcd60..18f29e900c15f 100644 --- a/tests/ui/implied_bounds_in_impls.fixed +++ b/tests/ui/implied_bounds_in_impls.fixed @@ -121,4 +121,33 @@ mod issue11435 { fn f3() -> impl Trait4 {} } +fn issue11880() { + trait X { + type T; + type U; + } + trait Y: X { + type T; + type V; + } + impl X for () { + type T = i32; + type U = String; + } + impl Y for () { + type T = u32; + type V = Vec; + } + + // Can't constrain `X::T` through `Y` + fn f() -> impl X + Y {} + fn f2() -> impl X + Y {} + + // X::T is never constrained in the first place, so it can be omitted + // and left unconstrained + fn f3() -> impl Y {} + fn f4() -> impl Y {} + fn f5() -> impl Y {} +} + fn main() {} diff --git a/tests/ui/implied_bounds_in_impls.rs b/tests/ui/implied_bounds_in_impls.rs index c96aac151a7d0..b7951e7dfba8b 100644 --- a/tests/ui/implied_bounds_in_impls.rs +++ b/tests/ui/implied_bounds_in_impls.rs @@ -121,4 +121,33 @@ mod issue11435 { fn f3() -> impl Trait3 + Trait4 {} } +fn issue11880() { + trait X { + type T; + type U; + } + trait Y: X { + type T; + type V; + } + impl X for () { + type T = i32; + type U = String; + } + impl Y for () { + type T = u32; + type V = Vec; + } + + // Can't constrain `X::T` through `Y` + fn f() -> impl X + Y {} + fn f2() -> impl X + Y {} + + // X::T is never constrained in the first place, so it can be omitted + // and left unconstrained + fn f3() -> impl X + Y {} + fn f4() -> impl X + Y {} + fn f5() -> impl X + Y {} +} + fn main() {} diff --git a/tests/ui/implied_bounds_in_impls.stderr b/tests/ui/implied_bounds_in_impls.stderr index fb44f2aba1744..3b09e4582e30d 100644 --- a/tests/ui/implied_bounds_in_impls.stderr +++ b/tests/ui/implied_bounds_in_impls.stderr @@ -192,5 +192,41 @@ LL - fn f3() -> impl Trait3 + Trait4 impl Trait4 {} | -error: aborting due to 16 previous errors +error: this bound is already specified as the supertrait of `Y` + --> $DIR/implied_bounds_in_impls.rs:148:21 + | +LL | fn f3() -> impl X + Y {} + | ^ + | +help: try removing this bound + | +LL - fn f3() -> impl X + Y {} +LL + fn f3() -> impl Y {} + | + +error: this bound is already specified as the supertrait of `Y` + --> $DIR/implied_bounds_in_impls.rs:149:21 + | +LL | fn f4() -> impl X + Y {} + | ^ + | +help: try removing this bound + | +LL - fn f4() -> impl X + Y {} +LL + fn f4() -> impl Y {} + | + +error: this bound is already specified as the supertrait of `Y` + --> $DIR/implied_bounds_in_impls.rs:150:21 + | +LL | fn f5() -> impl X + Y {} + | ^^^^^^^^^^^^^ + | +help: try removing this bound + | +LL - fn f5() -> impl X + Y {} +LL + fn f5() -> impl Y {} + | + +error: aborting due to 19 previous errors From a18e0a11f7a0a62a7fcaec178aad34f880b659dc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 8 Feb 2024 22:36:41 +0100 Subject: [PATCH 049/417] Extend `NONMINIMAL_BOOL` lint --- clippy_lints/src/booleans.rs | 26 ++++++++++++++++++++++++++ tests/ui/nonminimal_bool.rs | 8 ++++++++ tests/ui/nonminimal_bool.stderr | 26 +++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 2d1c250ace905..3c17f65f0d3c1 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -85,6 +85,32 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool { ) { NonminimalBoolVisitor { cx }.visit_body(body); } + + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + if let ExprKind::Unary(UnOp::Not, sub) = expr.kind + && !expr.span.from_expansion() + && let ExprKind::Binary(op, left, right) = sub.kind + { + let new_op = match op.node { + BinOpKind::Eq => "!=", + BinOpKind::Ne => "==", + _ => return, + }; + let Some(left) = snippet_opt(cx, left.span) else { return }; + let Some(right) = snippet_opt(cx, right.span) else { + return; + }; + span_lint_and_sugg( + cx, + NONMINIMAL_BOOL, + expr.span, + "this boolean expression can be simplified", + "try", + format!("{left} {new_op} {right}"), + Applicability::MachineApplicable, + ); + } + } } struct NonminimalBoolVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs index f7c3df7066f7d..ee092b9aca69b 100644 --- a/tests/ui/nonminimal_bool.rs +++ b/tests/ui/nonminimal_bool.rs @@ -156,3 +156,11 @@ fn issue11932() { x % 3 == 0 }; } + +fn issue_5794() { + let a = 0; + if !(12 == a) {} //~ ERROR: this boolean expression can be simplified + if !(a == 12) {} //~ ERROR: this boolean expression can be simplified + if !(12 != a) {} //~ ERROR: this boolean expression can be simplified + if !(a != 12) {} //~ ERROR: this boolean expression can be simplified +} diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr index fd1568d94e3ec..856b5cd08691a 100644 --- a/tests/ui/nonminimal_bool.stderr +++ b/tests/ui/nonminimal_bool.stderr @@ -114,5 +114,29 @@ error: this boolean expression can be simplified LL | if matches!(true, true) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)` -error: aborting due to 13 previous errors +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:162:8 + | +LL | if !(12 == a) {} + | ^^^^^^^^^^ help: try: `12 != a` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:163:8 + | +LL | if !(a == 12) {} + | ^^^^^^^^^^ help: try: `a != 12` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:164:8 + | +LL | if !(12 != a) {} + | ^^^^^^^^^^ help: try: `12 == a` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:165:8 + | +LL | if !(a != 12) {} + | ^^^^^^^^^^ help: try: `a == 12` + +error: aborting due to 17 previous errors From 5e7c437d415871052fdd92f0d402ac9fd050fefa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 9 Feb 2024 20:47:31 +0100 Subject: [PATCH 050/417] Extend `NONMINIMAL_BOOL` to check inverted boolean values --- clippy_lints/src/booleans.rs | 124 ++++++++++++++++++++++++++------ tests/ui/bool_comparison.fixed | 2 +- tests/ui/bool_comparison.rs | 2 +- tests/ui/nonminimal_bool.rs | 9 +++ tests/ui/nonminimal_bool.stderr | 77 +++++++++++++++++++- 5 files changed, 191 insertions(+), 23 deletions(-) diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 3c17f65f0d3c1..0d66f2d644d98 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -87,31 +87,115 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool { } fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { - if let ExprKind::Unary(UnOp::Not, sub) = expr.kind - && !expr.span.from_expansion() - && let ExprKind::Binary(op, left, right) = sub.kind - { - let new_op = match op.node { - BinOpKind::Eq => "!=", - BinOpKind::Ne => "==", - _ => return, + match expr.kind { + ExprKind::Unary(UnOp::Not, sub) => check_inverted_condition(cx, expr.span, sub), + // This check the case where an element in a boolean comparison is inverted, like: + // + // ``` + // let a = true; + // !a == false; + // ``` + ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq | BinOpKind::Ne) => { + check_inverted_bool_in_condition(cx, expr.span, op.node, left, right); + }, + _ => {}, + } + } +} + +fn inverted_bin_op_eq_str(op: BinOpKind) -> Option<&'static str> { + match op { + BinOpKind::Eq => Some("!="), + BinOpKind::Ne => Some("=="), + _ => None, + } +} + +fn bin_op_eq_str(op: BinOpKind) -> Option<&'static str> { + match op { + BinOpKind::Eq => Some("=="), + BinOpKind::Ne => Some("!="), + _ => None, + } +} + +fn check_inverted_condition(cx: &LateContext<'_>, expr_span: Span, sub_expr: &Expr<'_>) { + if !expr_span.from_expansion() + && let ExprKind::Binary(op, left, right) = sub_expr.kind + && let Some(left) = snippet_opt(cx, left.span) + && let Some(right) = snippet_opt(cx, right.span) + { + let Some(op) = inverted_bin_op_eq_str(op.node) else { + return; + }; + span_lint_and_sugg( + cx, + NONMINIMAL_BOOL, + expr_span, + "this boolean expression can be simplified", + "try", + format!("{left} {op} {right}",), + Applicability::MachineApplicable, + ); + } +} + +fn check_inverted_bool_in_condition( + cx: &LateContext<'_>, + expr_span: Span, + op: BinOpKind, + left: &Expr<'_>, + right: &Expr<'_>, +) { + if expr_span.from_expansion() + && (!cx.typeck_results().node_types()[left.hir_id].is_bool() + || !cx.typeck_results().node_types()[right.hir_id].is_bool()) + { + return; + } + + let suggestion = match (left.kind, right.kind) { + (ExprKind::Unary(UnOp::Not, left_sub), ExprKind::Unary(UnOp::Not, right_sub)) => { + let Some(left) = snippet_opt(cx, left_sub.span) else { + return; + }; + let Some(right) = snippet_opt(cx, right_sub.span) else { + return; + }; + let Some(op) = bin_op_eq_str(op) else { return }; + format!("{left} {op} {right}") + }, + (ExprKind::Unary(UnOp::Not, left_sub), _) => { + let Some(left) = snippet_opt(cx, left_sub.span) else { + return; }; - let Some(left) = snippet_opt(cx, left.span) else { return }; let Some(right) = snippet_opt(cx, right.span) else { return; }; - span_lint_and_sugg( - cx, - NONMINIMAL_BOOL, - expr.span, - "this boolean expression can be simplified", - "try", - format!("{left} {new_op} {right}"), - Applicability::MachineApplicable, - ); - } - } + let Some(op) = inverted_bin_op_eq_str(op) else { return }; + format!("{left} {op} {right}") + }, + (_, ExprKind::Unary(UnOp::Not, right_sub)) => { + let Some(left) = snippet_opt(cx, left.span) else { return }; + let Some(right) = snippet_opt(cx, right_sub.span) else { + return; + }; + let Some(op) = inverted_bin_op_eq_str(op) else { return }; + format!("{left} {op} {right}") + }, + _ => return, + }; + span_lint_and_sugg( + cx, + NONMINIMAL_BOOL, + expr_span, + "this boolean expression can be simplified", + "try", + suggestion, + Applicability::MachineApplicable, + ); } + struct NonminimalBoolVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, } diff --git a/tests/ui/bool_comparison.fixed b/tests/ui/bool_comparison.fixed index 02f1d09b83395..54bdf7f5d70a4 100644 --- a/tests/ui/bool_comparison.fixed +++ b/tests/ui/bool_comparison.fixed @@ -1,6 +1,6 @@ #![allow(clippy::needless_if)] #![warn(clippy::bool_comparison)] -#![allow(clippy::non_canonical_partial_ord_impl)] +#![allow(clippy::non_canonical_partial_ord_impl, clippy::nonminimal_bool)] fn main() { let x = true; diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index 5ef696d855eca..4fdf230524256 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -1,6 +1,6 @@ #![allow(clippy::needless_if)] #![warn(clippy::bool_comparison)] -#![allow(clippy::non_canonical_partial_ord_impl)] +#![allow(clippy::non_canonical_partial_ord_impl, clippy::nonminimal_bool)] fn main() { let x = true; diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs index ee092b9aca69b..908ef6cb2a02c 100644 --- a/tests/ui/nonminimal_bool.rs +++ b/tests/ui/nonminimal_bool.rs @@ -163,4 +163,13 @@ fn issue_5794() { if !(a == 12) {} //~ ERROR: this boolean expression can be simplified if !(12 != a) {} //~ ERROR: this boolean expression can be simplified if !(a != 12) {} //~ ERROR: this boolean expression can be simplified + + let b = true; + let c = false; + if !b == true {} //~ ERROR: this boolean expression can be simplified + if !b != true {} //~ ERROR: this boolean expression can be simplified + if true == !b {} //~ ERROR: this boolean expression can be simplified + if true != !b {} //~ ERROR: this boolean expression can be simplified + if !b == !c {} //~ ERROR: this boolean expression can be simplified + if !b != !c {} //~ ERROR: this boolean expression can be simplified } diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr index 856b5cd08691a..a317c8328d947 100644 --- a/tests/ui/nonminimal_bool.stderr +++ b/tests/ui/nonminimal_bool.stderr @@ -138,5 +138,80 @@ error: this boolean expression can be simplified LL | if !(a != 12) {} | ^^^^^^^^^^ help: try: `a == 12` -error: aborting due to 17 previous errors +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:169:8 + | +LL | if !b == true {} + | ^^^^^^^^^^ help: try: `b != true` + +error: this comparison might be written more concisely + --> $DIR/nonminimal_bool.rs:169:8 + | +LL | if !b == true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `b != true` + | + = note: `-D clippy::bool-comparison` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` + +error: equality checks against true are unnecessary + --> $DIR/nonminimal_bool.rs:169:8 + | +LL | if !b == true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!b` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:170:8 + | +LL | if !b != true {} + | ^^^^^^^^^^ help: try: `b == true` + +error: inequality checks against true can be replaced by a negation + --> $DIR/nonminimal_bool.rs:170:8 + | +LL | if !b != true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:171:8 + | +LL | if true == !b {} + | ^^^^^^^^^^ help: try: `true != b` + +error: this comparison might be written more concisely + --> $DIR/nonminimal_bool.rs:171:8 + | +LL | if true == !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `true != b` + +error: equality checks against true are unnecessary + --> $DIR/nonminimal_bool.rs:171:8 + | +LL | if true == !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!b` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:172:8 + | +LL | if true != !b {} + | ^^^^^^^^^^ help: try: `true == b` + +error: inequality checks against true can be replaced by a negation + --> $DIR/nonminimal_bool.rs:172:8 + | +LL | if true != !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:173:8 + | +LL | if !b == !c {} + | ^^^^^^^^ help: try: `b == c` + +error: this boolean expression can be simplified + --> $DIR/nonminimal_bool.rs:174:8 + | +LL | if !b != !c {} + | ^^^^^^^^ help: try: `b != c` + +error: aborting due to 29 previous errors From 4fbd5cc31fad26f5cb439ece09e634310c6868ae Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 11 Feb 2024 21:36:12 +0000 Subject: [PATCH 051/417] is_closure_like --- clippy_lints/src/redundant_locals.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/redundant_locals.rs b/clippy_lints/src/redundant_locals.rs index 700a5dd4a8511..6528a7b369f74 100644 --- a/clippy_lints/src/redundant_locals.rs +++ b/clippy_lints/src/redundant_locals.rs @@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals { fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_variable: HirId) -> bool { let closure_def_id = cx.tcx.hir().enclosing_body_owner(redefinition); - cx.tcx.is_closure_or_coroutine(closure_def_id.to_def_id()) + cx.tcx.is_closure_like(closure_def_id.to_def_id()) && cx.tcx.closure_captures(closure_def_id).iter().any(|c| { matches!(c.info.capture_kind, UpvarCapture::ByValue) && matches!(c.place.base, PlaceBase::Upvar(upvar) if upvar.var_path.hir_id == root_variable) From 83555914edf10727bab5a97113ce2b3faa9abb7b Mon Sep 17 00:00:00 2001 From: Gabriel Fernandes Date: Sun, 11 Feb 2024 21:11:13 -0300 Subject: [PATCH 052/417] [mem_replace_with_default] No longer triggers on unused expression --- clippy_lints/src/mem_replace.rs | 6 ++++-- tests/ui/mem_replace.fixed | 8 ++++++++ tests/ui/mem_replace.rs | 8 ++++++++ tests/ui/mem_replace.stderr | 10 +++++----- tests/ui/mem_replace_macro.rs | 4 ++-- tests/ui/mem_replace_macro.stderr | 6 +++--- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index fa4f4a47e38e2..1cdb7921f8166 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -3,7 +3,9 @@ use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lin use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_non_aggregate_primitive_type; -use clippy_utils::{is_default_equivalent, is_res_lang_ctor, path_res, peel_ref_operators, std_or_core}; +use clippy_utils::{ + is_default_equivalent, is_expr_used_or_unified, is_res_lang_ctor, path_res, peel_ref_operators, std_or_core, +}; use rustc_errors::Applicability; use rustc_hir::LangItem::OptionNone; use rustc_hir::{Expr, ExprKind}; @@ -232,7 +234,7 @@ impl<'tcx> LateLintPass<'tcx> for MemReplace { // Check that second argument is `Option::None` if is_res_lang_ctor(cx, path_res(cx, src), OptionNone) { check_replace_option_with_none(cx, dest, expr.span); - } else if self.msrv.meets(msrvs::MEM_TAKE) { + } else if self.msrv.meets(msrvs::MEM_TAKE) && is_expr_used_or_unified(cx.tcx, expr) { check_replace_with_default(cx, src, dest, expr.span); } check_replace_with_uninit(cx, src, dest, expr.span); diff --git a/tests/ui/mem_replace.fixed b/tests/ui/mem_replace.fixed index 453d0bcc57c53..78d8b3e9bce6b 100644 --- a/tests/ui/mem_replace.fixed +++ b/tests/ui/mem_replace.fixed @@ -71,6 +71,14 @@ fn dont_lint_primitive() { let _ = std::mem::replace(&mut pint, 0); } +// lint is disabled for expressions that are not used because changing to `take` is not the +// recommended fix. Additionally, the `replace` is #[must_use], so that lint will provide +// the correct suggestion +fn dont_lint_not_used() { + let mut s = String::from("foo"); + std::mem::replace(&mut s, String::default()); +} + fn main() { replace_option_with_none(); replace_with_default(); diff --git a/tests/ui/mem_replace.rs b/tests/ui/mem_replace.rs index 0c4e0f6032d8e..28915bf6daee8 100644 --- a/tests/ui/mem_replace.rs +++ b/tests/ui/mem_replace.rs @@ -71,6 +71,14 @@ fn dont_lint_primitive() { let _ = std::mem::replace(&mut pint, 0); } +// lint is disabled for expressions that are not used because changing to `take` is not the +// recommended fix. Additionally, the `replace` is #[must_use], so that lint will provide +// the correct suggestion +fn dont_lint_not_used() { + let mut s = String::from("foo"); + std::mem::replace(&mut s, String::default()); +} + fn main() { replace_option_with_none(); replace_with_default(); diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index ae5f4e5340a2a..c8ddf585fd2a5 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -119,31 +119,31 @@ LL | let _ = std::mem::replace(&mut slice, &[]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut slice)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:89:13 + --> $DIR/mem_replace.rs:97:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:119:13 + --> $DIR/mem_replace.rs:127:13 | LL | let _ = std::mem::replace(&mut f.0, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `f.0.take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:120:13 + --> $DIR/mem_replace.rs:128:13 | LL | let _ = std::mem::replace(&mut *f, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `(*f).take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:121:13 + --> $DIR/mem_replace.rs:129:13 | LL | let _ = std::mem::replace(&mut b.opt, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `b.opt.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:123:13 + --> $DIR/mem_replace.rs:131:13 | LL | let _ = std::mem::replace(&mut b.val, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut b.val)` diff --git a/tests/ui/mem_replace_macro.rs b/tests/ui/mem_replace_macro.rs index 132873858b7c5..c14ea2942f3ed 100644 --- a/tests/ui/mem_replace_macro.rs +++ b/tests/ui/mem_replace_macro.rs @@ -7,6 +7,6 @@ use proc_macros::{external, inline_macros}; #[inline_macros] fn main() { let s = &mut String::from("foo"); - inline!(std::mem::replace($s, Default::default())); - external!(std::mem::replace($s, Default::default())); + let _ = inline!(std::mem::replace($s, Default::default())); + let _ = external!(std::mem::replace($s, Default::default())); } diff --git a/tests/ui/mem_replace_macro.stderr b/tests/ui/mem_replace_macro.stderr index c6435e94e9673..63043e6bf261c 100644 --- a/tests/ui/mem_replace_macro.stderr +++ b/tests/ui/mem_replace_macro.stderr @@ -1,8 +1,8 @@ error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace_macro.rs:10:13 + --> $DIR/mem_replace_macro.rs:10:21 | -LL | inline!(std::mem::replace($s, Default::default())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _ = inline!(std::mem::replace($s, Default::default())); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::mem-replace-with-default` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_default)]` From 05101ffe5b20b404daebc34634566b948aa5d6b2 Mon Sep 17 00:00:00 2001 From: Frank King Date: Thu, 4 Jan 2024 21:53:06 +0800 Subject: [PATCH 053/417] Lower anonymous structs or unions to HIR --- clippy_lints/src/dereference.rs | 1 + clippy_utils/src/hir_utils.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index cdbb52f497b36..0ddfeaa0ae059 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -831,6 +831,7 @@ impl TyCoercionStability { | TyKind::Typeof(..) | TyKind::TraitObject(..) | TyKind::InferDelegation(..) + | TyKind::AnonAdt(..) | TyKind::Err(_) => Self::Reborrow, }; } diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index 4fa93ad23c369..d50332e82da5b 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -515,6 +515,7 @@ impl HirEqInterExpr<'_, '_, '_> { (TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r), (&TyKind::Tup(l), &TyKind::Tup(r)) => over(l, r, |l, r| self.eq_ty(l, r)), (&TyKind::Infer, &TyKind::Infer) => true, + (TyKind::AnonAdt(l_item_id), TyKind::AnonAdt(r_item_id)) => l_item_id == r_item_id, _ => false, } } @@ -1108,7 +1109,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { TyKind::Typeof(anon_const) => { self.hash_body(anon_const.body); }, - TyKind::Err(_) | TyKind::Infer | TyKind::Never | TyKind::InferDelegation(..) => {}, + TyKind::Err(_) | TyKind::Infer | TyKind::Never | TyKind::InferDelegation(..) | TyKind::AnonAdt(_) => {}, } } From 6fda300087f664f23bc19364dfaeea061ecd5a63 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 12 Feb 2024 15:26:59 +1100 Subject: [PATCH 054/417] Tweak delayed bug mentions. Now that we have both `delayed_bug` and `span_delayed_bug`, it makes sense to use the generic term "delayed bug" more. --- tests/integration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration.rs b/tests/integration.rs index 267f095f9c20f..7f4500826ff6c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -77,7 +77,7 @@ fn integration_test() { // the repo basically just contains a span_delayed_bug that forces rustc/clippy to panic: /* #![feature(rustc_attrs)] - #[rustc_error(span_delayed_bug_from_inside_query)] + #[rustc_error(delayed_bug_from_inside_query)] fn main() {} */ From 4a1372251850c6cf62dfe7d380bc515763426107 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 12 Feb 2024 15:26:59 +1100 Subject: [PATCH 055/417] Tweak delayed bug mentions. Now that we have both `delayed_bug` and `span_delayed_bug`, it makes sense to use the generic term "delayed bug" more. --- crates/hir-def/src/attr/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hir-def/src/attr/builtin.rs b/crates/hir-def/src/attr/builtin.rs index b20ee9e5bf6c8..55b9a1dfdcb91 100644 --- a/crates/hir-def/src/attr/builtin.rs +++ b/crates/hir-def/src/attr/builtin.rs @@ -650,7 +650,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing), rustc_attr!( TEST, rustc_error, Normal, - template!(Word, List: "span_delayed_bug_from_inside_query"), WarnFollowingWordOnly + template!(Word, List: "delayed_bug_from_inside_query"), WarnFollowingWordOnly ), rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing), rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing), From d55fdb25ce982f13496df04bd64c960687b43337 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 30 Jan 2024 14:20:22 +0000 Subject: [PATCH 056/417] Make `is_intrinsic` query return the intrinsic name --- clippy_utils/src/qualify_min_const_fn.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 8d5bcd665ad25..47195fcc17b48 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -335,7 +335,7 @@ fn check_terminator<'tcx>( // within const fns. `transmute` is allowed in all other const contexts. // This won't really scale to more intrinsics or functions. Let's allow const // transmutes in const fn before we add more hacks to this. - if tcx.is_intrinsic(fn_def_id) && tcx.item_name(fn_def_id) == sym::transmute { + if matches!(tcx.intrinsic(fn_def_id), Some(sym::transmute)) { return Err(( span, "can only call `transmute` from const items, not `const fn`".into(), From 7c8690ca978c20f675234e34f6bf062e2f5c718c Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 12 Feb 2024 13:20:52 -0500 Subject: [PATCH 057/417] Minor refactor format-args * Move all linting logic into a single format implementations struct This should help with the future format-args improvements. --- clippy_lints/src/format_args.rs | 511 ++++++++++++++++---------------- 1 file changed, 260 insertions(+), 251 deletions(-) diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 8af321e4d553b..0cd000915ed5e 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -4,7 +4,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::is_diag_trait_item; use clippy_utils::macros::{ find_format_arg_expr, find_format_args, format_arg_removal_span, format_placeholder_format_span, is_assert_macro, - is_format_macro, is_panic, root_macro_call, root_macro_call_first_node, FormatParamUsage, + is_format_macro, is_panic, root_macro_call, root_macro_call_first_node, FormatParamUsage, MacroCall, }; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{implements_trait, is_type_lang_item}; @@ -20,7 +20,6 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_middle::ty::Ty; use rustc_session::impl_lint_pass; -use rustc_span::def_id::DefId; use rustc_span::edition::Edition::Edition2021; use rustc_span::{sym, Span, Symbol}; @@ -189,32 +188,18 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { && is_format_macro(cx, macro_call.def_id) && let Some(format_args) = find_format_args(cx, expr, macro_call.expn) { - for piece in &format_args.template { - if let FormatArgsPiece::Placeholder(placeholder) = piece - && let Ok(index) = placeholder.argument.index - && let Some(arg) = format_args.arguments.all_args().get(index) - { - let arg_expr = find_format_arg_expr(expr, arg); - - check_unused_format_specifier(cx, placeholder, arg_expr); - - if placeholder.format_trait != FormatTrait::Display - || placeholder.format_options != FormatOptions::default() - || is_aliased(&format_args, index) - { - continue; - } + let linter = FormatArgsExpr { + cx, + expr, + macro_call, + format_args: &format_args, + ignore_mixed: self.ignore_mixed, + }; - if let Ok(arg_hir_expr) = arg_expr { - let name = cx.tcx.item_name(macro_call.def_id); - check_format_in_format_args(cx, macro_call.span, name, arg_hir_expr); - check_to_string_in_format_args(cx, name, arg_hir_expr); - } - } - } + linter.check_templates(); if self.msrv.meets(msrvs::FORMAT_ARGS_CAPTURE) { - check_uninlined_args(cx, &format_args, macro_call.span, macro_call.def_id, self.ignore_mixed); + linter.check_uninlined_args(); } } } @@ -222,255 +207,279 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { extract_msrv_attr!(LateContext); } -fn check_unused_format_specifier( - cx: &LateContext<'_>, - placeholder: &FormatPlaceholder, - arg_expr: Result<&Expr<'_>, &rustc_ast::Expr>, -) { - let ty_or_ast_expr = arg_expr.map(|expr| cx.typeck_results().expr_ty(expr).peel_refs()); - - let is_format_args = match ty_or_ast_expr { - Ok(ty) => is_type_lang_item(cx, ty, LangItem::FormatArguments), - Err(expr) => matches!(expr.peel_parens_and_refs().kind, rustc_ast::ExprKind::FormatArgs(_)), - }; - - let options = &placeholder.format_options; - - let arg_span = match arg_expr { - Ok(expr) => expr.span, - Err(expr) => expr.span, - }; - - if let Some(placeholder_span) = placeholder.span - && is_format_args - && *options != FormatOptions::default() - { - span_lint_and_then( - cx, - UNUSED_FORMAT_SPECS, - placeholder_span, - "format specifiers have no effect on `format_args!()`", - |diag| { - let mut suggest_format = |spec| { - let message = format!("for the {spec} to apply consider using `format!()`"); - - if let Some(mac_call) = root_macro_call(arg_span) - && cx.tcx.is_diagnostic_item(sym::format_args_macro, mac_call.def_id) - { - diag.span_suggestion( - cx.sess().source_map().span_until_char(mac_call.span, '!'), - message, - "format", - Applicability::MaybeIncorrect, - ); - } else { - diag.help(message); - } - }; +struct FormatArgsExpr<'a, 'tcx> { + cx: &'a LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, + macro_call: MacroCall, + format_args: &'a rustc_ast::FormatArgs, + ignore_mixed: bool, +} - if options.width.is_some() { - suggest_format("width"); +impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> { + fn check_templates(&self) { + for piece in &self.format_args.template { + if let FormatArgsPiece::Placeholder(placeholder) = piece + && let Ok(index) = placeholder.argument.index + && let Some(arg) = self.format_args.arguments.all_args().get(index) + { + let arg_expr = find_format_arg_expr(self.expr, arg); + + self.check_unused_format_specifier(placeholder, arg_expr); + + if let Ok(arg_expr) = arg_expr + && placeholder.format_trait == FormatTrait::Display + && placeholder.format_options == FormatOptions::default() + && !self.is_aliased(index) + { + let name = self.cx.tcx.item_name(self.macro_call.def_id); + self.check_format_in_format_args(name, arg_expr); + self.check_to_string_in_format_args(name, arg_expr); } + } + } + } - if options.precision.is_some() { - suggest_format("precision"); - } + fn check_unused_format_specifier( + &self, + placeholder: &FormatPlaceholder, + arg_expr: Result<&Expr<'_>, &rustc_ast::Expr>, + ) { + let ty_or_ast_expr = arg_expr.map(|expr| self.cx.typeck_results().expr_ty(expr).peel_refs()); - if let Some(format_span) = format_placeholder_format_span(placeholder) { - diag.span_suggestion_verbose( - format_span, - "if the current behavior is intentional, remove the format specifiers", - "", - Applicability::MaybeIncorrect, - ); - } - }, - ); - } -} + let is_format_args = match ty_or_ast_expr { + Ok(ty) => is_type_lang_item(self.cx, ty, LangItem::FormatArguments), + Err(expr) => matches!(expr.peel_parens_and_refs().kind, rustc_ast::ExprKind::FormatArgs(_)), + }; -fn check_uninlined_args( - cx: &LateContext<'_>, - args: &rustc_ast::FormatArgs, - call_site: Span, - def_id: DefId, - ignore_mixed: bool, -) { - if args.span.from_expansion() { - return; - } - if call_site.edition() < Edition2021 && (is_panic(cx, def_id) || is_assert_macro(cx, def_id)) { - // panic!, assert!, and debug_assert! before 2021 edition considers a single string argument as - // non-format - return; + let options = &placeholder.format_options; + + let arg_span = match arg_expr { + Ok(expr) => expr.span, + Err(expr) => expr.span, + }; + + if let Some(placeholder_span) = placeholder.span + && is_format_args + && *options != FormatOptions::default() + { + span_lint_and_then( + self.cx, + UNUSED_FORMAT_SPECS, + placeholder_span, + "format specifiers have no effect on `format_args!()`", + |diag| { + let mut suggest_format = |spec| { + let message = format!("for the {spec} to apply consider using `format!()`"); + + if let Some(mac_call) = root_macro_call(arg_span) + && self.cx.tcx.is_diagnostic_item(sym::format_args_macro, mac_call.def_id) + { + diag.span_suggestion( + self.cx.sess().source_map().span_until_char(mac_call.span, '!'), + message, + "format", + Applicability::MaybeIncorrect, + ); + } else { + diag.help(message); + } + }; + + if options.width.is_some() { + suggest_format("width"); + } + + if options.precision.is_some() { + suggest_format("precision"); + } + + if let Some(format_span) = format_placeholder_format_span(placeholder) { + diag.span_suggestion_verbose( + format_span, + "if the current behavior is intentional, remove the format specifiers", + "", + Applicability::MaybeIncorrect, + ); + } + }, + ); + } } - let mut fixes = Vec::new(); - // If any of the arguments are referenced by an index number, - // and that argument is not a simple variable and cannot be inlined, - // we cannot remove any other arguments in the format string, - // because the index numbers might be wrong after inlining. - // Example of an un-inlinable format: print!("{}{1}", foo, 2) - for (pos, usage) in format_arg_positions(args) { - if !check_one_arg(args, pos, usage, &mut fixes, ignore_mixed) { + fn check_uninlined_args(&self) { + if self.format_args.span.from_expansion() { + return; + } + if self.macro_call.span.edition() < Edition2021 + && (is_panic(self.cx, self.macro_call.def_id) || is_assert_macro(self.cx, self.macro_call.def_id)) + { + // panic!, assert!, and debug_assert! before 2021 edition considers a single string argument as + // non-format return; } - } - if fixes.is_empty() { - return; - } + let mut fixes = Vec::new(); + // If any of the arguments are referenced by an index number, + // and that argument is not a simple variable and cannot be inlined, + // we cannot remove any other arguments in the format string, + // because the index numbers might be wrong after inlining. + // Example of an un-inlinable format: print!("{}{1}", foo, 2) + for (pos, usage) in self.format_arg_positions() { + if !self.check_one_arg(pos, usage, &mut fixes) { + return; + } + } - // multiline span display suggestion is sometimes broken: https://github.com/rust-lang/rust/pull/102729#discussion_r988704308 - // in those cases, make the code suggestion hidden - let multiline_fix = fixes.iter().any(|(span, _)| cx.sess().source_map().is_multiline(*span)); - - // Suggest removing each argument only once, for example in `format!("{0} {0}", arg)`. - fixes.sort_unstable_by_key(|(span, _)| *span); - fixes.dedup_by_key(|(span, _)| *span); - - span_lint_and_then( - cx, - UNINLINED_FORMAT_ARGS, - call_site, - "variables can be used directly in the `format!` string", - |diag| { - diag.multipart_suggestion_with_style( - "change this to", - fixes, - Applicability::MachineApplicable, - if multiline_fix { CompletelyHidden } else { ShowCode }, - ); - }, - ); -} + if fixes.is_empty() { + return; + } -fn check_one_arg( - args: &rustc_ast::FormatArgs, - pos: &FormatArgPosition, - usage: FormatParamUsage, - fixes: &mut Vec<(Span, String)>, - ignore_mixed: bool, -) -> bool { - let index = pos.index.unwrap(); - let arg = &args.arguments.all_args()[index]; - - if !matches!(arg.kind, FormatArgumentKind::Captured(_)) - && let rustc_ast::ExprKind::Path(None, path) = &arg.expr.kind - && let [segment] = path.segments.as_slice() - && segment.args.is_none() - && let Some(arg_span) = format_arg_removal_span(args, index) - && let Some(pos_span) = pos.span - { - let replacement = match usage { - FormatParamUsage::Argument => segment.ident.name.to_string(), - FormatParamUsage::Width => format!("{}$", segment.ident.name), - FormatParamUsage::Precision => format!(".{}$", segment.ident.name), - }; - fixes.push((pos_span, replacement)); - fixes.push((arg_span, String::new())); - true // successful inlining, continue checking - } else { - // Do not continue inlining (return false) in case - // * if we can't inline a numbered argument, e.g. `print!("{0} ...", foo.bar, ...)` - // * if allow_mixed_uninlined_format_args is false and this arg hasn't been inlined already - pos.kind != FormatArgPositionKind::Number - && (!ignore_mixed || matches!(arg.kind, FormatArgumentKind::Captured(_))) - } -} + // multiline span display suggestion is sometimes broken: https://github.com/rust-lang/rust/pull/102729#discussion_r988704308 + // in those cases, make the code suggestion hidden + let multiline_fix = fixes + .iter() + .any(|(span, _)| self.cx.sess().source_map().is_multiline(*span)); -fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symbol, arg: &Expr<'_>) { - let expn_data = arg.span.ctxt().outer_expn_data(); - if expn_data.call_site.from_expansion() { - return; - } - let Some(mac_id) = expn_data.macro_def_id else { return }; - if !cx.tcx.is_diagnostic_item(sym::format_macro, mac_id) { - return; + // Suggest removing each argument only once, for example in `format!("{0} {0}", arg)`. + fixes.sort_unstable_by_key(|(span, _)| *span); + fixes.dedup_by_key(|(span, _)| *span); + + span_lint_and_then( + self.cx, + UNINLINED_FORMAT_ARGS, + self.macro_call.span, + "variables can be used directly in the `format!` string", + |diag| { + diag.multipart_suggestion_with_style( + "change this to", + fixes, + Applicability::MachineApplicable, + if multiline_fix { CompletelyHidden } else { ShowCode }, + ); + }, + ); } - span_lint_and_then( - cx, - FORMAT_IN_FORMAT_ARGS, - call_site, - &format!("`format!` in `{name}!` args"), - |diag| { - diag.help(format!( - "combine the `format!(..)` arguments with the outer `{name}!(..)` call" - )); - diag.help("or consider changing `format!` to `format_args!`"); - }, - ); -} -fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Expr<'_>) { - if !value.span.from_expansion() - && let ExprKind::MethodCall(_, receiver, [], to_string_span) = value.kind - && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id) - && is_diag_trait_item(cx, method_def_id, sym::ToString) - && let receiver_ty = cx.typeck_results().expr_ty(receiver) - && let Some(display_trait_id) = cx.tcx.get_diagnostic_item(sym::Display) - && let (n_needed_derefs, target) = - count_needed_derefs(receiver_ty, cx.typeck_results().expr_adjustments(receiver).iter()) - && implements_trait(cx, target, display_trait_id, &[]) - && let Some(sized_trait_id) = cx.tcx.lang_items().sized_trait() - && let Some(receiver_snippet) = snippet_opt(cx, receiver.span) - { - let needs_ref = !implements_trait(cx, receiver_ty, sized_trait_id, &[]); - if n_needed_derefs == 0 && !needs_ref { - span_lint_and_sugg( - cx, - TO_STRING_IN_FORMAT_ARGS, - to_string_span.with_lo(receiver.span.hi()), - &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), - "remove this", - String::new(), - Applicability::MachineApplicable, - ); + fn check_one_arg(&self, pos: &FormatArgPosition, usage: FormatParamUsage, fixes: &mut Vec<(Span, String)>) -> bool { + let index = pos.index.unwrap(); + let arg = &self.format_args.arguments.all_args()[index]; + + if !matches!(arg.kind, FormatArgumentKind::Captured(_)) + && let rustc_ast::ExprKind::Path(None, path) = &arg.expr.kind + && let [segment] = path.segments.as_slice() + && segment.args.is_none() + && let Some(arg_span) = format_arg_removal_span(self.format_args, index) + && let Some(pos_span) = pos.span + { + let replacement = match usage { + FormatParamUsage::Argument => segment.ident.name.to_string(), + FormatParamUsage::Width => format!("{}$", segment.ident.name), + FormatParamUsage::Precision => format!(".{}$", segment.ident.name), + }; + fixes.push((pos_span, replacement)); + fixes.push((arg_span, String::new())); + true // successful inlining, continue checking } else { - span_lint_and_sugg( - cx, - TO_STRING_IN_FORMAT_ARGS, - value.span, - &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), - "use this", - format!( - "{}{:*>n_needed_derefs$}{receiver_snippet}", - if needs_ref { "&" } else { "" }, - "" - ), - Applicability::MachineApplicable, - ); + // Do not continue inlining (return false) in case + // * if we can't inline a numbered argument, e.g. `print!("{0} ...", foo.bar, ...)` + // * if allow_mixed_uninlined_format_args is false and this arg hasn't been inlined already + pos.kind != FormatArgPositionKind::Number + && (!self.ignore_mixed || matches!(arg.kind, FormatArgumentKind::Captured(_))) } } -} -fn format_arg_positions( - format_args: &rustc_ast::FormatArgs, -) -> impl Iterator { - format_args.template.iter().flat_map(|piece| match piece { - FormatArgsPiece::Placeholder(placeholder) => { - let mut positions = ArrayVec::<_, 3>::new(); + fn check_format_in_format_args(&self, name: Symbol, arg: &Expr<'_>) { + let expn_data = arg.span.ctxt().outer_expn_data(); + if expn_data.call_site.from_expansion() { + return; + } + let Some(mac_id) = expn_data.macro_def_id else { return }; + if !self.cx.tcx.is_diagnostic_item(sym::format_macro, mac_id) { + return; + } + span_lint_and_then( + self.cx, + FORMAT_IN_FORMAT_ARGS, + self.macro_call.span, + &format!("`format!` in `{name}!` args"), + |diag| { + diag.help(format!( + "combine the `format!(..)` arguments with the outer `{name}!(..)` call" + )); + diag.help("or consider changing `format!` to `format_args!`"); + }, + ); + } - positions.push((&placeholder.argument, FormatParamUsage::Argument)); - if let Some(FormatCount::Argument(position)) = &placeholder.format_options.width { - positions.push((position, FormatParamUsage::Width)); - } - if let Some(FormatCount::Argument(position)) = &placeholder.format_options.precision { - positions.push((position, FormatParamUsage::Precision)); + fn check_to_string_in_format_args(&self, name: Symbol, value: &Expr<'_>) { + let cx = self.cx; + if !value.span.from_expansion() + && let ExprKind::MethodCall(_, receiver, [], to_string_span) = value.kind + && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id) + && is_diag_trait_item(cx, method_def_id, sym::ToString) + && let receiver_ty = cx.typeck_results().expr_ty(receiver) + && let Some(display_trait_id) = cx.tcx.get_diagnostic_item(sym::Display) + && let (n_needed_derefs, target) = + count_needed_derefs(receiver_ty, cx.typeck_results().expr_adjustments(receiver).iter()) + && implements_trait(cx, target, display_trait_id, &[]) + && let Some(sized_trait_id) = cx.tcx.lang_items().sized_trait() + && let Some(receiver_snippet) = snippet_opt(cx, receiver.span) + { + let needs_ref = !implements_trait(cx, receiver_ty, sized_trait_id, &[]); + if n_needed_derefs == 0 && !needs_ref { + span_lint_and_sugg( + cx, + TO_STRING_IN_FORMAT_ARGS, + to_string_span.with_lo(receiver.span.hi()), + &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), + "remove this", + String::new(), + Applicability::MachineApplicable, + ); + } else { + span_lint_and_sugg( + cx, + TO_STRING_IN_FORMAT_ARGS, + value.span, + &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), + "use this", + format!( + "{}{:*>n_needed_derefs$}{receiver_snippet}", + if needs_ref { "&" } else { "" }, + "" + ), + Applicability::MachineApplicable, + ); } + } + } - positions - }, - FormatArgsPiece::Literal(_) => ArrayVec::new(), - }) -} + fn format_arg_positions(&self) -> impl Iterator { + self.format_args.template.iter().flat_map(|piece| match piece { + FormatArgsPiece::Placeholder(placeholder) => { + let mut positions = ArrayVec::<_, 3>::new(); -/// Returns true if the format argument at `index` is referred to by multiple format params -fn is_aliased(format_args: &rustc_ast::FormatArgs, index: usize) -> bool { - format_arg_positions(format_args) - .filter(|(position, _)| position.index == Ok(index)) - .at_most_one() - .is_err() + positions.push((&placeholder.argument, FormatParamUsage::Argument)); + if let Some(FormatCount::Argument(position)) = &placeholder.format_options.width { + positions.push((position, FormatParamUsage::Width)); + } + if let Some(FormatCount::Argument(position)) = &placeholder.format_options.precision { + positions.push((position, FormatParamUsage::Precision)); + } + + positions + }, + FormatArgsPiece::Literal(_) => ArrayVec::new(), + }) + } + + /// Returns true if the format argument at `index` is referred to by multiple format params + fn is_aliased(&self, index: usize) -> bool { + self.format_arg_positions() + .filter(|(position, _)| position.index == Ok(index)) + .at_most_one() + .is_err() + } } fn count_needed_derefs<'tcx, I>(mut ty: Ty<'tcx>, mut iter: I) -> (usize, Ty<'tcx>) From 2c3ae882e85a902cfad7ec4eee7c3086cfd8da08 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 12 Feb 2024 13:32:09 -0500 Subject: [PATCH 058/417] Make macro_call a ref --- clippy_lints/src/format_args.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 0cd000915ed5e..61f550ce0beb4 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -191,7 +191,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { let linter = FormatArgsExpr { cx, expr, - macro_call, + macro_call: ¯o_call, format_args: &format_args, ignore_mixed: self.ignore_mixed, }; @@ -210,7 +210,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { struct FormatArgsExpr<'a, 'tcx> { cx: &'a LateContext<'tcx>, expr: &'tcx Expr<'tcx>, - macro_call: MacroCall, + macro_call: &'a MacroCall, format_args: &'a rustc_ast::FormatArgs, ignore_mixed: bool, } From f2064f71653c280b02c7e08b308acac42f4d0d6c Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 17 Dec 2023 17:28:24 +0100 Subject: [PATCH 059/417] Avoid UB in clippy transmute_ptr_to_ptr UI test --- tests/ui/transmute_ptr_to_ptr.fixed | 6 +++--- tests/ui/transmute_ptr_to_ptr.rs | 6 +++--- tests/ui/transmute_ptr_to_ptr.stderr | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/ui/transmute_ptr_to_ptr.fixed b/tests/ui/transmute_ptr_to_ptr.fixed index 4e145693c553a..696def08f142d 100644 --- a/tests/ui/transmute_ptr_to_ptr.fixed +++ b/tests/ui/transmute_ptr_to_ptr.fixed @@ -35,7 +35,7 @@ fn transmute_ptr_to_ptr() { // ref-ref transmutes; bad let _: &f32 = &*(&1u32 as *const u32 as *const f32); //~^ ERROR: transmute from a reference to a reference - let _: &f64 = &*(&1f32 as *const f32 as *const f64); + let _: &f32 = &*(&1f64 as *const f64 as *const f32); //~^ ERROR: transmute from a reference to a reference //:^ this test is here because both f32 and f64 are the same TypeVariant, but they are not // the same type @@ -43,8 +43,8 @@ fn transmute_ptr_to_ptr() { //~^ ERROR: transmute from a reference to a reference let _: &GenericParam = &*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam); //~^ ERROR: transmute from a reference to a reference - let u8_ref: &u8 = &0u8; - let u64_ref: &u64 = unsafe { &*(u8_ref as *const u8 as *const u64) }; + let u64_ref: &u64 = &0u64; + let u8_ref: &u8 = unsafe { &*(u64_ref as *const u64 as *const u8) }; //~^ ERROR: transmute from a reference to a reference } diff --git a/tests/ui/transmute_ptr_to_ptr.rs b/tests/ui/transmute_ptr_to_ptr.rs index 086aadc364740..0700d8c19576a 100644 --- a/tests/ui/transmute_ptr_to_ptr.rs +++ b/tests/ui/transmute_ptr_to_ptr.rs @@ -35,7 +35,7 @@ fn transmute_ptr_to_ptr() { // ref-ref transmutes; bad let _: &f32 = std::mem::transmute(&1u32); //~^ ERROR: transmute from a reference to a reference - let _: &f64 = std::mem::transmute(&1f32); + let _: &f32 = std::mem::transmute(&1f64); //~^ ERROR: transmute from a reference to a reference //:^ this test is here because both f32 and f64 are the same TypeVariant, but they are not // the same type @@ -43,8 +43,8 @@ fn transmute_ptr_to_ptr() { //~^ ERROR: transmute from a reference to a reference let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); //~^ ERROR: transmute from a reference to a reference - let u8_ref: &u8 = &0u8; - let u64_ref: &u64 = unsafe { std::mem::transmute(u8_ref) }; + let u64_ref: &u64 = &0u64; + let u8_ref: &u8 = unsafe { std::mem::transmute(u64_ref) }; //~^ ERROR: transmute from a reference to a reference } diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr index 9f8599921ec7d..6e3af1f733717 100644 --- a/tests/ui/transmute_ptr_to_ptr.stderr +++ b/tests/ui/transmute_ptr_to_ptr.stderr @@ -22,8 +22,8 @@ LL | let _: &f32 = std::mem::transmute(&1u32); error: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:38:23 | -LL | let _: &f64 = std::mem::transmute(&1f32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` +LL | let _: &f32 = std::mem::transmute(&1f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f64 as *const f64 as *const f32)` error: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:42:27 @@ -38,10 +38,10 @@ LL | let _: &GenericParam = std::mem::transmute(&GenericParam { t: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:47:38 + --> $DIR/transmute_ptr_to_ptr.rs:47:36 | -LL | let u64_ref: &u64 = unsafe { std::mem::transmute(u8_ref) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u8_ref as *const u8 as *const u64)` +LL | let u8_ref: &u8 = unsafe { std::mem::transmute(u64_ref) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u64_ref as *const u64 as *const u8)` error: aborting due to 7 previous errors From 61d6443467feff038e3e87dc35ab756031c5090c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Feb 2024 16:07:15 +0100 Subject: [PATCH 060/417] Unmark the feature gate as incomplete --- compiler/rustc_feature/src/unstable.rs | 2 +- ...ultivariant.min_exhaustive_patterns.stderr | 11 -- .../run_pass/multivariant.rs | 1 - ...bited-union-ref.exhaustive_patterns.stderr | 6 +- ...d-union-ref.min_exhaustive_patterns.stderr | 17 +-- .../usefulness/always-inhabited-union-ref.rs | 1 - .../empty-types.exhaustive_patterns.stderr | 100 ++++++------- .../empty-types.min_exh_pats.stderr | 139 ++++++++---------- .../usefulness/empty-types.normal.stderr | 98 ++++++------ tests/ui/pattern/usefulness/empty-types.rs | 1 - ...privately-empty.exhaustive_patterns.stderr | 2 +- ...ately-empty.min_exhaustive_patterns.stderr | 13 +- .../usefulness/match-privately-empty.rs | 1 - .../slice_of_empty.exhaustive_patterns.stderr | 2 +- ...ce_of_empty.min_exhaustive_patterns.stderr | 15 +- tests/ui/pattern/usefulness/slice_of_empty.rs | 1 - ...ted-irrefutable.exhaustive_patterns.stderr | 4 +- ...irrefutable.min_exhaustive_patterns.stderr | 4 +- .../ui/uninhabited/uninhabited-irrefutable.rs | 1 - 19 files changed, 183 insertions(+), 236 deletions(-) delete mode 100644 tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 9012b731a1323..93c183a65ef3e 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -518,7 +518,7 @@ declare_features! ( (unstable, marker_trait_attr, "1.30.0", Some(29864)), /// Allows exhaustive pattern matching on types that contain uninhabited types in cases that are /// unambiguously sound. - (incomplete, min_exhaustive_patterns, "1.77.0", Some(119612)), + (unstable, min_exhaustive_patterns, "1.77.0", Some(119612)), /// A minimal, sound subset of specialization intended to be used by the /// standard library until the soundness issues with specialization /// are fixed. diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr deleted file mode 100644 index b54341f82c794..0000000000000 --- a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/multivariant.rs:7:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs index bc2386e5d23d8..d14426cc5a670 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs @@ -5,7 +5,6 @@ // run-pass #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] pub fn main() { diff --git a/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr index 553daff2d969d..d6304a0b997d3 100644 --- a/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/always-inhabited-union-ref.rs:26:11 + --> $DIR/always-inhabited-union-ref.rs:25:11 | LL | match uninhab_ref() { | ^^^^^^^^^^^^^ @@ -14,13 +14,13 @@ LL + } | error[E0004]: non-exhaustive patterns: type `Foo` is non-empty - --> $DIR/always-inhabited-union-ref.rs:30:11 + --> $DIR/always-inhabited-union-ref.rs:29:11 | LL | match uninhab_union() { | ^^^^^^^^^^^^^^^ | note: `Foo` defined here - --> $DIR/always-inhabited-union-ref.rs:13:11 + --> $DIR/always-inhabited-union-ref.rs:12:11 | LL | pub union Foo { | ^^^ diff --git a/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr index a1d8002c64895..d6304a0b997d3 100644 --- a/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr @@ -1,14 +1,5 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/always-inhabited-union-ref.rs:7:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/always-inhabited-union-ref.rs:26:11 + --> $DIR/always-inhabited-union-ref.rs:25:11 | LL | match uninhab_ref() { | ^^^^^^^^^^^^^ @@ -23,13 +14,13 @@ LL + } | error[E0004]: non-exhaustive patterns: type `Foo` is non-empty - --> $DIR/always-inhabited-union-ref.rs:30:11 + --> $DIR/always-inhabited-union-ref.rs:29:11 | LL | match uninhab_union() { | ^^^^^^^^^^^^^^^ | note: `Foo` defined here - --> $DIR/always-inhabited-union-ref.rs:13:11 + --> $DIR/always-inhabited-union-ref.rs:12:11 | LL | pub union Foo { | ^^^ @@ -41,6 +32,6 @@ LL + _ => todo!(), LL + } | -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs b/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs index 247b7f21f6866..af1400c460f94 100644 --- a/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs +++ b/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs @@ -5,7 +5,6 @@ #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] #![allow(dead_code)] #![allow(unreachable_code)] diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index 0c55164a780b5..98c66c9dd0711 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -1,23 +1,23 @@ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:49:9 | LL | _ => {} | ^ | note: the lint level is defined here - --> $DIR/empty-types.rs:16:9 + --> $DIR/empty-types.rs:15:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:53:9 + --> $DIR/empty-types.rs:52:9 | LL | _x => {} | ^^ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:57:11 + --> $DIR/empty-types.rs:56:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -32,31 +32,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:72:9 + --> $DIR/empty-types.rs:71:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:79:9 + --> $DIR/empty-types.rs:78:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:82:9 + --> $DIR/empty-types.rs:81:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:86:9 + --> $DIR/empty-types.rs:85:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:90:11 + --> $DIR/empty-types.rs:89:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -75,19 +75,19 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:98:9 + --> $DIR/empty-types.rs:97:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:103:9 + --> $DIR/empty-types.rs:102:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:100:11 + --> $DIR/empty-types.rs:99:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -105,7 +105,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:107:9 + --> $DIR/empty-types.rs:106:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -119,121 +119,121 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:118:9 + --> $DIR/empty-types.rs:117:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:122:9 + --> $DIR/empty-types.rs:121:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:125:9 + --> $DIR/empty-types.rs:124:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:126:9 + --> $DIR/empty-types.rs:125:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:129:9 + --> $DIR/empty-types.rs:128:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:130:9 + --> $DIR/empty-types.rs:129:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:139:13 + --> $DIR/empty-types.rs:138:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:142:13 + --> $DIR/empty-types.rs:141:13 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:151:13 + --> $DIR/empty-types.rs:150:13 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:155:13 + --> $DIR/empty-types.rs:154:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:206:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:211:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:217:13 + --> $DIR/empty-types.rs:216:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:222:13 + --> $DIR/empty-types.rs:221:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:228:13 + --> $DIR/empty-types.rs:227:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:287:9 + --> $DIR/empty-types.rs:286:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:290:9 + --> $DIR/empty-types.rs:289:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:293:9 + --> $DIR/empty-types.rs:292:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:294:9 + --> $DIR/empty-types.rs:293:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:326:11 + --> $DIR/empty-types.rs:325:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -247,7 +247,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:337:11 + --> $DIR/empty-types.rs:336:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -260,7 +260,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:349:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -274,7 +274,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:356:11 + --> $DIR/empty-types.rs:355:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -288,25 +288,25 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:366:9 + --> $DIR/empty-types.rs:365:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:369:9 + --> $DIR/empty-types.rs:368:9 | LL | [_, _, _] => {} | ^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:372:9 + --> $DIR/empty-types.rs:371:9 | LL | [_, ..] => {} | ^^^^^^^ error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:385:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -320,13 +320,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:392:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:394:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -340,49 +340,49 @@ LL + [] => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:414:9 + --> $DIR/empty-types.rs:413:9 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:419:9 + --> $DIR/empty-types.rs:418:9 | LL | Some(_a) => {} | ^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:424:9 + --> $DIR/empty-types.rs:423:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:429:9 + --> $DIR/empty-types.rs:428:9 | LL | _a => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:600:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:603:9 | LL | _x => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:606:9 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:609:9 | LL | _x if false => {} | ^^ diff --git a/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr b/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr index ed5d125e68404..d5121e7043c73 100644 --- a/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr @@ -1,32 +1,23 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/empty-types.rs:13:35 - | -LL | #![cfg_attr(min_exh_pats, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:49:9 | LL | _ => {} | ^ | note: the lint level is defined here - --> $DIR/empty-types.rs:16:9 + --> $DIR/empty-types.rs:15:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:53:9 + --> $DIR/empty-types.rs:52:9 | LL | _x => {} | ^^ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:57:11 + --> $DIR/empty-types.rs:56:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,31 +32,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:72:9 + --> $DIR/empty-types.rs:71:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:79:9 + --> $DIR/empty-types.rs:78:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:82:9 + --> $DIR/empty-types.rs:81:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:86:9 + --> $DIR/empty-types.rs:85:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:90:11 + --> $DIR/empty-types.rs:89:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -84,19 +75,19 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:98:9 + --> $DIR/empty-types.rs:97:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:103:9 + --> $DIR/empty-types.rs:102:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:100:11 + --> $DIR/empty-types.rs:99:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -114,7 +105,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:107:9 + --> $DIR/empty-types.rs:106:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -128,7 +119,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:111:9 + --> $DIR/empty-types.rs:110:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(_)` not covered @@ -142,67 +133,67 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:118:9 + --> $DIR/empty-types.rs:117:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:122:9 + --> $DIR/empty-types.rs:121:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:125:9 + --> $DIR/empty-types.rs:124:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:126:9 + --> $DIR/empty-types.rs:125:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:129:9 + --> $DIR/empty-types.rs:128:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:130:9 + --> $DIR/empty-types.rs:129:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:139:13 + --> $DIR/empty-types.rs:138:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:142:13 + --> $DIR/empty-types.rs:141:13 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:151:13 + --> $DIR/empty-types.rs:150:13 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:155:13 + --> $DIR/empty-types.rs:154:13 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:164:15 + --> $DIR/empty-types.rs:163:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -220,61 +211,61 @@ LL + Some(_) => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:206:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:211:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:217:13 + --> $DIR/empty-types.rs:216:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:222:13 + --> $DIR/empty-types.rs:221:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:228:13 + --> $DIR/empty-types.rs:227:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:287:9 + --> $DIR/empty-types.rs:286:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:290:9 + --> $DIR/empty-types.rs:289:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:293:9 + --> $DIR/empty-types.rs:292:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:294:9 + --> $DIR/empty-types.rs:293:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:315:11 + --> $DIR/empty-types.rs:314:11 | LL | match *x {} | ^^ @@ -288,7 +279,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:317:11 + --> $DIR/empty-types.rs:316:11 | LL | match *x {} | ^^ @@ -302,7 +293,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:319:11 + --> $DIR/empty-types.rs:318:11 | LL | match *x {} | ^^ patterns `Ok(_)` and `Err(_)` not covered @@ -324,7 +315,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:321:11 + --> $DIR/empty-types.rs:320:11 | LL | match *x {} | ^^ @@ -338,7 +329,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:326:11 + --> $DIR/empty-types.rs:325:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -352,7 +343,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/empty-types.rs:328:11 + --> $DIR/empty-types.rs:327:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[_, ..]` not covered @@ -365,7 +356,7 @@ LL + &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered - --> $DIR/empty-types.rs:337:11 + --> $DIR/empty-types.rs:336:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered @@ -378,7 +369,7 @@ LL + &[] | &[_] | &[_, _] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:349:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered @@ -392,7 +383,7 @@ LL + &[] | &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:356:11 + --> $DIR/empty-types.rs:355:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -406,25 +397,25 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:366:9 + --> $DIR/empty-types.rs:365:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:369:9 + --> $DIR/empty-types.rs:368:9 | LL | [_, _, _] => {} | ^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:372:9 + --> $DIR/empty-types.rs:371:9 | LL | [_, ..] => {} | ^^^^^^^ error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:385:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -438,13 +429,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:392:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:394:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -458,31 +449,31 @@ LL + [] => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:414:9 + --> $DIR/empty-types.rs:413:9 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:419:9 + --> $DIR/empty-types.rs:418:9 | LL | Some(_a) => {} | ^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:424:9 + --> $DIR/empty-types.rs:423:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:429:9 + --> $DIR/empty-types.rs:428:9 | LL | _a => {} | ^^ error[E0004]: non-exhaustive patterns: `&Some(_)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:448:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered @@ -500,7 +491,7 @@ LL + &Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:489:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -518,7 +509,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:537:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -536,7 +527,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:548:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -554,7 +545,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:567:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -568,31 +559,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:600:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:603:9 | LL | _x => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:606:9 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:609:9 | LL | _x if false => {} | ^^ error[E0004]: non-exhaustive patterns: `&_` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:634:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&_` not covered @@ -607,7 +598,7 @@ LL + &_ => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:663:11 + --> $DIR/empty-types.rs:662:11 | LL | match *x { | ^^ pattern `Some(_)` not covered @@ -624,7 +615,7 @@ LL ~ None => {}, LL + Some(_) => todo!() | -error: aborting due to 63 previous errors; 1 warning emitted +error: aborting due to 63 previous errors Some errors have detailed explanations: E0004, E0005. For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index 2fdb51677dac5..dc01ac4ddcea2 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -1,23 +1,23 @@ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:49:9 | LL | _ => {} | ^ | note: the lint level is defined here - --> $DIR/empty-types.rs:16:9 + --> $DIR/empty-types.rs:15:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:53:9 + --> $DIR/empty-types.rs:52:9 | LL | _x => {} | ^^ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:57:11 + --> $DIR/empty-types.rs:56:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -32,7 +32,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:69:11 + --> $DIR/empty-types.rs:68:11 | LL | match tuple_half_never {} | ^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:76:11 + --> $DIR/empty-types.rs:75:11 | LL | match tuple_never {} | ^^^^^^^^^^^ @@ -60,13 +60,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:86:9 + --> $DIR/empty-types.rs:85:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:90:11 + --> $DIR/empty-types.rs:89:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered @@ -88,7 +88,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:92:11 + --> $DIR/empty-types.rs:91:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -106,7 +106,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:100:11 + --> $DIR/empty-types.rs:99:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -124,7 +124,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:105:9 + --> $DIR/empty-types.rs:104:9 | LL | let Ok(_x) = res_u32_never; | ^^^^^^ pattern `Err(_)` not covered @@ -138,7 +138,7 @@ LL | let Ok(_x) = res_u32_never else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:107:9 + --> $DIR/empty-types.rs:106:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -152,7 +152,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:111:9 + --> $DIR/empty-types.rs:110:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(_)` not covered @@ -166,7 +166,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:115:11 + --> $DIR/empty-types.rs:114:11 | LL | match result_never {} | ^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered @@ -188,7 +188,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:120:11 + --> $DIR/empty-types.rs:119:11 | LL | match result_never { | ^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -205,19 +205,19 @@ LL | Ok(_) => {}, Err(_) => todo!() | +++++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:139:13 + --> $DIR/empty-types.rs:138:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:142:13 + --> $DIR/empty-types.rs:141:13 | LL | _ if false => {} | ^ error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:145:15 + --> $DIR/empty-types.rs:144:15 | LL | match opt_void { | ^^^^^^^^ pattern `Some(_)` not covered @@ -235,7 +235,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:164:15 + --> $DIR/empty-types.rs:163:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -253,43 +253,43 @@ LL + Some(_) => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:206:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:211:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:217:13 + --> $DIR/empty-types.rs:216:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:222:13 + --> $DIR/empty-types.rs:221:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:228:13 + --> $DIR/empty-types.rs:227:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:287:9 + --> $DIR/empty-types.rs:286:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:315:11 + --> $DIR/empty-types.rs:314:11 | LL | match *x {} | ^^ @@ -303,7 +303,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:317:11 + --> $DIR/empty-types.rs:316:11 | LL | match *x {} | ^^ @@ -317,7 +317,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:319:11 + --> $DIR/empty-types.rs:318:11 | LL | match *x {} | ^^ patterns `Ok(_)` and `Err(_)` not covered @@ -339,7 +339,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:321:11 + --> $DIR/empty-types.rs:320:11 | LL | match *x {} | ^^ @@ -353,7 +353,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:326:11 + --> $DIR/empty-types.rs:325:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -367,7 +367,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/empty-types.rs:328:11 + --> $DIR/empty-types.rs:327:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[_, ..]` not covered @@ -380,7 +380,7 @@ LL + &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered - --> $DIR/empty-types.rs:337:11 + --> $DIR/empty-types.rs:336:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered @@ -393,7 +393,7 @@ LL + &[] | &[_] | &[_, _] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:349:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered @@ -407,7 +407,7 @@ LL + &[] | &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:356:11 + --> $DIR/empty-types.rs:355:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -421,7 +421,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:363:11 + --> $DIR/empty-types.rs:362:11 | LL | match array_3_never {} | ^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:385:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -449,13 +449,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:392:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:394:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -469,7 +469,7 @@ LL + [] => todo!() | error[E0004]: non-exhaustive patterns: `&Some(_)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:448:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered @@ -487,7 +487,7 @@ LL + &Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:489:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -505,7 +505,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:537:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -523,7 +523,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:548:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -541,7 +541,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:567:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -555,31 +555,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:600:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:603:9 | LL | _x => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:606:9 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:609:9 | LL | _x if false => {} | ^^ error[E0004]: non-exhaustive patterns: `&_` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:634:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&_` not covered @@ -594,7 +594,7 @@ LL + &_ => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:663:11 + --> $DIR/empty-types.rs:662:11 | LL | match *x { | ^^ pattern `Some(_)` not covered diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs index c66fd1edc19ec..1349aa1ddba7c 100644 --- a/tests/ui/pattern/usefulness/empty-types.rs +++ b/tests/ui/pattern/usefulness/empty-types.rs @@ -11,7 +11,6 @@ #![feature(never_type_fallback)] #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exh_pats, feature(min_exhaustive_patterns))] -//[min_exh_pats]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![allow(dead_code, unreachable_code)] #![deny(unreachable_patterns)] diff --git a/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr index 708a1511244c2..261a4b3353f23 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered - --> $DIR/match-privately-empty.rs:16:11 + --> $DIR/match-privately-empty.rs:15:11 | LL | match private::DATA { | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered diff --git a/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr index a6ce02c0c3c6a..261a4b3353f23 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr @@ -1,14 +1,5 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/match-privately-empty.rs:3:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered - --> $DIR/match-privately-empty.rs:16:11 + --> $DIR/match-privately-empty.rs:15:11 | LL | match private::DATA { | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered @@ -25,6 +16,6 @@ LL ~ Some(private::Private { misc: false, .. }) => {}, LL + Some(Private { misc: true, .. }) => todo!() | -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/match-privately-empty.rs b/tests/ui/pattern/usefulness/match-privately-empty.rs index 67a9aa2e91614..c58dc7d81388a 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.rs +++ b/tests/ui/pattern/usefulness/match-privately-empty.rs @@ -1,7 +1,6 @@ // revisions: min_exhaustive_patterns exhaustive_patterns #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] mod private { diff --git a/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr index 9770f680b2da8..e5e581447e66c 100644 --- a/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/slice_of_empty.rs:22:11 + --> $DIR/slice_of_empty.rs:21:11 | LL | match nevers { | ^^^^^^ pattern `&[]` not covered diff --git a/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr index 3b9e71f50d5ff..a1239466c9c2c 100644 --- a/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr @@ -1,14 +1,5 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/slice_of_empty.rs:3:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/slice_of_empty.rs:11:11 + --> $DIR/slice_of_empty.rs:10:11 | LL | match nevers { | ^^^^^^ pattern `&[_, ..]` not covered @@ -21,7 +12,7 @@ LL ~ &[_, ..] => todo!(), | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered - --> $DIR/slice_of_empty.rs:22:11 + --> $DIR/slice_of_empty.rs:21:11 | LL | match nevers { | ^^^^^^ patterns `&[]` and `&[_, _, ..]` not covered @@ -33,6 +24,6 @@ LL ~ &[_] => (), LL ~ &[] | &[_, _, ..] => todo!(), | -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/slice_of_empty.rs b/tests/ui/pattern/usefulness/slice_of_empty.rs index 5f64dd3fecc9a..aa5f4a2d368af 100644 --- a/tests/ui/pattern/usefulness/slice_of_empty.rs +++ b/tests/ui/pattern/usefulness/slice_of_empty.rs @@ -1,7 +1,6 @@ // revisions: min_exhaustive_patterns exhaustive_patterns #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] #![deny(unreachable_patterns)] diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr index c9131a8372ab1..bc1a9fa41915a 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/uninhabited-irrefutable.rs:32:9 + --> $DIR/uninhabited-irrefutable.rs:31:9 | LL | let Foo::D(_y, _z) = x; | ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered @@ -7,7 +7,7 @@ LL | let Foo::D(_y, _z) = x; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Foo` defined here - --> $DIR/uninhabited-irrefutable.rs:21:6 + --> $DIR/uninhabited-irrefutable.rs:20:6 | LL | enum Foo { | ^^^ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr index c9131a8372ab1..bc1a9fa41915a 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/uninhabited-irrefutable.rs:32:9 + --> $DIR/uninhabited-irrefutable.rs:31:9 | LL | let Foo::D(_y, _z) = x; | ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered @@ -7,7 +7,7 @@ LL | let Foo::D(_y, _z) = x; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Foo` defined here - --> $DIR/uninhabited-irrefutable.rs:21:6 + --> $DIR/uninhabited-irrefutable.rs:20:6 | LL | enum Foo { | ^^^ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.rs b/tests/ui/uninhabited/uninhabited-irrefutable.rs index 2ef3b668cb089..4ac69d81c4dd4 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.rs +++ b/tests/ui/uninhabited/uninhabited-irrefutable.rs @@ -1,7 +1,6 @@ // revisions: min_exhaustive_patterns exhaustive_patterns #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -#![cfg_attr(min_exhaustive_patterns, allow(incomplete_features))] #![feature(never_type)] mod foo { From 9dd6eda778b5320be1a9fbfb21eae3c1b733e744 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Feb 2024 16:21:24 +0100 Subject: [PATCH 061/417] Prefer `min_exhaustive_patterns` in compiler --- compiler/rustc_middle/src/lib.rs | 3 ++- compiler/rustc_target/src/lib.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 2aaece1060a1f..c9059ddc4bf25 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -24,6 +24,8 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] +#![cfg_attr(bootstrap, feature(exhaustive_patterns))] +#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))] #![feature(rustdoc_internals)] #![feature(allocator_api)] #![feature(array_windows)] @@ -32,7 +34,6 @@ #![feature(core_intrinsics)] #![feature(const_type_name)] #![feature(discriminant_kind)] -#![feature(exhaustive_patterns)] #![feature(coroutines)] #![feature(if_let_guard)] #![feature(inline_const)] diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index 04c5e60aa6ba1..8019d2b80cde0 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -9,9 +9,10 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] +#![cfg_attr(bootstrap, feature(exhaustive_patterns))] +#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))] #![feature(rustdoc_internals)] #![feature(assert_matches)] -#![feature(exhaustive_patterns)] #![feature(iter_intersperse)] #![feature(let_chains)] #![cfg_attr(bootstrap, feature(min_specialization))] From 8e83d0cd7530ee0421a6b91562c820101123edd5 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Feb 2024 16:34:25 +0100 Subject: [PATCH 062/417] Prefer `min_exhaustive_patterns` in tests --- tests/ui/pattern/usefulness/impl-trait.rs | 2 +- tests/ui/pattern/usefulness/uninhabited.rs | 2 +- tests/ui/reachable/unreachable-loop-patterns.rs | 2 +- .../uninhabited/indirect_match_with_exhaustive_patterns.rs | 2 +- .../indirect_match_with_exhaustive_patterns_same_crate.rs | 2 +- .../uninhabited/match_with_exhaustive_patterns.rs | 2 +- .../uninhabited/match_with_exhaustive_patterns_same_crate.rs | 2 +- tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs | 2 +- .../rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs | 2 +- tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs | 2 +- tests/ui/uninhabited/uninhabited-patterns.rs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/ui/pattern/usefulness/impl-trait.rs b/tests/ui/pattern/usefulness/impl-trait.rs index ceb97315e9dde..1fec9a2633eec 100644 --- a/tests/ui/pattern/usefulness/impl-trait.rs +++ b/tests/ui/pattern/usefulness/impl-trait.rs @@ -1,5 +1,5 @@ #![feature(never_type)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(type_alias_impl_trait)] #![feature(non_exhaustive_omitted_patterns_lint)] #![deny(unreachable_patterns)] diff --git a/tests/ui/pattern/usefulness/uninhabited.rs b/tests/ui/pattern/usefulness/uninhabited.rs index 5622808d4c7d6..fd2c1296f99bd 100644 --- a/tests/ui/pattern/usefulness/uninhabited.rs +++ b/tests/ui/pattern/usefulness/uninhabited.rs @@ -5,7 +5,7 @@ // `Ty::is_inhabited_from` function. #![feature(never_type)] #![feature(never_type_fallback)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![deny(unreachable_patterns)] macro_rules! assert_empty { diff --git a/tests/ui/reachable/unreachable-loop-patterns.rs b/tests/ui/reachable/unreachable-loop-patterns.rs index e9cef5f47d4aa..4294a18ba440f 100644 --- a/tests/ui/reachable/unreachable-loop-patterns.rs +++ b/tests/ui/reachable/unreachable-loop-patterns.rs @@ -1,5 +1,5 @@ #![feature(never_type, never_type_fallback)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![allow(unreachable_code)] #![deny(unreachable_patterns)] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs index be86519ecb159..dea0d5cf7c3cd 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs @@ -1,6 +1,6 @@ // aux-build:uninhabited.rs #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs index 60289aa780378..d1c9502074870 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs @@ -1,7 +1,7 @@ // check-pass #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] #[non_exhaustive] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs index 900dfff652ea6..75f6240946d78 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs @@ -1,6 +1,6 @@ // aux-build:uninhabited.rs #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs index de5530485f3e6..797e19b53128b 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs @@ -1,7 +1,7 @@ // check-pass #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] #[non_exhaustive] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs index 221b5cf6bfad8..27c260c610cf4 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs @@ -1,7 +1,7 @@ // aux-build:uninhabited.rs // build-pass (FIXME(62277): could be check-pass?) #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs index ffc496a975ecf..898be87cccab1 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs @@ -1,5 +1,5 @@ #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] #[non_exhaustive] diff --git a/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs b/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs index b59432078350e..db11dd0f099a0 100644 --- a/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs +++ b/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] enum Void {} fn main() { diff --git a/tests/ui/uninhabited/uninhabited-patterns.rs b/tests/ui/uninhabited/uninhabited-patterns.rs index 4e90691e5c809..ae12c0fc4af68 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.rs +++ b/tests/ui/uninhabited/uninhabited-patterns.rs @@ -1,6 +1,6 @@ #![feature(box_patterns)] #![feature(never_type)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![deny(unreachable_patterns)] mod foo { From c1c2c3e60c667660f73074199f261b73638e3593 Mon Sep 17 00:00:00 2001 From: Ethiraric Date: Mon, 12 Feb 2024 23:16:47 +0100 Subject: [PATCH 063/417] Ignore imported items in `min_ident_chars` Suppress the `min_ident_chars` warning for items whose name we cannot control. Do not warn for `use a::b`, but warn for `use a::b as c`, since `c` is a local identifier. Fixes #12232 --- clippy_lints/src/min_ident_chars.rs | 34 +++++++++++++++++-- .../min_ident_chars/auxiliary/extern_types.rs | 6 ++++ .../min_ident_chars/min_ident_chars.rs | 5 ++- .../min_ident_chars/min_ident_chars.stderr | 28 +++++++++------ 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 41168230752a8..79883c4ec77f8 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::{walk_item, Visitor}; -use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind}; +use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, UsePath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; @@ -105,11 +105,26 @@ impl Visitor<'_> for IdentVisitor<'_, '_> { let str = ident.as_str(); if conf.is_ident_too_short(cx, str, ident.span) { - if let Node::Item(item) = node - && let ItemKind::Use(..) = item.kind + // Check whether the node is part of a `use` statement. We don't want to emit a warning if the user + // has no control over the type. + let usenode = opt_as_use_node(node).or_else(|| { + cx.tcx + .hir() + .parent_iter(hir_id) + .find_map(|(_, node)| opt_as_use_node(node)) + }); + + // If the name of the identifier is the same as the one of the imported item, this means that we + // found a `use foo::bar`. We can early-return to not emit the warning. + // If however the identifier is different, this means it is an alias (`use foo::bar as baz`). In + // this case, we need to emit the warning for `baz`. + if let Some(imported_item_path) = usenode + && let Some(Res::Def(_, imported_item_defid)) = imported_item_path.res.first() + && cx.tcx.item_name(*imported_item_defid).as_str() == str { return; } + // `struct Awa(T)` // ^ if let Node::PathSegment(path) = node { @@ -160,3 +175,16 @@ fn emit_min_ident_chars(conf: &MinIdentChars, cx: &impl LintContext, ident: &str }; span_lint(cx, MIN_IDENT_CHARS, span, &help); } + +/// Attempt to convert the node to an [`ItemKind::Use`] node. +/// +/// If it is, return the [`UsePath`] contained within. +fn opt_as_use_node(node: Node<'_>) -> Option<&'_ UsePath<'_>> { + if let Node::Item(item) = node + && let ItemKind::Use(path, _) = item.kind + { + Some(path) + } else { + None + } +} diff --git a/tests/ui-toml/min_ident_chars/auxiliary/extern_types.rs b/tests/ui-toml/min_ident_chars/auxiliary/extern_types.rs index 06a144f2218ce..1f1f1c6f1a316 100644 --- a/tests/ui-toml/min_ident_chars/auxiliary/extern_types.rs +++ b/tests/ui-toml/min_ident_chars/auxiliary/extern_types.rs @@ -1,3 +1,9 @@ #![allow(nonstandard_style, unused)] pub struct Aaa; +pub struct Bbb; + +pub const N: u32 = 3; + +pub const M: u32 = 2; +pub const LONGER: u32 = 32; diff --git a/tests/ui-toml/min_ident_chars/min_ident_chars.rs b/tests/ui-toml/min_ident_chars/min_ident_chars.rs index 4326c7159c832..ded3c72c3e042 100644 --- a/tests/ui-toml/min_ident_chars/min_ident_chars.rs +++ b/tests/ui-toml/min_ident_chars/min_ident_chars.rs @@ -3,7 +3,10 @@ #![warn(clippy::min_ident_chars)] extern crate extern_types; -use extern_types::Aaa; +use extern_types::{Aaa, LONGER, M, N as W}; + +pub const N: u32 = 0; +pub const LONG: u32 = 32; struct Owo { Uwu: u128, diff --git a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr index 7f00fac492430..b498fd3365032 100644 --- a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr +++ b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr @@ -1,47 +1,53 @@ -error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:6:19 +error: this ident is too short (1 <= 3) + --> $DIR/min_ident_chars.rs:6:41 | -LL | use extern_types::Aaa; - | ^^^ +LL | use extern_types::{Aaa, LONGER, M, N as W}; + | ^ | = note: `-D clippy::min-ident-chars` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` +error: this ident is too short (1 <= 3) + --> $DIR/min_ident_chars.rs:8:11 + | +LL | pub const N: u32 = 0; + | ^ + error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:10:5 + --> $DIR/min_ident_chars.rs:13:5 | LL | aaa: Aaa, | ^^^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:15:9 + --> $DIR/min_ident_chars.rs:18:9 | LL | let vvv = 1; | ^^^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:16:9 + --> $DIR/min_ident_chars.rs:19:9 | LL | let uuu = 1; | ^^^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:17:14 + --> $DIR/min_ident_chars.rs:20:14 | LL | let (mut a, mut b) = (1, 2); | ^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:17:21 + --> $DIR/min_ident_chars.rs:20:21 | LL | let (mut a, mut b) = (1, 2); | ^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:18:9 + --> $DIR/min_ident_chars.rs:21:9 | LL | for i in 0..1000 {} | ^ -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors From b3b9f31a869326bcd623c84fd230777f397847f3 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 28 Jan 2024 20:53:28 +0000 Subject: [PATCH 064/417] Bump `indexmap` `swap` has been deprecated in favour of `swap_remove` - the behaviour is the same though. --- clippy_lints/src/copies.rs | 3 ++- clippy_lints/src/escape.rs | 6 ++++-- clippy_lints/src/index_refutable_slice.rs | 6 ++++-- clippy_lints/src/matches/match_same_arms.rs | 3 ++- clippy_lints/src/needless_pass_by_ref_mut.rs | 3 ++- clippy_lints/src/no_effect.rs | 6 ++++-- clippy_lints/src/only_used_in_recursion.rs | 3 ++- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index bd07c19a2d81c..247048bbc49da 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -511,7 +511,8 @@ fn scan_block_for_eq<'tcx>( for stmt in &stmts[stmts.len() - init..=stmts.len() - offset] { if let StmtKind::Local(l) = stmt.kind { l.pat.each_binding_or_first(&mut |_, id, _, _| { - eq.locals.remove(&id); + // FIXME(rust/#120456) - is `swap_remove` correct? + eq.locals.swap_remove(&id); }); } } diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 064bac2e7dc74..8857cb8e3827f 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -138,7 +138,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) { if cmt.place.projections.is_empty() { if let PlaceBase::Local(lid) = cmt.place.base { - self.set.remove(&lid); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.set.swap_remove(&lid); } } } @@ -146,7 +147,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) { if cmt.place.projections.is_empty() { if let PlaceBase::Local(lid) = cmt.place.base { - self.set.remove(&lid); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.set.swap_remove(&lid); } } } diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 51b4f26b6d131..41e9d5b1c2e9d 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -106,7 +106,8 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { } // The slice was used for something other than indexing - self.slice_lint_info.remove(&local_id); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.slice_lint_info.swap_remove(&local_id); } intravisit::walk_expr(self, expr); } diff --git a/clippy_lints/src/matches/match_same_arms.rs b/clippy_lints/src/matches/match_same_arms.rs index d645e6c6c05c9..6595658b7692b 100644 --- a/clippy_lints/src/matches/match_same_arms.rs +++ b/clippy_lints/src/matches/match_same_arms.rs @@ -415,6 +415,7 @@ fn pat_contains_local(pat: &Pat<'_>, id: HirId) -> bool { /// Returns true if all the bindings in the `Pat` are in `ids` and vice versa fn bindings_eq(pat: &Pat<'_>, mut ids: HirIdSet) -> bool { let mut result = true; - pat.each_binding_or_first(&mut |_, id, _, _| result &= ids.remove(&id)); + // FIXME(rust/#120456) - is `swap_remove` correct? + pat.each_binding_or_first(&mut |_, id, _, _| result &= ids.swap_remove(&id)); result && ids.is_empty() } diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index 149d440ecac49..710ecd745f8d6 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -382,7 +382,8 @@ impl<'tcx> euv::Delegate<'tcx> for MutablyUsedVariablesCtxt<'tcx> { self.add_mutably_used_var(*vid); } self.prev_bind = None; - self.prev_move_to_closure.remove(vid); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.prev_move_to_closure.swap_remove(vid); } } diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 580160efeb701..6a5555ca38362 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -98,7 +98,8 @@ impl<'tcx> LateLintPass<'tcx> for NoEffect { fn check_block_post(&mut self, cx: &LateContext<'tcx>, _: &'tcx rustc_hir::Block<'tcx>) { for hir_id in self.local_bindings.pop().unwrap() { - if let Some(span) = self.underscore_bindings.remove(&hir_id) { + // FIXME(rust/#120456) - is `swap_remove` correct? + if let Some(span) = self.underscore_bindings.swap_remove(&hir_id) { span_lint_hir( cx, NO_EFFECT_UNDERSCORE_BINDING, @@ -112,7 +113,8 @@ impl<'tcx> LateLintPass<'tcx> for NoEffect { fn check_expr(&mut self, _: &LateContext<'tcx>, expr: &'tcx rustc_hir::Expr<'tcx>) { if let Some(def_id) = path_to_local(expr) { - self.underscore_bindings.remove(&def_id); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.underscore_bindings.swap_remove(&def_id); } } } diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index ae14016f4823a..a568392ecc45e 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -153,7 +153,8 @@ impl Params { param.uses = Vec::new(); let key = (param.fn_id, param.idx); self.by_fn.remove(&key); - self.by_id.remove(&id); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.by_id.swap_remove(&id); } } From a52acccc588b77520a003a217b91f47413371cac Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Tue, 23 Aug 2022 21:45:15 +0900 Subject: [PATCH 065/417] Implement `RustIrDatabase::impl_provided_for()` for `ChalkContext` --- crates/hir-ty/src/chalk_db.rs | 197 ++++++++++++++++++++++------------ 1 file changed, 130 insertions(+), 67 deletions(-) diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index bd243518fc607..157f7ce462d91 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -1,7 +1,7 @@ //! The implementation of `RustIrDatabase` for Chalk, which provides information //! about the code that Chalk needs. use core::ops; -use std::{iter, sync::Arc}; +use std::{iter, ops::ControlFlow, sync::Arc}; use tracing::debug; @@ -136,81 +136,91 @@ impl chalk_solve::RustIrDatabase for ChalkContext<'_> { _ => self_ty_fp.as_ref().map(std::slice::from_ref).unwrap_or(&[]), }; - let trait_module = trait_.module(self.db.upcast()); - let type_module = match self_ty_fp { - Some(TyFingerprint::Adt(adt_id)) => Some(adt_id.module(self.db.upcast())), - Some(TyFingerprint::ForeignType(type_id)) => { - Some(from_foreign_def_id(type_id).module(self.db.upcast())) - } - Some(TyFingerprint::Dyn(trait_id)) => Some(trait_id.module(self.db.upcast())), - _ => None, - }; - - let mut def_blocks = - [trait_module.containing_block(), type_module.and_then(|it| it.containing_block())]; - - // Note: Since we're using impls_for_trait, only impls where the trait - // can be resolved should ever reach Chalk. impl_datum relies on that - // and will panic if the trait can't be resolved. - let in_deps = self.db.trait_impls_in_deps(self.krate); - let in_self = self.db.trait_impls_in_crate(self.krate); - - let block_impls = iter::successors(self.block, |&block_id| { - cov_mark::hit!(block_local_impls); - self.db.block_def_map(block_id).parent().and_then(|module| module.containing_block()) - }) - .inspect(|&block_id| { - // make sure we don't search the same block twice - def_blocks.iter_mut().for_each(|block| { - if *block == Some(block_id) { - *block = None; - } - }); - }) - .filter_map(|block_id| self.db.trait_impls_in_block(block_id)); - let id_to_chalk = |id: hir_def::ImplId| id.to_chalk(self.db); + let mut result = vec![]; - match fps { - [] => { - debug!("Unrestricted search for {:?} impls...", trait_); - let mut f = |impls: &TraitImpls| { - result.extend(impls.for_trait(trait_).map(id_to_chalk)); - }; - f(&in_self); - in_deps.iter().map(ops::Deref::deref).for_each(&mut f); - block_impls.for_each(|it| f(&it)); - def_blocks - .into_iter() - .flatten() - .filter_map(|it| self.db.trait_impls_in_block(it)) - .for_each(|it| f(&it)); - } - fps => { - let mut f = - |impls: &TraitImpls| { - result.extend(fps.iter().flat_map(|fp| { - impls.for_trait_and_self_ty(trait_, *fp).map(id_to_chalk) - })); - }; - f(&in_self); - in_deps.iter().map(ops::Deref::deref).for_each(&mut f); - block_impls.for_each(|it| f(&it)); - def_blocks - .into_iter() - .flatten() - .filter_map(|it| self.db.trait_impls_in_block(it)) - .for_each(|it| f(&it)); - } - } + if fps.is_empty() { + debug!("Unrestricted search for {:?} impls...", trait_); + self.for_trait_impls(trait_, self_ty_fp, |impls| { + result.extend(impls.for_trait(trait_).map(id_to_chalk)); + ControlFlow::Continue(()) + }) + } else { + self.for_trait_impls(trait_, self_ty_fp, |impls| { + result.extend( + fps.iter().flat_map(move |fp| { + impls.for_trait_and_self_ty(trait_, *fp).map(id_to_chalk) + }), + ); + ControlFlow::Continue(()) + }) + }; debug!("impls_for_trait returned {} impls", result.len()); result } fn impl_provided_for(&self, auto_trait_id: TraitId, kind: &chalk_ir::TyKind) -> bool { debug!("impl_provided_for {:?}, {:?}", auto_trait_id, kind); - false // FIXME + + let trait_id = from_chalk_trait_id(auto_trait_id); + let self_ty = kind.clone().intern(Interner); + // We cannot filter impls by `TyFingerprint` for the following types: + let self_ty_fp = match kind { + // because we need to find any impl whose Self type is a ref with the same mutability + // (we don't care about the inner type). + TyKind::Ref(..) => None, + // because we need to find any impl whose Self type is a tuple with the same arity. + TyKind::Tuple(..) => None, + _ => TyFingerprint::for_trait_impl(&self_ty), + }; + + let check_kind = |impl_id| { + let impl_self_ty = self.db.impl_self_ty(impl_id); + // NOTE(skip_binders): it's safe to skip binders here as we don't check substitutions. + let impl_self_kind = impl_self_ty.skip_binders().kind(Interner); + + match (kind, impl_self_kind) { + (TyKind::Adt(id_a, _), TyKind::Adt(id_b, _)) => id_a == id_b, + (TyKind::AssociatedType(id_a, _), TyKind::AssociatedType(id_b, _)) => id_a == id_b, + (TyKind::Scalar(scalar_a), TyKind::Scalar(scalar_b)) => scalar_a == scalar_b, + (TyKind::Str, TyKind::Str) => true, + (TyKind::Tuple(arity_a, _), TyKind::Tuple(arity_b, _)) => arity_a == arity_b, + (TyKind::OpaqueType(id_a, _), TyKind::OpaqueType(id_b, _)) => id_a == id_b, + (TyKind::Slice(_), TyKind::Slice(_)) => true, + (TyKind::FnDef(id_a, _), TyKind::FnDef(id_b, _)) => id_a == id_b, + (TyKind::Ref(id_a, _, _), TyKind::Ref(id_b, _, _)) => id_a == id_b, + (TyKind::Raw(id_a, _), TyKind::Raw(id_b, _)) => id_a == id_b, + (TyKind::Never, TyKind::Never) => true, + (TyKind::Array(_, _), TyKind::Array(_, _)) => true, + (TyKind::Closure(id_a, _), TyKind::Closure(id_b, _)) => id_a == id_b, + (TyKind::Coroutine(id_a, _), TyKind::Coroutine(id_b, _)) => id_a == id_b, + (TyKind::CoroutineWitness(id_a, _), TyKind::CoroutineWitness(id_b, _)) => { + id_a == id_b + } + (TyKind::Foreign(id_a), TyKind::Foreign(id_b)) => id_a == id_b, + (TyKind::Error, TyKind::Error) => true, + (_, _) => false, + } + }; + + if let Some(fp) = self_ty_fp { + self.for_trait_impls(trait_id, self_ty_fp, |impls| { + match impls.for_trait_and_self_ty(trait_id, fp).any(check_kind) { + true => ControlFlow::Break(()), + false => ControlFlow::Continue(()), + } + }) + } else { + self.for_trait_impls(trait_id, self_ty_fp, |impls| { + match impls.for_trait(trait_id).any(check_kind) { + true => ControlFlow::Break(()), + false => ControlFlow::Continue(()), + } + }) + } + .is_break() } + fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc { self.db.associated_ty_value(self.krate, id) } @@ -489,6 +499,59 @@ impl chalk_solve::RustIrDatabase for ChalkContext<'_> { } } +impl<'a> ChalkContext<'a> { + fn for_trait_impls( + &self, + trait_id: hir_def::TraitId, + self_ty_fp: Option, + mut f: impl FnMut(&TraitImpls) -> ControlFlow<()>, + ) -> ControlFlow<()> { + // Note: Since we're using `impls_for_trait` and `impl_provided_for`, + // only impls where the trait can be resolved should ever reach Chalk. + // `impl_datum` relies on that and will panic if the trait can't be resolved. + let in_deps = self.db.trait_impls_in_deps(self.krate); + let in_self = self.db.trait_impls_in_crate(self.krate); + let trait_module = trait_id.module(self.db.upcast()); + let type_module = match self_ty_fp { + Some(TyFingerprint::Adt(adt_id)) => Some(adt_id.module(self.db.upcast())), + Some(TyFingerprint::ForeignType(type_id)) => { + Some(from_foreign_def_id(type_id).module(self.db.upcast())) + } + Some(TyFingerprint::Dyn(trait_id)) => Some(trait_id.module(self.db.upcast())), + _ => None, + }; + + let mut def_blocks = + [trait_module.containing_block(), type_module.and_then(|it| it.containing_block())]; + + let block_impls = iter::successors(self.block, |&block_id| { + cov_mark::hit!(block_local_impls); + self.db.block_def_map(block_id).parent().and_then(|module| module.containing_block()) + }) + .inspect(|&block_id| { + // make sure we don't search the same block twice + def_blocks.iter_mut().for_each(|block| { + if *block == Some(block_id) { + *block = None; + } + }); + }) + .filter_map(|block_id| self.db.trait_impls_in_block(block_id)); + f(&in_self)?; + for it in in_deps.iter().map(ops::Deref::deref) { + f(it)?; + } + for it in block_impls { + f(&it)?; + } + for it in def_blocks.into_iter().flatten().filter_map(|it| self.db.trait_impls_in_block(it)) + { + f(&it)?; + } + ControlFlow::Continue(()) + } +} + impl chalk_ir::UnificationDatabase for &dyn HirDatabase { fn fn_def_variance( &self, From 4940017716b7d3eeba314a361a9e4afa64e85a95 Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Tue, 23 Aug 2022 21:56:56 +0900 Subject: [PATCH 066/417] Rename `StructDatum` -> `AdtDatum` --- crates/hir-ty/src/chalk_db.rs | 20 ++++++++++---------- crates/hir-ty/src/db.rs | 6 +++--- crates/hir/src/lib.rs | 4 ++-- crates/ide-db/src/apply_change.rs | 2 +- crates/ide-db/src/lib.rs | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index 157f7ce462d91..33ae07e3638e7 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -33,7 +33,7 @@ use crate::{ pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum; pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum; -pub(crate) type StructDatum = chalk_solve::rust_ir::AdtDatum; +pub(crate) type AdtDatum = chalk_solve::rust_ir::AdtDatum; pub(crate) type ImplDatum = chalk_solve::rust_ir::ImplDatum; pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum; @@ -53,8 +53,8 @@ impl chalk_solve::RustIrDatabase for ChalkContext<'_> { fn trait_datum(&self, trait_id: TraitId) -> Arc { self.db.trait_datum(self.krate, trait_id) } - fn adt_datum(&self, struct_id: AdtId) -> Arc { - self.db.struct_datum(self.krate, struct_id) + fn adt_datum(&self, struct_id: AdtId) -> Arc { + self.db.adt_datum(self.krate, struct_id) } fn adt_repr(&self, _struct_id: AdtId) -> Arc> { // FIXME: keep track of these @@ -712,13 +712,13 @@ fn lang_item_from_well_known_trait(trait_: WellKnownTrait) -> LangItem { } } -pub(crate) fn struct_datum_query( +pub(crate) fn adt_datum_query( db: &dyn HirDatabase, krate: CrateId, - struct_id: AdtId, -) -> Arc { - debug!("struct_datum {:?}", struct_id); - let chalk_ir::AdtId(adt_id) = struct_id; + adt_id: AdtId, +) -> Arc { + debug!("adt_datum {:?}", adt_id); + let chalk_ir::AdtId(adt_id) = adt_id; let generic_params = generics(db.upcast(), adt_id.into()); let upstream = adt_id.module(db.upcast()).krate() != krate; let where_clauses = { @@ -737,10 +737,10 @@ pub(crate) fn struct_datum_query( fields: Vec::new(), // FIXME add fields (only relevant for auto traits), }; let struct_datum_bound = rust_ir::AdtDatumBound { variants: vec![variant], where_clauses }; - let struct_datum = StructDatum { + let struct_datum = AdtDatum { // FIXME set ADT kind kind: rust_ir::AdtKind::Struct, - id: struct_id, + id: chalk_ir::AdtId(adt_id), binders: make_binders(db, &generic_params, struct_datum_bound), flags, }; diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs index fbd366864a439..42313ff52b1fd 100644 --- a/crates/hir-ty/src/db.rs +++ b/crates/hir-ty/src/db.rs @@ -220,12 +220,12 @@ pub trait HirDatabase: DefDatabase + Upcast { trait_id: chalk_db::TraitId, ) -> sync::Arc; - #[salsa::invoke(chalk_db::struct_datum_query)] - fn struct_datum( + #[salsa::invoke(chalk_db::adt_datum_query)] + fn adt_datum( &self, krate: CrateId, struct_id: chalk_db::AdtId, - ) -> sync::Arc; + ) -> sync::Arc; #[salsa::invoke(chalk_db::impl_datum_query)] fn impl_datum( diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 08f7bb14caa3a..beaa6dd4d67cb 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -3798,9 +3798,9 @@ impl Type { // For non-phantom_data adts we check variants/fields as well as generic parameters TyKind::Adt(adt_id, substitution) - if !db.struct_datum(krate, *adt_id).flags.phantom_data => + if !db.adt_datum(krate, *adt_id).flags.phantom_data => { - let adt_datum = &db.struct_datum(krate, *adt_id); + let adt_datum = &db.adt_datum(krate, *adt_id); let adt_datum_bound = adt_datum.binders.clone().substitute(Interner, substitution); adt_datum_bound diff --git a/crates/ide-db/src/apply_change.rs b/crates/ide-db/src/apply_change.rs index 296253aa1ee19..1a214ef0bf564 100644 --- a/crates/ide-db/src/apply_change.rs +++ b/crates/ide-db/src/apply_change.rs @@ -124,7 +124,7 @@ impl RootDatabase { hir::db::InternCoroutineQuery hir::db::AssociatedTyDataQuery hir::db::TraitDatumQuery - hir::db::StructDatumQuery + hir::db::AdtDatumQuery hir::db::ImplDatumQuery hir::db::FnDefDatumQuery hir::db::FnDefVarianceQuery diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs index 2881748dd477e..d31dad514aa56 100644 --- a/crates/ide-db/src/lib.rs +++ b/crates/ide-db/src/lib.rs @@ -280,7 +280,7 @@ impl RootDatabase { // hir_db::InternCoroutineQuery hir_db::AssociatedTyDataQuery hir_db::TraitDatumQuery - hir_db::StructDatumQuery + hir_db::AdtDatumQuery hir_db::ImplDatumQuery hir_db::FnDefDatumQuery hir_db::FnDefVarianceQuery From 03340742ea42c00588707001aca8a05c9d846e08 Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Wed, 24 Aug 2022 01:55:08 +0900 Subject: [PATCH 067/417] Return ADT fields and `phantom_data` flag from `adt_datum_query()` --- crates/hir-ty/src/chalk_db.rs | 59 ++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index 33ae07e3638e7..0fde0f661d74f 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -720,26 +720,55 @@ pub(crate) fn adt_datum_query( debug!("adt_datum {:?}", adt_id); let chalk_ir::AdtId(adt_id) = adt_id; let generic_params = generics(db.upcast(), adt_id.into()); - let upstream = adt_id.module(db.upcast()).krate() != krate; - let where_clauses = { - let generic_params = generics(db.upcast(), adt_id.into()); - let bound_vars = generic_params.bound_vars_subst(db, DebruijnIndex::INNERMOST); - convert_where_clauses(db, adt_id.into(), &bound_vars) - }; + let bound_vars_subst = generic_params.bound_vars_subst(db, DebruijnIndex::INNERMOST); + let where_clauses = convert_where_clauses(db, adt_id.into(), &bound_vars_subst); + + let phantom_data_id = db + .lang_item(krate, SmolStr::new_inline("phantom_data")) + .and_then(|item| item.as_struct()) + .map(|item| item.into()); let flags = rust_ir::AdtFlags { - upstream, - // FIXME set fundamental and phantom_data flags correctly + upstream: adt_id.module(db.upcast()).krate() != krate, + // FIXME set fundamental flags correctly fundamental: false, - phantom_data: false, + phantom_data: phantom_data_id == Some(adt_id), + }; + + let variant_id_to_fields = |id| { + let field_types = db.field_types(id); + let fields = id + .variant_data(db.upcast()) + .fields() + .iter() + .map(|(idx, _)| field_types[idx].clone().substitute(Interner, &bound_vars_subst)) + .collect(); + rust_ir::AdtVariantDatum { fields } }; - // FIXME provide enum variants properly (for auto traits) - let variant = rust_ir::AdtVariantDatum { - fields: Vec::new(), // FIXME add fields (only relevant for auto traits), + + let (kind, variants) = match adt_id { + hir_def::AdtId::StructId(id) => { + (rust_ir::AdtKind::Struct, vec![variant_id_to_fields(id.into())]) + } + hir_def::AdtId::EnumId(id) => { + let variants = db + .enum_data(id) + .variants + .iter() + .map(|(local_id, _)| { + let variant_id = hir_def::EnumVariantId { parent: id, local_id }; + variant_id_to_fields(variant_id.into()) + }) + .collect(); + (rust_ir::AdtKind::Enum, variants) + } + hir_def::AdtId::UnionId(id) => { + (rust_ir::AdtKind::Union, vec![variant_id_to_fields(id.into())]) + } }; - let struct_datum_bound = rust_ir::AdtDatumBound { variants: vec![variant], where_clauses }; + + let struct_datum_bound = rust_ir::AdtDatumBound { variants, where_clauses }; let struct_datum = AdtDatum { - // FIXME set ADT kind - kind: rust_ir::AdtKind::Struct, + kind, id: chalk_ir::AdtId(adt_id), binders: make_binders(db, &generic_params, struct_datum_bound), flags, From 4829f591fbf6ce7e91394775c8be10cdf9291d1b Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Wed, 24 Aug 2022 03:27:59 +0900 Subject: [PATCH 068/417] Add test for auto trait bounds --- crates/hir-ty/src/chalk_db.rs | 7 ++-- crates/hir-ty/src/tests/traits.rs | 55 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index 0fde0f661d74f..5039d51d70c00 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -724,7 +724,7 @@ pub(crate) fn adt_datum_query( let where_clauses = convert_where_clauses(db, adt_id.into(), &bound_vars_subst); let phantom_data_id = db - .lang_item(krate, SmolStr::new_inline("phantom_data")) + .lang_item(krate, LangItem::PhantomData) .and_then(|item| item.as_struct()) .map(|item| item.into()); let flags = rust_ir::AdtFlags { @@ -754,10 +754,7 @@ pub(crate) fn adt_datum_query( .enum_data(id) .variants .iter() - .map(|(local_id, _)| { - let variant_id = hir_def::EnumVariantId { parent: id, local_id }; - variant_id_to_fields(variant_id.into()) - }) + .map(|&(variant_id, _)| variant_id_to_fields(variant_id.into())) .collect(); (rust_ir::AdtKind::Enum, variants) } diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs index db14addaf185b..68cd6071ec79b 100644 --- a/crates/hir-ty/src/tests/traits.rs +++ b/crates/hir-ty/src/tests/traits.rs @@ -4553,3 +4553,58 @@ fn foo() { "#, ); } + +#[test] +fn auto_trait_bound() { + check_types( + r#" +//- minicore: sized +auto trait Send {} +impl !Send for *const T {} + +struct Yes; +trait IsSend { const IS_SEND: Yes; } +impl IsSend for T { const IS_SEND: Yes = Yes; } + +struct Struct(T); +enum Enum { A, B(T) } +union Union { t: T } + +#[lang = "phantom_data"] +struct PhantomData; + +fn f() { + T::IS_SEND; + //^^^^^^^^^^Yes + U::IS_SEND; + //^^^^^^^^^^{unknown} + <*const T>::IS_SEND; + //^^^^^^^^^^^^^^^^^^^{unknown} + Struct::::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^Yes + Struct::::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^{unknown} + Struct::<*const T>::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + Enum::::IS_SEND; + //^^^^^^^^^^^^^^^^^^Yes + Enum::::IS_SEND; + //^^^^^^^^^^^^^^^^^^{unknown} + Enum::<*const T>::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + Union::::IS_SEND; + //^^^^^^^^^^^^^^^^^^^Yes + Union::::IS_SEND; + //^^^^^^^^^^^^^^^^^^^{unknown} + Union::<*const T>::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + PhantomData::::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^^^^^^Yes + PhantomData::::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + PhantomData::<*const T>::IS_SEND; + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} +} +"#, + ); +} From 0eca3ef93eacd34e47d2893a3777e1d55593823c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 14 Feb 2024 13:35:43 +0100 Subject: [PATCH 069/417] Fix coerce_unsize_generic test --- crates/hir-ty/src/tests/coercion.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/hir-ty/src/tests/coercion.rs b/crates/hir-ty/src/tests/coercion.rs index d56b15b9b741e..bfb8df61a3330 100644 --- a/crates/hir-ty/src/tests/coercion.rs +++ b/crates/hir-ty/src/tests/coercion.rs @@ -536,7 +536,7 @@ fn test() { #[test] fn coerce_unsize_generic() { - check( + check_no_mismatches( r#" //- minicore: coerce_unsized struct Foo { t: T }; @@ -544,9 +544,7 @@ struct Bar(Foo); fn test() { let _: &Foo<[usize]> = &Foo { t: [1, 2, 3] }; - //^^^^^^^^^^^^^^^^^^^^^ expected &Foo<[usize]>, got &Foo<[i32; 3]> let _: &Bar<[usize]> = &Bar(Foo { t: [1, 2, 3] }); - //^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &Bar<[usize]>, got &Bar<[i32; 3]> } "#, ); From 9d18e197bcbd732a349ff8b51ecf6532d7ea822a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 14 Feb 2024 14:01:23 +0100 Subject: [PATCH 070/417] Filter out `{unknown}` types in `adt_datum_quqery` --- crates/hir-def/src/data/adt.rs | 2 +- crates/hir-ty/src/chalk_db.rs | 69 ++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/crates/hir-def/src/data/adt.rs b/crates/hir-def/src/data/adt.rs index 540f643ae7d91..f07b1257662d5 100644 --- a/crates/hir-def/src/data/adt.rs +++ b/crates/hir-def/src/data/adt.rs @@ -40,7 +40,7 @@ pub struct StructData { } bitflags! { - #[derive(Debug, Clone, PartialEq, Eq)] + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct StructFlags: u8 { const NO_FLAGS = 0; /// Indicates whether the struct is `PhantomData`. diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index 5039d51d70c00..49393f05a1ab9 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -10,9 +10,10 @@ use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait}; use base_db::CrateId; use hir_def::{ + data::adt::StructFlags, hir::Movability, lang_item::{LangItem, LangItemTarget}, - AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId, + AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId, VariantId, }; use hir_expand::name::name; @@ -159,6 +160,7 @@ impl chalk_solve::RustIrDatabase for ChalkContext<'_> { debug!("impls_for_trait returned {} impls", result.len()); result } + fn impl_provided_for(&self, auto_trait_id: TraitId, kind: &chalk_ir::TyKind) -> bool { debug!("impl_provided_for {:?}, {:?}", auto_trait_id, kind); @@ -183,22 +185,22 @@ impl chalk_solve::RustIrDatabase for ChalkContext<'_> { (TyKind::Adt(id_a, _), TyKind::Adt(id_b, _)) => id_a == id_b, (TyKind::AssociatedType(id_a, _), TyKind::AssociatedType(id_b, _)) => id_a == id_b, (TyKind::Scalar(scalar_a), TyKind::Scalar(scalar_b)) => scalar_a == scalar_b, - (TyKind::Str, TyKind::Str) => true, + (TyKind::Error, TyKind::Error) + | (TyKind::Str, TyKind::Str) + | (TyKind::Slice(_), TyKind::Slice(_)) + | (TyKind::Never, TyKind::Never) + | (TyKind::Array(_, _), TyKind::Array(_, _)) => true, (TyKind::Tuple(arity_a, _), TyKind::Tuple(arity_b, _)) => arity_a == arity_b, (TyKind::OpaqueType(id_a, _), TyKind::OpaqueType(id_b, _)) => id_a == id_b, - (TyKind::Slice(_), TyKind::Slice(_)) => true, (TyKind::FnDef(id_a, _), TyKind::FnDef(id_b, _)) => id_a == id_b, - (TyKind::Ref(id_a, _, _), TyKind::Ref(id_b, _, _)) => id_a == id_b, - (TyKind::Raw(id_a, _), TyKind::Raw(id_b, _)) => id_a == id_b, - (TyKind::Never, TyKind::Never) => true, - (TyKind::Array(_, _), TyKind::Array(_, _)) => true, + (TyKind::Ref(id_a, _, _), TyKind::Ref(id_b, _, _)) + | (TyKind::Raw(id_a, _), TyKind::Raw(id_b, _)) => id_a == id_b, (TyKind::Closure(id_a, _), TyKind::Closure(id_b, _)) => id_a == id_b, - (TyKind::Coroutine(id_a, _), TyKind::Coroutine(id_b, _)) => id_a == id_b, - (TyKind::CoroutineWitness(id_a, _), TyKind::CoroutineWitness(id_b, _)) => { + (TyKind::Coroutine(id_a, _), TyKind::Coroutine(id_b, _)) + | (TyKind::CoroutineWitness(id_a, _), TyKind::CoroutineWitness(id_b, _)) => { id_a == id_b } (TyKind::Foreign(id_a), TyKind::Foreign(id_b)) => id_a == id_b, - (TyKind::Error, TyKind::Error) => true, (_, _) => false, } }; @@ -653,7 +655,7 @@ pub(crate) fn trait_datum_query( coinductive: false, // only relevant for Chalk testing // FIXME: set these flags correctly marker: false, - fundamental: false, + fundamental: trait_data.fundamental, }; let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); let associated_ty_ids = trait_data.associated_types().map(to_assoc_type_id).collect(); @@ -715,33 +717,44 @@ fn lang_item_from_well_known_trait(trait_: WellKnownTrait) -> LangItem { pub(crate) fn adt_datum_query( db: &dyn HirDatabase, krate: CrateId, - adt_id: AdtId, + chalk_ir::AdtId(adt_id): AdtId, ) -> Arc { debug!("adt_datum {:?}", adt_id); - let chalk_ir::AdtId(adt_id) = adt_id; let generic_params = generics(db.upcast(), adt_id.into()); let bound_vars_subst = generic_params.bound_vars_subst(db, DebruijnIndex::INNERMOST); let where_clauses = convert_where_clauses(db, adt_id.into(), &bound_vars_subst); - let phantom_data_id = db - .lang_item(krate, LangItem::PhantomData) - .and_then(|item| item.as_struct()) - .map(|item| item.into()); + let (fundamental, phantom_data) = match adt_id { + hir_def::AdtId::StructId(s) => { + let flags = db.struct_data(s).flags; + ( + flags.contains(StructFlags::IS_FUNDAMENTAL), + flags.contains(StructFlags::IS_PHANTOM_DATA), + ) + } + // FIXME set fundamental flags correctly + hir_def::AdtId::UnionId(_) => (false, false), + hir_def::AdtId::EnumId(_) => (false, false), + }; let flags = rust_ir::AdtFlags { upstream: adt_id.module(db.upcast()).krate() != krate, - // FIXME set fundamental flags correctly - fundamental: false, - phantom_data: phantom_data_id == Some(adt_id), + fundamental, + phantom_data, }; - let variant_id_to_fields = |id| { - let field_types = db.field_types(id); - let fields = id - .variant_data(db.upcast()) - .fields() - .iter() - .map(|(idx, _)| field_types[idx].clone().substitute(Interner, &bound_vars_subst)) - .collect(); + let variant_id_to_fields = |id: VariantId| { + let variant_data = &id.variant_data(db.upcast()); + let fields = if variant_data.fields().is_empty() { + vec![] + } else { + let field_types = db.field_types(id); + variant_data + .fields() + .iter() + .map(|(idx, _)| field_types[idx].clone().substitute(Interner, &bound_vars_subst)) + .filter(|it| !it.contains_unknown()) + .collect() + }; rust_ir::AdtVariantDatum { fields } }; From b32d7c063106a1ac4a989be7d051b756f007c1f3 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Wed, 14 Feb 2024 13:31:02 +0000 Subject: [PATCH 071/417] Allow negative literals in `redundant_guards` --- clippy_lints/src/matches/redundant_guards.rs | 8 ++- tests/ui/redundant_guards.fixed | 8 +++ tests/ui/redundant_guards.rs | 8 +++ tests/ui/redundant_guards.stderr | 56 ++++++++++++++------ 4 files changed, 62 insertions(+), 18 deletions(-) diff --git a/clippy_lints/src/matches/redundant_guards.rs b/clippy_lints/src/matches/redundant_guards.rs index dfaaeb14ca3cb..a4374b28fa127 100644 --- a/clippy_lints/src/matches/redundant_guards.rs +++ b/clippy_lints/src/matches/redundant_guards.rs @@ -5,7 +5,7 @@ use clippy_utils::visitors::{for_each_expr, is_local_used}; use rustc_ast::{BorrowKind, LitKind}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{Arm, BinOpKind, Expr, ExprKind, MatchSource, Node, Pat, PatKind}; +use rustc_hir::{Arm, BinOpKind, Expr, ExprKind, MatchSource, Node, Pat, PatKind, UnOp}; use rustc_lint::LateContext; use rustc_span::symbol::Ident; use rustc_span::{Span, Symbol}; @@ -269,7 +269,11 @@ fn expr_can_be_pat(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Ctor(..), ..), ) }, - ExprKind::AddrOf(..) | ExprKind::Array(..) | ExprKind::Tup(..) | ExprKind::Struct(..) => true, + ExprKind::AddrOf(..) + | ExprKind::Array(..) + | ExprKind::Tup(..) + | ExprKind::Struct(..) + | ExprKind::Unary(UnOp::Neg, _) => true, ExprKind::Lit(lit) if !matches!(lit.node, LitKind::Float(..)) => true, _ => false, } { diff --git a/tests/ui/redundant_guards.fixed b/tests/ui/redundant_guards.fixed index aef26ef225c90..0a2ae911ad43d 100644 --- a/tests/ui/redundant_guards.fixed +++ b/tests/ui/redundant_guards.fixed @@ -117,6 +117,14 @@ fn h(v: Option) { }; } +fn negative_literal(i: i32) { + match i { + -1 => {}, + 1 => {}, + _ => {}, + } +} + // Do not lint fn f(s: Option) { diff --git a/tests/ui/redundant_guards.rs b/tests/ui/redundant_guards.rs index 5d476f5b04035..c8656f26ef339 100644 --- a/tests/ui/redundant_guards.rs +++ b/tests/ui/redundant_guards.rs @@ -117,6 +117,14 @@ fn h(v: Option) { }; } +fn negative_literal(i: i32) { + match i { + i if i == -1 => {}, + i if i == 1 => {}, + _ => {}, + } +} + // Do not lint fn f(s: Option) { diff --git a/tests/ui/redundant_guards.stderr b/tests/ui/redundant_guards.stderr index f78d2a814f9b2..27bd8bfabb154 100644 --- a/tests/ui/redundant_guards.stderr +++ b/tests/ui/redundant_guards.stderr @@ -108,7 +108,31 @@ LL + Some(0) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:165:28 + --> $DIR/redundant_guards.rs:122:14 + | +LL | i if i == -1 => {}, + | ^^^^^^^ + | +help: try + | +LL - i if i == -1 => {}, +LL + -1 => {}, + | + +error: redundant guard + --> $DIR/redundant_guards.rs:123:14 + | +LL | i if i == 1 => {}, + | ^^^^^^ + | +help: try + | +LL - i if i == 1 => {}, +LL + 1 => {}, + | + +error: redundant guard + --> $DIR/redundant_guards.rs:173:28 | LL | Some(ref x) if x == &1 => {}, | ^^^^^^^ @@ -120,7 +144,7 @@ LL + Some(1) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:166:28 + --> $DIR/redundant_guards.rs:174:28 | LL | Some(ref x) if &1 == x => {}, | ^^^^^^^ @@ -132,7 +156,7 @@ LL + Some(1) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:167:28 + --> $DIR/redundant_guards.rs:175:28 | LL | Some(ref x) if let &2 = x => {}, | ^^^^^^^^^^ @@ -144,7 +168,7 @@ LL + Some(2) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:168:28 + --> $DIR/redundant_guards.rs:176:28 | LL | Some(ref x) if matches!(x, &3) => {}, | ^^^^^^^^^^^^^^^ @@ -156,7 +180,7 @@ LL + Some(3) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:188:32 + --> $DIR/redundant_guards.rs:196:32 | LL | B { ref c, .. } if c == &1 => {}, | ^^^^^^^ @@ -168,7 +192,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:189:32 + --> $DIR/redundant_guards.rs:197:32 | LL | B { ref c, .. } if &1 == c => {}, | ^^^^^^^ @@ -180,7 +204,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:190:32 + --> $DIR/redundant_guards.rs:198:32 | LL | B { ref c, .. } if let &1 = c => {}, | ^^^^^^^^^^ @@ -192,7 +216,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:191:32 + --> $DIR/redundant_guards.rs:199:32 | LL | B { ref c, .. } if matches!(c, &1) => {}, | ^^^^^^^^^^^^^^^ @@ -204,7 +228,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:201:26 + --> $DIR/redundant_guards.rs:209:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -216,7 +240,7 @@ LL + Some(Some("")) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:212:26 + --> $DIR/redundant_guards.rs:220:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -228,7 +252,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:217:26 + --> $DIR/redundant_guards.rs:225:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -240,7 +264,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:228:26 + --> $DIR/redundant_guards.rs:236:26 | LL | Some(Some(x)) if x.starts_with(&[]) => {}, | ^^^^^^^^^^^^^^^^^^ @@ -252,7 +276,7 @@ LL + Some(Some([..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:233:26 + --> $DIR/redundant_guards.rs:241:26 | LL | Some(Some(x)) if x.starts_with(&[1]) => {}, | ^^^^^^^^^^^^^^^^^^^ @@ -264,7 +288,7 @@ LL + Some(Some([1, ..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:238:26 + --> $DIR/redundant_guards.rs:246:26 | LL | Some(Some(x)) if x.starts_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^^^ @@ -276,7 +300,7 @@ LL + Some(Some([1, 2, ..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:243:26 + --> $DIR/redundant_guards.rs:251:26 | LL | Some(Some(x)) if x.ends_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^ @@ -287,5 +311,5 @@ LL - Some(Some(x)) if x.ends_with(&[1, 2]) => {}, LL + Some(Some([.., 1, 2])) => {}, | -error: aborting due to 24 previous errors +error: aborting due to 26 previous errors From 9492de509fbf0793019dfe5ff8583b9a2c88dd83 Mon Sep 17 00:00:00 2001 From: Ethiraric Date: Wed, 14 Feb 2024 18:26:06 +0100 Subject: [PATCH 072/417] [`case_sensitive_file_extension_comparisons`]: Don't trigger on digits-only extensions --- .../src/methods/case_sensitive_file_extension_comparisons.rs | 1 + tests/ui/case_sensitive_file_extension_comparisons.fixed | 5 +++++ tests/ui/case_sensitive_file_extension_comparisons.rs | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs b/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs index a37087d0abffb..a5df863d800bb 100644 --- a/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs +++ b/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs @@ -38,6 +38,7 @@ pub(super) fn check<'tcx>( && ext_str.starts_with('.') && (ext_str.chars().skip(1).all(|c| c.is_uppercase() || c.is_ascii_digit()) || ext_str.chars().skip(1).all(|c| c.is_lowercase() || c.is_ascii_digit())) + && !ext_str.chars().skip(1).all(|c| c.is_ascii_digit()) && let recv_ty = cx.typeck_results().expr_ty(recv).peel_refs() && (recv_ty.is_str() || is_type_lang_item(cx, recv_ty, LangItem::String)) { diff --git a/tests/ui/case_sensitive_file_extension_comparisons.fixed b/tests/ui/case_sensitive_file_extension_comparisons.fixed index a816224c91c8d..8b4a165a97c68 100644 --- a/tests/ui/case_sensitive_file_extension_comparisons.fixed +++ b/tests/ui/case_sensitive_file_extension_comparisons.fixed @@ -63,4 +63,9 @@ fn main() { let _ = String::new().ends_with("a.ext"); let _ = "str".ends_with("a.extA"); TestStruct {}.ends_with("a.ext"); + + // Shouldn't fail if the extension has no ascii letter + let _ = String::new().ends_with(".123"); + let _ = "str".ends_with(".123"); + TestStruct {}.ends_with(".123"); } diff --git a/tests/ui/case_sensitive_file_extension_comparisons.rs b/tests/ui/case_sensitive_file_extension_comparisons.rs index 994de2805f742..e4b8178110b6c 100644 --- a/tests/ui/case_sensitive_file_extension_comparisons.rs +++ b/tests/ui/case_sensitive_file_extension_comparisons.rs @@ -51,4 +51,9 @@ fn main() { let _ = String::new().ends_with("a.ext"); let _ = "str".ends_with("a.extA"); TestStruct {}.ends_with("a.ext"); + + // Shouldn't fail if the extension has no ascii letter + let _ = String::new().ends_with(".123"); + let _ = "str".ends_with(".123"); + TestStruct {}.ends_with(".123"); } From ad7914f2e1122e12b82993c180043fe0d734c62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 14 Feb 2024 19:18:28 +0000 Subject: [PATCH 073/417] Fix msg for verbose suggestions with confusable capitalization When encountering a verbose/multipart suggestion that has changes that are only caused by different capitalization of ASCII letters that have little differenciation, expand the message to highlight that fact (like we already do for inline suggestions). The logic to do this was already present, but implemented incorrectly. --- tests/ui/match_str_case_mismatch.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/match_str_case_mismatch.stderr b/tests/ui/match_str_case_mismatch.stderr index f799a4698b943..b178fb7512cdb 100644 --- a/tests/ui/match_str_case_mismatch.stderr +++ b/tests/ui/match_str_case_mismatch.stderr @@ -17,7 +17,7 @@ error: this `match` arm has a differing case than its expression LL | "~!@#$%^&*()-_=+Foo" => {}, | ^^^^^^^^^^^^^^^^^^^^ | -help: consider changing the case of this arm to respect `to_ascii_lowercase` +help: consider changing the case of this arm to respect `to_ascii_lowercase` (notice the capitalization difference) | LL | "~!@#$%^&*()-_=+foo" => {}, | ~~~~~~~~~~~~~~~~~~~~ From 2526765fc83d0591828e95c7a621ee672244de12 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Thu, 15 Feb 2024 06:22:15 +0900 Subject: [PATCH 074/417] Check trait items --- clippy_lints/src/min_ident_chars.rs | 12 +++++-- tests/ui/min_ident_chars.rs | 6 ++++ tests/ui/min_ident_chars.stderr | 56 +++++++++++++++++++---------- 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 79883c4ec77f8..ec07f283c468a 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -2,8 +2,8 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_from_proc_macro; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_item, Visitor}; -use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, UsePath}; +use rustc_hir::intravisit::{walk_item, walk_trait_item, Visitor}; +use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, TraitItem, UsePath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; @@ -66,6 +66,14 @@ impl LateLintPass<'_> for MinIdentChars { walk_item(&mut IdentVisitor { conf: self, cx }, item); } + fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) { + if self.min_ident_chars_threshold == 0 { + return; + } + + walk_trait_item(&mut IdentVisitor { conf: self, cx }, item); + } + // This is necessary as `Node::Pat`s are not visited in `visit_id`. :/ fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { if let PatKind::Binding(_, _, ident, ..) = pat.kind diff --git a/tests/ui/min_ident_chars.rs b/tests/ui/min_ident_chars.rs index f99c35d5c57c4..1d89f26b6ee4d 100644 --- a/tests/ui/min_ident_chars.rs +++ b/tests/ui/min_ident_chars.rs @@ -37,6 +37,12 @@ struct Vec4 { struct AA(T, E); +trait Trait { + const A: u32 = 0; + type A; + fn a() {} +} + fn main() { // Allowed idents let w = 1; diff --git a/tests/ui/min_ident_chars.stderr b/tests/ui/min_ident_chars.stderr index e4181157ea23b..7490878d57262 100644 --- a/tests/ui/min_ident_chars.stderr +++ b/tests/ui/min_ident_chars.stderr @@ -68,112 +68,130 @@ LL | F, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:51:9 + --> $DIR/min_ident_chars.rs:41:11 + | +LL | const A: u32 = 0; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:42:10 + | +LL | type A; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:43:8 + | +LL | fn a() {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:57:9 | LL | let h = 1; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:52:9 + --> $DIR/min_ident_chars.rs:58:9 | LL | let e = 2; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:53:9 + --> $DIR/min_ident_chars.rs:59:9 | LL | let l = 3; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:54:9 + --> $DIR/min_ident_chars.rs:60:9 | LL | let l = 4; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:55:9 + --> $DIR/min_ident_chars.rs:61:9 | LL | let o = 6; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:59:10 + --> $DIR/min_ident_chars.rs:65:10 | LL | let (h, o, w) = (1, 2, 3); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:59:13 + --> $DIR/min_ident_chars.rs:65:13 | LL | let (h, o, w) = (1, 2, 3); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:10 + --> $DIR/min_ident_chars.rs:66:10 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:14 + --> $DIR/min_ident_chars.rs:66:14 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:17 + --> $DIR/min_ident_chars.rs:66:17 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:62:16 + --> $DIR/min_ident_chars.rs:68:16 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:62:19 + --> $DIR/min_ident_chars.rs:68:19 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:62:29 + --> $DIR/min_ident_chars.rs:68:29 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:66:9 + --> $DIR/min_ident_chars.rs:72:9 | LL | let o = 1; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:67:9 + --> $DIR/min_ident_chars.rs:73:9 | LL | let o = O { o }; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:81:4 + --> $DIR/min_ident_chars.rs:87:4 | LL | fn b() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:82:21 + --> $DIR/min_ident_chars.rs:88:21 | LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:82:29 + --> $DIR/min_ident_chars.rs:88:29 | LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ -error: aborting due to 29 previous errors +error: aborting due to 32 previous errors From d2aa1beed775e09a7f79f3a7761feece92572bf1 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 14 Feb 2024 14:50:49 +1100 Subject: [PATCH 075/417] Add an `ErrorGuaranteed` to `ast::TyKind::Err`. This makes it more like `hir::TyKind::Err`, and avoids a `span_delayed_bug` call in `LoweringContext::lower_ty_direct`. It also requires adding `ast::TyKind::Dummy`, now that `ast::TyKind::Err` can't be used for that purpose in the absence of an error emission. There are a couple of cases that aren't as neat as I would have liked, marked with `FIXME` comments. --- clippy_utils/src/ast_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_utils/src/ast_utils.rs b/clippy_utils/src/ast_utils.rs index adc35bd82ae39..0467a8a65709a 100644 --- a/clippy_utils/src/ast_utils.rs +++ b/clippy_utils/src/ast_utils.rs @@ -690,7 +690,7 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool { match (&l.kind, &r.kind) { (Paren(l), _) => eq_ty(l, r), (_, Paren(r)) => eq_ty(l, r), - (Never, Never) | (Infer, Infer) | (ImplicitSelf, ImplicitSelf) | (Err, Err) | (CVarArgs, CVarArgs) => true, + (Never, Never) | (Infer, Infer) | (ImplicitSelf, ImplicitSelf) | (Err(_), Err(_)) | (CVarArgs, CVarArgs) => true, (Slice(l), Slice(r)) => eq_ty(l, r), (Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value), (Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty), From f35eec867a1c64018e1b725094155ccccee73b27 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 14 Feb 2024 17:51:29 +0100 Subject: [PATCH 076/417] Add new lint `DEPRECATED_CLIPPY_CFG_ATTR` --- CHANGELOG.md | 1 + clippy_lints/src/attrs.rs | 125 ++++++++++++++++++++++------- clippy_lints/src/declared_lints.rs | 1 + 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6080fd3663b30..053f7de544649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5071,6 +5071,7 @@ Released 2018-09-13 [`default_trait_access`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access [`default_union_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_union_representation [`deprecated_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr +[`deprecated_clippy_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_clippy_cfg_attr [`deprecated_semver`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_semver [`deref_addrof`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_addrof [`deref_by_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_by_slicing diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index da38422874b44..755f4ad3c8929 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -433,6 +433,32 @@ declare_clippy_lint! { "prevent from misusing the wrong attr name" } +declare_clippy_lint! { + /// ### What it does + /// Checks for `#[cfg_attr(feature = "cargo-clippy", ...)]` and for + /// `#[cfg(feature = "cargo-clippy")]` and suggests to replace it with + /// `#[cfg_attr(clippy, ...)]` or `#[cfg(clippy)]`. + /// + /// ### Why is this bad? + /// This feature has been deprecated for years and shouldn't be used anymore. + /// + /// ### Example + /// ```no_run + /// #[cfg(feature = "cargo-clippy")] + /// struct Bar; + /// ``` + /// + /// Use instead: + /// ```no_run + /// #[cfg(clippy)] + /// struct Bar; + /// ``` + #[clippy::version = "1.78.0"] + pub DEPRECATED_CLIPPY_CFG_ATTR, + suspicious, + "usage of `cfg(feature = \"cargo-clippy\")` instead of `cfg(clippy)`" +} + declare_lint_pass!(Attributes => [ ALLOW_ATTRIBUTES_WITHOUT_REASON, INLINE_ALWAYS, @@ -794,6 +820,7 @@ impl_lint_pass!(EarlyAttributes => [ EMPTY_LINE_AFTER_DOC_COMMENTS, NON_MINIMAL_CFG, MAYBE_MISUSED_CFG, + DEPRECATED_CLIPPY_CFG_ATTR, ]); impl EarlyLintPass for EarlyAttributes { @@ -803,6 +830,7 @@ impl EarlyLintPass for EarlyAttributes { fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) { check_deprecated_cfg_attr(cx, attr, &self.msrv); + check_deprecated_cfg(cx, attr); check_mismatched_target_os(cx, attr); check_minimal_cfg_condition(cx, attr); check_misused_cfg(cx, attr); @@ -857,39 +885,80 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It } } +fn check_cargo_clippy_attr(cx: &EarlyContext<'_>, item: &rustc_ast::MetaItem) { + if item.has_name(sym::feature) && item.value_str().is_some_and(|v| v.as_str() == "cargo-clippy") { + span_lint_and_sugg( + cx, + DEPRECATED_CLIPPY_CFG_ATTR, + item.span, + "`feature = \"cargo-clippy\"` was replaced by `clippy`", + "replace with", + "clippy".to_string(), + Applicability::MachineApplicable, + ); + } +} + +fn check_deprecated_cfg_recursively(cx: &EarlyContext<'_>, attr: &rustc_ast::MetaItem) { + if let Some(ident) = attr.ident() { + if ["any", "all", "not"].contains(&ident.name.as_str()) { + let Some(list) = attr.meta_item_list() else { return }; + for item in list.iter().filter_map(|item| item.meta_item()) { + check_deprecated_cfg_recursively(cx, item); + } + } else { + check_cargo_clippy_attr(cx, attr); + } + } +} + +fn check_deprecated_cfg(cx: &EarlyContext<'_>, attr: &Attribute) { + if attr.has_name(sym::cfg) + && let Some(list) = attr.meta_item_list() + { + for item in list.iter().filter_map(|item| item.meta_item()) { + check_deprecated_cfg_recursively(cx, item); + } + } +} + fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute, msrv: &Msrv) { - if msrv.meets(msrvs::TOOL_ATTRIBUTES) - // check cfg_attr - && attr.has_name(sym::cfg_attr) + // check cfg_attr + if attr.has_name(sym::cfg_attr) && let Some(items) = attr.meta_item_list() && items.len() == 2 - // check for `rustfmt` && let Some(feature_item) = items[0].meta_item() - && feature_item.has_name(sym::rustfmt) - // check for `rustfmt_skip` and `rustfmt::skip` - && let Some(skip_item) = &items[1].meta_item() - && (skip_item.has_name(sym!(rustfmt_skip)) - || skip_item - .path - .segments - .last() - .expect("empty path in attribute") - .ident - .name - == sym::skip) - // Only lint outer attributes, because custom inner attributes are unstable - // Tracking issue: https://github.com/rust-lang/rust/issues/54726 - && attr.style == AttrStyle::Outer { - span_lint_and_sugg( - cx, - DEPRECATED_CFG_ATTR, - attr.span, - "`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes", - "use", - "#[rustfmt::skip]".to_string(), - Applicability::MachineApplicable, - ); + // check for `rustfmt` + if feature_item.has_name(sym::rustfmt) + && msrv.meets(msrvs::TOOL_ATTRIBUTES) + // check for `rustfmt_skip` and `rustfmt::skip` + && let Some(skip_item) = &items[1].meta_item() + && (skip_item.has_name(sym!(rustfmt_skip)) + || skip_item + .path + .segments + .last() + .expect("empty path in attribute") + .ident + .name + == sym::skip) + // Only lint outer attributes, because custom inner attributes are unstable + // Tracking issue: https://github.com/rust-lang/rust/issues/54726 + && attr.style == AttrStyle::Outer + { + span_lint_and_sugg( + cx, + DEPRECATED_CFG_ATTR, + attr.span, + "`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes", + "use", + "#[rustfmt::skip]".to_string(), + Applicability::MachineApplicable, + ); + } else { + check_deprecated_cfg_recursively(cx, feature_item); + } } } diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index b96a7af907007..c4d26e65b1a95 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -51,6 +51,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::attrs::ALLOW_ATTRIBUTES_WITHOUT_REASON_INFO, crate::attrs::BLANKET_CLIPPY_RESTRICTION_LINTS_INFO, crate::attrs::DEPRECATED_CFG_ATTR_INFO, + crate::attrs::DEPRECATED_CLIPPY_CFG_ATTR_INFO, crate::attrs::DEPRECATED_SEMVER_INFO, crate::attrs::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO, crate::attrs::EMPTY_LINE_AFTER_OUTER_ATTR_INFO, From 33603a6d80f090ad6ade21c7e9a369aba47b9f46 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 14 Feb 2024 20:12:05 +1100 Subject: [PATCH 077/417] Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`. This mostly works well, and eliminates a couple of delayed bugs. One annoying thing is that we should really also add an `ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`, so we have to fake it. --- clippy_lints/src/matches/match_same_arms.rs | 3 ++- clippy_lints/src/redundant_type_annotations.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_utils/src/consts.rs | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/matches/match_same_arms.rs b/clippy_lints/src/matches/match_same_arms.rs index 6595658b7692b..b8f7d96682014 100644 --- a/clippy_lints/src/matches/match_same_arms.rs +++ b/clippy_lints/src/matches/match_same_arms.rs @@ -295,7 +295,8 @@ impl<'a> NormalizedPat<'a> { LitKind::Char(val) => Self::LitInt(val.into()), LitKind::Int(val, _) => Self::LitInt(val.get()), LitKind::Bool(val) => Self::LitBool(val), - LitKind::Float(..) | LitKind::Err => Self::Wild, + LitKind::Float(..) => Self::Wild, + LitKind::Err(guar) => Self::Err(guar), }, _ => Self::Wild, }, diff --git a/clippy_lints/src/redundant_type_annotations.rs b/clippy_lints/src/redundant_type_annotations.rs index c8352c052659b..079e6500e3cf4 100644 --- a/clippy_lints/src/redundant_type_annotations.rs +++ b/clippy_lints/src/redundant_type_annotations.rs @@ -200,7 +200,7 @@ impl LateLintPass<'_> for RedundantTypeAnnotations { span_lint(cx, REDUNDANT_TYPE_ANNOTATIONS, local.span, "redundant type annotation"); } }, - LitKind::Err => (), + LitKind::Err(_) => (), LitKind::ByteStr(..) => { // We only lint if the type annotation is an array type (e.g. &[u8; 4]). // If instead it is a slice (e.g. &[u8]) it may not be redundant, so we diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 29c67341a467c..a0a6382046d02 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -279,7 +279,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { match lit.value.node { LitKind::Bool(val) => kind!("Bool({val:?})"), LitKind::Char(c) => kind!("Char({c:?})"), - LitKind::Err => kind!("Err"), + LitKind::Err(_) => kind!("Err"), LitKind::Byte(b) => kind!("Byte({b})"), LitKind::Int(i, suffix) => { let int_ty = match suffix { diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 61b38391d9e09..79c691992a85d 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -286,7 +286,7 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option>) -> Constan _ => bug!(), }, LitKind::Bool(b) => Constant::Bool(b), - LitKind::Err => Constant::Err, + LitKind::Err(_) => Constant::Err, } } From d33d8675d0fff6f9652790baa5346ac478e528ea Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 14 Feb 2024 20:12:05 +1100 Subject: [PATCH 078/417] Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`. This mostly works well, and eliminates a couple of delayed bugs. One annoying thing is that we should really also add an `ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`, so we have to fake it. --- crates/proc-macro-srv/src/server/rust_analyzer_span.rs | 4 ++-- crates/proc-macro-srv/src/server/token_id.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/proc-macro-srv/src/server/rust_analyzer_span.rs b/crates/proc-macro-srv/src/server/rust_analyzer_span.rs index c7c7bea994101..8a9d52a37a2f3 100644 --- a/crates/proc-macro-srv/src/server/rust_analyzer_span.rs +++ b/crates/proc-macro-srv/src/server/rust_analyzer_span.rs @@ -72,7 +72,7 @@ impl server::FreeFunctions for RaSpanServer { ) -> Result, ()> { // FIXME: keep track of LitKind and Suffix Ok(bridge::Literal { - kind: bridge::LitKind::Err, + kind: bridge::LitKind::Integer, // dummy symbol: Symbol::intern(self.interner, s), suffix: None, span: self.call_site, @@ -202,7 +202,7 @@ impl server::TokenStream for RaSpanServer { tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) => { bridge::TokenTree::Literal(bridge::Literal { // FIXME: handle literal kinds - kind: bridge::LitKind::Err, + kind: bridge::LitKind::Integer, // dummy symbol: Symbol::intern(self.interner, &lit.text), // FIXME: handle suffixes suffix: None, diff --git a/crates/proc-macro-srv/src/server/token_id.rs b/crates/proc-macro-srv/src/server/token_id.rs index edbdc67b482ff..15a9e0deae44f 100644 --- a/crates/proc-macro-srv/src/server/token_id.rs +++ b/crates/proc-macro-srv/src/server/token_id.rs @@ -64,7 +64,7 @@ impl server::FreeFunctions for TokenIdServer { ) -> Result, ()> { // FIXME: keep track of LitKind and Suffix Ok(bridge::Literal { - kind: bridge::LitKind::Err, + kind: bridge::LitKind::Integer, // dummy symbol: Symbol::intern(self.interner, s), suffix: None, span: self.call_site, @@ -187,7 +187,7 @@ impl server::TokenStream for TokenIdServer { tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) => { bridge::TokenTree::Literal(bridge::Literal { // FIXME: handle literal kinds - kind: bridge::LitKind::Err, + kind: bridge::LitKind::Integer, // dummy symbol: Symbol::intern(self.interner, &lit.text), // FIXME: handle suffixes suffix: None, From e3450ad19b6b5a6a67ba5bfdae53ac826953ba2a Mon Sep 17 00:00:00 2001 From: Matt Harding Date: Sun, 12 Nov 2023 05:58:42 +0000 Subject: [PATCH 079/417] Fix bootstrap issue with git on MSYS src/bootstrap runs git to find the root of the repository, but this can go awry when building in MSYS for the mingw target. This is because MSYS git returns a unix-y path, but bootstrap requires a Windows-y path. --- src/bootstrap/src/core/config/config.rs | 31 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index c0dd1e1208484..6fba6b20ace63 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1227,12 +1227,16 @@ impl Config { // Infer the rest of the configuration. // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary, - // running on a completely machine from where it was compiled. + // running on a completely different machine from where it was compiled. let mut cmd = Command::new("git"); - // NOTE: we cannot support running from outside the repository because the only path we have available - // is set at compile time, which can be wrong if bootstrap was downloaded from source. + // NOTE: we cannot support running from outside the repository because the only other path we have available + // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally. // We still support running outside the repository if we find we aren't in a git directory. - cmd.arg("rev-parse").arg("--show-toplevel"); + + // NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path, + // and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap + // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path. + cmd.arg("rev-parse").arg("--show-cdup"); // Discard stderr because we expect this to fail when building from a tarball. let output = cmd .stderr(std::process::Stdio::null()) @@ -1240,15 +1244,20 @@ impl Config { .ok() .and_then(|output| if output.status.success() { Some(output) } else { None }); if let Some(output) = output { - let git_root = String::from_utf8(output.stdout).unwrap(); - // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes. - let git_root = PathBuf::from(git_root.trim()).canonicalize().unwrap(); + let git_root_relative = String::from_utf8(output.stdout).unwrap(); + // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes, + // and to resolve any relative components. + let git_root = env::current_dir() + .unwrap() + .join(PathBuf::from(git_root_relative.trim())) + .canonicalize() + .unwrap(); let s = git_root.to_str().unwrap(); // Bootstrap is quite bad at handling /? in front of paths - let src = match s.strip_prefix("\\\\?\\") { + let git_root = match s.strip_prefix("\\\\?\\") { Some(p) => PathBuf::from(p), - None => PathBuf::from(git_root), + None => git_root, }; // If this doesn't have at least `stage0.json`, we guessed wrong. This can happen when, // for example, the build directory is inside of another unrelated git directory. @@ -1256,8 +1265,8 @@ impl Config { // // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1. - if src.join("src").join("stage0.json").exists() { - config.src = src; + if git_root.join("src").join("stage0.json").exists() { + config.src = git_root; } } else { // We're building from a tarball, not git sources. From f4eb6bd709cedf9e0b0baf904e06cbebcc884c64 Mon Sep 17 00:00:00 2001 From: Gabriel Goller Date: Thu, 15 Feb 2024 11:05:25 +0100 Subject: [PATCH 080/417] fix: documentation of `blocks_in_conditions` lint Updated documentation + example of `blocks_in_conditions` lint, which has been updated recently to include `match` statements as well. --- clippy_lints/src/blocks_in_conditions.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/blocks_in_conditions.rs b/clippy_lints/src/blocks_in_conditions.rs index eae87db26c6fd..62ef810f12b93 100644 --- a/clippy_lints/src/blocks_in_conditions.rs +++ b/clippy_lints/src/blocks_in_conditions.rs @@ -13,7 +13,7 @@ use rustc_span::sym; declare_clippy_lint! { /// ### What it does - /// Checks for `if` conditions that use blocks containing an + /// Checks for `if` and `match` conditions that use blocks containing an /// expression, statements or conditions that use closures with blocks. /// /// ### Why is this bad? @@ -25,6 +25,8 @@ declare_clippy_lint! { /// if { true } { /* ... */ } /// /// if { let x = somefunc(); x } { /* ... */ } + /// + /// match { let e = somefunc(); e } { /* ... */ } /// ``` /// /// Use instead: @@ -34,6 +36,9 @@ declare_clippy_lint! { /// /// let res = { let x = somefunc(); x }; /// if res { /* ... */ } + /// + /// let res = { let e = somefunc(); e }; + /// match res { /* ... */ } /// ``` #[clippy::version = "1.45.0"] pub BLOCKS_IN_CONDITIONS, From 183fade0ef7a5b98b81a9a054b6ff70d3cf3532b Mon Sep 17 00:00:00 2001 From: Gabriel Goller Date: Thu, 15 Feb 2024 11:44:22 +0100 Subject: [PATCH 081/417] fix: example in blocks_in_conditions lint Example in blocks_in_conditions lint didn't compile. --- clippy_lints/src/blocks_in_conditions.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/blocks_in_conditions.rs b/clippy_lints/src/blocks_in_conditions.rs index 62ef810f12b93..2eb0dac974258 100644 --- a/clippy_lints/src/blocks_in_conditions.rs +++ b/clippy_lints/src/blocks_in_conditions.rs @@ -26,7 +26,10 @@ declare_clippy_lint! { /// /// if { let x = somefunc(); x } { /* ... */ } /// - /// match { let e = somefunc(); e } { /* ... */ } + /// match { let e = somefunc(); e } { + /// // ... + /// # _ => {} + /// } /// ``` /// /// Use instead: @@ -38,7 +41,10 @@ declare_clippy_lint! { /// if res { /* ... */ } /// /// let res = { let e = somefunc(); e }; - /// match res { /* ... */ } + /// match res { + /// // ... + /// # _ => {} + /// } /// ``` #[clippy::version = "1.45.0"] pub BLOCKS_IN_CONDITIONS, From e0f82af3dd98b2548f08acc5b29567c3043e5aac Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 14 Feb 2024 23:16:48 +0100 Subject: [PATCH 082/417] Pass `--cfg clippy` to clippy-driver --- src/driver.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/driver.rs b/src/driver.rs index f5e52f787ab41..4a44f293b2f41 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -271,7 +271,9 @@ pub fn main() { }, _ => Some(s.to_string()), }) + // FIXME: remove this line in 1.79 to only keep `--cfg clippy`. .chain(vec!["--cfg".into(), r#"feature="cargo-clippy""#.into()]) + .chain(vec!["--cfg".into(), "clippy".into()]) .collect::>(); // We enable Clippy if one of the following conditions is met From cd6f03a3e82af4f50f6ebf68afdd13957dca3eb3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 14 Feb 2024 17:51:45 +0100 Subject: [PATCH 083/417] Add ui tests for `DEPRECATED_CLIPPY_CFG_ATTR` --- tests/ui/cfg_attr_cargo_clippy.fixed | 13 ++++++++ tests/ui/cfg_attr_cargo_clippy.rs | 13 ++++++++ tests/ui/cfg_attr_cargo_clippy.stderr | 47 +++++++++++++++++++++++++++ tests/ui/useless_attribute.fixed | 2 +- tests/ui/useless_attribute.rs | 2 +- tests/ui/useless_attribute.stderr | 4 +-- 6 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 tests/ui/cfg_attr_cargo_clippy.fixed create mode 100644 tests/ui/cfg_attr_cargo_clippy.rs create mode 100644 tests/ui/cfg_attr_cargo_clippy.stderr diff --git a/tests/ui/cfg_attr_cargo_clippy.fixed b/tests/ui/cfg_attr_cargo_clippy.fixed new file mode 100644 index 0000000000000..89815ffe9cbc1 --- /dev/null +++ b/tests/ui/cfg_attr_cargo_clippy.fixed @@ -0,0 +1,13 @@ +#![warn(clippy::deprecated_clippy_cfg_attr)] +#![allow(clippy::non_minimal_cfg)] +#![cfg_attr(clippy, doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was + +#[cfg_attr(clippy, derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg_attr(not(clippy), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(clippy)] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(not(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(any(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(all(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +pub struct Bar; + +fn main() {} diff --git a/tests/ui/cfg_attr_cargo_clippy.rs b/tests/ui/cfg_attr_cargo_clippy.rs new file mode 100644 index 0000000000000..745f8957641ed --- /dev/null +++ b/tests/ui/cfg_attr_cargo_clippy.rs @@ -0,0 +1,13 @@ +#![warn(clippy::deprecated_clippy_cfg_attr)] +#![allow(clippy::non_minimal_cfg)] +#![cfg_attr(feature = "cargo-clippy", doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was + +#[cfg_attr(feature = "cargo-clippy", derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(feature = "cargo-clippy")] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(not(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(any(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(all(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +pub struct Bar; + +fn main() {} diff --git a/tests/ui/cfg_attr_cargo_clippy.stderr b/tests/ui/cfg_attr_cargo_clippy.stderr new file mode 100644 index 0000000000000..0d67f8cd7bc3b --- /dev/null +++ b/tests/ui/cfg_attr_cargo_clippy.stderr @@ -0,0 +1,47 @@ +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:5:12 + | +LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + | + = note: `-D clippy::deprecated-clippy-cfg-attr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:6:16 + | +LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:7:7 + | +LL | #[cfg(feature = "cargo-clippy")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:8:11 + | +LL | #[cfg(not(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:9:11 + | +LL | #[cfg(any(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:10:11 + | +LL | #[cfg(all(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:3:13 + | +LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: aborting due to 7 previous errors + diff --git a/tests/ui/useless_attribute.fixed b/tests/ui/useless_attribute.fixed index 98a2bed0e81b5..c7d611f36cf8a 100644 --- a/tests/ui/useless_attribute.fixed +++ b/tests/ui/useless_attribute.fixed @@ -6,7 +6,7 @@ #![feature(rustc_private)] #![allow(dead_code)] -#![cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#![cfg_attr(clippy, allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index c5e324717b112..00cfa8f5d54f7 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -6,7 +6,7 @@ #![feature(rustc_private)] #[allow(dead_code)] -#[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#[cfg_attr(clippy, allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index e65c59abaf88f..cfb429ce77fc3 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -10,8 +10,8 @@ LL | #[allow(dead_code)] error: useless lint attribute --> $DIR/useless_attribute.rs:9:1 | -LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` +LL | #[cfg_attr(clippy, allow(dead_code))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(clippy, allow(dead_code)` error: useless lint attribute --> $DIR/useless_attribute.rs:20:5 From f4a3db8e4e40c075bce4a4e141becd41c2e0b1fa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 14 Feb 2024 23:18:17 +0100 Subject: [PATCH 084/417] Update clippy book to mention `cfg(clippy)` instead of feature `cargo-clippy` --- book/src/configuration.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index e8274bc4575d0..0552034645694 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -113,17 +113,14 @@ found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv) Very rarely, you may wish to prevent Clippy from evaluating certain sections of code entirely. You can do this with [conditional compilation](https://doc.rust-lang.org/reference/conditional-compilation.html) by checking that the -`cargo-clippy` feature is not set. You may need to provide a stub so that the code compiles: +`clippy` cfg is not set. You may need to provide a stub so that the code compiles: ```rust -#[cfg(not(feature = "cargo-clippy"))] +#[cfg(not(clippy)] include!(concat!(env!("OUT_DIR"), "/my_big_function-generated.rs")); -#[cfg(feature = "cargo-clippy")] +#[cfg(clippy)] fn my_big_function(_input: &str) -> Option { None } ``` - -This feature is not actually part of your crate, so specifying `--all-features` to other tools, e.g. `cargo test ---all-features`, will not disable it. From d846586bc9e0c056a92f8394b6209782238dc5e2 Mon Sep 17 00:00:00 2001 From: DropDemBits Date: Thu, 1 Feb 2024 20:38:42 -0500 Subject: [PATCH 085/417] fix: Support multiple tab stops in completions in VSCode Uses the native VSCode support for `SnippetTextEdit`s, but in a semi-hacky way as it's not fully supported yet. --- editors/code/src/commands.ts | 66 +++++++++++++++++++++++++-- editors/code/src/snippets.ts | 87 +++++++++++++++--------------------- 2 files changed, 98 insertions(+), 55 deletions(-) diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 3d33d255ad491..849fae5cf24b1 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -4,7 +4,11 @@ import * as ra from "./lsp_ext"; import * as path from "path"; import type { Ctx, Cmd, CtxInit } from "./ctx"; -import { applySnippetWorkspaceEdit, applySnippetTextEdits } from "./snippets"; +import { + applySnippetWorkspaceEdit, + applySnippetTextEdits, + type SnippetTextDocumentEdit, +} from "./snippets"; import { spawnSync } from "child_process"; import { type RunnableQuickPick, selectRunnable, createTask, createArgs } from "./run"; import { AstInspector } from "./ast_inspector"; @@ -1006,7 +1010,6 @@ export function resolveCodeAction(ctx: CtxInit): Cmd { return; } const itemEdit = item.edit; - const edit = await client.protocol2CodeConverter.asWorkspaceEdit(itemEdit); // filter out all text edits and recreate the WorkspaceEdit without them so we can apply // snippet edits on our own const lcFileSystemEdit = { @@ -1017,16 +1020,71 @@ export function resolveCodeAction(ctx: CtxInit): Cmd { lcFileSystemEdit, ); await vscode.workspace.applyEdit(fileSystemEdit); - await applySnippetWorkspaceEdit(edit); + + // replace all text edits so that we can convert snippet text edits into `vscode.SnippetTextEdit`s + // FIXME: this is a workaround until vscode-languageclient supports doing the SnippeTextEdit conversion itself + // also need to carry the snippetTextDocumentEdits separately, since we can't retrieve them again using WorkspaceEdit.entries + const [workspaceTextEdit, snippetTextDocumentEdits] = asWorkspaceSnippetEdit(ctx, itemEdit); + await applySnippetWorkspaceEdit(workspaceTextEdit, snippetTextDocumentEdits); if (item.command != null) { await vscode.commands.executeCommand(item.command.command, item.command.arguments); } }; } +function asWorkspaceSnippetEdit( + ctx: CtxInit, + item: lc.WorkspaceEdit, +): [vscode.WorkspaceEdit, SnippetTextDocumentEdit[]] { + const client = ctx.client; + + // partially borrowed from https://github.com/microsoft/vscode-languageserver-node/blob/295aaa393fda8ecce110c38880a00466b9320e63/client/src/common/protocolConverter.ts#L1060-L1101 + const result = new vscode.WorkspaceEdit(); + + if (item.documentChanges) { + const snippetTextDocumentEdits: SnippetTextDocumentEdit[] = []; + + for (const change of item.documentChanges) { + if (lc.TextDocumentEdit.is(change)) { + const uri = client.protocol2CodeConverter.asUri(change.textDocument.uri); + const snippetTextEdits: (vscode.TextEdit | vscode.SnippetTextEdit)[] = []; + + for (const edit of change.edits) { + if ( + "insertTextFormat" in edit && + edit.insertTextFormat === lc.InsertTextFormat.Snippet + ) { + // is a snippet text edit + snippetTextEdits.push( + new vscode.SnippetTextEdit( + client.protocol2CodeConverter.asRange(edit.range), + new vscode.SnippetString(edit.newText), + ), + ); + } else { + // always as a text document edit + snippetTextEdits.push( + vscode.TextEdit.replace( + client.protocol2CodeConverter.asRange(edit.range), + edit.newText, + ), + ); + } + } + + snippetTextDocumentEdits.push([uri, snippetTextEdits]); + } + } + return [result, snippetTextDocumentEdits]; + } else { + // we don't handle WorkspaceEdit.changes since it's not relevant for code actions + return [result, []]; + } +} + export function applySnippetWorkspaceEditCommand(_ctx: CtxInit): Cmd { return async (edit: vscode.WorkspaceEdit) => { - await applySnippetWorkspaceEdit(edit); + await applySnippetWorkspaceEdit(edit, edit.entries()); }; } diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts index d81765649ffb2..fb12125bcd842 100644 --- a/editors/code/src/snippets.ts +++ b/editors/code/src/snippets.ts @@ -3,20 +3,28 @@ import * as vscode from "vscode"; import { assert } from "./util"; import { unwrapUndefinable } from "./undefinable"; -export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) { - if (edit.entries().length === 1) { - const [uri, edits] = unwrapUndefinable(edit.entries()[0]); +export type SnippetTextDocumentEdit = [vscode.Uri, (vscode.TextEdit | vscode.SnippetTextEdit)[]]; + +export async function applySnippetWorkspaceEdit( + edit: vscode.WorkspaceEdit, + editEntries: SnippetTextDocumentEdit[], +) { + if (editEntries.length === 1) { + const [uri, edits] = unwrapUndefinable(editEntries[0]); const editor = await editorFromUri(uri); - if (editor) await applySnippetTextEdits(editor, edits); + if (editor) { + edit.set(uri, edits); + await vscode.workspace.applyEdit(edit); + } return; } - for (const [uri, edits] of edit.entries()) { + for (const [uri, edits] of editEntries) { const editor = await editorFromUri(uri); if (editor) { await editor.edit((builder) => { for (const indel of edits) { assert( - !parseSnippet(indel.newText), + !(indel instanceof vscode.SnippetTextEdit), `bad ws edit: snippet received with multiple edits: ${JSON.stringify( edit, )}`, @@ -39,53 +47,30 @@ async function editorFromUri(uri: vscode.Uri): Promise { - for (const indel of edits) { - const parsed = parseSnippet(indel.newText); - if (parsed) { - const [newText, [placeholderStart, placeholderLength]] = parsed; - const prefix = newText.substr(0, placeholderStart); - const lastNewline = prefix.lastIndexOf("\n"); - - const startLine = indel.range.start.line + lineDelta + countLines(prefix); - const startColumn = - lastNewline === -1 - ? indel.range.start.character + placeholderStart - : prefix.length - lastNewline - 1; - const endColumn = startColumn + placeholderLength; - selections.push( - new vscode.Selection( - new vscode.Position(startLine, startColumn), - new vscode.Position(startLine, endColumn), - ), - ); - builder.replace(indel.range, newText); - } else { - builder.replace(indel.range, indel.newText); - } - lineDelta += - countLines(indel.newText) - (indel.range.end.line - indel.range.start.line); - } - }); - if (selections.length > 0) editor.selections = selections; - if (selections.length === 1) { - const selection = unwrapUndefinable(selections[0]); - editor.revealRange(selection, vscode.TextEditorRevealType.InCenterIfOutsideViewport); - } + const edit = new vscode.WorkspaceEdit(); + edit.set(editor.document.uri, toSnippetTextEdits(edits)); + await vscode.workspace.applyEdit(edit); } -function parseSnippet(snip: string): [string, [number, number]] | undefined { - const m = snip.match(/\$(0|\{0:([^}]*)\})/); - if (!m) return undefined; - const placeholder = m[2] ?? ""; - if (m.index == null) return undefined; - const range: [number, number] = [m.index, placeholder.length]; - const insert = snip.replace(m[0], placeholder); - return [insert, range]; +function hasSnippet(snip: string): boolean { + const m = snip.match(/\$\d+|\{\d+:[^}]*\}/); + return m != null; } -function countLines(text: string): number { - return (text.match(/\n/g) || []).length; +function toSnippetTextEdits( + edits: vscode.TextEdit[], +): (vscode.TextEdit | vscode.SnippetTextEdit)[] { + return edits.map((textEdit) => { + // Note: text edits without any snippets are returned as-is instead of + // being wrapped in a SnippetTextEdit, as otherwise it would be + // treated as if it had a tab stop at the end. + if (hasSnippet(textEdit.newText)) { + return new vscode.SnippetTextEdit( + textEdit.range, + new vscode.SnippetString(textEdit.newText), + ); + } else { + return textEdit; + } + }); } From bcf14e27ce9d4331f4685fb759cf135a76ad119c Mon Sep 17 00:00:00 2001 From: DropDemBits Date: Thu, 15 Feb 2024 18:39:17 -0500 Subject: [PATCH 086/417] Work around snippet edits doubling up extra indentation We can't tell vscode to not add in the extra indentation, so we instead opt to remove it from the edits themselves, and then let vscode add it back in. --- editors/code/src/snippets.ts | 71 +++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts index fb12125bcd842..b3982bdf2be41 100644 --- a/editors/code/src/snippets.ts +++ b/editors/code/src/snippets.ts @@ -13,7 +13,7 @@ export async function applySnippetWorkspaceEdit( const [uri, edits] = unwrapUndefinable(editEntries[0]); const editor = await editorFromUri(uri); if (editor) { - edit.set(uri, edits); + edit.set(uri, removeLeadingWhitespace(editor, edits)); await vscode.workspace.applyEdit(edit); } return; @@ -48,7 +48,8 @@ async function editorFromUri(uri: vscode.Uri): Promise { + if (edit instanceof vscode.SnippetTextEdit) { + const snippetEdit: vscode.SnippetTextEdit = edit; + const firstLineEnd = snippetEdit.snippet.value.indexOf("\n"); + + if (firstLineEnd !== -1) { + // Is a multi-line snippet, remove the indentation which + // would be added back in by vscode. + const startLine = editor.document.lineAt(snippetEdit.range.start.line); + const leadingWhitespace = getLeadingWhitespace( + startLine.text, + 0, + startLine.firstNonWhitespaceCharacterIndex, + ); + + const [firstLine, rest] = splitAt(snippetEdit.snippet.value, firstLineEnd + 1); + const unindentedLines = rest + .split("\n") + .map((line) => line.replace(leadingWhitespace, "")) + .join("\n"); + + snippetEdit.snippet.value = firstLine + unindentedLines; + } + + return snippetEdit; + } else { + return edit; + } + }); +} + +// based on https://github.com/microsoft/vscode/blob/main/src/vs/base/common/strings.ts#L284 +function getLeadingWhitespace(str: string, start: number = 0, end: number = str.length): string { + for (let i = start; i < end; i++) { + const chCode = str.charCodeAt(i); + if (chCode !== " ".charCodeAt(0) && chCode !== " ".charCodeAt(0)) { + return str.substring(start, i); + } + } + return str.substring(start, end); +} + +function splitAt(str: string, index: number): [string, string] { + return [str.substring(0, index), str.substring(index)]; +} From f0adfe74b6e83e2fea8ad46710670b29572f4885 Mon Sep 17 00:00:00 2001 From: Centri3 <114838443+Centri3@users.noreply.github.com> Date: Tue, 6 Jun 2023 21:32:27 -0500 Subject: [PATCH 087/417] lint `new_without_default` on const fns too --- clippy_lints/src/new_without_default.rs | 4 ---- tests/ui/new_without_default.fixed | 10 ++++++++-- tests/ui/new_without_default.rs | 4 ++-- tests/ui/new_without_default.stderr | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 9de6ad4213755..b3b8a5e99638a 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -75,10 +75,6 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault { if let hir::ImplItemKind::Fn(ref sig, _) = impl_item.kind { let name = impl_item.ident.name; let id = impl_item.owner_id; - if sig.header.constness == hir::Constness::Const { - // can't be implemented by default - return; - } if sig.header.unsafety == hir::Unsafety::Unsafe { // can't be implemented for unsafe new return; diff --git a/tests/ui/new_without_default.fixed b/tests/ui/new_without_default.fixed index 1c7ba1a48c90d..85408c4e17f45 100644 --- a/tests/ui/new_without_default.fixed +++ b/tests/ui/new_without_default.fixed @@ -132,12 +132,18 @@ impl PrivateItem { } // We don't lint private items on public structs } -struct Const; +pub struct Const; + +impl Default for Const { + fn default() -> Self { + Self::new() + } +} impl Const { pub const fn new() -> Const { Const - } // const fns can't be implemented via Default + } // While Default is not const, it can still call const functions, so we should lint this } pub struct IgnoreGenericNew; diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index 964aa0f63da8e..3ac7292c2362f 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -114,12 +114,12 @@ impl PrivateItem { } // We don't lint private items on public structs } -struct Const; +pub struct Const; impl Const { pub const fn new() -> Const { Const - } // const fns can't be implemented via Default + } // While Default is not const, it can still call const functions, so we should lint this } pub struct IgnoreGenericNew; diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index acba5b0d7bd5d..6652a2642051b 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -55,6 +55,23 @@ LL + } LL + } | +error: you should consider adding a `Default` implementation for `Const` + --> $DIR/new_without_default.rs:120:5 + | +LL | / pub const fn new() -> Const { +LL | | Const +LL | | } // While Default is not const, it can still call const functions, so we should lint this + | |_____^ + | +help: try adding this + | +LL + impl Default for Const { +LL + fn default() -> Self { +LL + Self::new() +LL + } +LL + } + | + error: you should consider adding a `Default` implementation for `NewNotEqualToDerive` --> $DIR/new_without_default.rs:180:5 | @@ -149,5 +166,5 @@ LL + } LL + } | -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors From 80459c14a4a6d9613d2bc07f5f0df905e8f99a0d Mon Sep 17 00:00:00 2001 From: Matt Harding Date: Tue, 13 Feb 2024 04:37:31 +0000 Subject: [PATCH 088/417] Changes to CI related to mingw and MSYS --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++++++ src/ci/github-actions/ci.yml | 21 ++++++++++++++++++ src/ci/run.sh | 2 +- src/ci/scripts/install-clang.sh | 3 +-- src/ci/scripts/install-mingw.sh | 10 ++++----- src/ci/scripts/install-msys2.sh | 38 +++++++++++++++++++++++++++------ src/ci/shared.sh | 4 ++++ 7 files changed, 96 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26e589c092eda..464fd3b5640e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,9 +65,20 @@ jobs: - name: x86_64-gnu-tools os: ubuntu-20.04-16core-64gb env: {} + defaults: + run: + shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: + - if: "contains(matrix.os, 'windows')" + uses: msys2/setup-msys2@v2.22.0 + with: + msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" + update: false + release: true + path-type: inherit + install: "make dos2unix diffutils\n" - name: disable git crlf conversion run: git config --global core.autocrlf false - name: checkout the source code @@ -459,9 +470,20 @@ jobs: RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-extended --enable-profiler" SCRIPT: python x.py dist bootstrap --include-default-paths os: windows-2019-8core-32gb + defaults: + run: + shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: + - if: "contains(matrix.os, 'windows')" + uses: msys2/setup-msys2@v2.22.0 + with: + msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" + update: false + release: true + path-type: inherit + install: "make dos2unix diffutils\n" - name: disable git crlf conversion run: git config --global core.autocrlf false - name: checkout the source code @@ -587,9 +609,20 @@ jobs: env: CODEGEN_BACKENDS: "llvm,cranelift" os: ubuntu-20.04-16core-64gb + defaults: + run: + shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: + - if: "contains(matrix.os, 'windows')" + uses: msys2/setup-msys2@v2.22.0 + with: + msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" + update: false + release: true + path-type: inherit + install: "make dos2unix diffutils\n" - name: disable git crlf conversion run: git config --global core.autocrlf false - name: checkout the source code diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 43e48c01176f3..51d9dea5a0bc3 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -111,10 +111,31 @@ x--expand-yaml-anchors--remove: if: success() && !env.SKIP_JOB - &base-ci-job + defaults: + run: + shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }} timeout-minutes: 600 runs-on: "${{ matrix.os }}" env: *shared-ci-variables steps: + - if: contains(matrix.os, 'windows') + uses: msys2/setup-msys2@v2.22.0 + with: + # i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64. + msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }} + # don't try to download updates for already installed packages + update: false + # don't try to use the msys that comes built-in to the github runner, + # so we can control what is installed (i.e. not python) + release: true + # Inherit the full path from the Windows environment, with MSYS2's */bin/ + # dirs placed in front. This lets us run Windows-native Python etc. + path-type: inherit + install: > + make + dos2unix + diffutils + - name: disable git crlf conversion run: git config --global core.autocrlf false diff --git a/src/ci/run.sh b/src/ci/run.sh index 1cdcffc1a7544..3ad04c73d3da4 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -76,7 +76,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set dist.compression-profile=balance # the LLVM build, as not to run out of memory. # This is an attempt to fix the spurious build error tracked by # https://github.com/rust-lang/rust/issues/108227. -if isWindows && [[ ${CUSTOM_MINGW-0} -eq 1 ]]; then +if isKnownToBeMingwBuild; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.link-jobs=1" fi diff --git a/src/ci/scripts/install-clang.sh b/src/ci/scripts/install-clang.sh index 77164ed4117a9..aa7ff813f5161 100755 --- a/src/ci/scripts/install-clang.sh +++ b/src/ci/scripts/install-clang.sh @@ -37,8 +37,7 @@ if isMacOS; then # Configure `AR` specifically so rustbuild doesn't try to infer it as # `clang-ar` by accident. ciCommandSetEnv AR "ar" -elif isWindows && [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then - +elif isWindows && ! isKnownToBeMingwBuild; then # If we're compiling for MSVC then we, like most other distribution builders, # switch to clang as the compiler. This'll allow us eventually to enable LTO # amongst LLVM and rustc. Note that we only do this on MSVC as I don't think diff --git a/src/ci/scripts/install-mingw.sh b/src/ci/scripts/install-mingw.sh index 7eccb9b86502c..87b835b63db5b 100755 --- a/src/ci/scripts/install-mingw.sh +++ b/src/ci/scripts/install-mingw.sh @@ -38,11 +38,11 @@ if isWindows; then ;; esac - if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then - pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \ - mingw-w64-$arch-gcc \ - mingw-w64-$arch-python # the python package is actually for python3 - ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin" + if [[ "${CUSTOM_MINGW:-0}" == 0 ]]; then + pacboy -S --noconfirm toolchain:p + # According to the comment in the Windows part of install-clang.sh, in the future we might + # want to do this instead: + # pacboy -S --noconfirm clang:p ... else mingw_dir="mingw${bits}" diff --git a/src/ci/scripts/install-msys2.sh b/src/ci/scripts/install-msys2.sh index 0aa4b42a6a8fb..905edf38a09db 100755 --- a/src/ci/scripts/install-msys2.sh +++ b/src/ci/scripts/install-msys2.sh @@ -1,17 +1,12 @@ #!/bin/bash -# Download and install MSYS2, needed primarily for the test suite (run-make) but -# also used by the MinGW toolchain for assembling things. +# Clean up and prepare the MSYS2 installation. MSYS2 is needed primarily for +# the test suite (run-make), but is also used by the MinGW toolchain for assembling things. set -euo pipefail IFS=$'\n\t' source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" - if isWindows; then - msys2Path="c:/msys64" - mkdir -p "${msys2Path}/home/${USERNAME}" - ciCommandAddPath "${msys2Path}/usr/bin" - # Detect the native Python version installed on the agent. On GitHub # Actions, the C:\hostedtoolcache\windows\Python directory contains a # subdirectory for each installed Python version. @@ -29,4 +24,33 @@ if isWindows; then fi ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64" ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts" + + # Install pacboy for easily installing packages + pacman -S --noconfirm pactoys + + # Delete these pre-installed tools so we can't accidentally use them, because we are using the + # MSYS2 setup action versions instead. + # Delete pre-installed version of MSYS2 + rm -r "/c/msys64/" + # Delete Strawberry Perl, which contains a version of mingw + rm -r "/c/Strawberry/" + # Delete these other copies of mingw, I don't even know where they come from. + rm -r "/c/mingw64/" + rm -r "/c/mingw32/" + + if isKnownToBeMingwBuild; then + # Use the mingw version of CMake for mingw builds. + # However, the MSVC build needs native CMake, as it fails with the mingw one. + # Delete native CMake + rm -r "/c/Program Files/CMake/" + # Install mingw-w64-$arch-cmake + pacboy -S --noconfirm cmake:p + + # We use Git-for-Windows for MSVC builds, and MSYS2 Git for mingw builds, + # so that both are tested. + # Delete Windows-Git + rm -r "/c/Program Files/Git/" + # Install MSYS2 git + pacman -S --noconfirm git + fi fi diff --git a/src/ci/shared.sh b/src/ci/shared.sh index 720394af249b2..2b0a10e4d08d9 100644 --- a/src/ci/shared.sh +++ b/src/ci/shared.sh @@ -52,6 +52,10 @@ function isLinux { [[ "${OSTYPE}" = "linux-gnu" ]] } +function isKnownToBeMingwBuild { + isGitHubActions && [[ "${CI_JOB_NAME}" == *mingw ]] +} + function isCiBranch { if [[ $# -ne 1 ]]; then echo "usage: $0 " From e27c4722d364e0367a436f7d89c493eeb8ccf8ee Mon Sep 17 00:00:00 2001 From: Matt Harding Date: Tue, 13 Feb 2024 06:11:42 +0000 Subject: [PATCH 089/417] Update INSTALL.md instructions for MinGW --- INSTALL.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index b872d317e3627..d7e0fd72044e9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -145,10 +145,9 @@ toolchain. 1. Download the latest [MSYS2 installer][msys2] and go through the installer. -2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation - directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit - Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd - -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead.) +2. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit + or 64-bit Rust) either from your start menu, or by running `mingw64.exe` + or `mingw32.exe` from your MSYS2 installation directory (e.g. `C:\msys64`). 3. From this terminal, install the required tools: @@ -157,8 +156,7 @@ toolchain. pacman -Sy pacman-mirrors # Install build tools needed for Rust. If you're building a 32-bit compiler, - # then replace "x86_64" below with "i686". If you've already got Git, Python, - # or CMake installed and in PATH you can remove them from this list. + # then replace "x86_64" below with "i686". # Note that it is important that you do **not** use the 'python2', 'cmake', # and 'ninja' packages from the 'msys2' subsystem. # The build has historically been known to fail with these packages. @@ -175,9 +173,21 @@ toolchain. 4. Navigate to Rust's source code (or clone it), then build it: ```sh - python x.py setup user && python x.py build && python x.py install + python x.py setup dist && python x.py build && python x.py install ``` +If you want to use the native versions of Git, Python, or CMake you can remove +them from the above pacman command and install them from another source. Make +sure that they're in your Windows PATH, and edit the relevant `mingw[32|64].ini` +file in your MSYS2 installation directory by uncommenting the line +`MSYS2_PATH_TYPE=inherit` to include them in your MSYS2 PATH. + +Using Windows native Python can be helpful if you get errors when building LLVM. +You may also want to use Git for Windows, as it is often *much* faster. Turning +off real-time protection in the Windows Virus & Threat protections settings can +also help with long run times (although note that it will automatically turn +itself back on after some time). + ### MSVC MSVC builds of Rust additionally require an installation of Visual Studio 2017 From c975c5f69ef1709ed26f3c43b779eec0fde6c1e5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 25 Jan 2024 09:38:43 +0000 Subject: [PATCH 090/417] Bump ui_test version --- Cargo.toml | 2 +- tests/compile-test.rs | 41 ++++---- .../multiple_config_files/warn/Cargo.stderr | 2 +- .../absolute_paths.allow_crates.stderr | 8 +- .../absolute_paths.disallow_crates.stderr | 22 ++--- .../uninlined_format_args.stderr | 12 +-- .../arithmetic_side_effects_allowed.stderr | 18 ++-- .../array_size_threshold.stderr | 6 +- .../await_holding_invalid_type.stderr | 6 +- tests/ui-toml/bad_toml/conf_bad_toml.stderr | 2 +- .../bad_toml_type/conf_bad_type.stderr | 2 +- .../conf_deprecated_key.stderr | 6 +- tests/ui-toml/dbg_macro/dbg_macro.stderr | 18 ++-- .../decimal_literal_representation.stderr | 2 +- .../disallowed_macros.stderr | 32 +++---- .../disallowed_names.stderr | 4 +- .../disallowed_names.stderr | 2 +- .../disallowed_script_idents.stderr | 2 +- .../doc_markdown.stderr | 2 +- .../doc_markdown.stderr | 6 +- .../duplicated_keys/duplicated_keys.stderr | 2 +- .../duplicated_keys.stderr | 4 +- .../duplicated_keys.stderr | 4 +- .../enum_variant_size.stderr | 2 +- .../excessive_nesting.stderr | 74 +++++++-------- tests/ui-toml/expect_used/expect_used.stderr | 4 +- .../explicit_iter_loop.stderr | 4 +- .../fn_params_excessive_bools/test.stderr | 2 +- tests/ui-toml/functions_maxlines/test.stderr | 8 +- .../ifs_same_cond/ifs_same_cond.stderr | 4 +- .../impl_trait_in_params.stderr | 2 +- .../invalid_min_rust_version.stderr | 2 +- .../threshold5/item_name_repetitions.stderr | 4 +- .../large_futures/large_futures.stderr | 2 +- .../large_include_file.stderr | 4 +- .../large_stack_frames.stderr | 2 +- .../large_types_passed_by_value.stderr | 2 +- .../lint_decimal_readability/test.stderr | 4 +- .../manual_let_else/manual_let_else.stderr | 2 +- .../index_refutable_slice.stderr | 4 +- .../min_ident_chars/min_ident_chars.stderr | 16 ++-- .../min_rust_version/min_rust_version.stderr | 2 +- ...conf_missing_enforced_import_rename.stderr | 12 +-- .../module_inception/module_inception.stderr | 4 +- .../modulo_arithmetic.stderr | 8 +- .../conf_nonstandard_macro_braces.stderr | 16 ++-- tests/ui-toml/print_macro/print_macro.stderr | 4 +- .../private-doc-errors/doc_lints.stderr | 20 ++-- .../pub_crate_missing_doc.stderr | 14 +-- ...ub_underscore_fields.all_pub_fields.stderr | 14 +-- .../pub_underscore_fields.exported.stderr | 2 +- .../result_large_err/result_large_err.stderr | 2 +- tests/ui-toml/semicolon_block/both.stderr | 8 +- .../semicolon_inside_block.stderr | 2 +- .../semicolon_outside_block.stderr | 6 +- .../test.stderr | 28 +++--- .../struct_excessive_bools/test.stderr | 2 +- .../suppress_lint_in_const/test.stderr | 18 ++-- .../conf_french_disallowed_name.stderr | 14 +-- .../conf_disallowed_methods.stderr | 28 +++--- .../conf_disallowed_types.stderr | 42 ++++----- tests/ui-toml/toml_trivially_copy/test.stderr | 4 +- .../toml_unknown_key/conf_unknown_key.stderr | 6 +- .../too_large_for_stack/boxed_local.stderr | 2 +- .../too_large_for_stack/useless_vec.stderr | 2 +- .../too_many_arguments.stderr | 2 +- .../type_complexity/type_complexity.stderr | 2 +- .../type_repetition_in_bounds/main.stderr | 2 +- .../undocumented_unsafe_blocks.default.stderr | 74 +++++++-------- ...undocumented_unsafe_blocks.disabled.stderr | 94 +++++++++---------- .../unnecessary_box_returns.stderr | 2 +- tests/ui-toml/unwrap_used/unwrap_used.stderr | 56 +++++------ .../upper_case_acronyms.stderr | 26 ++--- tests/ui-toml/vec_box_sized/test.stderr | 6 +- .../verbose_bit_mask/verbose_bit_mask.stderr | 2 +- .../wildcard_imports/wildcard_imports.stderr | 6 +- .../wildcard_imports.stderr | 2 +- .../enums.stderr | 20 ++-- .../others.stderr | 30 +++--- .../traits.stderr | 32 +++---- .../shared_at_bottom.stderr | 20 ++-- .../shared_at_top.stderr | 20 ++-- .../shared_at_top_and_bottom.stderr | 22 ++--- .../valid_if_blocks.stderr | 22 ++--- .../complex_conditionals.stderr | 44 ++++----- .../complex_conditionals_nested.stderr | 8 +- .../checked_unwrap/simple_conditionals.stderr | 54 +++++------ .../ui/cmp_owned/asymmetric_partial_eq.stderr | 12 +-- tests/ui/cmp_owned/comparison_flip.stderr | 4 +- tests/ui/cmp_owned/with_suggestion.fixed | 2 +- tests/ui/cmp_owned/with_suggestion.stderr | 12 +-- tests/ui/cmp_owned/without_suggestion.stderr | 6 +- tests/ui/crashes/ice-10148.stderr | 2 +- tests/ui/crashes/ice-10645.stderr | 4 +- tests/ui/crashes/ice-10912.stderr | 4 +- tests/ui/crashes/ice-11065.rs | 1 - tests/ui/crashes/ice-11422.stderr | 2 +- tests/ui/crashes/ice-11803.stderr | 4 +- tests/ui/crashes/ice-2774.stderr | 2 +- tests/ui/crashes/ice-360.stderr | 6 +- tests/ui/crashes/ice-3717.stderr | 4 +- tests/ui/crashes/ice-3891.stderr | 2 +- tests/ui/crashes/ice-3969.stderr | 10 +- tests/ui/crashes/ice-5497.stderr | 2 +- tests/ui/crashes/ice-5835.stderr | 2 +- tests/ui/crashes/ice-5872.stderr | 2 +- tests/ui/crashes/ice-6250.stderr | 4 +- tests/ui/crashes/ice-6251.stderr | 8 +- tests/ui/crashes/ice-6252.stderr | 6 +- tests/ui/crashes/ice-6255.stderr | 2 +- tests/ui/crashes/ice-6256.stderr | 2 +- tests/ui/crashes/ice-7169.stderr | 2 +- tests/ui/crashes/ice-7868.stderr | 2 +- tests/ui/crashes/ice-7869.stderr | 2 +- tests/ui/crashes/ice-8250.stderr | 2 +- tests/ui/crashes/ice-8850.stderr | 6 +- tests/ui/crashes/ice-9041.stderr | 2 +- tests/ui/crashes/ice-9405.stderr | 2 +- tests/ui/crashes/ice-9445.stderr | 2 +- tests/ui/crashes/ice-9463.stderr | 8 +- tests/ui/crashes/ice-96721.stderr | 2 +- .../needless_lifetimes_impl_trait.stderr | 4 +- ...needless_pass_by_value-w-late-bound.stderr | 4 +- .../ui/crate_level_checks/no_std_swap.stderr | 2 +- .../std_main_recursion.stderr | 2 +- tests/ui/dbg_macro/dbg_macro.stderr | 38 ++++---- .../enums.stderr | 24 ++--- .../others.stderr | 10 +- .../traits.stderr | 22 ++--- tests/ui/doc/doc-fixable.stderr | 62 ++++++------ tests/ui/doc/unbalanced_ticks.stderr | 16 ++-- .../if_let_slice_binding.stderr | 22 ++--- .../slice_indexing_in_macro.stderr | 4 +- .../in_submodule.stderr | 2 +- .../root_module.stderr | 2 +- .../manual_memcpy/with_loop_counters.stderr | 22 ++--- .../without_loop_counters.stderr | 32 +++---- .../could_be_const.stderr | 22 ++--- tests/ui/needless_bool/fixable.stderr | 42 ++++----- tests/ui/needless_bool/simple.stderr | 8 +- .../out_of_bounds_indexing/issue-3102.stderr | 4 +- tests/ui/out_of_bounds_indexing/simple.stderr | 12 +-- .../pattern_type_mismatch/mutability.stderr | 4 +- .../pattern_alternatives.stderr | 6 +- .../pattern_structs.stderr | 16 ++-- .../pattern_tuples.stderr | 20 ++-- tests/ui/pattern_type_mismatch/syntax.stderr | 18 ++-- tests/ui/rc_clone_in_vec_init/arc.stderr | 8 +- tests/ui/rc_clone_in_vec_init/rc.stderr | 8 +- tests/ui/rc_clone_in_vec_init/weak.stderr | 16 ++-- .../ui/should_impl_trait/method_list_1.stderr | 30 +++--- .../ui/should_impl_trait/method_list_2.stderr | 30 +++--- .../expressions.stderr | 8 +- .../size_of_in_element_count/functions.stderr | 42 ++++----- 154 files changed, 928 insertions(+), 922 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 321424880d1e2..e8e932b24f92a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ color-print = "0.3.4" anstream = "0.5.0" [dev-dependencies] -ui_test = "0.21.2" +ui_test = "0.22.1" tester = "0.9" regex = "1.5" toml = "0.7.3" diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 3b7c974b65bee..8936888ad64a1 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -4,7 +4,8 @@ #![warn(rust_2018_idioms, unused_lifetimes)] #![allow(unused_extern_crates)] -use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, Mode, OutputConflictHandling}; +use ui_test::spanned::Spanned; +use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, Mode}; use std::collections::BTreeMap; use std::env::{self, set_var, var_os}; @@ -112,20 +113,21 @@ fn base_config(test_dir: &str) -> (Config, Args) { let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into())); let mut config = Config { - mode: Mode::Yolo { - rustfix: ui_test::RustfixMode::Everything, - }, filter_files: env::var("TESTNAME") .map(|filters| filters.split(',').map(str::to_string).collect()) .unwrap_or_default(), target: None, + bless_command: Some("cargo uibless".into()), out_dir: target_dir.join("ui_test"), ..Config::rustc(Path::new("tests").join(test_dir)) }; - config.with_args(&args, /* bless by default */ false); - if let OutputConflictHandling::Error(err) = &mut config.output_conflict_handling { - *err = "cargo uibless".into(); - } + config.comment_defaults.base().mode = Some(Spanned::dummy(Mode::Yolo { + rustfix: ui_test::RustfixMode::Everything, + })) + .into(); + config.comment_defaults.base().diagnostic_code_prefix = Some(Spanned::dummy("clippy::".into())).into(); + config.filter(&format!("tests/{test_dir}"), "$$DIR"); + config.with_args(&args); let current_exe_path = env::current_exe().unwrap(); let deps_path = current_exe_path.parent().unwrap(); let profile_path = deps_path.parent().unwrap(); @@ -179,9 +181,7 @@ fn run_internal_tests() { return; } let (mut config, args) = base_config("ui-internal"); - if let OutputConflictHandling::Error(err) = &mut config.output_conflict_handling { - *err = "cargo uitest --features internal -- -- --bless".into(); - } + config.bless_command = Some("cargo uitest --features internal -- -- --bless".into()); ui_test::run_tests_generic( vec![config], @@ -196,8 +196,10 @@ fn run_ui_toml() { let (mut config, args) = base_config("ui-toml"); config - .stderr_filters - .push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR")); + .comment_defaults + .base() + .normalize_stderr + .push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR".into())); ui_test::run_tests_generic( vec![config], @@ -213,6 +215,8 @@ fn run_ui_toml() { .unwrap(); } +// Allow `Default::default` as `OptWithSpan` is not nameable +#[allow(clippy::default_trait_access)] fn run_ui_cargo() { if IS_RUSTC_TEST_SUITE { return; @@ -234,11 +238,13 @@ fn run_ui_cargo() { } else { "cargo-clippy" }); - config.edition = None; + config.comment_defaults.base().edition = Default::default(); config - .stderr_filters - .push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR")); + .comment_defaults + .base() + .normalize_stderr + .push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR".into())); let ignored_32bit = |path: &Path| { // FIXME: for some reason the modules are linted in a different order for this test @@ -248,7 +254,8 @@ fn run_ui_cargo() { ui_test::run_tests_generic( vec![config], |path, config| { - path.ends_with("Cargo.toml") && ui_test::default_any_file_filter(path, config) && !ignored_32bit(path) + path.ends_with("Cargo.toml") + .then(|| ui_test::default_any_file_filter(path, config) && !ignored_32bit(path)) }, |_config, _path, _file_contents| {}, status_emitter::Text::from(args.format), diff --git a/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr b/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr index d82b9e73f786f..c8324ef05b110 100644 --- a/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr +++ b/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr @@ -1,2 +1,2 @@ -warning: using config file `$DIR/$DIR/.clippy.toml`, `$DIR/$DIR/clippy.toml` will be ignored +warning: using config file `$DIR/$DIR/multiple_config_files/warn/.clippy.toml`, `$DIR/$DIR/multiple_config_files/warn/clippy.toml` will be ignored diff --git a/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr b/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr index 99f08d9472789..b7254fc28e1e0 100644 --- a/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr +++ b/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr @@ -1,5 +1,5 @@ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:40:5 + --> $DIR/absolute_paths/absolute_paths.rs:40:5 | LL | std::f32::MAX; | ^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | std::f32::MAX; = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]` error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:41:5 + --> $DIR/absolute_paths/absolute_paths.rs:41:5 | LL | core::f32::MAX; | ^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:42:5 + --> $DIR/absolute_paths/absolute_paths.rs:42:5 | LL | ::core::f32::MAX; | ^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:58:5 + --> $DIR/absolute_paths/absolute_paths.rs:58:5 | LL | ::std::f32::MAX; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr b/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr index 017ba4cc24f11..c2ebb1bd43e3a 100644 --- a/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr +++ b/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr @@ -1,5 +1,5 @@ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:40:5 + --> $DIR/absolute_paths/absolute_paths.rs:40:5 | LL | std::f32::MAX; | ^^^^^^^^^^^^^ @@ -8,61 +8,61 @@ LL | std::f32::MAX; = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]` error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:41:5 + --> $DIR/absolute_paths/absolute_paths.rs:41:5 | LL | core::f32::MAX; | ^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:42:5 + --> $DIR/absolute_paths/absolute_paths.rs:42:5 | LL | ::core::f32::MAX; | ^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:43:5 + --> $DIR/absolute_paths/absolute_paths.rs:43:5 | LL | crate::a::b::c::C; | ^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:44:5 + --> $DIR/absolute_paths/absolute_paths.rs:44:5 | LL | crate::a::b::c::d::e::f::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:45:5 + --> $DIR/absolute_paths/absolute_paths.rs:45:5 | LL | crate::a::A; | ^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:46:5 + --> $DIR/absolute_paths/absolute_paths.rs:46:5 | LL | crate::a::b::B; | ^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:47:5 + --> $DIR/absolute_paths/absolute_paths.rs:47:5 | LL | crate::a::b::c::C::ZERO; | ^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:48:5 + --> $DIR/absolute_paths/absolute_paths.rs:48:5 | LL | helper::b::c::d::e::f(); | ^^^^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:49:5 + --> $DIR/absolute_paths/absolute_paths.rs:49:5 | LL | ::helper::b::c::d::e::f(); | ^^^^^^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths.rs:58:5 + --> $DIR/absolute_paths/absolute_paths.rs:58:5 | LL | ::std::f32::MAX; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr index b754f67edfb61..7227a45bb4368 100644 --- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr +++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:9:5 + --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:9:5 | LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:10:5 + --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:5 | LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {} is {local_f64:.local_i32$}", "x"); | error: literal with an empty format string - --> $DIR/uninlined_format_args.rs:10:35 + --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:35 | LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); | ^^^ @@ -39,7 +39,7 @@ LL + println!("Hello x is {:.*}", local_i32, local_f64); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:11:5 + --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5 | LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:12:5 + --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:12:5 | LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:13:5 + --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5 | LL | println!("{}, {}", local_i32, local_opt.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr index 5e8d26e074138..282d1529c03f4 100644 --- a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr +++ b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr @@ -1,5 +1,5 @@ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:69:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:69:13 | LL | let _ = Baz + Baz; | ^^^^^^^^^ @@ -8,49 +8,49 @@ LL | let _ = Baz + Baz; = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:80:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:80:13 | LL | let _ = 1i32 + Baz; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:83:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:83:13 | LL | let _ = 1i64 + Foo; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:87:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:87:13 | LL | let _ = 1i64 + Baz; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:98:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:98:13 | LL | let _ = Baz + 1i32; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:101:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:101:13 | LL | let _ = Foo + 1i64; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:105:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:105:13 | LL | let _ = Baz + 1i64; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:114:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:114:13 | LL | let _ = -Bar; | ^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed.rs:116:13 + --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:116:13 | LL | let _ = -Baz; | ^^^^ diff --git a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr index cf70b3c5cfcd2..5ceea60a2aba1 100644 --- a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr +++ b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr @@ -1,5 +1,5 @@ error: large array defined as const - --> $DIR/array_size_threshold.rs:4:1 + --> $DIR/array_size_threshold/array_size_threshold.rs:4:1 | LL | const ABOVE: [u8; 11] = [0; 11]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const ABOVE: [u8; 11] = [0; 11]; = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]` error: allocating a local array larger than 10 bytes - --> $DIR/array_size_threshold.rs:4:25 + --> $DIR/array_size_threshold/array_size_threshold.rs:4:25 | LL | const ABOVE: [u8; 11] = [0; 11]; | ^^^^^^^ @@ -20,7 +20,7 @@ LL | const ABOVE: [u8; 11] = [0; 11]; = help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]` error: allocating a local array larger than 10 bytes - --> $DIR/array_size_threshold.rs:8:17 + --> $DIR/array_size_threshold/array_size_threshold.rs:8:17 | LL | let above = [0u8; 11]; | ^^^^^^^^^ diff --git a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr index ddcd1940d475c..ac5d0ea2bd974 100644 --- a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr +++ b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr @@ -1,5 +1,5 @@ error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:5:9 + --> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:5:9 | LL | let _x = String::from("hello"); | ^^ @@ -9,13 +9,13 @@ LL | let _x = String::from("hello"); = help: to override `-D warnings` add `#[allow(clippy::await_holding_invalid_type)]` error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:10:9 + --> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:10:9 | LL | let x = Ipv4Addr::new(127, 0, 0, 1); | ^ error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:33:13 + --> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:33:13 | LL | let _x = String::from("hi!"); | ^^ diff --git a/tests/ui-toml/bad_toml/conf_bad_toml.stderr b/tests/ui-toml/bad_toml/conf_bad_toml.stderr index c308b7aa02398..d7e92c7fcf1c4 100644 --- a/tests/ui-toml/bad_toml/conf_bad_toml.stderr +++ b/tests/ui-toml/bad_toml/conf_bad_toml.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: expected `.`, `=` - --> $DIR/$DIR/clippy.toml:1:4 + --> $DIR/$DIR/bad_toml/clippy.toml:1:4 | LL | fn this_is_obviously(not: a, toml: file) { | ^ diff --git a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr index 1bcde2f30ed62..fe20d9eed89c2 100644 --- a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr +++ b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: invalid type: integer `42`, expected a sequence - --> $DIR/$DIR/clippy.toml:1:20 + --> $DIR/$DIR/bad_toml_type/clippy.toml:1:20 | LL | disallowed-names = 42 | ^^ diff --git a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr index 08fdb2d2dc322..8502e3d42fc21 100644 --- a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr +++ b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr @@ -1,17 +1,17 @@ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - --> $DIR/$DIR/clippy.toml:2:1 + --> $DIR/$DIR/conf_deprecated_key/clippy.toml:2:1 | LL | cyclomatic-complexity-threshold = 2 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `blacklisted-names`. Please use `disallowed-names` instead - --> $DIR/$DIR/clippy.toml:3:1 + --> $DIR/$DIR/conf_deprecated_key/clippy.toml:3:1 | LL | blacklisted-names = [ "..", "wibble" ] | ^^^^^^^^^^^^^^^^^ error: the function has a cognitive complexity of (3/2) - --> $DIR/conf_deprecated_key.rs:6:4 + --> $DIR/conf_deprecated_key/conf_deprecated_key.rs:6:4 | LL | fn cognitive_complexity() { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/dbg_macro/dbg_macro.stderr b/tests/ui-toml/dbg_macro/dbg_macro.stderr index 3a66f701e4df6..6042fa043f0db 100644 --- a/tests/ui-toml/dbg_macro/dbg_macro.stderr +++ b/tests/ui-toml/dbg_macro/dbg_macro.stderr @@ -1,5 +1,5 @@ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:5:22 + --> $DIR/dbg_macro/dbg_macro.rs:5:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:9:8 + --> $DIR/dbg_macro/dbg_macro.rs:9:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if n <= 1 { | ~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:10:9 + --> $DIR/dbg_macro/dbg_macro.rs:10:9 | LL | dbg!(1) | ^^^^^^^ @@ -34,7 +34,7 @@ LL | 1 | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:12:9 + --> $DIR/dbg_macro/dbg_macro.rs:12:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | n * factorial(n - 1) | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:17:5 + --> $DIR/dbg_macro/dbg_macro.rs:17:5 | LL | dbg!(42); | ^^^^^^^^ @@ -56,7 +56,7 @@ LL | 42; | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:18:5 + --> $DIR/dbg_macro/dbg_macro.rs:18:5 | LL | dbg!(dbg!(dbg!(42))); | ^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:19:14 + --> $DIR/dbg_macro/dbg_macro.rs:19:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:20:5 + --> $DIR/dbg_macro/dbg_macro.rs:20:5 | LL | dbg!(1, 2, dbg!(3, 4)); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:21:5 + --> $DIR/dbg_macro/dbg_macro.rs:21:5 | LL | dbg!(1, 2, 3, 4, 5); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr index 4510275c9a9a4..57eae317e4f2b 100644 --- a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr +++ b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr @@ -1,5 +1,5 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:4:13 + --> $DIR/decimal_literal_representation/decimal_literal_representation.rs:4:13 | LL | let _ = 16777215; | ^^^^^^^^ help: consider: `0x00FF_FFFF` diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr index 986a7b171c4a0..8ccf567bba2bd 100644 --- a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr +++ b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr @@ -1,5 +1,5 @@ error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros.rs:13:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:13:5 | LL | println!("one"); | ^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | println!("one"); = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]` error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros.rs:14:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:14:5 | LL | println!("two"); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `std::cfg` - --> $DIR/disallowed_macros.rs:15:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:15:5 | LL | cfg!(unix); | ^^^^^^^^^^ error: use of a disallowed macro `std::vec` - --> $DIR/disallowed_macros.rs:16:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:16:5 | LL | vec![1, 2, 3]; | ^^^^^^^^^^^^^ error: use of a disallowed macro `serde::Serialize` - --> $DIR/disallowed_macros.rs:18:14 + --> $DIR/disallowed_macros/disallowed_macros.rs:18:14 | LL | #[derive(Serialize)] | ^^^^^^^^^ @@ -34,43 +34,43 @@ LL | #[derive(Serialize)] = note: no serializing (from clippy.toml) error: use of a disallowed macro `macros::expr` - --> $DIR/disallowed_macros.rs:21:13 + --> $DIR/disallowed_macros/disallowed_macros.rs:21:13 | LL | let _ = macros::expr!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::stmt` - --> $DIR/disallowed_macros.rs:22:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:22:5 | LL | macros::stmt!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::pat` - --> $DIR/disallowed_macros.rs:23:9 + --> $DIR/disallowed_macros/disallowed_macros.rs:23:9 | LL | let macros::pat!() = 1; | ^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::ty` - --> $DIR/disallowed_macros.rs:24:12 + --> $DIR/disallowed_macros/disallowed_macros.rs:24:12 | LL | let _: macros::ty!() = ""; | ^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:25:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:25:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::binop` - --> $DIR/disallowed_macros.rs:26:13 + --> $DIR/disallowed_macros/disallowed_macros.rs:26:13 | LL | let _ = macros::binop!(1); | ^^^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::attr` - --> $DIR/disallowed_macros.rs:31:1 + --> $DIR/disallowed_macros/disallowed_macros.rs:31:1 | LL | / macros::attr! { LL | | struct S; @@ -78,25 +78,25 @@ LL | | } | |_^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:36:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:36:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:40:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:40:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:44:5 + --> $DIR/disallowed_macros/disallowed_macros.rs:44:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `proc_macros::Derive` - --> $DIR/disallowed_macros.rs:47:10 + --> $DIR/disallowed_macros/disallowed_macros.rs:47:10 | LL | #[derive(Derive)] | ^^^^^^ diff --git a/tests/ui-toml/disallowed_names_append/disallowed_names.stderr b/tests/ui-toml/disallowed_names_append/disallowed_names.stderr index 51cbe1abf599c..fdb6793e5ce6d 100644 --- a/tests/ui-toml/disallowed_names_append/disallowed_names.stderr +++ b/tests/ui-toml/disallowed_names_append/disallowed_names.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:5:9 + --> $DIR/disallowed_names_append/disallowed_names.rs:5:9 | LL | let foo = "bar"; | ^^^ @@ -8,7 +8,7 @@ LL | let foo = "bar"; = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `ducks` - --> $DIR/disallowed_names.rs:7:9 + --> $DIR/disallowed_names_append/disallowed_names.rs:7:9 | LL | let ducks = ["quack", "quack"]; | ^^^^^ diff --git a/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr b/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr index a5fece575f842..cf1e493d2deb1 100644 --- a/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr +++ b/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `ducks` - --> $DIR/disallowed_names.rs:7:9 + --> $DIR/disallowed_names_replace/disallowed_names.rs:7:9 | LL | let ducks = ["quack", "quack"]; | ^^^^^ diff --git a/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr index e83027e4e28ca..2f7407e0b17a3 100644 --- a/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr +++ b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr @@ -1,5 +1,5 @@ error: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana - --> $DIR/disallowed_script_idents.rs:4:9 + --> $DIR/disallowed_script_idents/disallowed_script_idents.rs:4:9 | LL | let カウンタ = 10; | ^^^^^^^^ diff --git a/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr b/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr index 877ca726fee0c..a0260fb16d812 100644 --- a/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr +++ b/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc_markdown.rs:9:5 + --> $DIR/doc_valid_idents_append/doc_markdown.rs:9:5 | LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted. | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr b/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr index 6567b5f1275d0..b3b801661af5a 100644 --- a/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr +++ b/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc_markdown.rs:6:5 + --> $DIR/doc_valid_idents_replace/doc_markdown.rs:6:5 | LL | /// OAuth and LaTeX are inside Clippy's default list. | ^^^^^ @@ -12,7 +12,7 @@ LL | /// `OAuth` and LaTeX are inside Clippy's default list. | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc_markdown.rs:6:15 + --> $DIR/doc_valid_idents_replace/doc_markdown.rs:6:15 | LL | /// OAuth and LaTeX are inside Clippy's default list. | ^^^^^ @@ -23,7 +23,7 @@ LL | /// OAuth and `LaTeX` are inside Clippy's default list. | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc_markdown.rs:9:5 + --> $DIR/doc_valid_idents_replace/doc_markdown.rs:9:5 | LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted. | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr index 3f2086b5ecb61..b06f17acb1406 100644 --- a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: duplicate key `cognitive-complexity-threshold` in document root - --> $DIR/$DIR/clippy.toml:2:1 + --> $DIR/$DIR/duplicated_keys/clippy.toml:2:1 | LL | cognitive-complexity-threshold = 4 | ^ diff --git a/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr index 3c38396338802..89f1ed292e69a 100644 --- a/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr @@ -1,11 +1,11 @@ error: error reading Clippy's configuration file: duplicate field `cognitive_complexity_threshold` (provided as `cyclomatic_complexity_threshold`) - --> $DIR/$DIR/clippy.toml:3:1 + --> $DIR/$DIR/duplicated_keys_deprecated/clippy.toml:3:1 | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - --> $DIR/$DIR/clippy.toml:3:1 + --> $DIR/$DIR/duplicated_keys_deprecated/clippy.toml:3:1 | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr index 3d37e4daa960b..ace7c5b6c23e2 100644 --- a/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr @@ -1,11 +1,11 @@ error: error reading Clippy's configuration file: duplicate field `cognitive-complexity-threshold` - --> $DIR/$DIR/clippy.toml:4:1 + --> $DIR/$DIR/duplicated_keys_deprecated_2/clippy.toml:4:1 | LL | cognitive-complexity-threshold = 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - --> $DIR/$DIR/clippy.toml:2:1 + --> $DIR/$DIR/duplicated_keys_deprecated_2/clippy.toml:2:1 | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/enum_variant_size/enum_variant_size.stderr b/tests/ui-toml/enum_variant_size/enum_variant_size.stderr index ca96c47b92bb5..8e6f9c8a9dab0 100644 --- a/tests/ui-toml/enum_variant_size/enum_variant_size.stderr +++ b/tests/ui-toml/enum_variant_size/enum_variant_size.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/enum_variant_size.rs:5:1 + --> $DIR/enum_variant_size/enum_variant_size.rs:5:1 | LL | / enum Bad { LL | | diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr b/tests/ui-toml/excessive_nesting/excessive_nesting.stderr index 74be5b2e2b92b..856bbd93e0deb 100644 --- a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr +++ b/tests/ui-toml/excessive_nesting/excessive_nesting.stderr @@ -1,5 +1,5 @@ error: this block is too nested - --> $DIR/excessive_nesting.rs:21:25 + --> $DIR/excessive_nesting/excessive_nesting.rs:21:25 | LL | let w = { 3 }; | ^^^^^ @@ -9,7 +9,7 @@ LL | let w = { 3 }; = help: to override `-D warnings` add `#[allow(clippy::excessive_nesting)]` error: this block is too nested - --> $DIR/excessive_nesting.rs:67:17 + --> $DIR/excessive_nesting/excessive_nesting.rs:67:17 | LL | / impl C { LL | | pub fn c() {} @@ -19,7 +19,7 @@ LL | | } = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:81:25 + --> $DIR/excessive_nesting/excessive_nesting.rs:81:25 | LL | let x = { 1 }; // not a warning, but cc is | ^^^^^ @@ -27,7 +27,7 @@ LL | let x = { 1 }; // not a warning, but cc is = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:98:17 + --> $DIR/excessive_nesting/excessive_nesting.rs:98:17 | LL | / pub mod e { LL | | pub mod f {} @@ -37,7 +37,7 @@ LL | | } // not here = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:111:18 + --> $DIR/excessive_nesting/excessive_nesting.rs:111:18 | LL | a_but_not({{{{{{{{0}}}}}}}}); | ^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | a_but_not({{{{{{{{0}}}}}}}}); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:112:12 + --> $DIR/excessive_nesting/excessive_nesting.rs:112:12 | LL | a.a({{{{{{{{{0}}}}}}}}}); | ^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | a.a({{{{{{{{{0}}}}}}}}}); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:113:12 + --> $DIR/excessive_nesting/excessive_nesting.rs:113:12 | LL | (0, {{{{{{{1}}}}}}}); | ^^^^^^^^^ @@ -61,7 +61,7 @@ LL | (0, {{{{{{{1}}}}}}}); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:118:25 + --> $DIR/excessive_nesting/excessive_nesting.rs:118:25 | LL | if true { | _________________________^ @@ -74,7 +74,7 @@ LL | | } = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:130:29 + --> $DIR/excessive_nesting/excessive_nesting.rs:130:29 | LL | let z = (|| { | _____________________________^ @@ -86,7 +86,7 @@ LL | | })(); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:149:13 + --> $DIR/excessive_nesting/excessive_nesting.rs:149:13 | LL | y += {{{{{5}}}}}; | ^^^^^ @@ -94,7 +94,7 @@ LL | y += {{{{{5}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:150:20 + --> $DIR/excessive_nesting/excessive_nesting.rs:150:20 | LL | let z = y + {{{{{{{{{5}}}}}}}}}; | ^^^^^^^^^^^^^ @@ -102,7 +102,7 @@ LL | let z = y + {{{{{{{{{5}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:151:12 + --> $DIR/excessive_nesting/excessive_nesting.rs:151:12 | LL | [0, {{{{{{{{{{0}}}}}}}}}}]; | ^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ LL | [0, {{{{{{{{{{0}}}}}}}}}}]; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:152:25 + --> $DIR/excessive_nesting/excessive_nesting.rs:152:25 | LL | let mut xx = [0; {{{{{{{{100}}}}}}}}]; | ^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | let mut xx = [0; {{{{{{{{100}}}}}}}}]; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:153:11 + --> $DIR/excessive_nesting/excessive_nesting.rs:153:11 | LL | xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL | xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}]; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:154:13 + --> $DIR/excessive_nesting/excessive_nesting.rs:154:13 | LL | &mut {{{{{{{{{{y}}}}}}}}}}; | ^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ LL | &mut {{{{{{{{{{y}}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:156:17 + --> $DIR/excessive_nesting/excessive_nesting.rs:156:17 | LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} | ^^^^ @@ -142,7 +142,7 @@ LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:156:28 + --> $DIR/excessive_nesting/excessive_nesting.rs:156:28 | LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} | ^^^^^^^^^^ @@ -150,7 +150,7 @@ LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:158:28 + --> $DIR/excessive_nesting/excessive_nesting.rs:158:28 | LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} | ^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:158:48 + --> $DIR/excessive_nesting/excessive_nesting.rs:158:48 | LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} | ^^^^^^^^ @@ -166,7 +166,7 @@ LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:160:14 + --> $DIR/excessive_nesting/excessive_nesting.rs:160:14 | LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} | ^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:160:35 + --> $DIR/excessive_nesting/excessive_nesting.rs:160:35 | LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} | ^^^^^^^^^^^^ @@ -182,7 +182,7 @@ LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:162:23 + --> $DIR/excessive_nesting/excessive_nesting.rs:162:23 | LL | let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +190,7 @@ LL | let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} }; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:164:8 + --> $DIR/excessive_nesting/excessive_nesting.rs:164:8 | LL | {{{{1;}}}}..{{{{{{3}}}}}}; | ^^^^ @@ -198,7 +198,7 @@ LL | {{{{1;}}}}..{{{{{{3}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:164:20 + --> $DIR/excessive_nesting/excessive_nesting.rs:164:20 | LL | {{{{1;}}}}..{{{{{{3}}}}}}; | ^^^^^^^ @@ -206,7 +206,7 @@ LL | {{{{1;}}}}..{{{{{{3}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:165:8 + --> $DIR/excessive_nesting/excessive_nesting.rs:165:8 | LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; | ^^^^ @@ -214,7 +214,7 @@ LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:165:21 + --> $DIR/excessive_nesting/excessive_nesting.rs:165:21 | LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -222,7 +222,7 @@ LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:166:10 + --> $DIR/excessive_nesting/excessive_nesting.rs:166:10 | LL | ..{{{{{{{5}}}}}}}; | ^^^^^^^^^ @@ -230,7 +230,7 @@ LL | ..{{{{{{{5}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:167:11 + --> $DIR/excessive_nesting/excessive_nesting.rs:167:11 | LL | ..={{{{{3}}}}}; | ^^^^^ @@ -238,7 +238,7 @@ LL | ..={{{{{3}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:168:8 + --> $DIR/excessive_nesting/excessive_nesting.rs:168:8 | LL | {{{{{1;}}}}}..; | ^^^^^^ @@ -246,7 +246,7 @@ LL | {{{{{1;}}}}}..; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:170:20 + --> $DIR/excessive_nesting/excessive_nesting.rs:170:20 | LL | loop { break {{{{1}}}} }; | ^^^^^ @@ -254,7 +254,7 @@ LL | loop { break {{{{1}}}} }; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:171:13 + --> $DIR/excessive_nesting/excessive_nesting.rs:171:13 | LL | loop {{{{{{}}}}}} | ^^^^^^ @@ -262,7 +262,7 @@ LL | loop {{{{{{}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:173:14 + --> $DIR/excessive_nesting/excessive_nesting.rs:173:14 | LL | match {{{{{{true}}}}}} { | ^^^^^^^^^^ @@ -270,7 +270,7 @@ LL | match {{{{{{true}}}}}} { = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:174:20 + --> $DIR/excessive_nesting/excessive_nesting.rs:174:20 | LL | true => {{{{}}}}, | ^^ @@ -278,7 +278,7 @@ LL | true => {{{{}}}}, = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:175:21 + --> $DIR/excessive_nesting/excessive_nesting.rs:175:21 | LL | false => {{{{}}}}, | ^^ @@ -286,7 +286,7 @@ LL | false => {{{{}}}}, = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:181:17 + --> $DIR/excessive_nesting/excessive_nesting.rs:181:17 | LL | / { LL | | println!("warning! :)"); @@ -296,7 +296,7 @@ LL | | } = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:190:28 + --> $DIR/excessive_nesting/excessive_nesting.rs:190:28 | LL | async fn c() -> u32 {{{{{{{0}}}}}}} | ^^^^^^^^^ @@ -304,7 +304,7 @@ LL | async fn c() -> u32 {{{{{{{0}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting.rs:196:8 + --> $DIR/excessive_nesting/excessive_nesting.rs:196:8 | LL | {{{{b().await}}}}; | ^^^^^^^^^^^ diff --git a/tests/ui-toml/expect_used/expect_used.stderr b/tests/ui-toml/expect_used/expect_used.stderr index 13b6d7ff9cd49..8cfe6dde184c6 100644 --- a/tests/ui-toml/expect_used/expect_used.stderr +++ b/tests/ui-toml/expect_used/expect_used.stderr @@ -1,5 +1,5 @@ error: used `expect()` on an `Option` value - --> $DIR/expect_used.rs:7:13 + --> $DIR/expect_used/expect_used.rs:7:13 | LL | let _ = opt.expect(""); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = opt.expect(""); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value - --> $DIR/expect_used.rs:12:13 + --> $DIR/expect_used/expect_used.rs:12:13 | LL | let _ = res.expect(""); | ^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr index 587d4f9b3f053..d01077bbc0375 100644 --- a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr +++ b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr @@ -1,5 +1,5 @@ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:6:14 + --> $DIR/explicit_iter_loop/explicit_iter_loop.rs:6:14 | LL | for _ in rmvec.iter() {} | ^^^^^^^^^^^^ help: to write this more concisely, try: `&*rmvec` @@ -8,7 +8,7 @@ LL | for _ in rmvec.iter() {} = help: to override `-D warnings` add `#[allow(clippy::explicit_iter_loop)]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:8:14 + --> $DIR/explicit_iter_loop/explicit_iter_loop.rs:8:14 | LL | for _ in rmvec.iter_mut() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *rmvec` diff --git a/tests/ui-toml/fn_params_excessive_bools/test.stderr b/tests/ui-toml/fn_params_excessive_bools/test.stderr index ceec4ea675530..975f1e831fe33 100644 --- a/tests/ui-toml/fn_params_excessive_bools/test.stderr +++ b/tests/ui-toml/fn_params_excessive_bools/test.stderr @@ -1,5 +1,5 @@ error: more than 1 bools in function parameters - --> $DIR/test.rs:4:1 + --> $DIR/fn_params_excessive_bools/test.rs:4:1 | LL | fn g(_: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/functions_maxlines/test.stderr b/tests/ui-toml/functions_maxlines/test.stderr index a2ca623e96620..f7aa96f0dfbd3 100644 --- a/tests/ui-toml/functions_maxlines/test.stderr +++ b/tests/ui-toml/functions_maxlines/test.stderr @@ -1,5 +1,5 @@ error: this function has too many lines (2/1) - --> $DIR/test.rs:19:1 + --> $DIR/functions_maxlines/test.rs:19:1 | LL | / fn too_many_lines() { LL | | println!("This is bad."); @@ -11,7 +11,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::too_many_lines)]` error: this function has too many lines (4/1) - --> $DIR/test.rs:25:1 + --> $DIR/functions_maxlines/test.rs:25:1 | LL | / async fn async_too_many_lines() { LL | | println!("This is bad."); @@ -20,7 +20,7 @@ LL | | } | |_^ error: this function has too many lines (4/1) - --> $DIR/test.rs:31:1 + --> $DIR/functions_maxlines/test.rs:31:1 | LL | / fn closure_too_many_lines() { LL | | let _ = { @@ -31,7 +31,7 @@ LL | | } | |_^ error: this function has too many lines (2/1) - --> $DIR/test.rs:53:1 + --> $DIR/functions_maxlines/test.rs:53:1 | LL | / fn comment_before_code() { LL | | let _ = "test"; diff --git a/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr b/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr index e0e77bf23f66d..e7c75e84f74c3 100644 --- a/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr +++ b/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr @@ -1,11 +1,11 @@ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:15:15 + --> $DIR/ifs_same_cond/ifs_same_cond.rs:15:15 | LL | } else if x.get() { | ^^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:13:8 + --> $DIR/ifs_same_cond/ifs_same_cond.rs:13:8 | LL | if x.get() { | ^^^^^^^ diff --git a/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr b/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr index bb1244ada9f44..6d67cf21c8d16 100644 --- a/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr +++ b/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:14:13 + --> $DIR/impl_trait_in_params/impl_trait_in_params.rs:14:13 | LL | fn t(_: impl Trait); | ^^^^^^^^^^ diff --git a/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr b/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr index a764840665a37..b8c957e9d92cc 100644 --- a/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr +++ b/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: not a valid Rust version - --> $DIR/$DIR/clippy.toml:1:8 + --> $DIR/$DIR/invalid_min_rust_version/clippy.toml:1:8 | LL | msrv = "invalid.version" | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr b/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr index 33802c44bf9a3..096c93500e27e 100644 --- a/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr +++ b/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr @@ -1,5 +1,5 @@ error: all fields have the same postfix: `data` - --> $DIR/item_name_repetitions.rs:9:1 + --> $DIR/item_name_repetitions/threshold5/item_name_repetitions.rs:9:1 | LL | / struct Data2 { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::struct_field_names)]` error: all variants have the same postfix: `Foo` - --> $DIR/item_name_repetitions.rs:23:1 + --> $DIR/item_name_repetitions/threshold5/item_name_repetitions.rs:23:1 | LL | / enum Foo2 { LL | | diff --git a/tests/ui-toml/large_futures/large_futures.stderr b/tests/ui-toml/large_futures/large_futures.stderr index 23c6215f9498f..ef8adb86aff7b 100644 --- a/tests/ui-toml/large_futures/large_futures.stderr +++ b/tests/ui-toml/large_futures/large_futures.stderr @@ -1,5 +1,5 @@ error: large future with a size of 1026 bytes - --> $DIR/large_futures.rs:18:5 + --> $DIR/large_futures/large_futures.rs:18:5 | LL | should_warn().await; | ^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(should_warn())` diff --git a/tests/ui-toml/large_include_file/large_include_file.stderr b/tests/ui-toml/large_include_file/large_include_file.stderr index 7508cd6c46e23..3128964bba576 100644 --- a/tests/ui-toml/large_include_file/large_include_file.stderr +++ b/tests/ui-toml/large_include_file/large_include_file.stderr @@ -1,5 +1,5 @@ error: attempted to include a large file - --> $DIR/large_include_file.rs:13:43 + --> $DIR/large_include_file/large_include_file.rs:13:43 | LL | const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) error: attempted to include a large file - --> $DIR/large_include_file.rs:14:35 + --> $DIR/large_include_file/large_include_file.rs:14:35 | LL | const TOO_BIG_INCLUDE_STR: &str = include_str!("too_big.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr index 5adf666278fc9..fee4ae9903d13 100644 --- a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr +++ b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr @@ -1,5 +1,5 @@ error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames.rs:12:1 + --> $DIR/large_stack_frames/large_stack_frames.rs:12:1 | LL | / fn f2() { LL | | diff --git a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr index 20026d358aef1..091d7911c6699 100644 --- a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr +++ b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr @@ -1,5 +1,5 @@ error: this argument (513 byte) is passed by value, but might be more efficient if passed by reference (limit: 512 byte) - --> $DIR/large_types_passed_by_value.rs:4:11 + --> $DIR/large_types_passed_by_value/large_types_passed_by_value.rs:4:11 | LL | fn f2(_v: [u8; 513]) {} | ^^^^^^^^^ help: consider passing by reference instead: `&[u8; 513]` diff --git a/tests/ui-toml/lint_decimal_readability/test.stderr b/tests/ui-toml/lint_decimal_readability/test.stderr index ef97e5d3f3128..ef4dd582bea00 100644 --- a/tests/ui-toml/lint_decimal_readability/test.stderr +++ b/tests/ui-toml/lint_decimal_readability/test.stderr @@ -1,5 +1,5 @@ error: digits grouped inconsistently by underscores - --> $DIR/test.rs:19:18 + --> $DIR/lint_decimal_readability/test.rs:19:18 | LL | let _fail1 = 100_200_300.123456789; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789` @@ -8,7 +8,7 @@ LL | let _fail1 = 100_200_300.123456789; = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: long literal lacking separators - --> $DIR/test.rs:22:18 + --> $DIR/lint_decimal_readability/test.rs:22:18 | LL | let _fail2 = 100200300.300200100; | ^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.300_200_100` diff --git a/tests/ui-toml/manual_let_else/manual_let_else.stderr b/tests/ui-toml/manual_let_else/manual_let_else.stderr index 67647cc5e95fe..7685e63ec3644 100644 --- a/tests/ui-toml/manual_let_else/manual_let_else.stderr +++ b/tests/ui-toml/manual_let_else/manual_let_else.stderr @@ -1,5 +1,5 @@ error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:9:5 + --> $DIR/manual_let_else/manual_let_else.rs:9:5 | LL | / let x = match Foo::A(1) { LL | | diff --git a/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr b/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr index 20ffacd092ada..cc1faa28487fc 100644 --- a/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr +++ b/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice.rs:5:17 + --> $DIR/max_suggested_slice_pattern_length/index_refutable_slice.rs:5:17 | LL | if let Some(slice) = slice { | ^^^^^ | note: the lint level is defined here - --> $DIR/index_refutable_slice.rs:1:9 + --> $DIR/max_suggested_slice_pattern_length/index_refutable_slice.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr index b498fd3365032..dc02c9fbd732e 100644 --- a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr +++ b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr @@ -1,5 +1,5 @@ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:6:41 + --> $DIR/min_ident_chars/min_ident_chars.rs:6:41 | LL | use extern_types::{Aaa, LONGER, M, N as W}; | ^ @@ -8,43 +8,43 @@ LL | use extern_types::{Aaa, LONGER, M, N as W}; = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:8:11 + --> $DIR/min_ident_chars/min_ident_chars.rs:8:11 | LL | pub const N: u32 = 0; | ^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:13:5 + --> $DIR/min_ident_chars/min_ident_chars.rs:13:5 | LL | aaa: Aaa, | ^^^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:18:9 + --> $DIR/min_ident_chars/min_ident_chars.rs:18:9 | LL | let vvv = 1; | ^^^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars.rs:19:9 + --> $DIR/min_ident_chars/min_ident_chars.rs:19:9 | LL | let uuu = 1; | ^^^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:20:14 + --> $DIR/min_ident_chars/min_ident_chars.rs:20:14 | LL | let (mut a, mut b) = (1, 2); | ^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:20:21 + --> $DIR/min_ident_chars/min_ident_chars.rs:20:21 | LL | let (mut a, mut b) = (1, 2); | ^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars.rs:21:9 + --> $DIR/min_ident_chars/min_ident_chars.rs:21:9 | LL | for i in 0..1000 {} | ^ diff --git a/tests/ui-toml/min_rust_version/min_rust_version.stderr b/tests/ui-toml/min_rust_version/min_rust_version.stderr index 5bf2bcd3bc616..9702a0881c1e1 100644 --- a/tests/ui-toml/min_rust_version/min_rust_version.stderr +++ b/tests/ui-toml/min_rust_version/min_rust_version.stderr @@ -1,5 +1,5 @@ error: you are using an explicit closure for cloning elements - --> $DIR/min_rust_version.rs:74:26 + --> $DIR/min_rust_version/min_rust_version.rs:74:26 | LL | let _: Option = Some(&16).map(|b| *b); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()` diff --git a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr index 0aea330d40bbc..74b0308c84956 100644 --- a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr +++ b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr @@ -1,5 +1,5 @@ error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:5:20 + --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:5:20 | LL | use std::process::{exit as wrong_exit, Child as Kid}; | ^^^^^^^^^^^^^^^^^^ help: try: `exit as goodbye` @@ -8,31 +8,31 @@ LL | use std::process::{exit as wrong_exit, Child as Kid}; = help: to override `-D warnings` add `#[allow(clippy::missing_enforced_import_renames)]` error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:6:1 + --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:6:1 | LL | use std::thread::sleep; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::thread::sleep as thread_sleep` error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:9:11 + --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:9:11 | LL | any::{type_name, Any}, | ^^^^^^^^^ help: try: `type_name as ident` error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:10:5 + --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:10:5 | LL | clone, | ^^^^^ help: try: `clone as foo` error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:11:5 + --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:11:5 | LL | sync :: Mutex, | ^^^^^^^^^^^^^ help: try: `sync :: Mutex as StdMutie` error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:15:5 + --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:15:5 | LL | use std::collections::BTreeMap as OopsWrongRename; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::collections::BTreeMap as Map` diff --git a/tests/ui-toml/module_inception/module_inception.stderr b/tests/ui-toml/module_inception/module_inception.stderr index 0eb25453b2564..ab2b30349ed3e 100644 --- a/tests/ui-toml/module_inception/module_inception.stderr +++ b/tests/ui-toml/module_inception/module_inception.stderr @@ -1,5 +1,5 @@ error: module has the same name as its containing module - --> $DIR/module_inception.rs:6:9 + --> $DIR/module_inception/module_inception.rs:6:9 | LL | / pub mod bar2 { LL | | pub mod foo2 {} @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::module_inception)]` error: module has the same name as its containing module - --> $DIR/module_inception.rs:11:5 + --> $DIR/module_inception/module_inception.rs:11:5 | LL | / pub mod foo2 { LL | | pub mod bar2 {} diff --git a/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr index da644b05a113d..c079b1394ac5c 100644 --- a/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr +++ b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic.rs:6:13 + --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:6:13 | LL | let c = a % b == 0; | ^^^^^ @@ -10,7 +10,7 @@ LL | let c = a % b == 0; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic.rs:7:13 + --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:7:13 | LL | let c = a % b != 0; | ^^^^^ @@ -19,7 +19,7 @@ LL | let c = a % b != 0; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic.rs:8:18 + --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:8:18 | LL | let c = 0 == a % b; | ^^^^^ @@ -28,7 +28,7 @@ LL | let c = 0 == a % b; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic.rs:9:18 + --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:9:18 | LL | let c = 0 != a % b; | ^^^^^ diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr index 483941d3c3125..2162ffe47f7ff 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr @@ -1,5 +1,5 @@ error: use of irregular braces for `vec!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:43:13 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:43:13 | LL | let _ = vec! {1, 2, 3}; | ^^^^^^^^^^^^^^ help: consider writing: `vec![1, 2, 3]` @@ -8,31 +8,31 @@ LL | let _ = vec! {1, 2, 3}; = help: to override `-D warnings` add `#[allow(clippy::nonstandard_macro_braces)]` error: use of irregular braces for `format!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:44:13 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:44:13 | LL | let _ = format!["ugh {} stop being such a good compiler", "hello"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `format!("ugh {} stop being such a good compiler", "hello")` error: use of irregular braces for `matches!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:45:13 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:45:13 | LL | let _ = matches!{{}, ()}; | ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())` error: use of irregular braces for `quote!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:46:13 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:46:13 | LL | let _ = quote!(let x = 1;); | ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}` error: use of irregular braces for `quote::quote!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:47:13 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:47:13 | LL | let _ = quote::quote!(match match match); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}` error: use of irregular braces for `vec!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:18:9 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:18:9 | LL | vec!{0, 0, 0} | ^^^^^^^^^^^^^ help: consider writing: `vec![0, 0, 0]` @@ -43,13 +43,13 @@ LL | let _ = test!(); // trigger when macro def is inside our own crate = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) error: use of irregular braces for `type_pos!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:56:12 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:56:12 | LL | let _: type_pos!(usize) = vec![]; | ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]` error: use of irregular braces for `eprint!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:58:5 + --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:58:5 | LL | eprint!("test if user config overrides defaults"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `eprint!["test if user config overrides defaults"]` diff --git a/tests/ui-toml/print_macro/print_macro.stderr b/tests/ui-toml/print_macro/print_macro.stderr index fe2d5afc6caaa..3f0a3919bcb17 100644 --- a/tests/ui-toml/print_macro/print_macro.stderr +++ b/tests/ui-toml/print_macro/print_macro.stderr @@ -1,5 +1,5 @@ error: use of `print!` - --> $DIR/print_macro.rs:6:5 + --> $DIR/print_macro/print_macro.rs:6:5 | LL | print!("{n}"); | ^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | print!("{n}"); = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `eprint!` - --> $DIR/print_macro.rs:7:5 + --> $DIR/print_macro/print_macro.rs:7:5 | LL | eprint!("{n}"); | ^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/private-doc-errors/doc_lints.stderr b/tests/ui-toml/private-doc-errors/doc_lints.stderr index 8533674804988..ef6262f22ebb4 100644 --- a/tests/ui-toml/private-doc-errors/doc_lints.stderr +++ b/tests/ui-toml/private-doc-errors/doc_lints.stderr @@ -1,58 +1,58 @@ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/doc_lints.rs:12:1 + --> $DIR/private-doc-errors/doc_lints.rs:12:1 | LL | fn you_dont_see_me() { | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/doc_lints.rs:2:5 + --> $DIR/private-doc-errors/doc_lints.rs:2:5 | LL | clippy::unnecessary_safety_doc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/doc_lints.rs:23:5 + --> $DIR/private-doc-errors/doc_lints.rs:23:5 | LL | pub fn only_crate_wide_accessible() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_lints.rs:23:5 + --> $DIR/private-doc-errors/doc_lints.rs:23:5 | LL | pub fn only_crate_wide_accessible() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/doc_lints.rs:3:5 + --> $DIR/private-doc-errors/doc_lints.rs:3:5 | LL | clippy::missing_errors_doc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/doc_lints.rs:38:5 + --> $DIR/private-doc-errors/doc_lints.rs:38:5 | LL | fn private(&self) { | ^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/doc_lints.rs:38:5 + --> $DIR/private-doc-errors/doc_lints.rs:38:5 | LL | fn private(&self) { | ^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/doc_lints.rs:41:9 + --> $DIR/private-doc-errors/doc_lints.rs:41:9 | LL | panic!(); | ^^^^^^^^ note: the lint level is defined here - --> $DIR/doc_lints.rs:4:5 + --> $DIR/private-doc-errors/doc_lints.rs:4:5 | LL | clippy::missing_panics_doc | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_lints.rs:49:9 + --> $DIR/private-doc-errors/doc_lints.rs:49:9 | LL | pub unsafe fn f() {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr index 2cf20b4604910..f987ff6956948 100644 --- a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr +++ b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr @@ -1,5 +1,5 @@ error: missing documentation for a function - --> $DIR/pub_crate_missing_doc.rs:13:5 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:13:5 | LL | pub(crate) fn crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | pub(crate) fn crate_no_docs() {} = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a function - --> $DIR/pub_crate_missing_doc.rs:16:5 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:16:5 | LL | pub(super) fn super_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/pub_crate_missing_doc.rs:24:9 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:24:9 | LL | pub(crate) fn sub_crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/pub_crate_missing_doc.rs:34:9 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:34:9 | LL | pub(crate) crate_field_no_docs: (), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/pub_crate_missing_doc.rs:40:5 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:40:5 | LL | / pub(crate) struct CrateStructNoDocs { LL | | /// some docs @@ -38,13 +38,13 @@ LL | | } | |_____^ error: missing documentation for a struct field - --> $DIR/pub_crate_missing_doc.rs:43:9 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:43:9 | LL | pub(crate) crate_field_no_docs: (), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a type alias - --> $DIR/pub_crate_missing_doc.rs:52:1 + --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:52:1 | LL | type CrateTypedefNoDocs = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr index c6bd499fd8cb3..5949e7e0ffc3a 100644 --- a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr +++ b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr @@ -1,5 +1,5 @@ error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:15:9 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:15:9 | LL | pub _b: u8, | ^^^^^^ @@ -9,7 +9,7 @@ LL | pub _b: u8, = help: to override `-D warnings` add `#[allow(clippy::pub_underscore_fields)]` error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:23:13 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:23:13 | LL | pub(in crate::inner) _f: Option<()>, | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | pub(in crate::inner) _f: Option<()>, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:27:13 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:27:13 | LL | pub _g: String, | ^^^^^^ @@ -25,7 +25,7 @@ LL | pub _g: String, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:34:9 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:34:9 | LL | pub _a: usize, | ^^^^^^ @@ -33,7 +33,7 @@ LL | pub _a: usize, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:41:9 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:41:9 | LL | pub _c: i64, | ^^^^^^ @@ -41,7 +41,7 @@ LL | pub _c: i64, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:44:9 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:44:9 | LL | pub _e: Option, | ^^^^^^ @@ -49,7 +49,7 @@ LL | pub _e: Option, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:57:9 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:57:9 | LL | pub(crate) _b: Option, | ^^^^^^^^^^^^^ diff --git a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr index b76f6b3d38822..e4474576f6957 100644 --- a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr +++ b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr @@ -1,5 +1,5 @@ error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields.rs:15:9 + --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:15:9 | LL | pub _b: u8, | ^^^^^^ diff --git a/tests/ui-toml/result_large_err/result_large_err.stderr b/tests/ui-toml/result_large_err/result_large_err.stderr index cc603fc0cc049..ad29b3d1f5058 100644 --- a/tests/ui-toml/result_large_err/result_large_err.stderr +++ b/tests/ui-toml/result_large_err/result_large_err.stderr @@ -1,5 +1,5 @@ error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:6:12 + --> $DIR/result_large_err/result_large_err.rs:6:12 | LL | fn f2() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes diff --git a/tests/ui-toml/semicolon_block/both.stderr b/tests/ui-toml/semicolon_block/both.stderr index ca6a7475cf37c..8588b500d3e32 100644 --- a/tests/ui-toml/semicolon_block/both.stderr +++ b/tests/ui-toml/semicolon_block/both.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` outside the block for consistent formatting - --> $DIR/both.rs:42:5 + --> $DIR/semicolon_block/both.rs:42:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/both.rs:43:5 + --> $DIR/semicolon_block/both.rs:43:5 | LL | unsafe { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block() }; | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/both.rs:48:5 + --> $DIR/semicolon_block/both.rs:48:5 | LL | / { LL | | unit_fn_block(); @@ -42,7 +42,7 @@ LL ~ } | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/both.rs:62:5 + --> $DIR/semicolon_block/both.rs:62:5 | LL | { m!(()); } | ^^^^^^^^^^^ diff --git a/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr b/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr index 0542e139b3408..14aadaeb93d7d 100644 --- a/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr +++ b/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:47:5 + --> $DIR/semicolon_block/semicolon_inside_block.rs:47:5 | LL | / { LL | | unit_fn_block(); diff --git a/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr b/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr index fcc409796e2dd..3c10c9bdf6804 100644 --- a/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr +++ b/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:41:5 + --> $DIR/semicolon_block/semicolon_outside_block.rs:41:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:42:5 + --> $DIR/semicolon_block/semicolon_outside_block.rs:42:5 | LL | unsafe { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:61:5 + --> $DIR/semicolon_block/semicolon_outside_block.rs:61:5 | LL | { m!(()); } | ^^^^^^^^^^^ diff --git a/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr index 6df11cc1fb7d4..1024ae1b9c228 100644 --- a/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr +++ b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr @@ -1,11 +1,11 @@ error: some fields in `NoGeneric` are not safe to be sent to another thread - --> $DIR/test.rs:11:1 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:11:1 | LL | unsafe impl Send for NoGeneric {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `rc_is_not_send` to another thread - --> $DIR/test.rs:8:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:8:5 | LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,75 +14,75 @@ LL | rc_is_not_send: Rc, = help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]` error: some fields in `MultiField` are not safe to be sent to another thread - --> $DIR/test.rs:19:1 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:19:1 | LL | unsafe impl Send for MultiField {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/test.rs:14:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:14:5 | LL | field1: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field2` to another thread - --> $DIR/test.rs:15:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:15:5 | LL | field2: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field3` to another thread - --> $DIR/test.rs:16:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:16:5 | LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `MyOption` are not safe to be sent to another thread - --> $DIR/test.rs:26:1 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:26:1 | LL | unsafe impl Send for MyOption {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/test.rs:22:12 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:22:12 | LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `HeuristicTest` are not safe to be sent to another thread - --> $DIR/test.rs:41:1 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:41:1 | LL | unsafe impl Send for HeuristicTest {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/test.rs:34:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:34:5 | LL | field1: Vec<*const NonSend>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field2` to another thread - --> $DIR/test.rs:35:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:35:5 | LL | field2: [*const NonSend; 3], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field3` to another thread - --> $DIR/test.rs:36:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:36:5 | LL | field3: (*const NonSend, *const NonSend, *const NonSend), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field4` to another thread - --> $DIR/test.rs:37:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:37:5 | LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field5` to another thread - --> $DIR/test.rs:38:5 + --> $DIR/strict_non_send_fields_in_send_ty/test.rs:38:5 | LL | field5: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/struct_excessive_bools/test.stderr b/tests/ui-toml/struct_excessive_bools/test.stderr index 31e0e33a39b25..c3ecfa1f91fae 100644 --- a/tests/ui-toml/struct_excessive_bools/test.stderr +++ b/tests/ui-toml/struct_excessive_bools/test.stderr @@ -1,5 +1,5 @@ error: more than 0 bools in a struct - --> $DIR/test.rs:3:1 + --> $DIR/struct_excessive_bools/test.rs:3:1 | LL | / struct S { LL | | a: bool, diff --git a/tests/ui-toml/suppress_lint_in_const/test.stderr b/tests/ui-toml/suppress_lint_in_const/test.stderr index 84e7eff45573e..39a22c4ae87a5 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/test.rs:38:14 + --> $DIR/suppress_lint_in_const/test.rs:38:14 | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant encountered - --> $DIR/test.rs:38:5 + --> $DIR/suppress_lint_in_const/test.rs:38:5 | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^^^^^^^^^^^^ error: indexing may panic - --> $DIR/test.rs:29:5 + --> $DIR/suppress_lint_in_const/test.rs:29:5 | LL | x[index]; | ^^^^^^^^ @@ -21,7 +21,7 @@ LL | x[index]; = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic - --> $DIR/test.rs:47:5 + --> $DIR/suppress_lint_in_const/test.rs:47:5 | LL | v[0]; | ^^^^ @@ -29,7 +29,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:48:5 + --> $DIR/suppress_lint_in_const/test.rs:48:5 | LL | v[10]; | ^^^^^ @@ -37,7 +37,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:49:5 + --> $DIR/suppress_lint_in_const/test.rs:49:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -45,7 +45,7 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:55:5 + --> $DIR/suppress_lint_in_const/test.rs:55:5 | LL | v[N]; | ^^^^ @@ -53,7 +53,7 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:56:5 + --> $DIR/suppress_lint_in_const/test.rs:56:5 | LL | v[M]; | ^^^^ @@ -61,7 +61,7 @@ LL | v[M]; = help: consider using `.get(n)` or `.get_mut(n)` instead error[E0080]: evaluation of constant value failed - --> $DIR/test.rs:16:24 + --> $DIR/suppress_lint_in_const/test.rs:16:24 | LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 diff --git a/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr b/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr index 621328292236a..8b33c2794287b 100644 --- a/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr +++ b/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `toto` - --> $DIR/conf_french_disallowed_name.rs:6:9 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:6:9 | LL | fn test(toto: ()) {} | ^^^^ @@ -8,37 +8,37 @@ LL | fn test(toto: ()) {} = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `toto` - --> $DIR/conf_french_disallowed_name.rs:9:9 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:9:9 | LL | let toto = 42; | ^^^^ error: use of a disallowed/placeholder name `tata` - --> $DIR/conf_french_disallowed_name.rs:10:9 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:10:9 | LL | let tata = 42; | ^^^^ error: use of a disallowed/placeholder name `titi` - --> $DIR/conf_french_disallowed_name.rs:11:9 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:11:9 | LL | let titi = 42; | ^^^^ error: use of a disallowed/placeholder name `toto` - --> $DIR/conf_french_disallowed_name.rs:17:10 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:17:10 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `tata` - --> $DIR/conf_french_disallowed_name.rs:17:21 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:17:21 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `titi` - --> $DIR/conf_french_disallowed_name.rs:17:28 + --> $DIR/toml_disallow/conf_french_disallowed_name.rs:17:28 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr index d9b70e3b77ce2..e68a8ebeaaa03 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr @@ -1,5 +1,5 @@ error: use of a disallowed method `regex::Regex::new` - --> $DIR/conf_disallowed_methods.rs:35:14 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:35:14 | LL | let re = Regex::new(r"ab.*c").unwrap(); | ^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let re = Regex::new(r"ab.*c").unwrap(); = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]` error: use of a disallowed method `regex::Regex::is_match` - --> $DIR/conf_disallowed_methods.rs:36:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:36:5 | LL | re.is_match("abc"); | ^^^^^^^^^^^^^^^^^^ @@ -16,73 +16,73 @@ LL | re.is_match("abc"); = note: no matching allowed (from clippy.toml) error: use of a disallowed method `std::iter::Iterator::sum` - --> $DIR/conf_disallowed_methods.rs:39:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:39:5 | LL | a.iter().sum::(); | ^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `slice::sort_unstable` - --> $DIR/conf_disallowed_methods.rs:41:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:41:5 | LL | a.sort_unstable(); | ^^^^^^^^^^^^^^^^^ error: use of a disallowed method `f32::clamp` - --> $DIR/conf_disallowed_methods.rs:43:13 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:43:13 | LL | let _ = 2.0f32.clamp(3.0f32, 4.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `regex::Regex::new` - --> $DIR/conf_disallowed_methods.rs:46:61 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:46:61 | LL | let indirect: fn(&str) -> Result = Regex::new; | ^^^^^^^^^^ error: use of a disallowed method `f32::clamp` - --> $DIR/conf_disallowed_methods.rs:49:28 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:49:28 | LL | let in_call = Box::new(f32::clamp); | ^^^^^^^^^^ error: use of a disallowed method `regex::Regex::new` - --> $DIR/conf_disallowed_methods.rs:50:53 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:50:53 | LL | let in_method_call = ["^", "$"].into_iter().map(Regex::new); | ^^^^^^^^^^ error: use of a disallowed method `futures::stream::select_all` - --> $DIR/conf_disallowed_methods.rs:53:31 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:53:31 | LL | let same_name_as_module = select_all(vec![empty::<()>()]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::local_fn` - --> $DIR/conf_disallowed_methods.rs:55:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:55:5 | LL | local_fn(); | ^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::local_mod::f` - --> $DIR/conf_disallowed_methods.rs:56:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:56:5 | LL | local_mod::f(); | ^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Struct::method` - --> $DIR/conf_disallowed_methods.rs:58:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:58:5 | LL | s.method(); | ^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Trait::provided_method` - --> $DIR/conf_disallowed_methods.rs:59:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:59:5 | LL | s.provided_method(); | ^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Trait::implemented_method` - --> $DIR/conf_disallowed_methods.rs:60:5 + --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:60:5 | LL | s.implemented_method(); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr index 4ac96deb44f3a..476456107d78b 100644 --- a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr +++ b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr @@ -1,5 +1,5 @@ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:7:1 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:7:1 | LL | use std::sync::atomic::AtomicU32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,61 +8,61 @@ LL | use std::sync::atomic::AtomicU32; = help: to override `-D warnings` add `#[allow(clippy::disallowed_types)]` error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:8:1 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:8:1 | LL | use std::time::Instant as Sneaky; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:12:33 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:12:33 | LL | fn bad_return_type() -> fn() -> Sneaky { | ^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:16:28 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:16:28 | LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} | ^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:16:39 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:16:39 | LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} | ^^^^^^^^^^^^^^^^^^^^^^ error: `std::io::Read` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:18:22 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:18:22 | LL | fn trait_obj(_: &dyn std::io::Read) {} | ^^^^^^^^^^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:20:33 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:20:33 | LL | fn full_and_single_path_prim(_: usize, _: bool) {} | ^^^^^ error: `bool` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:20:43 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:20:43 | LL | fn full_and_single_path_prim(_: usize, _: bool) {} | ^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:22:28 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:22:28 | LL | fn const_generics() {} | ^^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:24:24 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:24:24 | LL | struct GenArg([u8; U]); | ^^^^^ error: `std::net::Ipv4Addr` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:28:10 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:28:10 | LL | fn ip(_: std::net::Ipv4Addr) {} | ^^^^^^^^^^^^^^^^^^ @@ -70,61 +70,61 @@ LL | fn ip(_: std::net::Ipv4Addr) {} = note: no IPv4 allowed (from clippy.toml) error: `std::net::TcpListener` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:30:16 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:30:16 | LL | fn listener(_: std::net::TcpListener) {} | ^^^^^^^^^^^^^^^^^^^^^ error: `std::collections::HashMap` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:34:48 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:34:48 | LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::collections::HashMap` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:34:12 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:34:12 | LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:35:13 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:35:13 | LL | let _ = Sneaky::now(); | ^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:36:13 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:36:13 | LL | let _ = foo::atomic::AtomicU32::new(0); | ^^^^^^^^^^^^^^^^^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:37:17 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:37:17 | LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:37:48 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:37:48 | LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); | ^^^^^^^^^^^^^^^^^^^^^^ error: `syn::TypePath` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:38:43 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:38:43 | LL | let _: std::collections::BTreeMap<(), syn::TypePath> = Default::default(); | ^^^^^^^^^^^^^ error: `syn::Ident` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:39:13 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:39:13 | LL | let _ = syn::Ident::new("", todo!()); | ^^^^^^^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:41:12 + --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:41:12 | LL | let _: usize = 64_usize; | ^^^^^ diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index 262d302e72de7..664e87f3a0a9c 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,5 +1,5 @@ error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/test.rs:15:11 + --> $DIR/toml_trivially_copy/test.rs:15:11 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `u16` @@ -8,7 +8,7 @@ LL | fn bad(x: &u16, y: &Foo) {} = help: to override `-D warnings` add `#[allow(clippy::trivially_copy_pass_by_ref)]` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/test.rs:15:20 + --> $DIR/toml_trivially_copy/test.rs:15:20 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index f097d2503e163..c8dcc750237f3 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -72,7 +72,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports - --> $DIR/$DIR/clippy.toml:2:1 + --> $DIR/$DIR/toml_unknown_key/clippy.toml:2:1 | LL | foobar = 42 | ^^^^^^ @@ -151,7 +151,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports - --> $DIR/$DIR/clippy.toml:4:1 + --> $DIR/$DIR/toml_unknown_key/clippy.toml:4:1 | LL | barfoo = 53 | ^^^^^^ @@ -230,7 +230,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports - --> $DIR/$DIR/clippy.toml:7:1 + --> $DIR/$DIR/toml_unknown_key/clippy.toml:7:1 | LL | allow_mixed_uninlined_format_args = true | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: perhaps you meant: `allow-mixed-uninlined-format-args` diff --git a/tests/ui-toml/too_large_for_stack/boxed_local.stderr b/tests/ui-toml/too_large_for_stack/boxed_local.stderr index 54990c35228f7..2898d0d02f788 100644 --- a/tests/ui-toml/too_large_for_stack/boxed_local.stderr +++ b/tests/ui-toml/too_large_for_stack/boxed_local.stderr @@ -1,5 +1,5 @@ error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:1:6 + --> $DIR/too_large_for_stack/boxed_local.rs:1:6 | LL | fn f(x: Box<[u8; 500]>) {} | ^ diff --git a/tests/ui-toml/too_large_for_stack/useless_vec.stderr b/tests/ui-toml/too_large_for_stack/useless_vec.stderr index 5d289db8534bb..00823f3623651 100644 --- a/tests/ui-toml/too_large_for_stack/useless_vec.stderr +++ b/tests/ui-toml/too_large_for_stack/useless_vec.stderr @@ -1,5 +1,5 @@ error: useless use of `vec!` - --> $DIR/useless_vec.rs:4:13 + --> $DIR/too_large_for_stack/useless_vec.rs:4:13 | LL | let x = vec![0u8; 500]; | ^^^^^^^^^^^^^^ help: you can use an array directly: `[0u8; 500]` diff --git a/tests/ui-toml/too_many_arguments/too_many_arguments.stderr b/tests/ui-toml/too_many_arguments/too_many_arguments.stderr index 81d9bee737e29..fb6fbef7c5c78 100644 --- a/tests/ui-toml/too_many_arguments/too_many_arguments.stderr +++ b/tests/ui-toml/too_many_arguments/too_many_arguments.stderr @@ -1,5 +1,5 @@ error: this function has too many arguments (11/10) - --> $DIR/too_many_arguments.rs:4:1 + --> $DIR/too_many_arguments/too_many_arguments.rs:4:1 | LL | fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/type_complexity/type_complexity.stderr b/tests/ui-toml/type_complexity/type_complexity.stderr index df824400da82e..155ea6684ea49 100644 --- a/tests/ui-toml/type_complexity/type_complexity.stderr +++ b/tests/ui-toml/type_complexity/type_complexity.stderr @@ -1,5 +1,5 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:4:10 + --> $DIR/type_complexity/type_complexity.rs:4:10 | LL | fn f2(_: (u8, (u8, (u8, (u8, (u8, (u8, u8))))))) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/type_repetition_in_bounds/main.stderr b/tests/ui-toml/type_repetition_in_bounds/main.stderr index 444fbd12814d0..bab98d45a72b5 100644 --- a/tests/ui-toml/type_repetition_in_bounds/main.stderr +++ b/tests/ui-toml/type_repetition_in_bounds/main.stderr @@ -1,5 +1,5 @@ error: this type has already been used as a bound predicate - --> $DIR/main.rs:13:5 + --> $DIR/type_repetition_in_bounds/main.rs:13:5 | LL | T: Unpin + PartialEq, | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr index 15edf2a7dae47..7fecb7f37dc1d 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:266:19 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:266:19 | LL | /* Safety: */ unsafe {} | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | /* Safety: */ unsafe {} = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:270:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:5 | LL | unsafe {} | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:274:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:14 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:274:29 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:29 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:274:48 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:48 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:278:18 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:18 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:278:37 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:37 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:282:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:14 | LL | let _ = *unsafe { &42 }; | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = *unsafe { &42 }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:287:19 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:19 | LL | let _ = match unsafe {} { | ^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = match unsafe {} { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:293:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:293:14 | LL | let _ = &unsafe {}; | ^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = &unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:297:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14 | LL | let _ = [unsafe {}; 5]; | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = [unsafe {}; 5]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:301:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:13 | LL | let _ = unsafe {}; | ^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _ = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:311:8 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:311:8 | LL | t!(unsafe {}); | ^^^^^^^^^ @@ -105,7 +105,7 @@ LL | t!(unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:317:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:317:13 | LL | unsafe {} | ^^^^^^^^^ @@ -117,7 +117,7 @@ LL | t!(); = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:325:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:325:5 | LL | unsafe {} // SAFETY: | ^^^^^^^^^ @@ -125,7 +125,7 @@ LL | unsafe {} // SAFETY: = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:329:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5 | LL | unsafe { | ^^^^^^^^ @@ -133,7 +133,7 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:339:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:339:5 | LL | unsafe {}; | ^^^^^^^^^ @@ -141,7 +141,7 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:343:20 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:20 | LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:350:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:350:5 | LL | unsafe impl A for () {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | unsafe impl A for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:357:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:357:9 | LL | unsafe impl B for (u32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | unsafe impl B for (u32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:378:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:378:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:403:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:411:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:411:5 | LL | unsafe impl T for (i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -197,7 +197,7 @@ LL | unsafe impl T for (i32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:403:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL | no_safety_comment!(u32); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:417:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:417:5 | LL | unsafe impl T for (bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | unsafe impl T for (bool) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:463:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:463:5 | LL | unsafe impl NoComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | unsafe impl NoComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:467:19 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:19 | LL | /* SAFETY: */ unsafe impl InlineComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:471:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:5 | LL | unsafe impl TrailingComment for () {} // SAFETY: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,13 +241,13 @@ LL | unsafe impl TrailingComment for () {} // SAFETY: = help: consider adding a safety comment on the preceding line error: constant item has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks.rs:475:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5 | LL | const BIG_NUMBER: i32 = 1000000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks.rs:474:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:474:5 | LL | // SAFETY: | ^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | // SAFETY: = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:476:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5 | LL | unsafe impl Interference for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | unsafe impl Interference for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:483:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:483:5 | LL | unsafe impl ImplInFn for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | unsafe impl ImplInFn for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:492:1 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:492:1 | LL | unsafe impl CrateRoot for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | unsafe impl CrateRoot for () {} = help: consider adding a safety comment on the preceding line error: statement has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks.rs:505:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:505:5 | LL | / let _ = { LL | | if unsafe { true } { @@ -291,13 +291,13 @@ LL | | }; | |______^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks.rs:504:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:504:5 | LL | // SAFETY: this is more than one level away, so it should warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:506:12 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:12 | LL | if unsafe { true } { | ^^^^^^^^^^^^^^^ @@ -305,7 +305,7 @@ LL | if unsafe { true } { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:509:23 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:23 | LL | let bar = unsafe {}; | ^^^^^^^^^ diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr index cc9530f79b67c..03322de8be078 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:266:19 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:266:19 | LL | /* Safety: */ unsafe {} | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | /* Safety: */ unsafe {} = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:270:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:5 | LL | unsafe {} | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:274:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:14 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:274:29 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:29 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:274:48 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:48 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:278:18 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:18 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:278:37 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:37 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:282:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:14 | LL | let _ = *unsafe { &42 }; | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = *unsafe { &42 }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:287:19 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:19 | LL | let _ = match unsafe {} { | ^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = match unsafe {} { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:293:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:293:14 | LL | let _ = &unsafe {}; | ^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = &unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:297:14 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14 | LL | let _ = [unsafe {}; 5]; | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = [unsafe {}; 5]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:301:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:13 | LL | let _ = unsafe {}; | ^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _ = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:311:8 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:311:8 | LL | t!(unsafe {}); | ^^^^^^^^^ @@ -105,7 +105,7 @@ LL | t!(unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:317:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:317:13 | LL | unsafe {} | ^^^^^^^^^ @@ -117,7 +117,7 @@ LL | t!(); = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:325:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:325:5 | LL | unsafe {} // SAFETY: | ^^^^^^^^^ @@ -125,7 +125,7 @@ LL | unsafe {} // SAFETY: = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:329:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5 | LL | unsafe { | ^^^^^^^^ @@ -133,7 +133,7 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:339:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:339:5 | LL | unsafe {}; | ^^^^^^^^^ @@ -141,7 +141,7 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:343:20 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:20 | LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:350:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:350:5 | LL | unsafe impl A for () {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | unsafe impl A for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:357:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:357:9 | LL | unsafe impl B for (u32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | unsafe impl B for (u32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:378:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:378:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:403:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:411:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:411:5 | LL | unsafe impl T for (i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -197,7 +197,7 @@ LL | unsafe impl T for (i32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:403:13 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL | no_safety_comment!(u32); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:417:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:417:5 | LL | unsafe impl T for (bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | unsafe impl T for (bool) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:463:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:463:5 | LL | unsafe impl NoComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | unsafe impl NoComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:467:19 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:19 | LL | /* SAFETY: */ unsafe impl InlineComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:471:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:5 | LL | unsafe impl TrailingComment for () {} // SAFETY: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,13 +241,13 @@ LL | unsafe impl TrailingComment for () {} // SAFETY: = help: consider adding a safety comment on the preceding line error: constant item has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks.rs:475:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5 | LL | const BIG_NUMBER: i32 = 1000000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks.rs:474:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:474:5 | LL | // SAFETY: | ^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | // SAFETY: = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:476:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5 | LL | unsafe impl Interference for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | unsafe impl Interference for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:483:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:483:5 | LL | unsafe impl ImplInFn for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | unsafe impl ImplInFn for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:492:1 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:492:1 | LL | unsafe impl CrateRoot for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | unsafe impl CrateRoot for () {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:502:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:502:9 | LL | unsafe {}; | ^^^^^^^^^ @@ -287,7 +287,7 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: statement has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks.rs:505:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:505:5 | LL | / let _ = { LL | | if unsafe { true } { @@ -299,13 +299,13 @@ LL | | }; | |______^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks.rs:504:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:504:5 | LL | // SAFETY: this is more than one level away, so it should warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:506:12 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:12 | LL | if unsafe { true } { | ^^^^^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL | if unsafe { true } { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:509:23 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:23 | LL | let bar = unsafe {}; | ^^^^^^^^^ @@ -321,7 +321,7 @@ LL | let bar = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:527:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:527:9 | LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:531:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:531:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:535:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:535:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -345,7 +345,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:541:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:541:5 | LL | unsafe {} | ^^^^^^^^^ @@ -353,7 +353,7 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:545:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:545:5 | LL | unsafe { | ^^^^^^^^ @@ -361,7 +361,7 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:552:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:552:9 | LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -369,7 +369,7 @@ LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:557:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:557:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -377,7 +377,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:563:9 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:563:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks.rs:568:5 + --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:568:5 | LL | unsafe {} | ^^^^^^^^^ diff --git a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr index 9a747a19f7952..2ee7dd2ea8ed7 100644 --- a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr +++ b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr @@ -1,5 +1,5 @@ error: boxed return of the sized type `[u8; 64]` - --> $DIR/unnecessary_box_returns.rs:3:11 + --> $DIR/unnecessary_box_returns/unnecessary_box_returns.rs:3:11 | LL | fn f() -> Box<[u8; 64]> { | ^^^^^^^^^^^^^ help: try: `[u8; 64]` diff --git a/tests/ui-toml/unwrap_used/unwrap_used.stderr b/tests/ui-toml/unwrap_used/unwrap_used.stderr index cc22ea273d4f2..964ace5cf987e 100644 --- a/tests/ui-toml/unwrap_used/unwrap_used.stderr +++ b/tests/ui-toml/unwrap_used/unwrap_used.stderr @@ -1,5 +1,5 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:38:17 + --> $DIR/unwrap_used/unwrap_used.rs:38:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` @@ -8,7 +8,7 @@ LL | let _ = boxed_slice.get(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::get_unwrap)]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:38:17 + --> $DIR/unwrap_used/unwrap_used.rs:38:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,13 +19,13 @@ LL | let _ = boxed_slice.get(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:39:17 + --> $DIR/unwrap_used/unwrap_used.rs:39:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:39:17 + --> $DIR/unwrap_used/unwrap_used.rs:39:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,13 +34,13 @@ LL | let _ = some_slice.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:40:17 + --> $DIR/unwrap_used/unwrap_used.rs:40:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:40:17 + --> $DIR/unwrap_used/unwrap_used.rs:40:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,13 +49,13 @@ LL | let _ = some_vec.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:41:17 + --> $DIR/unwrap_used/unwrap_used.rs:41:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:41:17 + --> $DIR/unwrap_used/unwrap_used.rs:41:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,13 +64,13 @@ LL | let _ = some_vecdeque.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:42:17 + --> $DIR/unwrap_used/unwrap_used.rs:42:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_hashmap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:42:17 + --> $DIR/unwrap_used/unwrap_used.rs:42:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,13 +79,13 @@ LL | let _ = some_hashmap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:43:17 + --> $DIR/unwrap_used/unwrap_used.rs:43:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_btreemap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:43:17 + --> $DIR/unwrap_used/unwrap_used.rs:43:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,13 +94,13 @@ LL | let _ = some_btreemap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:47:21 + --> $DIR/unwrap_used/unwrap_used.rs:47:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:47:22 + --> $DIR/unwrap_used/unwrap_used.rs:47:22 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,13 +109,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:52:9 + --> $DIR/unwrap_used/unwrap_used.rs:52:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:52:10 + --> $DIR/unwrap_used/unwrap_used.rs:52:10 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,13 +124,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:53:9 + --> $DIR/unwrap_used/unwrap_used.rs:53:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:53:10 + --> $DIR/unwrap_used/unwrap_used.rs:53:10 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:54:9 + --> $DIR/unwrap_used/unwrap_used.rs:54:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:54:10 + --> $DIR/unwrap_used/unwrap_used.rs:54:10 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,13 +154,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:55:9 + --> $DIR/unwrap_used/unwrap_used.rs:55:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:55:10 + --> $DIR/unwrap_used/unwrap_used.rs:55:10 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -169,13 +169,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:67:17 + --> $DIR/unwrap_used/unwrap_used.rs:67:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:67:17 + --> $DIR/unwrap_used/unwrap_used.rs:67:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -184,13 +184,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:68:17 + --> $DIR/unwrap_used/unwrap_used.rs:68:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used.rs:68:17 + --> $DIR/unwrap_used/unwrap_used.rs:68:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,13 +199,13 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:75:13 + --> $DIR/unwrap_used/unwrap_used.rs:75:13 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used.rs:93:17 + --> $DIR/unwrap_used/unwrap_used.rs:93:17 | LL | let _ = Box::new([0]).get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&Box::new([0])[1]` diff --git a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr index 3fad561b17c97..b7bf06850388a 100644 --- a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr +++ b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr @@ -1,5 +1,5 @@ error: name `HTTPResponse` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:3:8 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:3:8 | LL | struct HTTPResponse; // not linted by default, but with cfg option | ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse` @@ -8,73 +8,73 @@ LL | struct HTTPResponse; // not linted by default, but with cfg option = help: to override `-D warnings` add `#[allow(clippy::upper_case_acronyms)]` error: name `NS` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:8:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:8:5 | LL | NS, // not linted | ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns` error: name `CWR` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:9:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:9:5 | LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` error: name `ECE` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:10:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:10:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` error: name `URG` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:11:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:11:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` error: name `ACK` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:12:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:12:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` error: name `PSH` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:13:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:13:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` error: name `RST` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:14:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:14:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` error: name `SYN` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:15:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:15:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` error: name `FIN` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:16:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:16:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` error: name `GCCLLVMSomething` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:21:8 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:21:8 | LL | struct GCCLLVMSomething; | ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething` error: name `WASD` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:38:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:38:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` error: name `WASDMixed` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:39:5 + --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:39:5 | LL | WASDMixed(String), | ^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `WasdMixed` diff --git a/tests/ui-toml/vec_box_sized/test.stderr b/tests/ui-toml/vec_box_sized/test.stderr index c88860ea8f6fd..c27d8b1df7b70 100644 --- a/tests/ui-toml/vec_box_sized/test.stderr +++ b/tests/ui-toml/vec_box_sized/test.stderr @@ -1,5 +1,5 @@ error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/test.rs:9:12 + --> $DIR/vec_box_sized/test.rs:9:12 | LL | struct Foo(Vec>); | ^^^^^^^^^^^^ help: try: `Vec` @@ -8,13 +8,13 @@ LL | struct Foo(Vec>); = help: to override `-D warnings` add `#[allow(clippy::vec_box)]` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/test.rs:10:12 + --> $DIR/vec_box_sized/test.rs:10:12 | LL | struct Bar(Vec>); | ^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/test.rs:14:18 + --> $DIR/vec_box_sized/test.rs:14:18 | LL | struct FooBarBaz(Vec>); | ^^^^^^^^^^^ help: try: `Vec` diff --git a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr index 5fcc63131bf47..cb9cfbf70c743 100644 --- a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr +++ b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr @@ -1,5 +1,5 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/verbose_bit_mask.rs:5:13 + --> $DIR/verbose_bit_mask/verbose_bit_mask.rs:5:13 | LL | let _ = v & 0b111111 == 0; | ^^^^^^^^^^^^^^^^^ help: try: `v.trailing_zeros() >= 6` diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr index a733d786d0e64..731964cb8064e 100644 --- a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports.rs:18:5 + --> $DIR/wildcard_imports/wildcard_imports.rs:18:5 | LL | use utils::*; | ^^^^^^^^ help: try: `utils::{BAR, print}` @@ -8,13 +8,13 @@ LL | use utils::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:20:5 + --> $DIR/wildcard_imports/wildcard_imports.rs:20:5 | LL | use my_crate::utils::*; | ^^^^^^^^^^^^^^^^^^ help: try: `my_crate::utils::my_util_fn` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:22:5 + --> $DIR/wildcard_imports/wildcard_imports.rs:22:5 | LL | use prelude::*; | ^^^^^^^^^^ help: try: `prelude::FOO` diff --git a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr index 12c2f9cbada70..de768260b7c1b 100644 --- a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr +++ b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports.rs:19:5 + --> $DIR/wildcard_imports_whitelist/wildcard_imports.rs:19:5 | LL | use utils_plus::*; | ^^^^^^^^^^^^^ help: try: `utils_plus::do_something` diff --git a/tests/ui/borrow_interior_mutable_const/enums.stderr b/tests/ui/borrow_interior_mutable_const/enums.stderr index b753ec92608a8..4d035b493a898 100644 --- a/tests/ui/borrow_interior_mutable_const/enums.stderr +++ b/tests/ui/borrow_interior_mutable_const/enums.stderr @@ -1,18 +1,18 @@ error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:22:14 + --> $DIR/borrow_interior_mutable_const/enums.rs:22:14 | LL | let _ = &UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here - --> $DIR/enums.rs:3:9 + --> $DIR/borrow_interior_mutable_const/enums.rs:3:9 | LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:37:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:37:18 | LL | let _ = &Self::TO_BE_FROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | let _ = &Self::TO_BE_FROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:41:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:41:18 | LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:50:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:50:18 | LL | let _ = &::TO_BE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _ = &::TO_BE_UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:52:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:52:18 | LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:74:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:74:18 | LL | let _ = &::TO_BE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = &::TO_BE_UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:91:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:91:18 | LL | let _ = &Self::UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _ = &Self::UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:92:18 + --> $DIR/borrow_interior_mutable_const/enums.rs:92:18 | LL | let _ = &Self::GENERIC_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _ = &Self::GENERIC_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/enums.rs:99:14 + --> $DIR/borrow_interior_mutable_const/enums.rs:99:14 | LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/borrow_interior_mutable_const/others.stderr b/tests/ui/borrow_interior_mutable_const/others.stderr index 200e04b8f6be5..0120b59992991 100644 --- a/tests/ui/borrow_interior_mutable_const/others.stderr +++ b/tests/ui/borrow_interior_mutable_const/others.stderr @@ -1,18 +1,18 @@ error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:54:5 + --> $DIR/borrow_interior_mutable_const/others.rs:54:5 | LL | ATOMIC.store(1, Ordering::SeqCst); | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here - --> $DIR/others.rs:1:9 + --> $DIR/borrow_interior_mutable_const/others.rs:1:9 | LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:55:16 + --> $DIR/borrow_interior_mutable_const/others.rs:55:16 | LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); | ^^^^^^ @@ -20,7 +20,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:58:22 + --> $DIR/borrow_interior_mutable_const/others.rs:58:22 | LL | let _once_ref = &ONCE_INIT; | ^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _once_ref = &ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:59:25 + --> $DIR/borrow_interior_mutable_const/others.rs:59:25 | LL | let _once_ref_2 = &&ONCE_INIT; | ^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _once_ref_2 = &&ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:60:27 + --> $DIR/borrow_interior_mutable_const/others.rs:60:27 | LL | let _once_ref_4 = &&&&ONCE_INIT; | ^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:61:26 + --> $DIR/borrow_interior_mutable_const/others.rs:61:26 | LL | let _once_mut = &mut ONCE_INIT; | ^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _once_mut = &mut ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:72:14 + --> $DIR/borrow_interior_mutable_const/others.rs:72:14 | LL | let _ = &ATOMIC_TUPLE; | ^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _ = &ATOMIC_TUPLE; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:73:14 + --> $DIR/borrow_interior_mutable_const/others.rs:73:14 | LL | let _ = &ATOMIC_TUPLE.0; | ^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _ = &ATOMIC_TUPLE.0; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:74:19 + --> $DIR/borrow_interior_mutable_const/others.rs:74:19 | LL | let _ = &(&&&&ATOMIC_TUPLE).0; | ^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:75:14 + --> $DIR/borrow_interior_mutable_const/others.rs:75:14 | LL | let _ = &ATOMIC_TUPLE.0[0]; | ^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0]; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:76:13 + --> $DIR/borrow_interior_mutable_const/others.rs:76:13 | LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); | ^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:82:13 + --> $DIR/borrow_interior_mutable_const/others.rs:82:13 | LL | let _ = ATOMIC_TUPLE.0[0]; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _ = ATOMIC_TUPLE.0[0]; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:87:5 + --> $DIR/borrow_interior_mutable_const/others.rs:87:5 | LL | CELL.set(2); | ^^^^ @@ -108,7 +108,7 @@ LL | CELL.set(2); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/others.rs:88:16 + --> $DIR/borrow_interior_mutable_const/others.rs:88:16 | LL | assert_eq!(CELL.get(), 6); | ^^^^ diff --git a/tests/ui/borrow_interior_mutable_const/traits.stderr b/tests/ui/borrow_interior_mutable_const/traits.stderr index add223acd68c7..5480811fde253 100644 --- a/tests/ui/borrow_interior_mutable_const/traits.stderr +++ b/tests/ui/borrow_interior_mutable_const/traits.stderr @@ -1,18 +1,18 @@ error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:15:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:15:18 | LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here - --> $DIR/traits.rs:1:9 + --> $DIR/borrow_interior_mutable_const/traits.rs:1:9 | LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:26:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:26:18 | LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | let _ = &Self::ATOMIC; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:51:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:51:18 | LL | let _ = &Self::TO_BE_CONCRETE; | ^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _ = &Self::TO_BE_CONCRETE; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:86:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:86:18 | LL | let _ = &Self::TO_BE_UNFROZEN; | ^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _ = &Self::TO_BE_UNFROZEN; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:87:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:87:18 | LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:109:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:109:18 | LL | let _ = &Self::BOUNDED; | ^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = &Self::BOUNDED; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:122:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:122:18 | LL | let _ = &Self::BOUNDED; | ^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _ = &Self::BOUNDED; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:151:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:151:18 | LL | let _ = &Self::SELF; | ^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _ = &Self::SELF; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:152:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:152:18 | LL | let _ = &Self::WRAPPED_SELF; | ^^^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | let _ = &Self::WRAPPED_SELF; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:162:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:162:18 | LL | let _ = &Self::INDIRECT; | ^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | let _ = &Self::INDIRECT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:172:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:172:18 | LL | let _ = &Self::INDIRECT; | ^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | let _ = &Self::INDIRECT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:191:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:191:18 | LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _ = &Self::ATOMIC; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:195:18 + --> $DIR/borrow_interior_mutable_const/traits.rs:195:18 | LL | let _ = &Self::BOUNDED_ASSOC_TYPE; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | let _ = &Self::BOUNDED_ASSOC_TYPE; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:200:5 + --> $DIR/borrow_interior_mutable_const/traits.rs:200:5 | LL | u64::ATOMIC.store(5, Ordering::SeqCst); | ^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | u64::ATOMIC.store(5, Ordering::SeqCst); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/traits.rs:201:16 + --> $DIR/borrow_interior_mutable_const/traits.rs:201:16 | LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); | ^^^^^^^^^^^ diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_bottom.stderr index 8223df0fe7bab..52148987a87e0 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -1,5 +1,5 @@ error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:35:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:35:5 | LL | / let result = false; LL | | @@ -11,7 +11,7 @@ LL | | }; | = note: the end suggestion probably needs some adjustments to use the expression result correctly note: the lint level is defined here - --> $DIR/shared_at_bottom.rs:1:36 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:1:36 | LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL ~ result; | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:55:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:55:5 | LL | / println!("Same end of block"); LL | | @@ -40,7 +40,7 @@ LL + println!("Same end of block"); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:73:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:73:5 | LL | / println!( LL | | @@ -61,7 +61,7 @@ LL + ); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:86:9 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:86:9 | LL | / println!("Hello World"); LL | | @@ -75,7 +75,7 @@ LL + println!("Hello World"); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:103:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:103:5 | LL | / let later_used_value = "A string value"; LL | | @@ -94,7 +94,7 @@ LL + println!("{}", later_used_value); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:117:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:117:5 | LL | / let simple_examples = "I now identify as a &str :)"; LL | | @@ -112,7 +112,7 @@ LL + println!("This is the new simple_example: {}", simple_examples); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:183:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:183:5 | LL | / x << 2 LL | | @@ -128,7 +128,7 @@ LL ~ x << 2; | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:192:5 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:192:5 | LL | / x * 4 LL | | @@ -144,7 +144,7 @@ LL + x * 4 | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:206:44 + --> $DIR/branches_sharing_code/shared_at_bottom.rs:206:44 | LL | if x == 17 { b = 1; a = 0x99; } else { a = 0x99; } | ^^^^^^^^^^^ diff --git a/tests/ui/branches_sharing_code/shared_at_top.stderr b/tests/ui/branches_sharing_code/shared_at_top.stderr index 317d1577226ca..b57f89542974d 100644 --- a/tests/ui/branches_sharing_code/shared_at_top.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top.stderr @@ -1,12 +1,12 @@ error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:11:5 + --> $DIR/branches_sharing_code/shared_at_top.rs:11:5 | LL | / if true { LL | | println!("Hello World!"); | |_________________________________^ | note: the lint level is defined here - --> $DIR/shared_at_top.rs:1:9 + --> $DIR/branches_sharing_code/shared_at_top.rs:1:9 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + if true { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:21:5 + --> $DIR/branches_sharing_code/shared_at_top.rs:21:5 | LL | / if x == 0 { LL | | let y = 9; @@ -35,7 +35,7 @@ LL + if x == 0 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:43:5 + --> $DIR/branches_sharing_code/shared_at_top.rs:43:5 | LL | / let _ = if x == 7 { LL | | @@ -49,7 +49,7 @@ LL + let _ = if x == 7 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:62:5 + --> $DIR/branches_sharing_code/shared_at_top.rs:62:5 | LL | / if x == 10 { LL | | let used_value_name = "Different type"; @@ -65,7 +65,7 @@ LL + if x == 10 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:77:5 + --> $DIR/branches_sharing_code/shared_at_top.rs:77:5 | LL | / if x == 11 { LL | | @@ -82,7 +82,7 @@ LL + if x == 11 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:94:5 + --> $DIR/branches_sharing_code/shared_at_top.rs:94:5 | LL | / if x == 2020 { LL | | @@ -98,7 +98,7 @@ LL + if x == 2020 { | error: this `if` has identical blocks - --> $DIR/shared_at_top.rs:103:18 + --> $DIR/branches_sharing_code/shared_at_top.rs:103:18 | LL | if x == 2019 { | __________________^ @@ -107,7 +107,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/shared_at_top.rs:105:12 + --> $DIR/branches_sharing_code/shared_at_top.rs:105:12 | LL | } else { | ____________^ @@ -115,7 +115,7 @@ LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual"); LL | | } | |_____^ note: the lint level is defined here - --> $DIR/shared_at_top.rs:1:40 + --> $DIR/branches_sharing_code/shared_at_top.rs:1:40 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr index 74495fca8ab75..1d3a3d463e1bf 100644 --- a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr @@ -1,5 +1,5 @@ error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:17:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:17:5 | LL | / if x == 7 { LL | | @@ -9,13 +9,13 @@ LL | | let _overlap_end = 2 * t; | |_________________________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:30:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:30:5 | LL | / let _u = 9; LL | | } | |_____^ note: the lint level is defined here - --> $DIR/shared_at_top_and_bottom.rs:1:9 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:1:9 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL + let _u = 9; | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:34:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:34:5 | LL | / if x == 99 { LL | | @@ -43,7 +43,7 @@ LL | | let _overlap_middle = r * r; | |____________________________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:46:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:46:5 | LL | / let _overlap_end = r * r * r; LL | | let z = "end"; @@ -65,7 +65,7 @@ LL + let z = "end"; | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:64:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:64:5 | LL | / if (x > 7 && y < 13) || (x + y) % 2 == 1 { LL | | @@ -75,7 +75,7 @@ LL | | let e_id = gen_id(a, b); | |________________________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:85:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:85:5 | LL | / let pack = DataPack { LL | | id: e_id, @@ -105,7 +105,7 @@ LL + process_data(pack); | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:98:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:98:5 | LL | / let _ = if x == 7 { LL | | @@ -113,7 +113,7 @@ LL | | let _ = 19; | |___________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:108:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:108:5 | LL | / x << 2 LL | | }; @@ -131,7 +131,7 @@ LL ~ x << 2; | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:111:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:111:5 | LL | / if x == 9 { LL | | @@ -139,7 +139,7 @@ LL | | let _ = 17; | |___________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:121:5 + --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:121:5 | LL | / x * 4 LL | | } diff --git a/tests/ui/branches_sharing_code/valid_if_blocks.stderr b/tests/ui/branches_sharing_code/valid_if_blocks.stderr index 0daf2ff6967cd..151adba77c22b 100644 --- a/tests/ui/branches_sharing_code/valid_if_blocks.stderr +++ b/tests/ui/branches_sharing_code/valid_if_blocks.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:109:14 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:109:14 | LL | if false { | ______________^ @@ -7,20 +7,20 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:110:12 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:110:12 | LL | } else { | ____________^ LL | | } | |_____^ note: the lint level is defined here - --> $DIR/valid_if_blocks.rs:1:40 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:1:40 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:121:15 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:121:15 | LL | if x == 0 { | _______________^ @@ -31,7 +31,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:125:12 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:125:12 | LL | } else { | ____________^ @@ -42,19 +42,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:133:23 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:133:23 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ | note: same as this - --> $DIR/valid_if_blocks.rs:133:34 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:133:34 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:140:23 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:140:23 | LL | } else if x == 68 { | _______________________^ @@ -65,7 +65,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:144:12 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:144:12 | LL | } else { | ____________^ @@ -76,7 +76,7 @@ LL | | }; | |_____^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:153:23 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:153:23 | LL | } else if x == 68 { | _______________________^ @@ -85,7 +85,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:155:12 + --> $DIR/branches_sharing_code/valid_if_blocks.rs:155:12 | LL | } else { | ____________^ diff --git a/tests/ui/checked_unwrap/complex_conditionals.stderr b/tests/ui/checked_unwrap/complex_conditionals.stderr index 73c074a93393f..72599db146f65 100644 --- a/tests/ui/checked_unwrap/complex_conditionals.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:13:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:13:9 | LL | if x.is_ok() && y.is_err() { | --------- the check is happening here @@ -9,13 +9,13 @@ LL | x.unwrap(); | = help: try using `if let` or `match` note: the lint level is defined here - --> $DIR/complex_conditionals.rs:1:35 + --> $DIR/checked_unwrap/complex_conditionals.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:16:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:16:9 | LL | if x.is_ok() && y.is_err() { | --------- because of this check @@ -24,13 +24,13 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/complex_conditionals.rs:1:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:19:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:19:9 | LL | if x.is_ok() && y.is_err() { | ---------- because of this check @@ -39,7 +39,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_err` - --> $DIR/complex_conditionals.rs:22:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:22:9 | LL | if x.is_ok() && y.is_err() { | ---------- the check is happening here @@ -50,7 +50,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:38:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:38:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -59,7 +59,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:41:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:41:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -70,7 +70,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:44:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:44:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -79,7 +79,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:47:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:47:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -90,7 +90,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:53:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:53:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -101,7 +101,7 @@ LL | x.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:56:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:56:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -110,7 +110,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:59:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:59:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -119,7 +119,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:62:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:62:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -130,7 +130,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `z` after checking its variant with `is_err` - --> $DIR/complex_conditionals.rs:65:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:65:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here @@ -141,7 +141,7 @@ LL | z.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:68:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:68:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check @@ -150,7 +150,7 @@ LL | z.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:78:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:78:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -159,7 +159,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:81:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:81:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -170,7 +170,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `y` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:84:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:84:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -181,7 +181,7 @@ LL | y.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:87:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:87:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -190,7 +190,7 @@ LL | y.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:90:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:90:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check @@ -199,7 +199,7 @@ LL | z.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `z` after checking its variant with `is_err` - --> $DIR/complex_conditionals.rs:93:9 + --> $DIR/checked_unwrap/complex_conditionals.rs:93:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- the check is happening here diff --git a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr index d9f701a5b2e00..8d93ef6036414 100644 --- a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/complex_conditionals_nested.rs:13:13 + --> $DIR/checked_unwrap/complex_conditionals_nested.rs:13:13 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -8,13 +8,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/complex_conditionals_nested.rs:1:35 + --> $DIR/checked_unwrap/complex_conditionals_nested.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals_nested.rs:17:13 + --> $DIR/checked_unwrap/complex_conditionals_nested.rs:17:13 | LL | if x.is_some() { | ----------- because of this check @@ -23,7 +23,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/complex_conditionals_nested.rs:1:9 + --> $DIR/checked_unwrap/complex_conditionals_nested.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/checked_unwrap/simple_conditionals.stderr b/tests/ui/checked_unwrap/simple_conditionals.stderr index a5afbba7317e9..c3eba55402364 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:47:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:47:9 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -8,13 +8,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/simple_conditionals.rs:3:35 + --> $DIR/checked_unwrap/simple_conditionals.rs:3:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:50:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:50:9 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -23,7 +23,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:54:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:54:9 | LL | if x.is_some() { | ----------- because of this check @@ -32,13 +32,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/simple_conditionals.rs:3:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:3:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `expect()` will always panic - --> $DIR/simple_conditionals.rs:57:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:57:9 | LL | if x.is_some() { | ----------- because of this check @@ -47,7 +47,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:62:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:62:9 | LL | if x.is_none() { | ----------- because of this check @@ -56,7 +56,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_none` - --> $DIR/simple_conditionals.rs:66:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:66:9 | LL | if x.is_none() { | -------------- help: try: `if let Some(..) = x` @@ -65,7 +65,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:14:13 + --> $DIR/checked_unwrap/simple_conditionals.rs:14:13 | LL | if $a.is_some() { | --------------- help: try: `if let Some(..) = x` @@ -79,7 +79,7 @@ LL | m!(x); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:79:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:79:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok(..) = x` @@ -88,7 +88,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:82:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:82:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok(..) = x` @@ -97,7 +97,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/simple_conditionals.rs:85:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:85:9 | LL | if x.is_ok() { | --------- because of this check @@ -106,7 +106,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:89:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:89:9 | LL | if x.is_ok() { | --------- because of this check @@ -115,7 +115,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `expect()` will always panic - --> $DIR/simple_conditionals.rs:92:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:92:9 | LL | if x.is_ok() { | --------- because of this check @@ -124,7 +124,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:95:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:95:9 | LL | if x.is_ok() { | ------------ help: try: `if let Err(..) = x` @@ -133,7 +133,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:100:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:100:9 | LL | if x.is_err() { | ---------- because of this check @@ -142,7 +142,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_err` - --> $DIR/simple_conditionals.rs:103:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:103:9 | LL | if x.is_err() { | ------------- help: try: `if let Err(..) = x` @@ -151,7 +151,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_err` - --> $DIR/simple_conditionals.rs:107:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:107:9 | LL | if x.is_err() { | ------------- help: try: `if let Ok(..) = x` @@ -160,7 +160,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/simple_conditionals.rs:110:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:110:9 | LL | if x.is_err() { | ---------- because of this check @@ -169,7 +169,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:135:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:135:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some(..) = &option` @@ -177,7 +177,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:138:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:138:9 | LL | if option.is_some() { | ---------------- because of this check @@ -186,7 +186,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:145:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:145:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok(..) = &result` @@ -194,7 +194,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:148:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:148:9 | LL | if result.is_ok() { | -------------- because of this check @@ -203,7 +203,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:154:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:154:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some(..) = &mut option` @@ -211,7 +211,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:157:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:157:9 | LL | if option.is_some() { | ---------------- because of this check @@ -220,7 +220,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:163:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:163:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok(..) = &mut result` @@ -228,7 +228,7 @@ LL | result.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:166:9 + --> $DIR/checked_unwrap/simple_conditionals.rs:166:9 | LL | if result.is_ok() { | -------------- because of this check diff --git a/tests/ui/cmp_owned/asymmetric_partial_eq.stderr b/tests/ui/cmp_owned/asymmetric_partial_eq.stderr index 6431b3619be9a..bcefef81d1425 100644 --- a/tests/ui/cmp_owned/asymmetric_partial_eq.stderr +++ b/tests/ui/cmp_owned/asymmetric_partial_eq.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:46:12 + --> $DIR/cmp_owned/asymmetric_partial_eq.rs:46:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` @@ -8,7 +8,7 @@ LL | if borrowed.to_owned() == owned {} = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:47:21 + --> $DIR/cmp_owned/asymmetric_partial_eq.rs:47:21 | LL | if owned == borrowed.to_owned() {} | ---------^^^^^^^^^^^^^^^^^^^ @@ -16,13 +16,13 @@ LL | if owned == borrowed.to_owned() {} | help: try: `borrowed == owned` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:65:21 + --> $DIR/cmp_owned/asymmetric_partial_eq.rs:65:21 | LL | if owned == borrowed.to_owned() {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:66:12 + --> $DIR/cmp_owned/asymmetric_partial_eq.rs:66:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^--------- @@ -30,7 +30,7 @@ LL | if borrowed.to_owned() == owned {} | help: try: `owned == borrowed` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:92:20 + --> $DIR/cmp_owned/asymmetric_partial_eq.rs:92:20 | LL | if "Hi" == borrowed.to_string() {} | --------^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | if "Hi" == borrowed.to_string() {} | help: try: `borrowed == "Hi"` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:93:12 + --> $DIR/cmp_owned/asymmetric_partial_eq.rs:93:12 | LL | if borrowed.to_string() == "Hi" {} | ^^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` diff --git a/tests/ui/cmp_owned/comparison_flip.stderr b/tests/ui/cmp_owned/comparison_flip.stderr index 09a495996f2cc..400da925c21db 100644 --- a/tests/ui/cmp_owned/comparison_flip.stderr +++ b/tests/ui/cmp_owned/comparison_flip.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/comparison_flip.rs:6:8 + --> $DIR/cmp_owned/comparison_flip.rs:6:8 | LL | if a.to_string() != "bar" { | ^^^^^^^^^^^^^ help: try: `a` @@ -8,7 +8,7 @@ LL | if a.to_string() != "bar" { = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/comparison_flip.rs:10:17 + --> $DIR/cmp_owned/comparison_flip.rs:10:17 | LL | if "bar" != a.to_string() { | ---------^^^^^^^^^^^^^ diff --git a/tests/ui/cmp_owned/with_suggestion.fixed b/tests/ui/cmp_owned/with_suggestion.fixed index 8846092fef40f..ab72e096cc7c7 100644 --- a/tests/ui/cmp_owned/with_suggestion.fixed +++ b/tests/ui/cmp_owned/with_suggestion.fixed @@ -29,7 +29,7 @@ struct Foo; impl PartialEq for Foo { // Allow this here, because it emits the lint // without a suggestion. This is tested in - // `$DIR/without_suggestion.rs` + // `tests/ui/cmp_owned/without_suggestion.rs` #[allow(clippy::cmp_owned)] fn eq(&self, other: &Self) -> bool { self.to_owned() == *other diff --git a/tests/ui/cmp_owned/with_suggestion.stderr b/tests/ui/cmp_owned/with_suggestion.stderr index 0b1127c1a61bd..f236ada648af7 100644 --- a/tests/ui/cmp_owned/with_suggestion.stderr +++ b/tests/ui/cmp_owned/with_suggestion.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:5:14 + --> $DIR/cmp_owned/with_suggestion.rs:5:14 | LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` @@ -8,31 +8,31 @@ LL | x != "foo".to_string(); = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:7:9 + --> $DIR/cmp_owned/with_suggestion.rs:7:9 | LL | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:14:10 + --> $DIR/cmp_owned/with_suggestion.rs:14:10 | LL | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:16:10 + --> $DIR/cmp_owned/with_suggestion.rs:16:10 | LL | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:20:5 + --> $DIR/cmp_owned/with_suggestion.rs:20:5 | LL | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:22:30 + --> $DIR/cmp_owned/with_suggestion.rs:22:30 | LL | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` diff --git a/tests/ui/cmp_owned/without_suggestion.stderr b/tests/ui/cmp_owned/without_suggestion.stderr index c4f63bd09cb81..07d3b7fa6df1a 100644 --- a/tests/ui/cmp_owned/without_suggestion.stderr +++ b/tests/ui/cmp_owned/without_suggestion.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/without_suggestion.rs:7:5 + --> $DIR/cmp_owned/without_suggestion.rs:7:5 | LL | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating @@ -8,13 +8,13 @@ LL | y.to_owned() == *x; = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/without_suggestion.rs:13:5 + --> $DIR/cmp_owned/without_suggestion.rs:13:5 | LL | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/without_suggestion.rs:25:9 + --> $DIR/cmp_owned/without_suggestion.rs:25:9 | LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating diff --git a/tests/ui/crashes/ice-10148.stderr b/tests/ui/crashes/ice-10148.stderr index ece3e1c394037..2451c496546b2 100644 --- a/tests/ui/crashes/ice-10148.stderr +++ b/tests/ui/crashes/ice-10148.stderr @@ -1,5 +1,5 @@ error: empty string literal in `println!` - --> $DIR/ice-10148.rs:8:5 + --> $DIR/crashes/ice-10148.rs:8:5 | LL | println!(with_span!(""something "")); | ^^^^^^^^^^^^^^^^^^^^-----------^^^^^ diff --git a/tests/ui/crashes/ice-10645.stderr b/tests/ui/crashes/ice-10645.stderr index 7fc62d4fcf855..47fa3d8530e9d 100644 --- a/tests/ui/crashes/ice-10645.stderr +++ b/tests/ui/crashes/ice-10645.stderr @@ -1,11 +1,11 @@ warning: future cannot be sent between threads safely - --> $DIR/ice-10645.rs:5:1 + --> $DIR/crashes/ice-10645.rs:5:1 | LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `bar` is not `Send` | note: captured value is not `Send` - --> $DIR/ice-10645.rs:5:29 + --> $DIR/crashes/ice-10645.rs:5:29 | LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^ has type `T` which is not `Send` diff --git a/tests/ui/crashes/ice-10912.stderr b/tests/ui/crashes/ice-10912.stderr index 2be297b56250f..d2f7b540e48d3 100644 --- a/tests/ui/crashes/ice-10912.stderr +++ b/tests/ui/crashes/ice-10912.stderr @@ -1,11 +1,11 @@ error: expected at least one digit in exponent - --> $DIR/ice-10912.rs:3:28 + --> $DIR/crashes/ice-10912.rs:3:28 | LL | fn f2() -> impl Sized { && 3.14159265358979323846E } | ^^^^^^^^^^^^^^^^^^^^^^^ error: long literal lacking separators - --> $DIR/ice-10912.rs:3:28 + --> $DIR/crashes/ice-10912.rs:3:28 | LL | fn f2() -> impl Sized { && 3.14159265358979323846E } | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider: `3.141_592_653_589_793_238_46` diff --git a/tests/ui/crashes/ice-11065.rs b/tests/ui/crashes/ice-11065.rs index f5cf6b1cd77a2..a17d7e38e0c35 100644 --- a/tests/ui/crashes/ice-11065.rs +++ b/tests/ui/crashes/ice-11065.rs @@ -1,6 +1,5 @@ #![warn(clippy::useless_conversion)] -use std::iter::FromIterator; use std::option::IntoIter as OptionIter; fn eq(a: T, b: T) -> bool { diff --git a/tests/ui/crashes/ice-11422.stderr b/tests/ui/crashes/ice-11422.stderr index b3dcc00f3d9ef..0e940c4280a1d 100644 --- a/tests/ui/crashes/ice-11422.stderr +++ b/tests/ui/crashes/ice-11422.stderr @@ -1,5 +1,5 @@ error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/ice-11422.rs:6:31 + --> $DIR/crashes/ice-11422.rs:6:31 | LL | fn gen() -> impl PartialOrd + PartialEq + Debug {} | ^^^^^^^^^ diff --git a/tests/ui/crashes/ice-11803.stderr b/tests/ui/crashes/ice-11803.stderr index b8289048a8b90..338ce6371c959 100644 --- a/tests/ui/crashes/ice-11803.stderr +++ b/tests/ui/crashes/ice-11803.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/ice-11803.rs:5:54 + --> $DIR/crashes/ice-11803.rs:5:54 | LL | pub fn g>>() { | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | pub fn g>, { /* Gen | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/ice-11803.rs:5:33 + --> $DIR/crashes/ice-11803.rs:5:33 | LL | pub fn g>>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-2774.stderr b/tests/ui/crashes/ice-2774.stderr index 188a5985024e7..7c5c3508fec8d 100644 --- a/tests/ui/crashes/ice-2774.stderr +++ b/tests/ui/crashes/ice-2774.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/ice-2774.rs:15:28 + --> $DIR/crashes/ice-2774.rs:15:28 | LL | pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { | ^^ ^^ diff --git a/tests/ui/crashes/ice-360.stderr b/tests/ui/crashes/ice-360.stderr index a84697a9f291d..7a17706e870b9 100644 --- a/tests/ui/crashes/ice-360.stderr +++ b/tests/ui/crashes/ice-360.stderr @@ -1,5 +1,5 @@ error: this loop never actually loops - --> $DIR/ice-360.rs:5:5 + --> $DIR/crashes/ice-360.rs:5:5 | LL | / loop { LL | | @@ -13,7 +13,7 @@ LL | | } = note: `#[deny(clippy::never_loop)]` on by default error: this loop could be written as a `while let` loop - --> $DIR/ice-360.rs:5:5 + --> $DIR/crashes/ice-360.rs:5:5 | LL | / loop { LL | | @@ -28,7 +28,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/ice-360.rs:13:9 + --> $DIR/crashes/ice-360.rs:13:9 | LL | loop {} | ^^^^^^^ diff --git a/tests/ui/crashes/ice-3717.stderr b/tests/ui/crashes/ice-3717.stderr index 863608fca8bdf..66d4341b3d70a 100644 --- a/tests/ui/crashes/ice-3717.stderr +++ b/tests/ui/crashes/ice-3717.stderr @@ -1,11 +1,11 @@ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/ice-3717.rs:7:21 + --> $DIR/crashes/ice-3717.rs:7:21 | LL | pub fn ice_3717(_: &HashSet) { | ^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/ice-3717.rs:1:9 + --> $DIR/crashes/ice-3717.rs:1:9 | LL | #![deny(clippy::implicit_hasher)] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-3891.stderr b/tests/ui/crashes/ice-3891.stderr index 5358734fed04e..f8c02a175eefe 100644 --- a/tests/ui/crashes/ice-3891.stderr +++ b/tests/ui/crashes/ice-3891.stderr @@ -1,5 +1,5 @@ error: invalid suffix `x` for number literal - --> $DIR/ice-3891.rs:2:5 + --> $DIR/crashes/ice-3891.rs:2:5 | LL | 1x; | ^^ invalid suffix `x` diff --git a/tests/ui/crashes/ice-3969.stderr b/tests/ui/crashes/ice-3969.stderr index c6bef3004d377..d090d457237e6 100644 --- a/tests/ui/crashes/ice-3969.stderr +++ b/tests/ui/crashes/ice-3969.stderr @@ -1,5 +1,5 @@ error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:20:10 + --> $DIR/crashes/ice-3969.rs:20:10 | LL | str: Sized; | ^^^^^ @@ -8,25 +8,25 @@ LL | str: Sized; = help: to override `-D warnings` add `#[allow(trivial_bounds)]` error: trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:26:30 + --> $DIR/crashes/ice-3969.rs:26:30 | LL | for<'a> Dst: Sized, | ^^^^^ error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:34:10 + --> $DIR/crashes/ice-3969.rs:34:10 | LL | str: Sized, | ^^^^^ error: trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:42:13 + --> $DIR/crashes/ice-3969.rs:42:13 | LL | String: ::std::ops::Neg, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:50:10 + --> $DIR/crashes/ice-3969.rs:50:10 | LL | i32: Iterator, | ^^^^^^^^ diff --git a/tests/ui/crashes/ice-5497.stderr b/tests/ui/crashes/ice-5497.stderr index 3efaf05827e80..cb09fecdffcf3 100644 --- a/tests/ui/crashes/ice-5497.stderr +++ b/tests/ui/crashes/ice-5497.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/ice-5497.rs:11:22 + --> $DIR/crashes/ice-5497.rs:11:22 | LL | const OOB: i32 = [1][1] + T::OOB; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/crashes/ice-5835.stderr b/tests/ui/crashes/ice-5835.stderr index 1f930e1f6d2cc..20ea1b37056b6 100644 --- a/tests/ui/crashes/ice-5835.stderr +++ b/tests/ui/crashes/ice-5835.stderr @@ -1,5 +1,5 @@ error: using tabs in doc comments is not recommended - --> $DIR/ice-5835.rs:3:10 + --> $DIR/crashes/ice-5835.rs:3:10 | LL | /// 位 | ^^^^ help: consider using four spaces per tab diff --git a/tests/ui/crashes/ice-5872.stderr b/tests/ui/crashes/ice-5872.stderr index d0067a2239e97..b6651966f202d 100644 --- a/tests/ui/crashes/ice-5872.stderr +++ b/tests/ui/crashes/ice-5872.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/ice-5872.rs:4:39 + --> $DIR/crashes/ice-5872.rs:4:39 | LL | let _ = vec![1, 2, 3].into_iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` diff --git a/tests/ui/crashes/ice-6250.stderr b/tests/ui/crashes/ice-6250.stderr index 97390af3e89ed..8f34accea92c7 100644 --- a/tests/ui/crashes/ice-6250.stderr +++ b/tests/ui/crashes/ice-6250.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ice-6250.rs:12:14 + --> $DIR/crashes/ice-6250.rs:12:14 | LL | for reference in vec![1, 2, 3] { | --------- expected due to the type of this binding @@ -8,7 +8,7 @@ LL | Some(reference) = cache.data.get(key) { | ^^^^^^^^^ expected integer, found `&i32` error[E0308]: mismatched types - --> $DIR/ice-6250.rs:12:9 + --> $DIR/crashes/ice-6250.rs:12:9 | LL | Some(reference) = cache.data.get(key) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` diff --git a/tests/ui/crashes/ice-6251.stderr b/tests/ui/crashes/ice-6251.stderr index 0196c9923dbe6..e4d7929f2cdb8 100644 --- a/tests/ui/crashes/ice-6251.stderr +++ b/tests/ui/crashes/ice-6251.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/ice-6251.rs:4:45 + --> $DIR/crashes/ice-6251.rs:4:45 | LL | fn bug() -> impl Iterator { | ^ doesn't have a size known at compile-time @@ -12,7 +12,7 @@ LL | fn bug() -> impl Iterator { | + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/ice-6251.rs:4:54 + --> $DIR/crashes/ice-6251.rs:4:54 | LL | fn bug() -> impl Iterator { | ^ doesn't have a size known at compile-time @@ -21,13 +21,13 @@ LL | fn bug() -> impl Iterator { = note: the return type of a function must have a statically known size error[E0308]: mismatched types - --> $DIR/ice-6251.rs:4:44 + --> $DIR/crashes/ice-6251.rs:4:44 | LL | fn bug() -> impl Iterator { | ^^^^^^^^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/ice-6251.rs:4:44: 4:53}` + found closure `{closure@$DIR/crashes/ice-6251.rs:4:44: 4:53}` error: aborting due to 3 previous errors diff --git a/tests/ui/crashes/ice-6252.stderr b/tests/ui/crashes/ice-6252.stderr index f6d0976091c53..91e31c81ead59 100644 --- a/tests/ui/crashes/ice-6252.stderr +++ b/tests/ui/crashes/ice-6252.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `PhantomData` in this scope - --> $DIR/ice-6252.rs:9:9 + --> $DIR/crashes/ice-6252.rs:9:9 | LL | _n: PhantomData, | ^^^^^^^^^^^ not found in this scope @@ -12,7 +12,7 @@ LL + use std::marker::PhantomData; | error[E0412]: cannot find type `VAL` in this scope - --> $DIR/ice-6252.rs:11:63 + --> $DIR/crashes/ice-6252.rs:11:63 | LL | impl TypeVal for Multiply where N: TypeVal {} | ^^^ not found in this scope @@ -23,7 +23,7 @@ LL | impl TypeVal for Multiply where N: TypeVal {} | +++++ error[E0046]: not all trait items implemented, missing: `VAL` - --> $DIR/ice-6252.rs:11:1 + --> $DIR/crashes/ice-6252.rs:11:1 | LL | const VAL: T; | ------------ `VAL` from trait diff --git a/tests/ui/crashes/ice-6255.stderr b/tests/ui/crashes/ice-6255.stderr index bc13319bef023..5599ef08c384c 100644 --- a/tests/ui/crashes/ice-6255.stderr +++ b/tests/ui/crashes/ice-6255.stderr @@ -1,5 +1,5 @@ error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/ice-6255.rs:6:9 + --> $DIR/crashes/ice-6255.rs:6:9 | LL | extern crate std as core; | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-6256.stderr b/tests/ui/crashes/ice-6256.stderr index cba6df194eccb..1f9cdd31f8795 100644 --- a/tests/ui/crashes/ice-6256.stderr +++ b/tests/ui/crashes/ice-6256.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/ice-6256.rs:13:26 + --> $DIR/crashes/ice-6256.rs:13:26 | LL | let f = |x: &dyn TT| x.func(); | - - ^^^^^^^^ diff --git a/tests/ui/crashes/ice-7169.stderr b/tests/ui/crashes/ice-7169.stderr index 3126de93d2241..5f75802037f9d 100644 --- a/tests/ui/crashes/ice-7169.stderr +++ b/tests/ui/crashes/ice-7169.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/ice-7169.rs:10:12 + --> $DIR/crashes/ice-7169.rs:10:12 | LL | if let Ok(_) = Ok::<_, ()>(A::::default()) {} | -------^^^^^-------------------------------------- help: try: `if Ok::<_, ()>(A::::default()).is_ok()` diff --git a/tests/ui/crashes/ice-7868.stderr b/tests/ui/crashes/ice-7868.stderr index 3315a8d907ae6..4b0d992e61363 100644 --- a/tests/ui/crashes/ice-7868.stderr +++ b/tests/ui/crashes/ice-7868.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/auxiliary/ice-7868-aux.rs:2:5 + --> $DIR/crashes/auxiliary/ice-7868-aux.rs:2:5 | LL | unsafe { 0 }; | ^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-7869.stderr b/tests/ui/crashes/ice-7869.stderr index 22f2c7e46fdc5..bf36749bc45b5 100644 --- a/tests/ui/crashes/ice-7869.stderr +++ b/tests/ui/crashes/ice-7869.stderr @@ -1,5 +1,5 @@ error: all variants have the same prefix: `Työ` - --> $DIR/ice-7869.rs:1:1 + --> $DIR/crashes/ice-7869.rs:1:1 | LL | / enum Tila { LL | | diff --git a/tests/ui/crashes/ice-8250.stderr b/tests/ui/crashes/ice-8250.stderr index 397e978af0bd6..169216f9f7b16 100644 --- a/tests/ui/crashes/ice-8250.stderr +++ b/tests/ui/crashes/ice-8250.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `splitn` - --> $DIR/ice-8250.rs:2:13 + --> $DIR/crashes/ice-8250.rs:2:13 | LL | let _ = s[1..].splitn(2, '.').next()?; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s[1..].split('.')` diff --git a/tests/ui/crashes/ice-8850.stderr b/tests/ui/crashes/ice-8850.stderr index aa140f305e39d..0a6c70163343f 100644 --- a/tests/ui/crashes/ice-8850.stderr +++ b/tests/ui/crashes/ice-8850.stderr @@ -1,5 +1,5 @@ error: returning the result of a `let` binding from a block - --> $DIR/ice-8850.rs:4:5 + --> $DIR/crashes/ice-8850.rs:4:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding @@ -15,7 +15,7 @@ LL ~ FN() + 1 | error: returning the result of a `let` binding from a block - --> $DIR/ice-8850.rs:12:5 + --> $DIR/crashes/ice-8850.rs:12:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ FN() + 1 | error: returning the result of a `let` binding from a block - --> $DIR/ice-8850.rs:27:5 + --> $DIR/crashes/ice-8850.rs:27:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding diff --git a/tests/ui/crashes/ice-9041.stderr b/tests/ui/crashes/ice-9041.stderr index 67589d1a8ab32..e54a0196c7fe4 100644 --- a/tests/ui/crashes/ice-9041.stderr +++ b/tests/ui/crashes/ice-9041.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/ice-9041.rs:5:19 + --> $DIR/crashes/ice-9041.rs:5:19 | LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|p| is_thing_ready(&p))` diff --git a/tests/ui/crashes/ice-9405.stderr b/tests/ui/crashes/ice-9405.stderr index 56649a2bdfcb5..921190fbde71b 100644 --- a/tests/ui/crashes/ice-9405.stderr +++ b/tests/ui/crashes/ice-9405.stderr @@ -1,5 +1,5 @@ warning: multiple lines skipped by escaped newline - --> $DIR/ice-9405.rs:6:10 + --> $DIR/crashes/ice-9405.rs:6:10 | LL | "\ | __________^ diff --git a/tests/ui/crashes/ice-9445.stderr b/tests/ui/crashes/ice-9445.stderr index f97b4536e129a..fd3c3e69512dc 100644 --- a/tests/ui/crashes/ice-9445.stderr +++ b/tests/ui/crashes/ice-9445.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/ice-9445.rs:1:1 + --> $DIR/crashes/ice-9445.rs:1:1 | LL | const UNINIT: core::mem::MaybeUninit> = core::mem::MaybeUninit::uninit(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-9463.stderr b/tests/ui/crashes/ice-9463.stderr index 911795694c38e..e03a971aabbae 100644 --- a/tests/ui/crashes/ice-9463.stderr +++ b/tests/ui/crashes/ice-9463.stderr @@ -1,23 +1,23 @@ error: this arithmetic operation will overflow - --> $DIR/ice-9463.rs:3:14 + --> $DIR/crashes/ice-9463.rs:3:14 | LL | let _x = -1_i32 >> -1; | ^^^^^^^^^^^^ attempt to shift right by `-1_i32`, which would overflow | note: the lint level is defined here - --> $DIR/ice-9463.rs:1:9 + --> $DIR/crashes/ice-9463.rs:1:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ error: this arithmetic operation will overflow - --> $DIR/ice-9463.rs:5:14 + --> $DIR/crashes/ice-9463.rs:5:14 | LL | let _y = 1u32 >> 10000000000000u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift right by `1316134912_u32`, which would overflow error: literal out of range for `u32` - --> $DIR/ice-9463.rs:5:22 + --> $DIR/crashes/ice-9463.rs:5:22 | LL | let _y = 1u32 >> 10000000000000u32; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-96721.stderr b/tests/ui/crashes/ice-96721.stderr index 1741c7c6a0a22..2bbcf9c84557a 100644 --- a/tests/ui/crashes/ice-96721.stderr +++ b/tests/ui/crashes/ice-96721.stderr @@ -1,5 +1,5 @@ error: malformed `path` attribute input - --> $DIR/ice-96721.rs:7:1 + --> $DIR/crashes/ice-96721.rs:7:1 | LL | #[path = foo!()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` diff --git a/tests/ui/crashes/needless_lifetimes_impl_trait.stderr b/tests/ui/crashes/needless_lifetimes_impl_trait.stderr index 2ebb9d5cd1a12..737587cc05a7e 100644 --- a/tests/ui/crashes/needless_lifetimes_impl_trait.stderr +++ b/tests/ui/crashes/needless_lifetimes_impl_trait.stderr @@ -1,11 +1,11 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes_impl_trait.rs:15:12 + --> $DIR/crashes/needless_lifetimes_impl_trait.rs:15:12 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { | ^^ ^^ ^^ | note: the lint level is defined here - --> $DIR/needless_lifetimes_impl_trait.rs:1:9 + --> $DIR/crashes/needless_lifetimes_impl_trait.rs:1:9 | LL | #![deny(clippy::needless_lifetimes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr index b318f8d3f7af1..b4141c864f138 100644 --- a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr +++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr @@ -1,11 +1,11 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value-w-late-bound.rs:7:12 + --> $DIR/crashes/needless_pass_by_value-w-late-bound.rs:7:12 | LL | fn test(x: Foo<'_>) {} | ^^^^^^^ help: consider taking a reference instead: `&Foo<'_>` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value-w-late-bound.rs:5:1 + --> $DIR/crashes/needless_pass_by_value-w-late-bound.rs:5:1 | LL | struct Foo<'a>(&'a [(); 100]); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/crate_level_checks/no_std_swap.stderr b/tests/ui/crate_level_checks/no_std_swap.stderr index 7ef8d08d5d69e..29a6341a90709 100644 --- a/tests/ui/crate_level_checks/no_std_swap.stderr +++ b/tests/ui/crate_level_checks/no_std_swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to swap `a` and `b` - --> $DIR/no_std_swap.rs:12:5 + --> $DIR/crate_level_checks/no_std_swap.rs:12:5 | LL | / a = b; LL | | diff --git a/tests/ui/crate_level_checks/std_main_recursion.stderr b/tests/ui/crate_level_checks/std_main_recursion.stderr index 3bc406206e4b5..9452cc0d4b5a4 100644 --- a/tests/ui/crate_level_checks/std_main_recursion.stderr +++ b/tests/ui/crate_level_checks/std_main_recursion.stderr @@ -1,5 +1,5 @@ error: recursing into entrypoint `main` - --> $DIR/std_main_recursion.rs:5:5 + --> $DIR/crate_level_checks/std_main_recursion.rs:5:5 | LL | main(); | ^^^^ diff --git a/tests/ui/dbg_macro/dbg_macro.stderr b/tests/ui/dbg_macro/dbg_macro.stderr index 4d00421c71186..70d832f2ac5bc 100644 --- a/tests/ui/dbg_macro/dbg_macro.stderr +++ b/tests/ui/dbg_macro/dbg_macro.stderr @@ -1,5 +1,5 @@ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/auxiliary/submodule.rs:2:5 + --> $DIR/dbg_macro/auxiliary/submodule.rs:2:5 | LL | dbg!(); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:9:22 + --> $DIR/dbg_macro/dbg_macro.rs:9:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:15:8 + --> $DIR/dbg_macro/dbg_macro.rs:15:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | if n <= 1 { | ~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:17:9 + --> $DIR/dbg_macro/dbg_macro.rs:17:9 | LL | dbg!(1) | ^^^^^^^ @@ -46,7 +46,7 @@ LL | 1 | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:20:9 + --> $DIR/dbg_macro/dbg_macro.rs:20:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | n * factorial(n - 1) | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:26:5 + --> $DIR/dbg_macro/dbg_macro.rs:26:5 | LL | dbg!(42); | ^^^^^^^^ @@ -68,7 +68,7 @@ LL | 42; | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:28:5 + --> $DIR/dbg_macro/dbg_macro.rs:28:5 | LL | dbg!(dbg!(dbg!(42))); | ^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:30:14 + --> $DIR/dbg_macro/dbg_macro.rs:30:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:32:5 + --> $DIR/dbg_macro/dbg_macro.rs:32:5 | LL | dbg!(1, 2, dbg!(3, 4)); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:34:5 + --> $DIR/dbg_macro/dbg_macro.rs:34:5 | LL | dbg!(1, 2, 3, 4, 5); | ^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:55:5 + --> $DIR/dbg_macro/dbg_macro.rs:55:5 | LL | dbg!(); | ^^^^^^^ @@ -124,7 +124,7 @@ LL + | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:58:13 + --> $DIR/dbg_macro/dbg_macro.rs:58:13 | LL | let _ = dbg!(); | ^^^^^^ @@ -135,7 +135,7 @@ LL | let _ = (); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:60:9 + --> $DIR/dbg_macro/dbg_macro.rs:60:9 | LL | bar(dbg!()); | ^^^^^^ @@ -146,7 +146,7 @@ LL | bar(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:62:10 + --> $DIR/dbg_macro/dbg_macro.rs:62:10 | LL | foo!(dbg!()); | ^^^^^^ @@ -157,7 +157,7 @@ LL | foo!(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:64:16 + --> $DIR/dbg_macro/dbg_macro.rs:64:16 | LL | foo2!(foo!(dbg!())); | ^^^^^^ @@ -168,7 +168,7 @@ LL | foo2!(foo!(())); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:86:9 + --> $DIR/dbg_macro/dbg_macro.rs:86:9 | LL | dbg!(2); | ^^^^^^^ @@ -179,7 +179,7 @@ LL | 2; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:93:5 + --> $DIR/dbg_macro/dbg_macro.rs:93:5 | LL | dbg!(1); | ^^^^^^^ @@ -190,7 +190,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:99:5 + --> $DIR/dbg_macro/dbg_macro.rs:99:5 | LL | dbg!(1); | ^^^^^^^ @@ -201,7 +201,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:106:9 + --> $DIR/dbg_macro/dbg_macro.rs:106:9 | LL | dbg!(1); | ^^^^^^^ diff --git a/tests/ui/declare_interior_mutable_const/enums.stderr b/tests/ui/declare_interior_mutable_const/enums.stderr index 6d34373886d5a..94e61a13ee7a7 100644 --- a/tests/ui/declare_interior_mutable_const/enums.stderr +++ b/tests/ui/declare_interior_mutable_const/enums.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:12:1 + --> $DIR/declare_interior_mutable_const/enums.rs:12:1 | LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(tru = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable - --> $DIR/enums.rs:23:1 + --> $DIR/declare_interior_mutable_const/enums.rs:23:1 | LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/enums.rs:45:1 + --> $DIR/declare_interior_mutable_const/enums.rs:45:1 | LL | const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { | ^---- @@ -33,56 +33,56 @@ LL | | }; | |__^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:60:5 + --> $DIR/declare_interior_mutable_const/enums.rs:60:5 | LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:61:5 + --> $DIR/declare_interior_mutable_const/enums.rs:61:5 | LL | const TO_BE_FROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:64:5 + --> $DIR/declare_interior_mutable_const/enums.rs:64:5 | LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:90:5 + --> $DIR/declare_interior_mutable_const/enums.rs:90:5 | LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:102:5 + --> $DIR/declare_interior_mutable_const/enums.rs:102:5 | LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:105:5 + --> $DIR/declare_interior_mutable_const/enums.rs:105:5 | LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:111:5 + --> $DIR/declare_interior_mutable_const/enums.rs:111:5 | LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:118:5 + --> $DIR/declare_interior_mutable_const/enums.rs:118:5 | LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric = LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | |____________________________________________________________________^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:120:5 + --> $DIR/declare_interior_mutable_const/enums.rs:120:5 | LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/declare_interior_mutable_const/others.stderr b/tests/ui/declare_interior_mutable_const/others.stderr index cc286b9f7f685..c79f143df3619 100644 --- a/tests/ui/declare_interior_mutable_const/others.stderr +++ b/tests/ui/declare_interior_mutable_const/others.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/others.rs:9:1 + --> $DIR/declare_interior_mutable_const/others.rs:9:1 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable - --> $DIR/others.rs:10:1 + --> $DIR/declare_interior_mutable_const/others.rs:10:1 | LL | const CELL: Cell = Cell::new(6); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | const CELL: Cell = Cell::new(6); | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/others.rs:11:1 + --> $DIR/declare_interior_mutable_const/others.rs:11:1 | LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], V | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/others.rs:16:9 + --> $DIR/declare_interior_mutable_const/others.rs:16:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | declare_const!(_ONCE: Once = Once::new()); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should never be interior mutable - --> $DIR/others.rs:43:13 + --> $DIR/declare_interior_mutable_const/others.rs:43:13 | LL | const _BAZ: Cell = Cell::new(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/declare_interior_mutable_const/traits.stderr b/tests/ui/declare_interior_mutable_const/traits.stderr index 7647cd96fec77..925a54b9a5955 100644 --- a/tests/ui/declare_interior_mutable_const/traits.stderr +++ b/tests/ui/declare_interior_mutable_const/traits.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:15:5 + --> $DIR/declare_interior_mutable_const/traits.rs:15:5 | LL | const ATOMIC: AtomicUsize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | const ATOMIC: AtomicUsize; = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable - --> $DIR/traits.rs:9:9 + --> $DIR/declare_interior_mutable_const/traits.rs:9:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -19,55 +19,55 @@ LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should never be interior mutable - --> $DIR/traits.rs:43:5 + --> $DIR/declare_interior_mutable_const/traits.rs:43:5 | LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:68:5 + --> $DIR/declare_interior_mutable_const/traits.rs:68:5 | LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:69:5 + --> $DIR/declare_interior_mutable_const/traits.rs:69:5 | LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:88:5 + --> $DIR/declare_interior_mutable_const/traits.rs:88:5 | LL | const BOUNDED: T::ToBeBounded; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:116:5 + --> $DIR/declare_interior_mutable_const/traits.rs:116:5 | LL | const SELF: Self = AtomicUsize::new(17); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:117:5 + --> $DIR/declare_interior_mutable_const/traits.rs:117:5 | LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:125:5 + --> $DIR/declare_interior_mutable_const/traits.rs:125:5 | LL | const INDIRECT: Cell<*const T>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:141:5 + --> $DIR/declare_interior_mutable_const/traits.rs:141:5 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:147:5 + --> $DIR/declare_interior_mutable_const/traits.rs:147:5 | LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/doc/doc-fixable.stderr b/tests/ui/doc/doc-fixable.stderr index 033604e030a98..8d2ef481eb100 100644 --- a/tests/ui/doc/doc-fixable.stderr +++ b/tests/ui/doc/doc-fixable.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:9:9 + --> $DIR/doc/doc-fixable.rs:9:9 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^ @@ -12,7 +12,7 @@ LL | /// The `foo_bar` function does _nothing_. See also foo::bar. (note the dot | ~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:9:51 + --> $DIR/doc/doc-fixable.rs:9:51 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^^ @@ -23,7 +23,7 @@ LL | /// The foo_bar function does _nothing_. See also `foo::bar`. (note the dot | ~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:10:83 + --> $DIR/doc/doc-fixable.rs:10:83 | LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun | ^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. B | ~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:12:13 + --> $DIR/doc/doc-fixable.rs:12:13 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. | ^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | /// Here be `::a::global:path`, and _::another::global::path_. :: is not a | ~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:12:36 + --> $DIR/doc/doc-fixable.rs:12:36 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | /// Here be ::a::global:path, and _`::another::global::path`_. :: is not a | ~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:13:25 + --> $DIR/doc/doc-fixable.rs:13:25 | LL | /// Import an item from ::awesome::global::blob:: (Intended postfix) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | /// Import an item from `::awesome::global::blob::` (Intended postfix) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:14:31 + --> $DIR/doc/doc-fixable.rs:14:31 | LL | /// These are the options for ::Cat: (Intended trailing single colon, shouldn't be linted) | ^^^^^ @@ -78,7 +78,7 @@ LL | /// These are the options for `::Cat`: (Intended trailing single colon, sho | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:15:22 + --> $DIR/doc/doc-fixable.rs:15:22 | LL | /// That's not code ~NotInCodeBlock~. | ^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | /// That's not code ~`NotInCodeBlock`~. | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:16:5 + --> $DIR/doc/doc-fixable.rs:16:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:30:5 + --> $DIR/doc/doc-fixable.rs:30:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:37:5 + --> $DIR/doc/doc-fixable.rs:37:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:51:5 + --> $DIR/doc/doc-fixable.rs:51:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:75:5 + --> $DIR/doc/doc-fixable.rs:75:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:92:5 + --> $DIR/doc/doc-fixable.rs:92:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:100:8 + --> $DIR/doc/doc-fixable.rs:100:8 | LL | /// ## CamelCaseThing | ^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | /// ## `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:103:7 + --> $DIR/doc/doc-fixable.rs:103:7 | LL | /// # CamelCaseThing | ^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | /// # `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:105:22 + --> $DIR/doc/doc-fixable.rs:105:22 | LL | /// Not a title #897 CamelCaseThing | ^^^^^^^^^^^^^^ @@ -188,7 +188,7 @@ LL | /// Not a title #897 `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:106:5 + --> $DIR/doc/doc-fixable.rs:106:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:113:5 + --> $DIR/doc/doc-fixable.rs:113:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -210,7 +210,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:126:5 + --> $DIR/doc/doc-fixable.rs:126:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -221,7 +221,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:137:43 + --> $DIR/doc/doc-fixable.rs:137:43 | LL | /** E.g., serialization of an empty list: FooBar | ^^^^^^ @@ -232,7 +232,7 @@ LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:142:5 + --> $DIR/doc/doc-fixable.rs:142:5 | LL | And BarQuz too. | ^^^^^^ @@ -243,7 +243,7 @@ LL | And `BarQuz` too. | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:143:1 + --> $DIR/doc/doc-fixable.rs:143:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -254,7 +254,7 @@ LL | `be_sure_we_got_to_the_end_of_it` | error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:148:43 + --> $DIR/doc/doc-fixable.rs:148:43 | LL | /** E.g., serialization of an empty list: FooBar | ^^^^^^ @@ -265,7 +265,7 @@ LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:153:5 + --> $DIR/doc/doc-fixable.rs:153:5 | LL | And BarQuz too. | ^^^^^^ @@ -276,7 +276,7 @@ LL | And `BarQuz` too. | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:154:1 + --> $DIR/doc/doc-fixable.rs:154:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -287,7 +287,7 @@ LL | `be_sure_we_got_to_the_end_of_it` | error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:165:5 + --> $DIR/doc/doc-fixable.rs:165:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -298,7 +298,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:184:22 + --> $DIR/doc/doc-fixable.rs:184:22 | LL | /// An iterator over mycrate::Collection's values. | ^^^^^^^^^^^^^^^^^^^ @@ -309,7 +309,7 @@ LL | /// An iterator over `mycrate::Collection`'s values. | ~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:208:34 + --> $DIR/doc/doc-fixable.rs:208:34 | LL | /// Foo \[bar\] \[baz\] \[qux\]. DocMarkdownLint | ^^^^^^^^^^^^^^^ @@ -320,7 +320,7 @@ LL | /// Foo \[bar\] \[baz\] \[qux\]. `DocMarkdownLint` | ~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:231:22 + --> $DIR/doc/doc-fixable.rs:231:22 | LL | /// There is no try (do() or do_not()). | ^^^^ @@ -331,7 +331,7 @@ LL | /// There is no try (`do()` or do_not()). | ~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:231:30 + --> $DIR/doc/doc-fixable.rs:231:30 | LL | /// There is no try (do() or do_not()). | ^^^^^^^^ diff --git a/tests/ui/doc/unbalanced_ticks.stderr b/tests/ui/doc/unbalanced_ticks.stderr index 89ad8db3916c2..b14dbdd945bac 100644 --- a/tests/ui/doc/unbalanced_ticks.stderr +++ b/tests/ui/doc/unbalanced_ticks.stderr @@ -1,5 +1,5 @@ error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:7:5 + --> $DIR/doc/unbalanced_ticks.rs:7:5 | LL | /// This is a doc comment with `unbalanced_tick marks and several words that | _____^ @@ -14,7 +14,7 @@ LL | | /// very `confusing_and_misleading`. = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:14:5 + --> $DIR/doc/unbalanced_ticks.rs:14:5 | LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/unbalanced_ticks.rs:17:32 + --> $DIR/doc/unbalanced_ticks.rs:17:32 | LL | /// This paragraph is fine and should_be linted normally. | ^^^^^^^^^ @@ -33,7 +33,7 @@ LL | /// This paragraph is fine and `should_be` linted normally. | ~~~~~~~~~~~ error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:20:5 + --> $DIR/doc/unbalanced_ticks.rs:20:5 | LL | /// Double unbalanced backtick from ``here to here` should lint. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | /// Double unbalanced backtick from ``here to here` should lint. = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/unbalanced_ticks.rs:34:8 + --> $DIR/doc/unbalanced_ticks.rs:34:8 | LL | /// ## not_fine | ^^^^^^^^ @@ -52,7 +52,7 @@ LL | /// ## `not_fine` | ~~~~~~~~~~ error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:37:5 + --> $DIR/doc/unbalanced_ticks.rs:37:5 | LL | /// ### `unbalanced | ^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | /// ### `unbalanced = help: a backtick may be missing a pair error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:40:5 + --> $DIR/doc/unbalanced_ticks.rs:40:5 | LL | /// - This `item has unbalanced tick marks | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | /// - This `item has unbalanced tick marks = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/unbalanced_ticks.rs:42:23 + --> $DIR/doc/unbalanced_ticks.rs:42:23 | LL | /// - This item needs backticks_here | ^^^^^^^^^^^^^^ diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr index f0e635954c5a9..d08ba64d9bae2 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:14:17 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:14:17 | LL | if let Some(slice) = slice { | ^^^^^ | note: the lint level is defined here - --> $DIR/if_let_slice_binding.rs:1:9 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:21:17 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:21:17 | LL | if let Some(slice) = slice { | ^^^^^ @@ -34,7 +34,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:28:17 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:28:17 | LL | if let Some(slice) = slice { | ^^^^^ @@ -50,7 +50,7 @@ LL ~ println!("{}", slice_0); | error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:36:26 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:36:26 | LL | if let SomeEnum::One(slice) | SomeEnum::Three(slice) = slice_wrapped { | ^^^^^ @@ -65,7 +65,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:44:29 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:44:29 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { | ^ @@ -80,7 +80,7 @@ LL | println!("{} -> {}", a_2, b[1]); | ~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:44:38 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:44:38 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { | ^ @@ -95,7 +95,7 @@ LL | println!("{} -> {}", a[2], b_1); | ~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:53:21 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:53:21 | LL | if let Some(ref slice) = slice { | ^^^^^ @@ -110,7 +110,7 @@ LL | println!("{:?}", slice_1); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:62:17 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:62:17 | LL | if let Some(slice) = &slice { | ^^^^^ @@ -125,7 +125,7 @@ LL | println!("{:?}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:132:17 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:132:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ @@ -140,7 +140,7 @@ LL | println!("This is awesome! {}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:140:17 + --> $DIR/index_refutable_slice/if_let_slice_binding.rs:140:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ diff --git a/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr b/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr index 429861e993e82..40da4b53b8e0d 100644 --- a/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr +++ b/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/slice_indexing_in_macro.rs:23:21 + --> $DIR/index_refutable_slice/slice_indexing_in_macro.rs:23:21 | LL | if let Some(slice) = slice; | ^^^^^ | note: the lint level is defined here - --> $DIR/slice_indexing_in_macro.rs:1:9 + --> $DIR/index_refutable_slice/slice_indexing_in_macro.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/items_after_test_module/in_submodule.stderr b/tests/ui/items_after_test_module/in_submodule.stderr index 30aa90d29bf8c..7d4675af0f046 100644 --- a/tests/ui/items_after_test_module/in_submodule.stderr +++ b/tests/ui/items_after_test_module/in_submodule.stderr @@ -1,5 +1,5 @@ error: items after a test module - --> $DIR/auxiliary/submodule.rs:2:1 + --> $DIR/items_after_test_module/auxiliary/submodule.rs:2:1 | LL | mod tests {} | ^^^^^^^^^ diff --git a/tests/ui/items_after_test_module/root_module.stderr b/tests/ui/items_after_test_module/root_module.stderr index 17b07cc32f4e3..b736b166295d9 100644 --- a/tests/ui/items_after_test_module/root_module.stderr +++ b/tests/ui/items_after_test_module/root_module.stderr @@ -1,5 +1,5 @@ error: items after a test module - --> $DIR/root_module.rs:12:1 + --> $DIR/items_after_test_module/root_module.rs:12:1 | LL | mod tests { | ^^^^^^^^^ diff --git a/tests/ui/manual_memcpy/with_loop_counters.stderr b/tests/ui/manual_memcpy/with_loop_counters.stderr index 3f000fbab6994..ffa396ec01aa7 100644 --- a/tests/ui/manual_memcpy/with_loop_counters.stderr +++ b/tests/ui/manual_memcpy/with_loop_counters.stderr @@ -1,5 +1,5 @@ error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:5:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:5:5 | LL | / for i in 3..src.len() { LL | | @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:13:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:13:5 | LL | / for i in 3..src.len() { LL | | @@ -23,7 +23,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..(src.len() - 3)].copy_from_slice(&src[3..]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:20:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:20:5 | LL | / for i in 0..src.len() { LL | | @@ -33,7 +33,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(src.len() + 3)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:27:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:27:5 | LL | / for i in 0..src.len() { LL | | @@ -43,7 +43,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[3..(src.len() + 3)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:34:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:34:5 | LL | / for i in 3..(3 + src.len()) { LL | | @@ -53,7 +53,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(3 + src.len())].copy_from_slice(&src[..(3 + src.len() - 3)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:41:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:41:5 | LL | / for i in 5..src.len() { LL | | @@ -63,7 +63,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[5..src.len()].copy_from_slice(&src[(3 - 2)..((src.len() - 2) + 3 - 5)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:48:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:48:5 | LL | / for i in 0..dst.len() { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[2..(dst.len() + 2)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:55:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:55:5 | LL | / for i in 3..10 { LL | | @@ -83,7 +83,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..10].copy_from_slice(&src[5..(10 + 5 - 3)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:63:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:63:5 | LL | / for i in 0..src.len() { LL | | @@ -101,7 +101,7 @@ LL + dst2[30..(src.len() + 30)].copy_from_slice(&src[..]); | error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:74:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:74:5 | LL | / for i in 0..1 << 1 { LL | | @@ -111,7 +111,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(0 << 1)..((1 << 1) + (0 << 1))].copy_from_slice(&src[2..((1 << 1) + 2)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:82:5 + --> $DIR/manual_memcpy/with_loop_counters.rs:82:5 | LL | / for i in 3..src.len() { LL | | diff --git a/tests/ui/manual_memcpy/without_loop_counters.stderr b/tests/ui/manual_memcpy/without_loop_counters.stderr index 4b5cd274da78f..0d9b50d162d7c 100644 --- a/tests/ui/manual_memcpy/without_loop_counters.stderr +++ b/tests/ui/manual_memcpy/without_loop_counters.stderr @@ -1,5 +1,5 @@ error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:8:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:8:5 | LL | / for i in 0..src.len() { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:15:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:15:5 | LL | / for i in 0..src.len() { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[10..(src.len() + 10)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:21:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:21:5 | LL | / for i in 0..src.len() { LL | | @@ -30,7 +30,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[10..(src.len() + 10)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:27:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:27:5 | LL | / for i in 11..src.len() { LL | | @@ -39,7 +39,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[11..src.len()].copy_from_slice(&src[(11 - 10)..(src.len() - 10)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:33:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:33:5 | LL | / for i in 0..dst.len() { LL | | @@ -48,7 +48,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..dst.len()]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:47:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:47:5 | LL | / for i in 10..256 { LL | | @@ -64,7 +64,7 @@ LL + dst2[(10 + 500)..(256 + 500)].copy_from_slice(&src[10..256]); | error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:60:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:60:5 | LL | / for i in 10..LOOP_OFFSET { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].copy_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:74:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:74:5 | LL | / for i in 0..src_vec.len() { LL | | @@ -82,7 +82,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst_vec[..src_vec.len()].copy_from_slice(&src_vec[..]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:104:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:104:5 | LL | / for i in from..from + src.len() { LL | | @@ -91,7 +91,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + src.len())].copy_from_slice(&src[..(from + src.len() - from)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:109:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:109:5 | LL | / for i in from..from + 3 { LL | | @@ -100,7 +100,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + 3)].copy_from_slice(&src[..(from + 3 - from)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:115:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:115:5 | LL | / for i in 0..5 { LL | | @@ -109,7 +109,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:121:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:121:5 | LL | / for i in 0..0 { LL | | @@ -118,7 +118,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:145:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:145:5 | LL | / for i in 0..4 { LL | | @@ -127,7 +127,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..4]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:151:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:151:5 | LL | / for i in 0..5 { LL | | @@ -136,7 +136,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:157:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:157:5 | LL | / for i in 0..5 { LL | | @@ -145,7 +145,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:165:5 + --> $DIR/manual_memcpy/without_loop_counters.rs:165:5 | LL | / for i in 0..src.len() { LL | | diff --git a/tests/ui/missing_const_for_fn/could_be_const.stderr b/tests/ui/missing_const_for_fn/could_be_const.stderr index b3a8ad8fa717e..4d01e5ce17034 100644 --- a/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -1,5 +1,5 @@ error: this could be a `const fn` - --> $DIR/could_be_const.rs:14:5 + --> $DIR/missing_const_for_fn/could_be_const.rs:14:5 | LL | / pub fn new() -> Self { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::missing_const_for_fn)]` error: this could be a `const fn` - --> $DIR/could_be_const.rs:20:5 + --> $DIR/missing_const_for_fn/could_be_const.rs:20:5 | LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:27:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:27:1 | LL | / fn one() -> i32 { LL | | @@ -30,7 +30,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:33:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:33:1 | LL | / fn two() -> i32 { LL | | @@ -40,7 +40,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:40:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:40:1 | LL | / fn string() -> String { LL | | @@ -49,7 +49,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:46:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:46:1 | LL | / unsafe fn four() -> i32 { LL | | @@ -58,7 +58,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:52:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:52:1 | LL | / fn generic(t: T) -> T { LL | | @@ -67,7 +67,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:61:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:61:1 | LL | / fn generic_arr(t: [T; 1]) -> T { LL | | @@ -76,7 +76,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:75:9 + --> $DIR/missing_const_for_fn/could_be_const.rs:75:9 | LL | / pub fn b(self, a: &A) -> B { LL | | @@ -85,7 +85,7 @@ LL | | } | |_________^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:85:5 + --> $DIR/missing_const_for_fn/could_be_const.rs:85:5 | LL | / fn const_fn_stabilized_before_msrv(byte: u8) { LL | | @@ -94,7 +94,7 @@ LL | | } | |_____^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:97:1 + --> $DIR/missing_const_for_fn/could_be_const.rs:97:1 | LL | / fn msrv_1_46() -> i32 { LL | | diff --git a/tests/ui/needless_bool/fixable.stderr b/tests/ui/needless_bool/fixable.stderr index 72b0670c95bae..67018d8d70639 100644 --- a/tests/ui/needless_bool/fixable.stderr +++ b/tests/ui/needless_bool/fixable.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:41:5 + --> $DIR/needless_bool/fixable.rs:41:5 | LL | / if x { LL | | true @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:46:5 + --> $DIR/needless_bool/fixable.rs:46:5 | LL | / if x { LL | | false @@ -22,7 +22,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:51:5 + --> $DIR/needless_bool/fixable.rs:51:5 | LL | / if x && y { LL | | false @@ -32,7 +32,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!(x && y)` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:59:5 + --> $DIR/needless_bool/fixable.rs:59:5 | LL | / if a == b { LL | | false @@ -42,7 +42,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a != b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:64:5 + --> $DIR/needless_bool/fixable.rs:64:5 | LL | / if a != b { LL | | false @@ -52,7 +52,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a == b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:69:5 + --> $DIR/needless_bool/fixable.rs:69:5 | LL | / if a < b { LL | | false @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a >= b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:74:5 + --> $DIR/needless_bool/fixable.rs:74:5 | LL | / if a <= b { LL | | false @@ -72,7 +72,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a > b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:79:5 + --> $DIR/needless_bool/fixable.rs:79:5 | LL | / if a > b { LL | | false @@ -82,7 +82,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a <= b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:84:5 + --> $DIR/needless_bool/fixable.rs:84:5 | LL | / if a >= b { LL | | false @@ -92,7 +92,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a < b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:112:5 + --> $DIR/needless_bool/fixable.rs:112:5 | LL | / if x { LL | | return true; @@ -102,7 +102,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:120:5 + --> $DIR/needless_bool/fixable.rs:120:5 | LL | / if x { LL | | return false; @@ -112,7 +112,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:128:5 + --> $DIR/needless_bool/fixable.rs:128:5 | LL | / if x && y { LL | | return true; @@ -122,7 +122,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:136:5 + --> $DIR/needless_bool/fixable.rs:136:5 | LL | / if x && y { LL | | return false; @@ -132,7 +132,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/fixable.rs:144:8 + --> $DIR/needless_bool/fixable.rs:144:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -141,25 +141,25 @@ LL | if x == true {}; = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against false can be replaced by a negation - --> $DIR/fixable.rs:148:8 + --> $DIR/needless_bool/fixable.rs:148:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/fixable.rs:158:8 + --> $DIR/needless_bool/fixable.rs:158:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/fixable.rs:159:8 + --> $DIR/needless_bool/fixable.rs:159:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:168:12 + --> $DIR/needless_bool/fixable.rs:168:12 | LL | } else if returns_bool() { | ____________^ @@ -170,7 +170,7 @@ LL | | }; | |_____^ help: you can reduce it to: `{ !returns_bool() }` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:181:5 + --> $DIR/needless_bool/fixable.rs:181:5 | LL | / if unsafe { no(4) } & 1 != 0 { LL | | true @@ -180,13 +180,13 @@ LL | | }; | |_____^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:186:30 + --> $DIR/needless_bool/fixable.rs:186:30 | LL | let _brackets_unneeded = if unsafe { no(4) } & 1 != 0 { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `unsafe { no(4) } & 1 != 0` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:189:9 + --> $DIR/needless_bool/fixable.rs:189:9 | LL | if unsafe { no(4) } & 1 != 0 { true } else { false } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` diff --git a/tests/ui/needless_bool/simple.stderr b/tests/ui/needless_bool/simple.stderr index a44205c59b75b..6846565b68e1d 100644 --- a/tests/ui/needless_bool/simple.stderr +++ b/tests/ui/needless_bool/simple.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression will always return true - --> $DIR/simple.rs:14:5 + --> $DIR/needless_bool/simple.rs:14:5 | LL | / if x { LL | | true @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression will always return false - --> $DIR/simple.rs:19:5 + --> $DIR/needless_bool/simple.rs:19:5 | LL | / if x { LL | | false @@ -22,7 +22,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return true - --> $DIR/simple.rs:34:5 + --> $DIR/needless_bool/simple.rs:34:5 | LL | / if x { LL | | return true; @@ -32,7 +32,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return false - --> $DIR/simple.rs:42:5 + --> $DIR/needless_bool/simple.rs:42:5 | LL | / if x { LL | | return false; diff --git a/tests/ui/out_of_bounds_indexing/issue-3102.stderr b/tests/ui/out_of_bounds_indexing/issue-3102.stderr index 37db11caab8aa..15b728e1daf54 100644 --- a/tests/ui/out_of_bounds_indexing/issue-3102.stderr +++ b/tests/ui/out_of_bounds_indexing/issue-3102.stderr @@ -1,5 +1,5 @@ error: range is out of bounds - --> $DIR/issue-3102.rs:9:13 + --> $DIR/out_of_bounds_indexing/issue-3102.rs:9:13 | LL | &x[num..10]; | ^^ @@ -8,7 +8,7 @@ LL | &x[num..10]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> $DIR/issue-3102.rs:12:8 + --> $DIR/out_of_bounds_indexing/issue-3102.rs:12:8 | LL | &x[10..num]; | ^^ diff --git a/tests/ui/out_of_bounds_indexing/simple.stderr b/tests/ui/out_of_bounds_indexing/simple.stderr index ddef38beb315a..00c401cdbfb20 100644 --- a/tests/ui/out_of_bounds_indexing/simple.stderr +++ b/tests/ui/out_of_bounds_indexing/simple.stderr @@ -1,5 +1,5 @@ error: range is out of bounds - --> $DIR/simple.rs:7:11 + --> $DIR/out_of_bounds_indexing/simple.rs:7:11 | LL | &x[..=4]; | ^ @@ -8,31 +8,31 @@ LL | &x[..=4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> $DIR/simple.rs:10:11 + --> $DIR/out_of_bounds_indexing/simple.rs:10:11 | LL | &x[1..5]; | ^ error: range is out of bounds - --> $DIR/simple.rs:12:8 + --> $DIR/out_of_bounds_indexing/simple.rs:12:8 | LL | &x[5..]; | ^ error: range is out of bounds - --> $DIR/simple.rs:14:10 + --> $DIR/out_of_bounds_indexing/simple.rs:14:10 | LL | &x[..5]; | ^ error: range is out of bounds - --> $DIR/simple.rs:16:8 + --> $DIR/out_of_bounds_indexing/simple.rs:16:8 | LL | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> $DIR/simple.rs:18:12 + --> $DIR/out_of_bounds_indexing/simple.rs:18:12 | LL | &x[0..=4]; | ^ diff --git a/tests/ui/pattern_type_mismatch/mutability.stderr b/tests/ui/pattern_type_mismatch/mutability.stderr index f21e1894af2a2..39bdad891c313 100644 --- a/tests/ui/pattern_type_mismatch/mutability.stderr +++ b/tests/ui/pattern_type_mismatch/mutability.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/mutability.rs:9:9 + --> $DIR/pattern_type_mismatch/mutability.rs:9:9 | LL | Some(_) => (), | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(_) => (), = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/mutability.rs:16:9 + --> $DIR/pattern_type_mismatch/mutability.rs:16:9 | LL | Some(_) => (), | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr b/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr index b72c24840d7d4..bb63492c473fb 100644 --- a/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_alternatives.rs:15:12 + --> $DIR/pattern_type_mismatch/pattern_alternatives.rs:15:12 | LL | if let Value::B | Value::A(_) = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | if let Value::B | Value::A(_) = ref_value {} = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_alternatives.rs:17:34 + --> $DIR/pattern_type_mismatch/pattern_alternatives.rs:17:34 | LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_alternatives.rs:19:32 + --> $DIR/pattern_type_mismatch/pattern_alternatives.rs:19:32 | LL | if let Value::B | Value::A(Some(_)) = *ref_value {} | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_structs.stderr b/tests/ui/pattern_type_mismatch/pattern_structs.stderr index c46c7de6dd658..043c669f25027 100644 --- a/tests/ui/pattern_type_mismatch/pattern_structs.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_structs.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:13:9 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:13:9 | LL | let Struct { .. } = ref_value; | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let Struct { .. } = ref_value; = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:15:33 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:15:33 | LL | if let &Struct { ref_inner: Some(_) } = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &Struct { ref_inner: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:17:32 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:17:32 | LL | if let Struct { ref_inner: Some(_) } = *ref_value {} | ^^^^^^^ @@ -25,7 +25,7 @@ LL | if let Struct { ref_inner: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:35:12 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:35:12 | LL | if let StructEnum::Var { .. } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let StructEnum::Var { .. } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:37:12 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:37:12 | LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:39:42 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:39:42 | LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:41:41 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:41:41 | LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} | ^^^^^^^ @@ -57,7 +57,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:43:12 + --> $DIR/pattern_type_mismatch/pattern_structs.rs:43:12 | LL | if let StructEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr index b365731d5619c..b204b0b80b53e 100644 --- a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:11:9 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:11:9 | LL | let TupleStruct(_) = ref_value; | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let TupleStruct(_) = ref_value; = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:13:25 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:13:25 | LL | if let &TupleStruct(Some(_)) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &TupleStruct(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:15:24 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:15:24 | LL | if let TupleStruct(Some(_)) = *ref_value {} | ^^^^^^^ @@ -25,7 +25,7 @@ LL | if let TupleStruct(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:33:12 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:33:12 | LL | if let TupleEnum::Var(_) = ref_value {} | ^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let TupleEnum::Var(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:35:28 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:35:28 | LL | if let &TupleEnum::Var(Some(_)) = ref_value {} | ^^^^^^^ @@ -41,7 +41,7 @@ LL | if let &TupleEnum::Var(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:37:27 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:37:27 | LL | if let TupleEnum::Var(Some(_)) = *ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let TupleEnum::Var(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:39:12 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:39:12 | LL | if let TupleEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | if let TupleEnum::Empty = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:55:9 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:55:9 | LL | let (_a, _b) = ref_value; | ^^^^^^^^ @@ -65,7 +65,7 @@ LL | let (_a, _b) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:57:18 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:57:18 | LL | if let &(_a, Some(_)) = ref_value {} | ^^^^^^^ @@ -73,7 +73,7 @@ LL | if let &(_a, Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:59:17 + --> $DIR/pattern_type_mismatch/pattern_tuples.rs:59:17 | LL | if let (_a, Some(_)) = *ref_value {} | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/syntax.stderr b/tests/ui/pattern_type_mismatch/syntax.stderr index dfe4639c7746f..4a6db7bf02c62 100644 --- a/tests/ui/pattern_type_mismatch/syntax.stderr +++ b/tests/ui/pattern_type_mismatch/syntax.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/syntax.rs:11:9 + --> $DIR/pattern_type_mismatch/syntax.rs:11:9 | LL | Some(_) => (), | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(_) => (), = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/syntax.rs:31:12 + --> $DIR/pattern_type_mismatch/syntax.rs:31:12 | LL | if let Some(_) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let Some(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:43:15 + --> $DIR/pattern_type_mismatch/syntax.rs:43:15 | LL | while let Some(_) = ref_value { | ^^^^^^^ @@ -25,7 +25,7 @@ LL | while let Some(_) = ref_value { = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:62:9 + --> $DIR/pattern_type_mismatch/syntax.rs:62:9 | LL | for (_a, _b) in slice.iter() {} | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | for (_a, _b) in slice.iter() {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:73:9 + --> $DIR/pattern_type_mismatch/syntax.rs:73:9 | LL | let (_n, _m) = ref_value; | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | let (_n, _m) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:83:12 + --> $DIR/pattern_type_mismatch/syntax.rs:83:12 | LL | fn foo((_a, _b): &(i32, i32)) {} | ^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn foo((_a, _b): &(i32, i32)) {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:98:10 + --> $DIR/pattern_type_mismatch/syntax.rs:98:10 | LL | foo(|(_a, _b)| ()); | ^^^^^^^^ @@ -57,7 +57,7 @@ LL | foo(|(_a, _b)| ()); = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:115:9 + --> $DIR/pattern_type_mismatch/syntax.rs:115:9 | LL | Some(_) => (), | ^^^^^^^ @@ -65,7 +65,7 @@ LL | Some(_) => (), = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:136:17 + --> $DIR/pattern_type_mismatch/syntax.rs:136:17 | LL | Some(_) => (), | ^^^^^^^ diff --git a/tests/ui/rc_clone_in_vec_init/arc.stderr b/tests/ui/rc_clone_in_vec_init/arc.stderr index 5dc4b5a10e526..a5d050ad8f16d 100644 --- a/tests/ui/rc_clone_in_vec_init/arc.stderr +++ b/tests/ui/rc_clone_in_vec_init/arc.stderr @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:9:13 + --> $DIR/rc_clone_in_vec_init/arc.rs:9:13 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:19:21 + --> $DIR/rc_clone_in_vec_init/arc.rs:19:21 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:27:13 + --> $DIR/rc_clone_in_vec_init/arc.rs:27:13 | LL | let v = vec![ | _____________^ @@ -77,7 +77,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:38:14 + --> $DIR/rc_clone_in_vec_init/arc.rs:38:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_clone_in_vec_init/rc.stderr b/tests/ui/rc_clone_in_vec_init/rc.stderr index e6bc6f68b3e49..fbf4517c1d229 100644 --- a/tests/ui/rc_clone_in_vec_init/rc.stderr +++ b/tests/ui/rc_clone_in_vec_init/rc.stderr @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:10:13 + --> $DIR/rc_clone_in_vec_init/rc.rs:10:13 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:20:21 + --> $DIR/rc_clone_in_vec_init/rc.rs:20:21 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:28:13 + --> $DIR/rc_clone_in_vec_init/rc.rs:28:13 | LL | let v = vec![ | _____________^ @@ -77,7 +77,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:39:14 + --> $DIR/rc_clone_in_vec_init/rc.rs:39:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_clone_in_vec_init/weak.stderr b/tests/ui/rc_clone_in_vec_init/weak.stderr index 25d7dae72da30..658b308d68c53 100644 --- a/tests/ui/rc_clone_in_vec_init/weak.stderr +++ b/tests/ui/rc_clone_in_vec_init/weak.stderr @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:10:13 + --> $DIR/rc_clone_in_vec_init/weak.rs:10:13 | LL | let v = vec![SyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:13:14 + --> $DIR/rc_clone_in_vec_init/weak.rs:13:14 | LL | let v2 = vec![UnSyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:17:13 + --> $DIR/rc_clone_in_vec_init/weak.rs:17:13 | LL | let v = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:20:13 + --> $DIR/rc_clone_in_vec_init/weak.rs:20:13 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:30:21 + --> $DIR/rc_clone_in_vec_init/weak.rs:30:21 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:33:22 + --> $DIR/rc_clone_in_vec_init/weak.rs:33:22 | LL | let v2 = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:41:13 + --> $DIR/rc_clone_in_vec_init/weak.rs:41:13 | LL | let v = vec![ | _____________^ @@ -169,7 +169,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:52:14 + --> $DIR/rc_clone_in_vec_init/weak.rs:52:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/should_impl_trait/method_list_1.stderr b/tests/ui/should_impl_trait/method_list_1.stderr index c9894eec53a20..46df34c3432ad 100644 --- a/tests/ui/should_impl_trait/method_list_1.stderr +++ b/tests/ui/should_impl_trait/method_list_1.stderr @@ -1,5 +1,5 @@ error: method `add` can be confused for the standard trait method `std::ops::Add::add` - --> $DIR/method_list_1.rs:25:5 + --> $DIR/should_impl_trait/method_list_1.rs:25:5 | LL | / pub fn add(self, other: T) -> T { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]` error: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` - --> $DIR/method_list_1.rs:30:5 + --> $DIR/should_impl_trait/method_list_1.rs:30:5 | LL | / pub fn as_mut(&mut self) -> &mut T { LL | | @@ -23,7 +23,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsMut` or choosing a less ambiguous method name error: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` - --> $DIR/method_list_1.rs:35:5 + --> $DIR/should_impl_trait/method_list_1.rs:35:5 | LL | / pub fn as_ref(&self) -> &T { LL | | @@ -34,7 +34,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsRef` or choosing a less ambiguous method name error: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` - --> $DIR/method_list_1.rs:40:5 + --> $DIR/should_impl_trait/method_list_1.rs:40:5 | LL | / pub fn bitand(self, rhs: T) -> T { LL | | @@ -45,7 +45,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitAnd` or choosing a less ambiguous method name error: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` - --> $DIR/method_list_1.rs:45:5 + --> $DIR/should_impl_trait/method_list_1.rs:45:5 | LL | / pub fn bitor(self, rhs: Self) -> Self { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitOr` or choosing a less ambiguous method name error: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` - --> $DIR/method_list_1.rs:50:5 + --> $DIR/should_impl_trait/method_list_1.rs:50:5 | LL | / pub fn bitxor(self, rhs: Self) -> Self { LL | | @@ -67,7 +67,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitXor` or choosing a less ambiguous method name error: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` - --> $DIR/method_list_1.rs:55:5 + --> $DIR/should_impl_trait/method_list_1.rs:55:5 | LL | / pub fn borrow(&self) -> &str { LL | | @@ -78,7 +78,7 @@ LL | | } = help: consider implementing the trait `std::borrow::Borrow` or choosing a less ambiguous method name error: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` - --> $DIR/method_list_1.rs:60:5 + --> $DIR/should_impl_trait/method_list_1.rs:60:5 | LL | / pub fn borrow_mut(&mut self) -> &mut str { LL | | @@ -89,7 +89,7 @@ LL | | } = help: consider implementing the trait `std::borrow::BorrowMut` or choosing a less ambiguous method name error: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` - --> $DIR/method_list_1.rs:65:5 + --> $DIR/should_impl_trait/method_list_1.rs:65:5 | LL | / pub fn clone(&self) -> Self { LL | | @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::clone::Clone` or choosing a less ambiguous method name error: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` - --> $DIR/method_list_1.rs:70:5 + --> $DIR/should_impl_trait/method_list_1.rs:70:5 | LL | / pub fn cmp(&self, other: &Self) -> Self { LL | | @@ -111,7 +111,7 @@ LL | | } = help: consider implementing the trait `std::cmp::Ord` or choosing a less ambiguous method name error: method `default` can be confused for the standard trait method `std::default::Default::default` - --> $DIR/method_list_1.rs:75:5 + --> $DIR/should_impl_trait/method_list_1.rs:75:5 | LL | / pub fn default() -> Self { LL | | @@ -122,7 +122,7 @@ LL | | } = help: consider implementing the trait `std::default::Default` or choosing a less ambiguous method name error: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` - --> $DIR/method_list_1.rs:80:5 + --> $DIR/should_impl_trait/method_list_1.rs:80:5 | LL | / pub fn deref(&self) -> &Self { LL | | @@ -133,7 +133,7 @@ LL | | } = help: consider implementing the trait `std::ops::Deref` or choosing a less ambiguous method name error: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` - --> $DIR/method_list_1.rs:85:5 + --> $DIR/should_impl_trait/method_list_1.rs:85:5 | LL | / pub fn deref_mut(&mut self) -> &mut Self { LL | | @@ -144,7 +144,7 @@ LL | | } = help: consider implementing the trait `std::ops::DerefMut` or choosing a less ambiguous method name error: method `div` can be confused for the standard trait method `std::ops::Div::div` - --> $DIR/method_list_1.rs:90:5 + --> $DIR/should_impl_trait/method_list_1.rs:90:5 | LL | / pub fn div(self, rhs: Self) -> Self { LL | | @@ -155,7 +155,7 @@ LL | | } = help: consider implementing the trait `std::ops::Div` or choosing a less ambiguous method name error: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` - --> $DIR/method_list_1.rs:95:5 + --> $DIR/should_impl_trait/method_list_1.rs:95:5 | LL | / pub fn drop(&mut self) { LL | | diff --git a/tests/ui/should_impl_trait/method_list_2.stderr b/tests/ui/should_impl_trait/method_list_2.stderr index c257f41134266..1f452c7003443 100644 --- a/tests/ui/should_impl_trait/method_list_2.stderr +++ b/tests/ui/should_impl_trait/method_list_2.stderr @@ -1,5 +1,5 @@ error: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` - --> $DIR/method_list_2.rs:26:5 + --> $DIR/should_impl_trait/method_list_2.rs:26:5 | LL | / pub fn eq(&self, other: &Self) -> bool { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]` error: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` - --> $DIR/method_list_2.rs:31:5 + --> $DIR/should_impl_trait/method_list_2.rs:31:5 | LL | / pub fn from_iter(iter: T) -> Self { LL | | @@ -23,7 +23,7 @@ LL | | } = help: consider implementing the trait `std::iter::FromIterator` or choosing a less ambiguous method name error: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` - --> $DIR/method_list_2.rs:36:5 + --> $DIR/should_impl_trait/method_list_2.rs:36:5 | LL | / pub fn from_str(s: &str) -> Result { LL | | @@ -34,7 +34,7 @@ LL | | } = help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name error: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` - --> $DIR/method_list_2.rs:41:5 + --> $DIR/should_impl_trait/method_list_2.rs:41:5 | LL | / pub fn hash(&self, state: &mut T) { LL | | @@ -45,7 +45,7 @@ LL | | } = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name error: method `index` can be confused for the standard trait method `std::ops::Index::index` - --> $DIR/method_list_2.rs:46:5 + --> $DIR/should_impl_trait/method_list_2.rs:46:5 | LL | / pub fn index(&self, index: usize) -> &Self { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` - --> $DIR/method_list_2.rs:51:5 + --> $DIR/should_impl_trait/method_list_2.rs:51:5 | LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { LL | | @@ -67,7 +67,7 @@ LL | | } = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` - --> $DIR/method_list_2.rs:56:5 + --> $DIR/should_impl_trait/method_list_2.rs:56:5 | LL | / pub fn into_iter(self) -> Self { LL | | @@ -78,7 +78,7 @@ LL | | } = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` - --> $DIR/method_list_2.rs:61:5 + --> $DIR/should_impl_trait/method_list_2.rs:61:5 | LL | / pub fn mul(self, rhs: Self) -> Self { LL | | @@ -89,7 +89,7 @@ LL | | } = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` - --> $DIR/method_list_2.rs:66:5 + --> $DIR/should_impl_trait/method_list_2.rs:66:5 | LL | / pub fn neg(self) -> Self { LL | | @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` - --> $DIR/method_list_2.rs:71:5 + --> $DIR/should_impl_trait/method_list_2.rs:71:5 | LL | / pub fn next(&mut self) -> Option { LL | | @@ -111,7 +111,7 @@ LL | | } = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name error: method `not` can be confused for the standard trait method `std::ops::Not::not` - --> $DIR/method_list_2.rs:76:5 + --> $DIR/should_impl_trait/method_list_2.rs:76:5 | LL | / pub fn not(self) -> Self { LL | | @@ -122,7 +122,7 @@ LL | | } = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` - --> $DIR/method_list_2.rs:81:5 + --> $DIR/should_impl_trait/method_list_2.rs:81:5 | LL | / pub fn rem(self, rhs: Self) -> Self { LL | | @@ -133,7 +133,7 @@ LL | | } = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` - --> $DIR/method_list_2.rs:86:5 + --> $DIR/should_impl_trait/method_list_2.rs:86:5 | LL | / pub fn shl(self, rhs: Self) -> Self { LL | | @@ -144,7 +144,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` - --> $DIR/method_list_2.rs:91:5 + --> $DIR/should_impl_trait/method_list_2.rs:91:5 | LL | / pub fn shr(self, rhs: Self) -> Self { LL | | @@ -155,7 +155,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` - --> $DIR/method_list_2.rs:96:5 + --> $DIR/should_impl_trait/method_list_2.rs:96:5 | LL | / pub fn sub(self, rhs: Self) -> Self { LL | | diff --git a/tests/ui/size_of_in_element_count/expressions.stderr b/tests/ui/size_of_in_element_count/expressions.stderr index 47f9632b8d123..ea8dc92ff1826 100644 --- a/tests/ui/size_of_in_element_count/expressions.stderr +++ b/tests/ui/size_of_in_element_count/expressions.stderr @@ -1,5 +1,5 @@ error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:15:62 + --> $DIR/size_of_in_element_count/expressions.rs:15:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::( = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:19:62 + --> $DIR/size_of_in_element_count/expressions.rs:19:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * si = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:23:47 + --> $DIR/size_of_in_element_count/expressions.rs:23:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() / 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:33:47 + --> $DIR/size_of_in_element_count/expressions.rs:33:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::())) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/size_of_in_element_count/functions.stderr b/tests/ui/size_of_in_element_count/functions.stderr index aba4c800e44df..ad1174e5e7bc0 100644 --- a/tests/ui/size_of_in_element_count/functions.stderr +++ b/tests/ui/size_of_in_element_count/functions.stderr @@ -1,5 +1,5 @@ error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:18:68 + --> $DIR/size_of_in_element_count/functions.rs:18:68 | LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of: = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:20:62 + --> $DIR/size_of_in_element_count/functions.rs:20:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:23:49 + --> $DIR/size_of_in_element_count/functions.rs:23:49 | LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:25:64 + --> $DIR/size_of_in_element_count/functions.rs:25:64 | LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of:: $DIR/functions.rs:27:51 + --> $DIR/size_of_in_element_count/functions.rs:27:51 | LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:29:66 + --> $DIR/size_of_in_element_count/functions.rs:29:66 | LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::< = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:32:47 + --> $DIR/size_of_in_element_count/functions.rs:32:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:34:47 + --> $DIR/size_of_in_element_count/functions.rs:34:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:37:46 + --> $DIR/size_of_in_element_count/functions.rs:37:46 | LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:39:47 + --> $DIR/size_of_in_element_count/functions.rs:39:47 | LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:42:66 + --> $DIR/size_of_in_element_count/functions.rs:42:66 | LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::< = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:45:46 + --> $DIR/size_of_in_element_count/functions.rs:45:46 | LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:47:38 + --> $DIR/size_of_in_element_count/functions.rs:47:38 | LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:50:49 + --> $DIR/size_of_in_element_count/functions.rs:50:49 | LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:52:41 + --> $DIR/size_of_in_element_count/functions.rs:52:41 | LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:55:33 + --> $DIR/size_of_in_element_count/functions.rs:55:33 | LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:57:29 + --> $DIR/size_of_in_element_count/functions.rs:57:29 | LL | y.as_ptr().wrapping_sub(size_of::()); | ^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | y.as_ptr().wrapping_sub(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:59:29 + --> $DIR/size_of_in_element_count/functions.rs:59:29 | LL | unsafe { y.as_ptr().add(size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | unsafe { y.as_ptr().add(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:61:33 + --> $DIR/size_of_in_element_count/functions.rs:61:33 | LL | y.as_mut_ptr().wrapping_add(size_of::()); | ^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ LL | y.as_mut_ptr().wrapping_add(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:63:32 + --> $DIR/size_of_in_element_count/functions.rs:63:32 | LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -161,7 +161,7 @@ LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:65:36 + --> $DIR/size_of_in_element_count/functions.rs:65:36 | LL | y.as_mut_ptr().wrapping_offset(size_of::() as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^ From 9b5e4c6d57decaa419e3af48d0c6b95cb5b7620e Mon Sep 17 00:00:00 2001 From: beetrees Date: Fri, 16 Feb 2024 19:02:19 +0000 Subject: [PATCH 091/417] Ensure ASM syntax detect `global_asm!` and `asm!` only on x86 architectures --- clippy_lints/src/asm_syntax.rs | 37 ++++++++-- tests/ui/asm_syntax.stderr | 46 ------------ tests/ui/asm_syntax_not_x86.rs | 24 ++++++ tests/ui/asm_syntax_x86.i686.stderr | 73 +++++++++++++++++++ tests/ui/{asm_syntax.rs => asm_syntax_x86.rs} | 23 ++++-- tests/ui/asm_syntax_x86.x86_64.stderr | 73 +++++++++++++++++++ 6 files changed, 219 insertions(+), 57 deletions(-) delete mode 100644 tests/ui/asm_syntax.stderr create mode 100644 tests/ui/asm_syntax_not_x86.rs create mode 100644 tests/ui/asm_syntax_x86.i686.stderr rename tests/ui/{asm_syntax.rs => asm_syntax_x86.rs} (64%) create mode 100644 tests/ui/asm_syntax_x86.x86_64.stderr diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index feb6437ee26ac..c2fa56e136031 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -2,8 +2,11 @@ use std::fmt; use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions}; -use rustc_lint::{EarlyContext, EarlyLintPass, Lint}; +use rustc_ast::{InlineAsm, Item, ItemKind}; +use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext}; use rustc_session::declare_lint_pass; +use rustc_span::Span; +use rustc_target::asm::InlineAsmArch; #[derive(Clone, Copy, PartialEq, Eq)] enum AsmStyle { @@ -31,8 +34,14 @@ impl std::ops::Not for AsmStyle { } } -fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr, check_for: AsmStyle) { - if let ExprKind::InlineAsm(ref inline_asm) = expr.kind { +fn check_asm_syntax( + lint: &'static Lint, + cx: &EarlyContext<'_>, + inline_asm: &InlineAsm, + span: Span, + check_for: AsmStyle, +) { + if matches!(cx.sess().asm_arch, Some(InlineAsmArch::X86 | InlineAsmArch::X86_64)) { let style = if inline_asm.options.contains(InlineAsmOptions::ATT_SYNTAX) { AsmStyle::Att } else { @@ -43,7 +52,7 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr span_lint_and_help( cx, lint, - expr.span, + span, &format!("{style} x86 assembly syntax used"), None, &format!("use {} x86 assembly syntax", !style), @@ -89,7 +98,15 @@ declare_lint_pass!(InlineAsmX86IntelSyntax => [INLINE_ASM_X86_INTEL_SYNTAX]); impl EarlyLintPass for InlineAsmX86IntelSyntax { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { - check_expr_asm_syntax(Self::get_lints()[0], cx, expr, AsmStyle::Intel); + if let ExprKind::InlineAsm(inline_asm) = &expr.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Intel); + } + } + + fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { + if let ItemKind::GlobalAsm(inline_asm) = &item.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Intel); + } } } @@ -130,6 +147,14 @@ declare_lint_pass!(InlineAsmX86AttSyntax => [INLINE_ASM_X86_ATT_SYNTAX]); impl EarlyLintPass for InlineAsmX86AttSyntax { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { - check_expr_asm_syntax(Self::get_lints()[0], cx, expr, AsmStyle::Att); + if let ExprKind::InlineAsm(inline_asm) = &expr.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Att); + } + } + + fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { + if let ItemKind::GlobalAsm(inline_asm) = &item.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Att); + } } } diff --git a/tests/ui/asm_syntax.stderr b/tests/ui/asm_syntax.stderr deleted file mode 100644 index 537ea8c57e9b2..0000000000000 --- a/tests/ui/asm_syntax.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error: Intel x86 assembly syntax used - --> $DIR/asm_syntax.rs:8:9 - | -LL | asm!(""); - | ^^^^^^^^ - | - = help: use AT&T x86 assembly syntax - = note: `-D clippy::inline-asm-x86-intel-syntax` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]` - -error: Intel x86 assembly syntax used - --> $DIR/asm_syntax.rs:10:9 - | -LL | asm!("", options()); - | ^^^^^^^^^^^^^^^^^^^ - | - = help: use AT&T x86 assembly syntax - -error: Intel x86 assembly syntax used - --> $DIR/asm_syntax.rs:12:9 - | -LL | asm!("", options(nostack)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: use AT&T x86 assembly syntax - -error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax.rs:26:9 - | -LL | asm!("", options(att_syntax)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: use Intel x86 assembly syntax - = note: `-D clippy::inline-asm-x86-att-syntax` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]` - -error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax.rs:28:9 - | -LL | asm!("", options(nostack, att_syntax)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: use Intel x86 assembly syntax - -error: aborting due to 5 previous errors - diff --git a/tests/ui/asm_syntax_not_x86.rs b/tests/ui/asm_syntax_not_x86.rs new file mode 100644 index 0000000000000..33cea4806814b --- /dev/null +++ b/tests/ui/asm_syntax_not_x86.rs @@ -0,0 +1,24 @@ +//@ignore-target-i686 +//@ignore-target-x86 +//@needs-asm-support + +#[warn(clippy::inline_asm_x86_intel_syntax)] +#[warn(clippy::inline_asm_x86_att_syntax)] +mod dont_warn { + use std::arch::{asm, global_asm}; + + pub(super) unsafe fn use_asm() { + asm!(""); + asm!("", options()); + asm!("", options(nostack)); + } + + global_asm!(""); + global_asm!("", options()); +} + +fn main() { + unsafe { + dont_warn::use_asm(); + } +} diff --git a/tests/ui/asm_syntax_x86.i686.stderr b/tests/ui/asm_syntax_x86.i686.stderr new file mode 100644 index 0000000000000..dee78f97e68a0 --- /dev/null +++ b/tests/ui/asm_syntax_x86.i686.stderr @@ -0,0 +1,73 @@ +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:10:9 + | +LL | asm!(""); + | ^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + = note: `-D clippy::inline-asm-x86-intel-syntax` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]` + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:12:9 + | +LL | asm!("", options()); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:14:9 + | +LL | asm!("", options(nostack)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:20:5 + | +LL | global_asm!(""); + | ^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:22:5 + | +LL | global_asm!("", options()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: AT&T x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:35:9 + | +LL | asm!("", options(att_syntax)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use Intel x86 assembly syntax + = note: `-D clippy::inline-asm-x86-att-syntax` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]` + +error: AT&T x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:37:9 + | +LL | asm!("", options(nostack, att_syntax)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use Intel x86 assembly syntax + +error: AT&T x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:43:5 + | +LL | global_asm!("", options(att_syntax)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use Intel x86 assembly syntax + = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 8 previous errors + diff --git a/tests/ui/asm_syntax.rs b/tests/ui/asm_syntax_x86.rs similarity index 64% rename from tests/ui/asm_syntax.rs rename to tests/ui/asm_syntax_x86.rs index 0a7eb86bc03f3..835943b43894c 100644 --- a/tests/ui/asm_syntax.rs +++ b/tests/ui/asm_syntax_x86.rs @@ -1,10 +1,12 @@ -//@only-target-x86_64 -//@ignore-target-aarch64 +//@revisions: i686 x86_64 +//@[i686] only-target-i686 +//@[x86_64] only-target-x86_64 #[warn(clippy::inline_asm_x86_intel_syntax)] mod warn_intel { + use std::arch::{asm, global_asm}; + pub(super) unsafe fn use_asm() { - use std::arch::asm; asm!(""); //~^ ERROR: Intel x86 assembly syntax used asm!("", options()); @@ -14,12 +16,19 @@ mod warn_intel { asm!("", options(att_syntax)); asm!("", options(nostack, att_syntax)); } + + global_asm!(""); + //~^ ERROR: Intel x86 assembly syntax used + global_asm!("", options()); + //~^ ERROR: Intel x86 assembly syntax used + global_asm!("", options(att_syntax)); } #[warn(clippy::inline_asm_x86_att_syntax)] mod warn_att { + use std::arch::{asm, global_asm}; + pub(super) unsafe fn use_asm() { - use std::arch::asm; asm!(""); asm!("", options()); asm!("", options(nostack)); @@ -28,9 +37,13 @@ mod warn_att { asm!("", options(nostack, att_syntax)); //~^ ERROR: AT&T x86 assembly syntax used } + + global_asm!(""); + global_asm!("", options()); + global_asm!("", options(att_syntax)); + //~^ ERROR: AT&T x86 assembly syntax used } -#[cfg(target_arch = "x86_64")] fn main() { unsafe { warn_att::use_asm(); diff --git a/tests/ui/asm_syntax_x86.x86_64.stderr b/tests/ui/asm_syntax_x86.x86_64.stderr new file mode 100644 index 0000000000000..dee78f97e68a0 --- /dev/null +++ b/tests/ui/asm_syntax_x86.x86_64.stderr @@ -0,0 +1,73 @@ +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:10:9 + | +LL | asm!(""); + | ^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + = note: `-D clippy::inline-asm-x86-intel-syntax` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]` + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:12:9 + | +LL | asm!("", options()); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:14:9 + | +LL | asm!("", options(nostack)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:20:5 + | +LL | global_asm!(""); + | ^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: Intel x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:22:5 + | +LL | global_asm!("", options()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use AT&T x86 assembly syntax + = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: AT&T x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:35:9 + | +LL | asm!("", options(att_syntax)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use Intel x86 assembly syntax + = note: `-D clippy::inline-asm-x86-att-syntax` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]` + +error: AT&T x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:37:9 + | +LL | asm!("", options(nostack, att_syntax)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use Intel x86 assembly syntax + +error: AT&T x86 assembly syntax used + --> $DIR/asm_syntax_x86.rs:43:5 + | +LL | global_asm!("", options(att_syntax)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use Intel x86 assembly syntax + = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 8 previous errors + From 1ac4d934a8fb0541fb2ae089e7c8d068fe622f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 17 Feb 2024 12:46:18 +0100 Subject: [PATCH 092/417] remove a couple of redundant clones --- clippy_utils/src/diagnostics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_utils/src/diagnostics.rs b/clippy_utils/src/diagnostics.rs index 56978eb2ee805..5199959c0f2b3 100644 --- a/clippy_utils/src/diagnostics.rs +++ b/clippy_utils/src/diagnostics.rs @@ -84,9 +84,9 @@ pub fn span_lint_and_help( cx.span_lint(lint, span, msg.to_string(), |diag| { let help = help.to_string(); if let Some(help_span) = help_span { - diag.span_help(help_span, help.to_string()); + diag.span_help(help_span, help); } else { - diag.help(help.to_string()); + diag.help(help); } docs_link(diag, lint); }); From 1d107ab2be2e6c735c32451e9f27a0275babd954 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sat, 17 Feb 2024 12:16:29 +0000 Subject: [PATCH 093/417] Remove $DIR replacement in test output --- .github/driver.sh | 4 +- tests/compile-test.rs | 1 - .../multiple_config_files/warn/Cargo.stderr | 2 +- .../check_clippy_version_attribute.stderr | 10 +- tests/ui-internal/check_formulation.stderr | 4 +- .../collapsible_span_lint_calls.stderr | 12 +- .../default_deprecation_reason.stderr | 4 +- tests/ui-internal/default_lint.stderr | 4 +- tests/ui-internal/disallow_span_lint.stderr | 4 +- .../interning_defined_symbol.stderr | 10 +- .../ui-internal/invalid_msrv_attr_impl.stderr | 6 +- tests/ui-internal/invalid_paths.stderr | 6 +- .../ui-internal/lint_without_lint_pass.stderr | 4 +- tests/ui-internal/outer_expn_data.stderr | 4 +- tests/ui-internal/unnecessary_def_path.stderr | 32 +-- ...unnecessary_def_path_hardcoded_path.stderr | 6 +- .../ui-internal/unnecessary_symbol_str.stderr | 12 +- .../absolute_paths.allow_crates.stderr | 8 +- .../absolute_paths.disallow_crates.stderr | 22 +- .../uninlined_format_args.stderr | 12 +- .../arithmetic_side_effects_allowed.stderr | 18 +- .../array_size_threshold.stderr | 6 +- .../await_holding_invalid_type.stderr | 6 +- tests/ui-toml/bad_toml/conf_bad_toml.stderr | 2 +- .../bad_toml_type/conf_bad_type.stderr | 2 +- .../conf_deprecated_key.stderr | 6 +- tests/ui-toml/dbg_macro/dbg_macro.stderr | 18 +- .../decimal_literal_representation.stderr | 2 +- .../disallowed_macros.stderr | 32 +-- .../disallowed_names.stderr | 4 +- .../disallowed_names.stderr | 2 +- .../disallowed_script_idents.stderr | 2 +- .../doc_markdown.stderr | 2 +- .../doc_markdown.stderr | 6 +- .../duplicated_keys/duplicated_keys.stderr | 2 +- .../duplicated_keys.stderr | 4 +- .../duplicated_keys.stderr | 4 +- .../enum_variant_size.stderr | 2 +- .../excessive_nesting.stderr | 74 +++--- tests/ui-toml/expect_used/expect_used.stderr | 4 +- .../explicit_iter_loop.stderr | 4 +- .../fn_params_excessive_bools/test.stderr | 2 +- tests/ui-toml/functions_maxlines/test.stderr | 8 +- .../ifs_same_cond/ifs_same_cond.stderr | 4 +- .../impl_trait_in_params.stderr | 2 +- .../invalid_min_rust_version.stderr | 2 +- .../threshold5/item_name_repetitions.stderr | 4 +- .../large_futures/large_futures.stderr | 2 +- .../large_include_file.stderr | 4 +- .../large_stack_frames.stderr | 2 +- .../large_types_passed_by_value.stderr | 2 +- .../lint_decimal_readability/test.stderr | 4 +- .../manual_let_else/manual_let_else.stderr | 2 +- .../index_refutable_slice.stderr | 4 +- .../min_ident_chars/min_ident_chars.stderr | 16 +- .../min_rust_version/min_rust_version.stderr | 2 +- ...conf_missing_enforced_import_rename.stderr | 12 +- .../module_inception/module_inception.stderr | 4 +- .../modulo_arithmetic.stderr | 8 +- .../conf_nonstandard_macro_braces.stderr | 16 +- tests/ui-toml/print_macro/print_macro.stderr | 4 +- .../private-doc-errors/doc_lints.stderr | 20 +- .../pub_crate_missing_doc.stderr | 14 +- ...ub_underscore_fields.all_pub_fields.stderr | 14 +- .../pub_underscore_fields.exported.stderr | 2 +- .../result_large_err/result_large_err.stderr | 2 +- tests/ui-toml/semicolon_block/both.stderr | 8 +- .../semicolon_inside_block.stderr | 2 +- .../semicolon_outside_block.stderr | 6 +- .../test.stderr | 28 +-- .../struct_excessive_bools/test.stderr | 2 +- .../suppress_lint_in_const/test.stderr | 18 +- .../conf_french_disallowed_name.stderr | 14 +- .../conf_disallowed_methods.stderr | 28 +-- .../conf_disallowed_types.stderr | 42 ++-- tests/ui-toml/toml_trivially_copy/test.stderr | 4 +- .../toml_unknown_key/conf_unknown_key.stderr | 6 +- .../too_large_for_stack/boxed_local.stderr | 2 +- .../too_large_for_stack/useless_vec.stderr | 2 +- .../too_many_arguments.stderr | 2 +- .../type_complexity/type_complexity.stderr | 2 +- .../type_repetition_in_bounds/main.stderr | 2 +- .../undocumented_unsafe_blocks.default.stderr | 74 +++--- ...undocumented_unsafe_blocks.disabled.stderr | 94 +++---- .../unnecessary_box_returns.stderr | 2 +- tests/ui-toml/unwrap_used/unwrap_used.stderr | 56 ++--- .../upper_case_acronyms.stderr | 26 +- tests/ui-toml/vec_box_sized/test.stderr | 6 +- .../verbose_bit_mask/verbose_bit_mask.stderr | 2 +- .../wildcard_imports/wildcard_imports.stderr | 6 +- .../wildcard_imports.stderr | 2 +- tests/ui/absurd-extreme-comparisons.stderr | 36 +-- tests/ui/allow_attributes.stderr | 4 +- .../ui/allow_attributes_without_reason.stderr | 10 +- tests/ui/almost_complete_range.stderr | 54 ++-- tests/ui/approx_const.stderr | 46 ++-- tests/ui/arc_with_non_send_sync.stderr | 6 +- tests/ui/arithmetic_side_effects.stderr | 238 +++++++++--------- tests/ui/as_conversions.stderr | 6 +- tests/ui/as_ptr_cast_mut.stderr | 4 +- tests/ui/as_underscore.stderr | 4 +- tests/ui/asm_syntax_x86.i686.stderr | 16 +- tests/ui/asm_syntax_x86.x86_64.stderr | 16 +- tests/ui/assertions_on_constants.stderr | 20 +- tests/ui/assertions_on_result_states.stderr | 14 +- tests/ui/assign_ops.stderr | 22 +- tests/ui/assign_ops2.stderr | 20 +- tests/ui/async_yields_async.stderr | 12 +- tests/ui/attrs.stderr | 6 +- tests/ui/await_holding_lock.stderr | 52 ++-- tests/ui/await_holding_refcell_ref.stderr | 24 +- tests/ui/bind_instead_of_map.stderr | 8 +- tests/ui/bind_instead_of_map_multipart.stderr | 12 +- tests/ui/bit_masks.stderr | 34 +-- .../blanket_clippy_restriction_lints.stderr | 6 +- tests/ui/blocks_in_conditions.stderr | 8 +- tests/ui/blocks_in_conditions_closure.stderr | 6 +- tests/ui/bool_assert_comparison.stderr | 66 ++--- tests/ui/bool_comparison.stderr | 50 ++-- tests/ui/bool_to_int_with_if.stderr | 18 +- tests/ui/borrow_as_ptr.stderr | 4 +- tests/ui/borrow_as_ptr_no_std.stderr | 4 +- tests/ui/borrow_box.stderr | 22 +- tests/ui/borrow_deref_ref.stderr | 6 +- tests/ui/borrow_deref_ref_unfixable.stderr | 2 +- .../enums.stderr | 20 +- .../others.stderr | 30 +-- .../traits.stderr | 32 +-- tests/ui/box_collection.stderr | 18 +- tests/ui/box_default.stderr | 32 +-- tests/ui/boxed_local.stderr | 8 +- .../shared_at_bottom.stderr | 20 +- .../shared_at_top.stderr | 20 +- .../shared_at_top_and_bottom.stderr | 22 +- .../valid_if_blocks.stderr | 22 +- tests/ui/builtin_type_shadow.stderr | 4 +- tests/ui/bytecount.stderr | 8 +- tests/ui/bytes_count_to_len.stderr | 8 +- tests/ui/bytes_nth.stderr | 6 +- ...ensitive_file_extension_comparisons.stderr | 12 +- tests/ui/cast.stderr | 126 +++++----- tests/ui/cast_abs_to_unsigned.stderr | 36 +-- tests/ui/cast_alignment.stderr | 8 +- tests/ui/cast_enum_constructor.stderr | 4 +- tests/ui/cast_lossless_bool.stderr | 28 +-- tests/ui/cast_lossless_float.stderr | 22 +- tests/ui/cast_lossless_integer.stderr | 42 ++-- tests/ui/cast_nan_to_int.stderr | 12 +- tests/ui/cast_raw_slice_pointer_cast.stderr | 14 +- tests/ui/cast_size.32bit.stderr | 38 +-- tests/ui/cast_size.64bit.stderr | 36 +-- tests/ui/cast_slice_different_sizes.stderr | 28 +-- tests/ui/cfg_attr_cargo_clippy.stderr | 14 +- tests/ui/cfg_attr_rustfmt.stderr | 6 +- tests/ui/cfg_features.stderr | 16 +- tests/ui/char_lit_as_u8.stderr | 2 +- tests/ui/char_lit_as_u8_suggestions.stderr | 8 +- tests/ui/checked_conversions.stderr | 34 +-- .../complex_conditionals.stderr | 44 ++-- .../complex_conditionals_nested.stderr | 8 +- .../checked_unwrap/simple_conditionals.stderr | 54 ++-- tests/ui/clear_with_drain.stderr | 42 ++-- tests/ui/clone_on_copy.stderr | 18 +- tests/ui/cloned_instead_of_copied.stderr | 16 +- tests/ui/cmp_null.stderr | 4 +- .../ui/cmp_owned/asymmetric_partial_eq.stderr | 12 +- tests/ui/cmp_owned/comparison_flip.stderr | 4 +- tests/ui/cmp_owned/with_suggestion.stderr | 12 +- tests/ui/cmp_owned/without_suggestion.stderr | 6 +- tests/ui/cognitive_complexity.stderr | 40 +-- .../ui/cognitive_complexity_attr_used.stderr | 2 +- tests/ui/collapsible_else_if.stderr | 16 +- tests/ui/collapsible_if.stderr | 18 +- tests/ui/collapsible_match.stderr | 48 ++-- tests/ui/collapsible_match2.stderr | 20 +- tests/ui/collapsible_str_replace.stderr | 28 +-- tests/ui/collection_is_never_read.stderr | 40 +-- tests/ui/comparison_chain.stderr | 14 +- tests/ui/comparison_to_empty.stderr | 18 +- tests/ui/const_comparisons.stderr | 62 ++--- tests/ui/copy_iterator.stderr | 2 +- tests/ui/crashes/ice-10148.stderr | 2 +- tests/ui/crashes/ice-10645.stderr | 4 +- tests/ui/crashes/ice-10912.stderr | 4 +- tests/ui/crashes/ice-11422.stderr | 2 +- tests/ui/crashes/ice-11803.stderr | 4 +- tests/ui/crashes/ice-2774.stderr | 2 +- tests/ui/crashes/ice-360.stderr | 6 +- tests/ui/crashes/ice-3717.stderr | 4 +- tests/ui/crashes/ice-3891.stderr | 2 +- tests/ui/crashes/ice-3969.stderr | 10 +- tests/ui/crashes/ice-5497.stderr | 2 +- tests/ui/crashes/ice-5835.stderr | 2 +- tests/ui/crashes/ice-5872.stderr | 2 +- tests/ui/crashes/ice-6250.stderr | 4 +- tests/ui/crashes/ice-6251.stderr | 8 +- tests/ui/crashes/ice-6252.stderr | 6 +- tests/ui/crashes/ice-6255.stderr | 2 +- tests/ui/crashes/ice-6256.stderr | 2 +- tests/ui/crashes/ice-7169.stderr | 2 +- tests/ui/crashes/ice-7868.stderr | 2 +- tests/ui/crashes/ice-7869.stderr | 2 +- tests/ui/crashes/ice-8250.stderr | 2 +- tests/ui/crashes/ice-8850.stderr | 6 +- tests/ui/crashes/ice-9041.stderr | 2 +- tests/ui/crashes/ice-9405.stderr | 2 +- tests/ui/crashes/ice-9445.stderr | 2 +- tests/ui/crashes/ice-9463.stderr | 8 +- tests/ui/crashes/ice-96721.stderr | 2 +- .../needless_lifetimes_impl_trait.stderr | 4 +- ...needless_pass_by_value-w-late-bound.stderr | 4 +- tests/ui/crate_in_macro_def.stderr | 2 +- .../ui/crate_level_checks/no_std_swap.stderr | 2 +- .../std_main_recursion.stderr | 2 +- tests/ui/create_dir.stderr | 4 +- tests/ui/dbg_macro/dbg_macro.stderr | 38 +-- tests/ui/debug_assert_with_mut_call.stderr | 56 ++--- .../ui/decimal_literal_representation.stderr | 14 +- .../enums.stderr | 24 +- .../others.stderr | 10 +- .../traits.stderr | 22 +- tests/ui/def_id_nocore.stderr | 2 +- .../default_constructed_unit_structs.stderr | 12 +- tests/ui/default_instead_of_iter_empty.stderr | 6 +- ...efault_instead_of_iter_empty_no_std.stderr | 4 +- tests/ui/default_numeric_fallback_f64.stderr | 46 ++-- tests/ui/default_numeric_fallback_i32.stderr | 56 ++--- tests/ui/default_trait_access.stderr | 18 +- tests/ui/default_union_representation.stderr | 8 +- tests/ui/deprecated.stderr | 32 +-- tests/ui/deprecated_old.stderr | 6 +- tests/ui/deref_addrof.stderr | 20 +- tests/ui/deref_addrof_double_trigger.stderr | 6 +- tests/ui/deref_by_slicing.stderr | 18 +- tests/ui/derivable_impls.stderr | 16 +- tests/ui/derive.stderr | 20 +- tests/ui/derive_ord_xor_partial_ord.stderr | 16 +- tests/ui/derive_partial_eq_without_eq.stderr | 22 +- tests/ui/derived_hash_with_manual_eq.stderr | 8 +- tests/ui/disallowed_names.stderr | 28 +-- tests/ui/disallowed_script_idents.stderr | 6 +- tests/ui/diverging_sub_expression.stderr | 22 +- tests/ui/doc/doc-fixable.stderr | 62 ++--- tests/ui/doc/unbalanced_ticks.stderr | 16 +- tests/ui/doc_errors.stderr | 14 +- tests/ui/doc_link_with_quotes.stderr | 4 +- tests/ui/doc_unsafe.stderr | 12 +- tests/ui/double_comparison.stderr | 16 +- tests/ui/double_must_use.stderr | 8 +- tests/ui/double_neg.stderr | 2 +- tests/ui/double_parens.stderr | 12 +- tests/ui/drain_collect.stderr | 22 +- tests/ui/drop_non_drop.stderr | 8 +- tests/ui/duplicate_underscore_argument.stderr | 2 +- tests/ui/duration_subsec.stderr | 10 +- tests/ui/eager_transmute.stderr | 34 +-- tests/ui/else_if_without_else.stderr | 4 +- tests/ui/empty_drop.stderr | 4 +- tests/ui/empty_enum.stderr | 2 +- .../empty_enum_variants_with_brackets.stderr | 8 +- tests/ui/empty_line_after_doc_comments.stderr | 6 +- .../empty_line_after_outer_attribute.stderr | 12 +- tests/ui/empty_loop.stderr | 6 +- tests/ui/empty_loop_no_std.stderr | 4 +- tests/ui/empty_structs_with_brackets.stderr | 4 +- tests/ui/endian_bytes.stderr | 172 ++++++------- tests/ui/entry.stderr | 20 +- tests/ui/entry_btree.stderr | 2 +- tests/ui/entry_with_else.stderr | 14 +- tests/ui/enum_clike_unportable_variant.stderr | 18 +- tests/ui/enum_glob_use.stderr | 6 +- tests/ui/enum_variants.stderr | 32 +-- tests/ui/eprint_with_newline.stderr | 18 +- tests/ui/eq_op.stderr | 58 ++--- tests/ui/eq_op_macros.stderr | 24 +- tests/ui/equatable_if_let.stderr | 28 +-- tests/ui/erasing_op.stderr | 10 +- tests/ui/err_expect.stderr | 4 +- tests/ui/error_impl_error.stderr | 14 +- tests/ui/eta.stderr | 62 ++--- tests/ui/excessive_precision.stderr | 30 +-- tests/ui/exhaustive_items.stderr | 10 +- tests/ui/exit1.stderr | 2 +- tests/ui/exit2.stderr | 2 +- tests/ui/expect.stderr | 6 +- tests/ui/expect_fun_call.stderr | 30 +-- tests/ui/expect_tool_lint_rfc_2383.stderr | 12 +- tests/ui/explicit_auto_deref.stderr | 90 +++---- tests/ui/explicit_counter_loop.stderr | 18 +- tests/ui/explicit_deref_methods.stderr | 24 +- tests/ui/explicit_into_iter_loop.stderr | 12 +- tests/ui/explicit_iter_loop.stderr | 38 +-- tests/ui/explicit_write.stderr | 26 +- tests/ui/extend_with_drain.stderr | 8 +- tests/ui/extra_unused_lifetimes.stderr | 12 +- tests/ui/extra_unused_type_parameters.stderr | 16 +- ...ra_unused_type_parameters_unfixable.stderr | 6 +- tests/ui/fallible_impl_from.stderr | 18 +- tests/ui/field_reassign_with_default.stderr | 44 ++-- tests/ui/filetype_is_file.stderr | 6 +- tests/ui/filter_map_bool_then.stderr | 20 +- tests/ui/filter_map_identity.stderr | 8 +- tests/ui/filter_map_next.stderr | 2 +- tests/ui/filter_map_next_fixable.stderr | 4 +- tests/ui/flat_map_identity.stderr | 6 +- tests/ui/flat_map_option.stderr | 4 +- tests/ui/float_arithmetic.stderr | 34 +-- tests/ui/float_cmp.stderr | 12 +- tests/ui/float_cmp_const.stderr | 16 +- tests/ui/float_equality_without_abs.stderr | 22 +- tests/ui/floating_point_abs.stderr | 16 +- tests/ui/floating_point_exp.stderr | 10 +- tests/ui/floating_point_hypot.stderr | 6 +- tests/ui/floating_point_log.stderr | 58 ++--- tests/ui/floating_point_logbase.stderr | 10 +- tests/ui/floating_point_mul_add.stderr | 26 +- tests/ui/floating_point_powf.stderr | 62 ++--- tests/ui/floating_point_powi.stderr | 28 +-- tests/ui/floating_point_rad.stderr | 16 +- tests/ui/fn_address_comparisons.stderr | 4 +- tests/ui/fn_params_excessive_bools.stderr | 14 +- tests/ui/fn_to_numeric_cast.32bit.stderr | 46 ++-- tests/ui/fn_to_numeric_cast.64bit.stderr | 46 ++-- tests/ui/fn_to_numeric_cast_any.stderr | 34 +-- tests/ui/for_kv_map.stderr | 10 +- tests/ui/forget_non_drop.stderr | 8 +- tests/ui/format.stderr | 30 +-- tests/ui/format_args.stderr | 50 ++-- tests/ui/format_args_unfixable.stderr | 36 +-- tests/ui/format_collect.stderr | 18 +- tests/ui/format_push_string.stderr | 10 +- tests/ui/formatting.stderr | 12 +- tests/ui/four_forward_slashes.stderr | 10 +- .../ui/four_forward_slashes_first_line.stderr | 2 +- tests/ui/from_iter_instead_of_collect.stderr | 30 +-- tests/ui/from_over_into.stderr | 14 +- tests/ui/from_over_into_unfixable.stderr | 8 +- tests/ui/from_raw_with_void_ptr.stderr | 20 +- tests/ui/from_str_radix_10.stderr | 16 +- tests/ui/functions.stderr | 32 +-- tests/ui/functions_maxlines.stderr | 2 +- tests/ui/future_not_send.stderr | 36 +-- tests/ui/get_first.stderr | 10 +- tests/ui/get_last_with_len.stderr | 12 +- tests/ui/get_unwrap.stderr | 62 ++--- tests/ui/identity_op.stderr | 104 ++++---- tests/ui/if_let_mutex.stderr | 6 +- tests/ui/if_not_else.stderr | 4 +- tests/ui/if_same_then_else.stderr | 24 +- tests/ui/if_same_then_else2.stderr | 24 +- tests/ui/if_then_some_else_none.stderr | 10 +- tests/ui/ifs_same_cond.stderr | 16 +- tests/ui/ignored_unit_patterns.stderr | 18 +- tests/ui/impl.stderr | 16 +- ...impl_hash_with_borrow_str_and_bytes.stderr | 6 +- tests/ui/impl_trait_in_params.stderr | 8 +- tests/ui/implicit_clone.stderr | 22 +- tests/ui/implicit_hasher.stderr | 12 +- tests/ui/implicit_return.stderr | 32 +-- tests/ui/implicit_saturating_add.stderr | 48 ++-- tests/ui/implicit_saturating_sub.stderr | 46 ++-- tests/ui/implied_bounds_in_impls.stderr | 38 +-- tests/ui/incompatible_msrv.stderr | 6 +- tests/ui/inconsistent_digit_grouping.stderr | 22 +- .../ui/inconsistent_struct_constructor.stderr | 4 +- .../if_let_slice_binding.stderr | 22 +- .../slice_indexing_in_macro.stderr | 4 +- tests/ui/indexing_slicing_index.stderr | 36 +-- tests/ui/indexing_slicing_slice.stderr | 32 +-- tests/ui/ineffective_open_options.stderr | 4 +- tests/ui/inefficient_to_string.stderr | 14 +- .../ui/infallible_destructuring_match.stderr | 8 +- tests/ui/infinite_iter.stderr | 32 +-- tests/ui/infinite_loop.stderr | 22 +- tests/ui/infinite_loops.stderr | 34 +-- tests/ui/inherent_to_string.stderr | 4 +- tests/ui/inline_fn_without_body.stderr | 6 +- tests/ui/inspect_for_each.stderr | 2 +- tests/ui/int_plus_one.stderr | 8 +- tests/ui/integer_division.stderr | 6 +- tests/ui/into_iter_on_ref.stderr | 54 ++-- tests/ui/into_iter_without_iter.stderr | 12 +- tests/ui/invalid_null_ptr_usage.stderr | 50 ++-- tests/ui/invalid_upcast_comparisons.stderr | 54 ++-- tests/ui/is_digit_ascii_radix.stderr | 6 +- tests/ui/issue-3145.stderr | 2 +- tests/ui/issue-7447.stderr | 4 +- tests/ui/issue_2356.stderr | 4 +- tests/ui/issue_4266.stderr | 6 +- tests/ui/items_after_statement.stderr | 6 +- .../in_submodule.stderr | 2 +- .../root_module.stderr | 2 +- tests/ui/iter_cloned_collect.stderr | 10 +- tests/ui/iter_count.stderr | 50 ++-- tests/ui/iter_filter_is_ok.stderr | 24 +- tests/ui/iter_filter_is_some.stderr | 20 +- tests/ui/iter_kv_map.stderr | 76 +++--- tests/ui/iter_next_loop.stderr | 2 +- tests/ui/iter_next_slice.stderr | 8 +- tests/ui/iter_not_returning_iterator.stderr | 6 +- tests/ui/iter_nth.stderr | 14 +- tests/ui/iter_nth_zero.stderr | 6 +- tests/ui/iter_on_empty_collections.stderr | 12 +- tests/ui/iter_on_single_items.stderr | 12 +- tests/ui/iter_out_of_bounds.stderr | 30 +-- tests/ui/iter_over_hash_type.stderr | 26 +- tests/ui/iter_overeager_cloned.stderr | 38 +-- tests/ui/iter_skip_next.stderr | 14 +- tests/ui/iter_skip_next_unfixable.stderr | 12 +- tests/ui/iter_skip_zero.stderr | 10 +- tests/ui/iter_with_drain.stderr | 12 +- tests/ui/iter_without_into_iter.stderr | 16 +- tests/ui/iterator_step_by_zero.stderr | 14 +- tests/ui/join_absolute_paths.stderr | 8 +- tests/ui/large_const_arrays.stderr | 18 +- tests/ui/large_digit_groups.stderr | 10 +- tests/ui/large_enum_variant.32bit.stderr | 44 ++-- tests/ui/large_enum_variant.64bit.stderr | 44 ++-- tests/ui/large_futures.stderr | 16 +- tests/ui/large_stack_arrays.stderr | 14 +- tests/ui/large_stack_frames.stderr | 6 +- tests/ui/large_types_passed_by_value.stderr | 16 +- tests/ui/len_without_is_empty.stderr | 42 ++-- tests/ui/len_zero.stderr | 46 ++-- tests/ui/len_zero_ranges.stderr | 4 +- tests/ui/let_and_return.stderr | 10 +- tests/ui/let_if_seq.stderr | 8 +- tests/ui/let_underscore_future.stderr | 6 +- tests/ui/let_underscore_lock.stderr | 8 +- tests/ui/let_underscore_must_use.stderr | 24 +- tests/ui/let_underscore_untyped.stderr | 20 +- tests/ui/let_unit.stderr | 6 +- tests/ui/let_with_type_underscore.stderr | 20 +- tests/ui/lines_filter_map_ok.stderr | 24 +- tests/ui/linkedlist.stderr | 18 +- tests/ui/literals.stderr | 40 +-- tests/ui/lossy_float_literal.stderr | 22 +- tests/ui/macro_use_imports.stderr | 8 +- tests/ui/manual_assert.edition2018.stderr | 18 +- tests/ui/manual_assert.edition2021.stderr | 18 +- tests/ui/manual_async_fn.stderr | 26 +- tests/ui/manual_bits.stderr | 58 ++--- tests/ui/manual_c_str_literals.stderr | 26 +- tests/ui/manual_clamp.stderr | 70 +++--- tests/ui/manual_filter.stderr | 30 +-- tests/ui/manual_filter_map.stderr | 76 +++--- tests/ui/manual_find.stderr | 4 +- tests/ui/manual_find_fixable.stderr | 24 +- tests/ui/manual_find_map.stderr | 78 +++--- tests/ui/manual_flatten.stderr | 36 +-- tests/ui/manual_float_methods.stderr | 12 +- tests/ui/manual_hash_one.stderr | 8 +- tests/ui/manual_instant_elapsed.stderr | 4 +- tests/ui/manual_is_ascii_check.stderr | 44 ++-- tests/ui/manual_is_variant_and.stderr | 16 +- tests/ui/manual_let_else.stderr | 60 ++--- tests/ui/manual_let_else_match.stderr | 20 +- tests/ui/manual_let_else_question_mark.stderr | 14 +- tests/ui/manual_main_separator_str.stderr | 8 +- tests/ui/manual_map_option.stderr | 42 ++-- tests/ui/manual_map_option_2.stderr | 10 +- .../manual_memcpy/with_loop_counters.stderr | 22 +- .../without_loop_counters.stderr | 32 +-- tests/ui/manual_next_back.stderr | 4 +- tests/ui/manual_non_exhaustive_enum.stderr | 8 +- tests/ui/manual_non_exhaustive_struct.stderr | 20 +- tests/ui/manual_ok_or.stderr | 10 +- tests/ui/manual_range_patterns.stderr | 38 +-- tests/ui/manual_rem_euclid.stderr | 20 +- tests/ui/manual_retain.stderr | 76 +++--- tests/ui/manual_saturating_arithmetic.stderr | 48 ++-- tests/ui/manual_slice_size_calculation.stderr | 14 +- tests/ui/manual_split_once.stderr | 38 +-- tests/ui/manual_str_repeat.stderr | 20 +- tests/ui/manual_string_new.stderr | 18 +- tests/ui/manual_strip.stderr | 32 +-- tests/ui/manual_try_fold.stderr | 8 +- tests/ui/manual_unwrap_or.stderr | 28 +-- tests/ui/manual_while_let_some.stderr | 14 +- tests/ui/many_single_char_names.stderr | 10 +- tests/ui/map_clone.stderr | 30 +-- tests/ui/map_collect_result_unit.stderr | 4 +- tests/ui/map_err.stderr | 2 +- tests/ui/map_flatten.stderr | 8 +- tests/ui/map_flatten_fixable.stderr | 18 +- tests/ui/map_identity.stderr | 22 +- tests/ui/map_unwrap_or.stderr | 30 +-- tests/ui/map_unwrap_or_fixable.stderr | 4 +- tests/ui/match_as_ref.stderr | 6 +- tests/ui/match_bool.stderr | 18 +- tests/ui/match_expr_like_matches_macro.stderr | 28 +-- tests/ui/match_on_vec_items.stderr | 16 +- tests/ui/match_overlapping_arm.stderr | 32 +-- tests/ui/match_ref_pats.stderr | 10 +- tests/ui/match_result_ok.stderr | 6 +- tests/ui/match_same_arms.stderr | 32 +-- tests/ui/match_same_arms2.stderr | 50 ++-- .../ui/match_same_arms_non_exhaustive.stderr | 8 +- tests/ui/match_single_binding.stderr | 48 ++-- tests/ui/match_single_binding2.stderr | 8 +- tests/ui/match_str_case_mismatch.stderr | 14 +- tests/ui/match_wild_err_arm.stderr | 8 +- .../match_wildcard_for_single_variants.stderr | 20 +- tests/ui/mem_forget.stderr | 8 +- tests/ui/mem_replace.stderr | 48 ++-- tests/ui/mem_replace_macro.stderr | 2 +- tests/ui/mem_replace_no_std.stderr | 14 +- tests/ui/methods.stderr | 4 +- tests/ui/methods_fixable.stderr | 2 +- tests/ui/methods_unfixable.stderr | 4 +- tests/ui/min_ident_chars.stderr | 64 ++--- tests/ui/min_max.stderr | 26 +- tests/ui/min_rust_version_attr.stderr | 12 +- tests/ui/min_rust_version_invalid_attr.stderr | 12 +- tests/ui/mismatched_target_os_non_unix.stderr | 8 +- tests/ui/mismatched_target_os_unix.stderr | 34 +-- tests/ui/mismatching_type_param_order.stderr | 20 +- tests/ui/misnamed_getters.stderr | 36 +-- tests/ui/missing_assert_message.stderr | 32 +-- tests/ui/missing_asserts_for_indexing.stderr | 94 +++---- ...sing_asserts_for_indexing_unfixable.stderr | 56 ++--- .../could_be_const.stderr | 22 +- tests/ui/missing_doc.stderr | 26 +- tests/ui/missing_doc_crate_missing.stderr | 2 +- tests/ui/missing_doc_impl.stderr | 14 +- tests/ui/missing_fields_in_debug.stderr | 16 +- tests/ui/missing_inline.stderr | 12 +- tests/ui/missing_panics_doc.stderr | 48 ++-- tests/ui/missing_spin_loop.stderr | 12 +- tests/ui/missing_spin_loop_no_std.stderr | 2 +- tests/ui/missing_trait_methods.stderr | 8 +- tests/ui/mistyped_literal_suffix.stderr | 32 +-- .../ui/mixed_read_write_in_expression.stderr | 16 +- tests/ui/module_inception.stderr | 8 +- tests/ui/module_name_repetitions.stderr | 10 +- tests/ui/modulo_arithmetic_float.stderr | 20 +- tests/ui/modulo_arithmetic_integral.stderr | 34 +-- .../modulo_arithmetic_integral_const.stderr | 34 +-- tests/ui/modulo_one.stderr | 16 +- tests/ui/multi_assignments.stderr | 12 +- tests/ui/multiple_unsafe_ops_per_block.stderr | 58 ++--- tests/ui/must_use_candidates.stderr | 10 +- tests/ui/must_use_unit.stderr | 6 +- tests/ui/mut_from_ref.stderr | 24 +- tests/ui/mut_key.stderr | 34 +-- tests/ui/mut_mut.stderr | 18 +- tests/ui/mut_mutex_lock.stderr | 2 +- tests/ui/mut_range_bound.stderr | 14 +- tests/ui/mut_reference.stderr | 6 +- tests/ui/mutex_atomic.stderr | 22 +- tests/ui/needless_arbitrary_self_type.stderr | 12 +- ...dless_arbitrary_self_type_unfixable.stderr | 2 +- tests/ui/needless_bitwise_bool.stderr | 2 +- tests/ui/needless_bool/fixable.stderr | 42 ++-- tests/ui/needless_bool/simple.stderr | 8 +- tests/ui/needless_bool_assign.stderr | 10 +- tests/ui/needless_borrow.stderr | 54 ++-- tests/ui/needless_borrow_pat.stderr | 24 +- tests/ui/needless_borrowed_ref.stderr | 34 +-- .../needless_borrows_for_generic_args.stderr | 24 +- tests/ui/needless_collect.stderr | 38 +-- tests/ui/needless_collect_indirect.stderr | 32 +-- tests/ui/needless_continue.stderr | 16 +- tests/ui/needless_doc_main.stderr | 8 +- tests/ui/needless_else.stderr | 2 +- tests/ui/needless_for_each_fixable.stderr | 16 +- tests/ui/needless_for_each_unfixable.stderr | 2 +- tests/ui/needless_if.stderr | 14 +- tests/ui/needless_late_init.stderr | 32 +-- tests/ui/needless_lifetimes.stderr | 92 +++---- tests/ui/needless_match.stderr | 26 +- tests/ui/needless_option_as_deref.stderr | 6 +- tests/ui/needless_option_take.stderr | 2 +- .../needless_parens_on_range_literals.stderr | 12 +- tests/ui/needless_pass_by_ref_mut.stderr | 62 ++--- tests/ui/needless_pass_by_value.stderr | 52 ++-- tests/ui/needless_pub_self.stderr | 6 +- tests/ui/needless_question_mark.stderr | 30 +-- tests/ui/needless_range_loop.stderr | 28 +-- tests/ui/needless_range_loop2.stderr | 16 +- tests/ui/needless_raw_string.stderr | 14 +- tests/ui/needless_raw_string_hashes.stderr | 30 +-- tests/ui/needless_return.stderr | 104 ++++---- .../needless_return_with_question_mark.stderr | 4 +- tests/ui/needless_splitn.stderr | 26 +- tests/ui/needless_update.stderr | 2 +- tests/ui/neg_cmp_op_on_partial_ord.stderr | 8 +- tests/ui/neg_multiply.stderr | 16 +- tests/ui/never_loop.stderr | 32 +-- tests/ui/new_ret_no_self.stderr | 24 +- tests/ui/new_ret_no_self_overflow.stderr | 2 +- tests/ui/new_without_default.stderr | 18 +- tests/ui/no_effect.stderr | 58 ++--- tests/ui/no_effect_replace.stderr | 16 +- tests/ui/no_effect_return.stderr | 18 +- tests/ui/no_mangle_with_rust_abi.stderr | 10 +- tests/ui/non_canonical_clone_impl.stderr | 8 +- .../ui/non_canonical_partial_ord_impl.stderr | 4 +- ...nonical_partial_ord_impl_fully_qual.stderr | 4 +- tests/ui/non_expressive_names.stderr | 12 +- tests/ui/non_minimal_cfg.stderr | 8 +- tests/ui/non_minimal_cfg2.stderr | 2 +- tests/ui/non_octal_unix_permissions.stderr | 8 +- tests/ui/non_send_fields_in_send_ty.stderr | 52 ++-- tests/ui/nonminimal_bool.stderr | 58 ++--- tests/ui/nonminimal_bool_methods.stderr | 26 +- tests/ui/numbered_fields.stderr | 4 +- tests/ui/obfuscated_if_else.stderr | 2 +- tests/ui/octal_escapes.stderr | 18 +- tests/ui/ok_expect.stderr | 10 +- tests/ui/only_used_in_recursion.stderr | 64 ++--- tests/ui/only_used_in_recursion2.stderr | 20 +- tests/ui/op_ref.stderr | 8 +- tests/ui/open_options.stderr | 16 +- tests/ui/open_options_fixable.stderr | 2 +- tests/ui/option_as_ref_cloned.stderr | 6 +- tests/ui/option_as_ref_deref.stderr | 36 +-- tests/ui/option_env_unwrap.stderr | 14 +- tests/ui/option_filter_map.stderr | 16 +- tests/ui/option_if_let_else.stderr | 50 ++-- tests/ui/option_map_or_err_ok.stderr | 2 +- tests/ui/option_map_or_none.stderr | 10 +- tests/ui/option_map_unit_fn_fixable.stderr | 38 +-- tests/ui/option_map_unit_fn_unfixable.stderr | 8 +- tests/ui/option_option.stderr | 26 +- tests/ui/or_fun_call.stderr | 62 ++--- tests/ui/or_then_unwrap.stderr | 6 +- .../out_of_bounds_indexing/issue-3102.stderr | 4 +- tests/ui/out_of_bounds_indexing/simple.stderr | 12 +- tests/ui/overflow_check_conditional.stderr | 16 +- tests/ui/overly_complex_bool_expr.stderr | 20 +- tests/ui/panic_in_result_fn.stderr | 8 +- tests/ui/panic_in_result_fn_assertions.stderr | 12 +- tests/ui/panicking_macros.stderr | 32 +-- tests/ui/partial_pub_fields.stderr | 8 +- tests/ui/partialeq_ne_impl.stderr | 2 +- tests/ui/partialeq_to_none.stderr | 30 +-- tests/ui/path_buf_push_overwrite.stderr | 2 +- tests/ui/path_ends_with_ext.stderr | 4 +- .../pattern_type_mismatch/mutability.stderr | 4 +- .../pattern_alternatives.stderr | 6 +- .../pattern_structs.stderr | 16 +- .../pattern_tuples.stderr | 20 +- tests/ui/pattern_type_mismatch/syntax.stderr | 18 +- tests/ui/patterns.stderr | 6 +- .../ui/permissions_set_readonly_false.stderr | 2 +- tests/ui/precedence.stderr | 24 +- tests/ui/print.stderr | 16 +- tests/ui/print_in_format_impl.stderr | 14 +- tests/ui/print_literal.stderr | 32 +-- tests/ui/print_stderr.stderr | 4 +- tests/ui/print_with_newline.stderr | 18 +- tests/ui/println_empty_string.stderr | 8 +- tests/ui/proc_macro.stderr | 2 +- tests/ui/ptr_arg.stderr | 48 ++-- tests/ui/ptr_as_ptr.stderr | 66 ++--- tests/ui/ptr_cast_constness.stderr | 14 +- tests/ui/ptr_eq.stderr | 4 +- tests/ui/ptr_eq_no_std.stderr | 4 +- tests/ui/ptr_offset_with_cast.stderr | 4 +- tests/ui/pub_use.stderr | 2 +- tests/ui/pub_with_shorthand.stderr | 8 +- tests/ui/pub_without_shorthand.stderr | 6 +- tests/ui/question_mark.stderr | 32 +-- tests/ui/question_mark_used.stderr | 2 +- tests/ui/range.stderr | 2 +- tests/ui/range_contains.stderr | 42 ++-- tests/ui/range_plus_minus_one.stderr | 18 +- tests/ui/rc_buffer.stderr | 16 +- tests/ui/rc_buffer_arc.stderr | 16 +- tests/ui/rc_clone_in_vec_init/arc.stderr | 8 +- tests/ui/rc_clone_in_vec_init/rc.stderr | 8 +- tests/ui/rc_clone_in_vec_init/weak.stderr | 16 +- tests/ui/rc_mutex.stderr | 8 +- tests/ui/read_line_without_trim.stderr | 20 +- tests/ui/read_zero_byte_vec.stderr | 22 +- tests/ui/readonly_write_lock.stderr | 4 +- tests/ui/recursive_format_impl.stderr | 20 +- tests/ui/redundant_allocation.stderr | 40 +-- tests/ui/redundant_allocation_fixable.stderr | 24 +- tests/ui/redundant_as_str.stderr | 4 +- tests/ui/redundant_async_block.stderr | 20 +- tests/ui/redundant_at_rest_pattern.stderr | 12 +- tests/ui/redundant_clone.stderr | 60 ++--- tests/ui/redundant_closure_call_early.stderr | 4 +- .../ui/redundant_closure_call_fixable.stderr | 34 +-- tests/ui/redundant_closure_call_late.stderr | 6 +- tests/ui/redundant_else.stderr | 14 +- tests/ui/redundant_field_names.stderr | 16 +- tests/ui/redundant_guards.stderr | 52 ++-- tests/ui/redundant_locals.stderr | 56 ++--- ...dundant_pattern_matching_drop_order.stderr | 44 ++-- ...undant_pattern_matching_if_let_true.stderr | 14 +- .../redundant_pattern_matching_ipaddr.stderr | 40 +-- .../redundant_pattern_matching_option.stderr | 60 ++--- .../ui/redundant_pattern_matching_poll.stderr | 40 +-- .../redundant_pattern_matching_result.stderr | 56 ++--- tests/ui/redundant_pub_crate.stderr | 32 +-- tests/ui/redundant_slicing.stderr | 6 +- tests/ui/redundant_static_lifetimes.stderr | 36 +-- ...redundant_static_lifetimes_multiple.stderr | 20 +- tests/ui/redundant_type_annotations.stderr | 34 +-- tests/ui/ref_as_ptr.stderr | 88 +++---- tests/ui/ref_binding_to_reference.stderr | 14 +- tests/ui/ref_option_ref.stderr | 22 +- tests/ui/ref_patterns.stderr | 6 +- tests/ui/regex.stderr | 48 ++-- tests/ui/rename.stderr | 116 ++++----- tests/ui/renamed_builtin_attr.stderr | 2 +- tests/ui/repeat_once.stderr | 12 +- tests/ui/repeat_vec_with_capacity.stderr | 6 +- tests/ui/repl_uninit.stderr | 8 +- tests/ui/reserve_after_initialization.stderr | 6 +- .../ui/rest_pat_in_fully_bound_structs.stderr | 6 +- tests/ui/result_filter_map.stderr | 8 +- tests/ui/result_large_err.stderr | 24 +- tests/ui/result_map_or_into_option.stderr | 6 +- tests/ui/result_map_unit_fn_fixable.stderr | 36 +-- tests/ui/result_map_unit_fn_unfixable.stderr | 12 +- tests/ui/result_unit_error.stderr | 10 +- tests/ui/return_self_not_must_use.stderr | 6 +- tests/ui/reversed_empty_ranges_fixable.stderr | 8 +- ...reversed_empty_ranges_loops_fixable.stderr | 12 +- ...versed_empty_ranges_loops_unfixable.stderr | 4 +- .../ui/reversed_empty_ranges_unfixable.stderr | 6 +- .../ui/same_functions_in_if_condition.stderr | 26 +- tests/ui/same_item_push.stderr | 10 +- tests/ui/same_name_method.stderr | 24 +- tests/ui/search_is_some.stderr | 16 +- tests/ui/search_is_some_fixable_none.stderr | 86 +++---- tests/ui/search_is_some_fixable_some.stderr | 94 +++---- tests/ui/seek_from_current.stderr | 2 +- .../ui/seek_to_start_instead_of_rewind.stderr | 6 +- tests/ui/self_assignment.stderr | 22 +- tests/ui/self_named_constructors.stderr | 2 +- tests/ui/semicolon_if_nothing_returned.stderr | 10 +- tests/ui/semicolon_inside_block.stderr | 8 +- tests/ui/semicolon_outside_block.stderr | 8 +- tests/ui/serde.stderr | 2 +- tests/ui/shadow.stderr | 92 +++---- tests/ui/short_circuit_statement.stderr | 6 +- .../ui/should_impl_trait/method_list_1.stderr | 30 +-- .../ui/should_impl_trait/method_list_2.stderr | 30 +-- tests/ui/should_panic_without_expect.stderr | 4 +- tests/ui/significant_drop_in_scrutinee.stderr | 52 ++-- tests/ui/significant_drop_tightening.stderr | 8 +- tests/ui/similar_names.stderr | 20 +- tests/ui/single_call_fn.stderr | 16 +- tests/ui/single_char_add_str.stderr | 30 +-- tests/ui/single_char_lifetime_names.stderr | 10 +- tests/ui/single_char_pattern.stderr | 80 +++--- tests/ui/single_component_path_imports.stderr | 4 +- ...component_path_imports_nested_first.stderr | 6 +- tests/ui/single_element_loop.stderr | 14 +- tests/ui/single_match.stderr | 36 +-- tests/ui/single_match_else.stderr | 18 +- tests/ui/single_range_in_vec_init.stderr | 20 +- .../expressions.stderr | 8 +- .../size_of_in_element_count/functions.stderr | 42 ++-- tests/ui/size_of_ref.stderr | 6 +- tests/ui/skip_while_next.stderr | 4 +- tests/ui/slow_vector_initialization.stderr | 26 +- tests/ui/stable_sort_primitive.stderr | 14 +- tests/ui/starts_ends_with.stderr | 32 +-- tests/ui/std_instead_of_core.stderr | 22 +- tests/ui/str_split.stderr | 20 +- tests/ui/str_to_string.stderr | 4 +- tests/ui/string_add.stderr | 8 +- tests/ui/string_add_assign.stderr | 6 +- tests/ui/string_extend.stderr | 8 +- tests/ui/string_from_utf8_as_bytes.stderr | 2 +- tests/ui/string_lit_as_bytes.stderr | 14 +- tests/ui/string_lit_chars_any.stderr | 10 +- tests/ui/string_slice.stderr | 6 +- tests/ui/string_to_string.stderr | 2 +- tests/ui/strlen_on_c_strings.stderr | 14 +- tests/ui/struct_excessive_bools.stderr | 4 +- tests/ui/struct_fields.stderr | 48 ++-- tests/ui/suspicious_arithmetic_impl.stderr | 18 +- tests/ui/suspicious_command_arg_space.stderr | 4 +- tests/ui/suspicious_doc_comments.stderr | 18 +- .../suspicious_doc_comments_unfixable.stderr | 4 +- tests/ui/suspicious_else_formatting.stderr | 18 +- tests/ui/suspicious_map.stderr | 4 +- .../ui/suspicious_operation_groupings.stderr | 52 ++-- tests/ui/suspicious_splitn.stderr | 18 +- tests/ui/suspicious_to_owned.stderr | 12 +- .../ui/suspicious_unary_op_formatting.stderr | 8 +- tests/ui/suspicious_xor_used_as_pow.stderr | 14 +- tests/ui/swap.stderr | 34 +-- tests/ui/swap_ptr_to_ref.stderr | 8 +- tests/ui/swap_ptr_to_ref_unfixable.stderr | 6 +- tests/ui/tabs_in_doc_comments.stderr | 16 +- tests/ui/temporary_assignment.stderr | 8 +- tests/ui/test_attr_in_doctest.stderr | 6 +- tests/ui/tests_outside_test_module.stderr | 2 +- ...local_initializer_can_be_made_const.stderr | 8 +- tests/ui/to_digit_is_some.stderr | 4 +- ...o_string_in_format_args_incremental.stderr | 2 +- tests/ui/to_string_trait_impl.stderr | 4 +- tests/ui/toplevel_ref_arg.stderr | 12 +- tests/ui/toplevel_ref_arg_non_rustfix.stderr | 4 +- tests/ui/track-diagnostics.stderr | 2 +- tests/ui/trailing_empty_array.stderr | 22 +- tests/ui/trailing_zeros.stderr | 4 +- tests/ui/trait_duplication_in_bounds.stderr | 20 +- ...ait_duplication_in_bounds_unfixable.stderr | 18 +- tests/ui/transmute.stderr | 72 +++--- tests/ui/transmute_32bit.stderr | 8 +- tests/ui/transmute_64bit.stderr | 4 +- tests/ui/transmute_collection.stderr | 36 +-- tests/ui/transmute_float_to_int.stderr | 12 +- tests/ui/transmute_int_to_char.stderr | 4 +- tests/ui/transmute_int_to_char_no_std.stderr | 4 +- tests/ui/transmute_int_to_non_zero.stderr | 20 +- tests/ui/transmute_null_to_fn.stderr | 12 +- tests/ui/transmute_ptr_to_ptr.stderr | 14 +- tests/ui/transmute_ptr_to_ref.stderr | 44 ++-- tests/ui/transmute_ref_to_ref.stderr | 8 +- tests/ui/transmute_ref_to_ref_no_std.stderr | 8 +- tests/ui/transmute_undefined_repr.stderr | 24 +- ...transmutes_expressible_as_ptr_casts.stderr | 20 +- tests/ui/transmuting_null.stderr | 6 +- tests/ui/trim_split_whitespace.stderr | 16 +- tests/ui/trivially_copy_pass_by_ref.stderr | 38 +-- tests/ui/try_err.stderr | 24 +- tests/ui/tuple_array_conversions.stderr | 20 +- tests/ui/type_complexity.stderr | 30 +-- tests/ui/type_id_on_box.stderr | 6 +- tests/ui/type_repetition_in_bounds.stderr | 12 +- tests/ui/types.stderr | 2 +- .../ui/unchecked_duration_subtraction.stderr | 8 +- tests/ui/unconditional_recursion.stderr | 90 +++---- tests/ui/unicode.stderr | 20 +- tests/ui/uninhabited_references.stderr | 8 +- tests/ui/uninit.stderr | 6 +- tests/ui/uninit_vec.stderr | 22 +- tests/ui/uninlined_format_args.stderr | 142 +++++------ ...lined_format_args_panic.edition2018.stderr | 2 +- ...lined_format_args_panic.edition2021.stderr | 12 +- tests/ui/unit_arg.stderr | 20 +- tests/ui/unit_arg_empty_blocks.stderr | 8 +- tests/ui/unit_cmp.stderr | 12 +- tests/ui/unit_hash.stderr | 6 +- tests/ui/unit_return_expecting_ord.stderr | 12 +- tests/ui/unknown_attribute.stderr | 2 +- tests/ui/unknown_clippy_lints.stderr | 18 +- tests/ui/unnecessary_box_returns.stderr | 8 +- tests/ui/unnecessary_cast.stderr | 80 +++--- tests/ui/unnecessary_cast_unfixable.stderr | 4 +- tests/ui/unnecessary_clone.stderr | 18 +- .../unnecessary_fallible_conversions.stderr | 20 +- ...sary_fallible_conversions_unfixable.stderr | 12 +- tests/ui/unnecessary_filter_map.stderr | 10 +- tests/ui/unnecessary_find_map.stderr | 10 +- tests/ui/unnecessary_fold.stderr | 32 +-- tests/ui/unnecessary_iter_cloned.stderr | 4 +- tests/ui/unnecessary_join.stderr | 4 +- tests/ui/unnecessary_lazy_eval.stderr | 126 +++++----- .../ui/unnecessary_lazy_eval_unfixable.stderr | 8 +- tests/ui/unnecessary_literal_unwrap.stderr | 106 ++++---- ...nnecessary_literal_unwrap_unfixable.stderr | 204 +++++++-------- .../ui/unnecessary_map_on_constructor.stderr | 16 +- tests/ui/unnecessary_operation.stderr | 38 +-- .../ui/unnecessary_owned_empty_strings.stderr | 4 +- .../ui/unnecessary_result_map_or_else.stderr | 8 +- tests/ui/unnecessary_safety_comment.stderr | 36 +-- tests/ui/unnecessary_self_imports.stderr | 4 +- tests/ui/unnecessary_sort_by.stderr | 24 +- .../unnecessary_struct_initialization.stderr | 12 +- tests/ui/unnecessary_to_owned.stderr | 170 ++++++------- tests/ui/unnecessary_to_owned_on_split.stderr | 18 +- tests/ui/unnecessary_unsafety_doc.stderr | 14 +- tests/ui/unnecessary_wraps.stderr | 14 +- tests/ui/unneeded_field_pattern.stderr | 4 +- tests/ui/unneeded_wildcard_pattern.stderr | 30 +-- tests/ui/unnested_or_patterns.stderr | 34 +-- tests/ui/unnested_or_patterns2.stderr | 16 +- tests/ui/unreadable_literal.stderr | 20 +- tests/ui/unsafe_derive_deserialize.stderr | 8 +- tests/ui/unsafe_removed_from_name.stderr | 10 +- tests/ui/unseparated_prefix_literals.stderr | 18 +- tests/ui/unused_async.stderr | 10 +- tests/ui/unused_enumerate_index.stderr | 4 +- tests/ui/unused_format_specs_unfixable.stderr | 8 +- tests/ui/unused_io_amount.stderr | 70 +++--- tests/ui/unused_peekable.stderr | 16 +- tests/ui/unused_rounding.stderr | 10 +- tests/ui/unused_self.stderr | 18 +- tests/ui/unused_unit.stderr | 40 +-- tests/ui/unwrap.stderr | 6 +- tests/ui/unwrap_expect_used.stderr | 12 +- tests/ui/unwrap_in_result.stderr | 8 +- tests/ui/unwrap_or.stderr | 4 +- tests/ui/unwrap_or_else_default.stderr | 32 +-- tests/ui/upper_case_acronyms.stderr | 24 +- tests/ui/use_self.stderr | 84 +++---- tests/ui/use_self_trait.stderr | 32 +-- tests/ui/used_underscore_binding.stderr | 24 +- tests/ui/useless_asref.stderr | 38 +-- tests/ui/useless_attribute.stderr | 6 +- tests/ui/useless_conversion.stderr | 76 +++--- tests/ui/useless_conversion_try.stderr | 20 +- tests/ui/vec.stderr | 40 +-- tests/ui/vec_box_sized.stderr | 18 +- tests/ui/vec_init_then_push.stderr | 16 +- tests/ui/vec_resize_to_zero.stderr | 2 +- tests/ui/verbose_file_reads.stderr | 4 +- tests/ui/waker_clone_wake.stderr | 4 +- tests/ui/while_let_loop.stderr | 10 +- tests/ui/while_let_on_iterator.stderr | 54 ++-- tests/ui/wild_in_or_pats.stderr | 8 +- tests/ui/wildcard_enum_match_arm.stderr | 14 +- tests/ui/wildcard_imports.stderr | 44 ++-- .../wildcard_imports_2021.edition2018.stderr | 44 ++-- .../wildcard_imports_2021.edition2021.stderr | 44 ++-- tests/ui/write_literal.stderr | 24 +- tests/ui/write_literal_2.stderr | 28 +-- tests/ui/write_with_newline.stderr | 18 +- tests/ui/writeln_empty_string.stderr | 4 +- tests/ui/wrong_self_convention.stderr | 48 ++-- tests/ui/wrong_self_convention2.stderr | 4 +- tests/ui/wrong_self_conventions_mut.stderr | 4 +- tests/ui/zero_div_zero.stderr | 8 +- tests/ui/zero_offset.stderr | 16 +- tests/ui/zero_ptr.stderr | 10 +- tests/ui/zero_ptr_no_std.stderr | 8 +- tests/ui/zero_sized_btreemap_values.stderr | 26 +- tests/ui/zero_sized_hashmap_values.stderr | 26 +- 929 files changed, 9157 insertions(+), 9158 deletions(-) diff --git a/.github/driver.sh b/.github/driver.sh index 40a2aad0f5379..11fd6b5c79ed8 100755 --- a/.github/driver.sh +++ b/.github/driver.sh @@ -32,7 +32,7 @@ test "$sysroot" = $desired_sysroot ) # Check that the --sysroot argument is only passed once via arg_file.txt (SYSROOT is ignored) -( +( echo "fn main() {}" > target/driver_test.rs echo "--sysroot="$(./target/debug/clippy-driver --print sysroot)"" > arg_file.txt echo "--verbose" >> arg_file.txt @@ -45,7 +45,7 @@ unset CARGO_MANIFEST_DIR # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 # FIXME: How to match the clippy invocation in compile-test.rs? ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1 -sed -e "s,tests/ui,\$DIR," -e "/= help: for/d" double_neg.stderr > normalized.stderr +sed -e "/= help: for/d" double_neg.stderr > normalized.stderr diff -u normalized.stderr tests/ui/double_neg.stderr # make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 8936888ad64a1..09f7badcd2022 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -126,7 +126,6 @@ fn base_config(test_dir: &str) -> (Config, Args) { })) .into(); config.comment_defaults.base().diagnostic_code_prefix = Some(Spanned::dummy("clippy::".into())).into(); - config.filter(&format!("tests/{test_dir}"), "$$DIR"); config.with_args(&args); let current_exe_path = env::current_exe().unwrap(); let deps_path = current_exe_path.parent().unwrap(); diff --git a/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr b/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr index c8324ef05b110..43272c2da5a32 100644 --- a/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr +++ b/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr @@ -1,2 +1,2 @@ -warning: using config file `$DIR/$DIR/multiple_config_files/warn/.clippy.toml`, `$DIR/$DIR/multiple_config_files/warn/clippy.toml` will be ignored +warning: using config file `$DIR/tests/ui-cargo/multiple_config_files/warn/.clippy.toml`, `$DIR/tests/ui-cargo/multiple_config_files/warn/clippy.toml` will be ignored diff --git a/tests/ui-internal/check_clippy_version_attribute.stderr b/tests/ui-internal/check_clippy_version_attribute.stderr index fd8c8379f5bfc..631c292f5249e 100644 --- a/tests/ui-internal/check_clippy_version_attribute.stderr +++ b/tests/ui-internal/check_clippy_version_attribute.stderr @@ -1,5 +1,5 @@ error: this item has an invalid `clippy::version` attribute - --> $DIR/check_clippy_version_attribute.rs:40:1 + --> tests/ui-internal/check_clippy_version_attribute.rs:40:1 | LL | / declare_tool_lint! { LL | | #[clippy::version = "1.2.3.4.5.6"] @@ -12,7 +12,7 @@ LL | | } | = help: please use a valid semantic version, see `doc/adding_lints.md` note: the lint level is defined here - --> $DIR/check_clippy_version_attribute.rs:1:9 + --> tests/ui-internal/check_clippy_version_attribute.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | #![deny(clippy::internal)] = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) error: this item has an invalid `clippy::version` attribute - --> $DIR/check_clippy_version_attribute.rs:48:1 + --> tests/ui-internal/check_clippy_version_attribute.rs:48:1 | LL | / declare_tool_lint! { LL | | #[clippy::version = "I'm a string"] @@ -35,7 +35,7 @@ LL | | } = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) error: this lint is missing the `clippy::version` attribute or version value - --> $DIR/check_clippy_version_attribute.rs:59:1 + --> tests/ui-internal/check_clippy_version_attribute.rs:59:1 | LL | / declare_tool_lint! { LL | | #[clippy::version] @@ -51,7 +51,7 @@ LL | | } = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) error: this lint is missing the `clippy::version` attribute or version value - --> $DIR/check_clippy_version_attribute.rs:67:1 + --> tests/ui-internal/check_clippy_version_attribute.rs:67:1 | LL | / declare_tool_lint! { LL | | pub clippy::MISSING_ATTRIBUTE_TWO, diff --git a/tests/ui-internal/check_formulation.stderr b/tests/ui-internal/check_formulation.stderr index 42a872d9a83f7..12514370e6ded 100644 --- a/tests/ui-internal/check_formulation.stderr +++ b/tests/ui-internal/check_formulation.stderr @@ -1,5 +1,5 @@ error: non-standard lint formulation - --> $DIR/check_formulation.rs:23:5 + --> tests/ui-internal/check_formulation.rs:23:5 | LL | /// Check for lint formulations that are correct | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | /// Check for lint formulations that are correct = help: to override `-D warnings` add `#[allow(clippy::almost_standard_lint_formulation)]` error: non-standard lint formulation - --> $DIR/check_formulation.rs:33:5 + --> tests/ui-internal/check_formulation.rs:33:5 | LL | /// Detects uses of incorrect formulations | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/collapsible_span_lint_calls.stderr b/tests/ui-internal/collapsible_span_lint_calls.stderr index dce2daad68a88..104995918de2e 100644 --- a/tests/ui-internal/collapsible_span_lint_calls.stderr +++ b/tests/ui-internal/collapsible_span_lint_calls.stderr @@ -1,5 +1,5 @@ error: this call is collapsible - --> $DIR/collapsible_span_lint_calls.rs:35:9 + --> tests/ui-internal/collapsible_span_lint_calls.rs:35:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { LL | | db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable); @@ -7,14 +7,14 @@ LL | | }); | |__________^ help: collapse into: `span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable)` | note: the lint level is defined here - --> $DIR/collapsible_span_lint_calls.rs:1:9 + --> tests/ui-internal/collapsible_span_lint_calls.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]` error: this call is collapsible - --> $DIR/collapsible_span_lint_calls.rs:38:9 + --> tests/ui-internal/collapsible_span_lint_calls.rs:38:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { LL | | db.span_help(expr.span, help_msg); @@ -22,7 +22,7 @@ LL | | }); | |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg)` error: this call is collapsible - --> $DIR/collapsible_span_lint_calls.rs:41:9 + --> tests/ui-internal/collapsible_span_lint_calls.rs:41:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { LL | | db.help(help_msg); @@ -30,7 +30,7 @@ LL | | }); | |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg)` error: this call is collapsible - --> $DIR/collapsible_span_lint_calls.rs:44:9 + --> tests/ui-internal/collapsible_span_lint_calls.rs:44:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { LL | | db.span_note(expr.span, note_msg); @@ -38,7 +38,7 @@ LL | | }); | |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg)` error: this call is collapsible - --> $DIR/collapsible_span_lint_calls.rs:47:9 + --> tests/ui-internal/collapsible_span_lint_calls.rs:47:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { LL | | db.note(note_msg); diff --git a/tests/ui-internal/default_deprecation_reason.stderr b/tests/ui-internal/default_deprecation_reason.stderr index 595e4c138b472..3b7c747c23f41 100644 --- a/tests/ui-internal/default_deprecation_reason.stderr +++ b/tests/ui-internal/default_deprecation_reason.stderr @@ -1,5 +1,5 @@ error: the lint `COOL_LINT_DEFAULT` has the default deprecation reason - --> $DIR/default_deprecation_reason.rs:8:1 + --> tests/ui-internal/default_deprecation_reason.rs:8:1 | LL | / declare_deprecated_lint! { LL | | /// ### What it does @@ -11,7 +11,7 @@ LL | | } | |_^ | note: the lint level is defined here - --> $DIR/default_deprecation_reason.rs:1:9 + --> tests/ui-internal/default_deprecation_reason.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/default_lint.stderr b/tests/ui-internal/default_lint.stderr index ab2470210254a..c939125e875c4 100644 --- a/tests/ui-internal/default_lint.stderr +++ b/tests/ui-internal/default_lint.stderr @@ -1,5 +1,5 @@ error: the lint `TEST_LINT_DEFAULT` has the default lint description - --> $DIR/default_lint.rs:18:1 + --> tests/ui-internal/default_lint.rs:18:1 | LL | / declare_tool_lint! { LL | | pub clippy::TEST_LINT_DEFAULT, @@ -10,7 +10,7 @@ LL | | } | |_^ | note: the lint level is defined here - --> $DIR/default_lint.rs:1:9 + --> tests/ui-internal/default_lint.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/disallow_span_lint.stderr b/tests/ui-internal/disallow_span_lint.stderr index 5ca183d41a93a..1a1ad26290c29 100644 --- a/tests/ui-internal/disallow_span_lint.stderr +++ b/tests/ui-internal/disallow_span_lint.stderr @@ -1,5 +1,5 @@ error: use of a disallowed method `rustc_lint::context::LintContext::span_lint` - --> $DIR/disallow_span_lint.rs:14:5 + --> tests/ui-internal/disallow_span_lint.rs:14:5 | LL | cx.span_lint(lint, span, msg, |_| {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | cx.span_lint(lint, span, msg, |_| {}); = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]` error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint` - --> $DIR/disallow_span_lint.rs:24:5 + --> tests/ui-internal/disallow_span_lint.rs:24:5 | LL | tcx.node_span_lint(lint, hir_id, span, msg, |_| {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/interning_defined_symbol.stderr b/tests/ui-internal/interning_defined_symbol.stderr index b8d9721ee875d..6d86768d344e9 100644 --- a/tests/ui-internal/interning_defined_symbol.stderr +++ b/tests/ui-internal/interning_defined_symbol.stderr @@ -1,30 +1,30 @@ error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:17:13 + --> tests/ui-internal/interning_defined_symbol.rs:17:13 | LL | let _ = Symbol::intern("f32"); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::f32` | note: the lint level is defined here - --> $DIR/interning_defined_symbol.rs:1:9 + --> tests/ui-internal/interning_defined_symbol.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]` error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:20:13 + --> tests/ui-internal/interning_defined_symbol.rs:20:13 | LL | let _ = sym!(f32); | ^^^^^^^^^ help: try: `rustc_span::sym::f32` error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:23:13 + --> tests/ui-internal/interning_defined_symbol.rs:23:13 | LL | let _ = Symbol::intern("proc-macro"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro` error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:26:13 + --> tests/ui-internal/interning_defined_symbol.rs:26:13 | LL | let _ = Symbol::intern("self"); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::symbol::kw::SelfLower` diff --git a/tests/ui-internal/invalid_msrv_attr_impl.stderr b/tests/ui-internal/invalid_msrv_attr_impl.stderr index e97f6aea7e262..aa649c627a164 100644 --- a/tests/ui-internal/invalid_msrv_attr_impl.stderr +++ b/tests/ui-internal/invalid_msrv_attr_impl.stderr @@ -1,11 +1,11 @@ error: `extract_msrv_attr!` macro missing from `LateLintPass` implementation - --> $DIR/invalid_msrv_attr_impl.rs:28:1 + --> tests/ui-internal/invalid_msrv_attr_impl.rs:28:1 | LL | impl LateLintPass<'_> for Pass { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/invalid_msrv_attr_impl.rs:1:9 + --> tests/ui-internal/invalid_msrv_attr_impl.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + extract_msrv_attr!(LateContext); | error: `extract_msrv_attr!` macro missing from `EarlyLintPass` implementation - --> $DIR/invalid_msrv_attr_impl.rs:32:1 + --> tests/ui-internal/invalid_msrv_attr_impl.rs:32:1 | LL | impl EarlyLintPass for Pass { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/invalid_paths.stderr b/tests/ui-internal/invalid_paths.stderr index 988d32d5259e2..fc530a2efa378 100644 --- a/tests/ui-internal/invalid_paths.stderr +++ b/tests/ui-internal/invalid_paths.stderr @@ -1,5 +1,5 @@ error: invalid path - --> $DIR/invalid_paths.rs:15:5 + --> tests/ui-internal/invalid_paths.rs:15:5 | LL | pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute" = help: to override `-D warnings` add `#[allow(clippy::invalid_paths)]` error: invalid path - --> $DIR/invalid_paths.rs:18:5 + --> tests/ui-internal/invalid_paths.rs:18:5 | LL | pub const BAD_CRATE_PATH: [&str; 2] = ["bad", "path"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid path - --> $DIR/invalid_paths.rs:21:5 + --> tests/ui-internal/invalid_paths.rs:21:5 | LL | pub const BAD_MOD_PATH: [&str; 2] = ["std", "xxx"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/lint_without_lint_pass.stderr b/tests/ui-internal/lint_without_lint_pass.stderr index de55876b1d709..187bba97fd419 100644 --- a/tests/ui-internal/lint_without_lint_pass.stderr +++ b/tests/ui-internal/lint_without_lint_pass.stderr @@ -1,5 +1,5 @@ error: the lint `TEST_LINT` is not added to any `LintPass` - --> $DIR/lint_without_lint_pass.rs:12:1 + --> tests/ui-internal/lint_without_lint_pass.rs:12:1 | LL | / declare_tool_lint! { LL | | pub clippy::TEST_LINT, @@ -10,7 +10,7 @@ LL | | } | |_^ | note: the lint level is defined here - --> $DIR/lint_without_lint_pass.rs:1:9 + --> tests/ui-internal/lint_without_lint_pass.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/outer_expn_data.stderr b/tests/ui-internal/outer_expn_data.stderr index 0d5b01325994b..33ac91e4fb0de 100644 --- a/tests/ui-internal/outer_expn_data.stderr +++ b/tests/ui-internal/outer_expn_data.stderr @@ -1,11 +1,11 @@ error: usage of `outer_expn().expn_data()` - --> $DIR/outer_expn_data.rs:23:34 + --> tests/ui-internal/outer_expn_data.rs:23:34 | LL | let _ = expr.span.ctxt().outer_expn().expn_data(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `outer_expn_data()` | note: the lint level is defined here - --> $DIR/outer_expn_data.rs:1:9 + --> tests/ui-internal/outer_expn_data.rs:1:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/unnecessary_def_path.stderr b/tests/ui-internal/unnecessary_def_path.stderr index dd963d24ced15..79da173161348 100644 --- a/tests/ui-internal/unnecessary_def_path.stderr +++ b/tests/ui-internal/unnecessary_def_path.stderr @@ -1,72 +1,72 @@ error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:36:13 + --> tests/ui-internal/unnecessary_def_path.rs:36:13 | LL | let _ = match_type(cx, ty, &OPTION); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)` | note: the lint level is defined here - --> $DIR/unnecessary_def_path.rs:2:9 + --> tests/ui-internal/unnecessary_def_path.rs:2:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:37:13 + --> tests/ui-internal/unnecessary_def_path.rs:37:13 | LL | let _ = match_type(cx, ty, RESULT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:38:13 + --> tests/ui-internal/unnecessary_def_path.rs:38:13 | LL | let _ = match_type(cx, ty, &["core", "result", "Result"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:42:13 + --> tests/ui-internal/unnecessary_def_path.rs:42:13 | LL | let _ = clippy_utils::ty::match_type(cx, ty, rc_path); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Rc)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:44:13 + --> tests/ui-internal/unnecessary_def_path.rs:44:13 | LL | let _ = match_type(cx, ty, &paths::OPTION); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:45:13 + --> tests/ui-internal/unnecessary_def_path.rs:45:13 | LL | let _ = match_type(cx, ty, paths::RESULT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:47:13 + --> tests/ui-internal/unnecessary_def_path.rs:47:13 | LL | let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_lang_item(cx, ty, LangItem::OwnedBox)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:48:13 + --> tests/ui-internal/unnecessary_def_path.rs:48:13 | LL | let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:50:13 + --> tests/ui-internal/unnecessary_def_path.rs:50:13 | LL | let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:51:13 + --> tests/ui-internal/unnecessary_def_path.rs:51:13 | LL | let _ = match_def_path(cx, did, &["core", "option", "Option"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.is_diagnostic_item(sym::Option, did)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:52:13 + --> tests/ui-internal/unnecessary_def_path.rs:52:13 | LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OptionSome) == Some(did)` @@ -74,25 +74,25 @@ LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]); = help: if this `DefId` came from a constructor expression or pattern then the parent `DefId` should be used instead error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:54:13 + --> tests/ui-internal/unnecessary_def_path.rs:54:13 | LL | let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_trait_method(cx, expr, sym::AsRef)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:56:13 + --> tests/ui-internal/unnecessary_def_path.rs:56:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_path_diagnostic_item(cx, expr, sym::Option)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:57:13 + --> tests/ui-internal/unnecessary_def_path.rs:57:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id))` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:58:13 + --> tests/ui-internal/unnecessary_def_path.rs:58:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome)` diff --git a/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr b/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr index 58b1fd92b5dc9..e4575d99d03a9 100644 --- a/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr +++ b/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr @@ -1,5 +1,5 @@ error: hardcoded path to a diagnostic item - --> $DIR/unnecessary_def_path_hardcoded_path.rs:10:36 + --> tests/ui-internal/unnecessary_def_path_hardcoded_path.rs:10:36 | LL | const DEREF_TRAIT: [&str; 4] = ["core", "ops", "deref", "Deref"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const DEREF_TRAIT: [&str; 4] = ["core", "ops", "deref", "Deref"]; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_def_path)]` error: hardcoded path to a language item - --> $DIR/unnecessary_def_path_hardcoded_path.rs:11:40 + --> tests/ui-internal/unnecessary_def_path_hardcoded_path.rs:11:40 | LL | const DEREF_MUT_TRAIT: [&str; 4] = ["core", "ops", "deref", "DerefMut"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | const DEREF_MUT_TRAIT: [&str; 4] = ["core", "ops", "deref", "DerefMut"] = help: convert all references to use `LangItem::DerefMut` error: hardcoded path to a diagnostic item - --> $DIR/unnecessary_def_path_hardcoded_path.rs:12:43 + --> tests/ui-internal/unnecessary_def_path_hardcoded_path.rs:12:43 | LL | const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-internal/unnecessary_symbol_str.stderr b/tests/ui-internal/unnecessary_symbol_str.stderr index 8e2aa59539356..551167a9ff58b 100644 --- a/tests/ui-internal/unnecessary_symbol_str.stderr +++ b/tests/ui-internal/unnecessary_symbol_str.stderr @@ -1,36 +1,36 @@ error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:15:5 + --> tests/ui-internal/unnecessary_symbol_str.rs:15:5 | LL | Symbol::intern("foo").as_str() == "clippy"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::sym::clippy` | note: the lint level is defined here - --> $DIR/unnecessary_symbol_str.rs:2:9 + --> tests/ui-internal/unnecessary_symbol_str.rs:2:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::unnecessary_symbol_str)]` implied by `#[deny(clippy::internal)]` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:16:5 + --> tests/ui-internal/unnecessary_symbol_str.rs:16:5 | LL | Symbol::intern("foo").to_string() == "self"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:17:5 + --> tests/ui-internal/unnecessary_symbol_str.rs:17:5 | LL | Symbol::intern("foo").to_ident_string() != "Self"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:18:5 + --> tests/ui-internal/unnecessary_symbol_str.rs:18:5 | LL | &*Ident::empty().as_str() == "clippy"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:19:5 + --> tests/ui-internal/unnecessary_symbol_str.rs:19:5 | LL | "clippy" == Ident::empty().to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name` diff --git a/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr b/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr index b7254fc28e1e0..1cc1034cd89b3 100644 --- a/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr +++ b/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr @@ -1,5 +1,5 @@ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:40:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:40:5 | LL | std::f32::MAX; | ^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | std::f32::MAX; = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]` error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:41:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:41:5 | LL | core::f32::MAX; | ^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:42:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:42:5 | LL | ::core::f32::MAX; | ^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:58:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:58:5 | LL | ::std::f32::MAX; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr b/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr index c2ebb1bd43e3a..f342ebf6632e8 100644 --- a/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr +++ b/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr @@ -1,5 +1,5 @@ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:40:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:40:5 | LL | std::f32::MAX; | ^^^^^^^^^^^^^ @@ -8,61 +8,61 @@ LL | std::f32::MAX; = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]` error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:41:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:41:5 | LL | core::f32::MAX; | ^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:42:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:42:5 | LL | ::core::f32::MAX; | ^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:43:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:43:5 | LL | crate::a::b::c::C; | ^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:44:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:44:5 | LL | crate::a::b::c::d::e::f::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:45:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:45:5 | LL | crate::a::A; | ^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:46:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:46:5 | LL | crate::a::b::B; | ^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:47:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:47:5 | LL | crate::a::b::c::C::ZERO; | ^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:48:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:48:5 | LL | helper::b::c::d::e::f(); | ^^^^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:49:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:49:5 | LL | ::helper::b::c::d::e::f(); | ^^^^^^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> $DIR/absolute_paths/absolute_paths.rs:58:5 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:58:5 | LL | ::std::f32::MAX; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr index 7227a45bb4368..73ef620bd12eb 100644 --- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr +++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:9:5 + --> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:9:5 | LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:5 + --> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:5 | LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {} is {local_f64:.local_i32$}", "x"); | error: literal with an empty format string - --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:35 + --> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:35 | LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); | ^^^ @@ -39,7 +39,7 @@ LL + println!("Hello x is {:.*}", local_i32, local_f64); | error: variables can be used directly in the `format!` string - --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5 + --> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5 | LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5); | error: variables can be used directly in the `format!` string - --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:12:5 + --> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:12:5 | LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5); | error: variables can be used directly in the `format!` string - --> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5 + --> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5 | LL | println!("{}, {}", local_i32, local_opt.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr index 282d1529c03f4..3c5216023b543 100644 --- a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr +++ b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr @@ -1,5 +1,5 @@ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:69:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:69:13 | LL | let _ = Baz + Baz; | ^^^^^^^^^ @@ -8,49 +8,49 @@ LL | let _ = Baz + Baz; = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:80:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:80:13 | LL | let _ = 1i32 + Baz; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:83:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:83:13 | LL | let _ = 1i64 + Foo; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:87:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:87:13 | LL | let _ = 1i64 + Baz; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:98:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:98:13 | LL | let _ = Baz + 1i32; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:101:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:101:13 | LL | let _ = Foo + 1i64; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:105:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:105:13 | LL | let _ = Baz + 1i64; | ^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:114:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:114:13 | LL | let _ = -Bar; | ^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:116:13 + --> tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:116:13 | LL | let _ = -Baz; | ^^^^ diff --git a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr index 5ceea60a2aba1..009153bc4a11b 100644 --- a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr +++ b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr @@ -1,5 +1,5 @@ error: large array defined as const - --> $DIR/array_size_threshold/array_size_threshold.rs:4:1 + --> tests/ui-toml/array_size_threshold/array_size_threshold.rs:4:1 | LL | const ABOVE: [u8; 11] = [0; 11]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const ABOVE: [u8; 11] = [0; 11]; = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]` error: allocating a local array larger than 10 bytes - --> $DIR/array_size_threshold/array_size_threshold.rs:4:25 + --> tests/ui-toml/array_size_threshold/array_size_threshold.rs:4:25 | LL | const ABOVE: [u8; 11] = [0; 11]; | ^^^^^^^ @@ -20,7 +20,7 @@ LL | const ABOVE: [u8; 11] = [0; 11]; = help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]` error: allocating a local array larger than 10 bytes - --> $DIR/array_size_threshold/array_size_threshold.rs:8:17 + --> tests/ui-toml/array_size_threshold/array_size_threshold.rs:8:17 | LL | let above = [0u8; 11]; | ^^^^^^^^^ diff --git a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr index ac5d0ea2bd974..a74d8757e4a5f 100644 --- a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr +++ b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr @@ -1,5 +1,5 @@ error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:5:9 + --> tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs:5:9 | LL | let _x = String::from("hello"); | ^^ @@ -9,13 +9,13 @@ LL | let _x = String::from("hello"); = help: to override `-D warnings` add `#[allow(clippy::await_holding_invalid_type)]` error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:10:9 + --> tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs:10:9 | LL | let x = Ipv4Addr::new(127, 0, 0, 1); | ^ error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:33:13 + --> tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs:33:13 | LL | let _x = String::from("hi!"); | ^^ diff --git a/tests/ui-toml/bad_toml/conf_bad_toml.stderr b/tests/ui-toml/bad_toml/conf_bad_toml.stderr index d7e92c7fcf1c4..eaf174b04b492 100644 --- a/tests/ui-toml/bad_toml/conf_bad_toml.stderr +++ b/tests/ui-toml/bad_toml/conf_bad_toml.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: expected `.`, `=` - --> $DIR/$DIR/bad_toml/clippy.toml:1:4 + --> $DIR/tests/ui-toml/bad_toml/clippy.toml:1:4 | LL | fn this_is_obviously(not: a, toml: file) { | ^ diff --git a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr index fe20d9eed89c2..5cf22ac6a227c 100644 --- a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr +++ b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: invalid type: integer `42`, expected a sequence - --> $DIR/$DIR/bad_toml_type/clippy.toml:1:20 + --> $DIR/tests/ui-toml/bad_toml_type/clippy.toml:1:20 | LL | disallowed-names = 42 | ^^ diff --git a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr index 8502e3d42fc21..627498dc175cd 100644 --- a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr +++ b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr @@ -1,17 +1,17 @@ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - --> $DIR/$DIR/conf_deprecated_key/clippy.toml:2:1 + --> $DIR/tests/ui-toml/conf_deprecated_key/clippy.toml:2:1 | LL | cyclomatic-complexity-threshold = 2 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `blacklisted-names`. Please use `disallowed-names` instead - --> $DIR/$DIR/conf_deprecated_key/clippy.toml:3:1 + --> $DIR/tests/ui-toml/conf_deprecated_key/clippy.toml:3:1 | LL | blacklisted-names = [ "..", "wibble" ] | ^^^^^^^^^^^^^^^^^ error: the function has a cognitive complexity of (3/2) - --> $DIR/conf_deprecated_key/conf_deprecated_key.rs:6:4 + --> tests/ui-toml/conf_deprecated_key/conf_deprecated_key.rs:6:4 | LL | fn cognitive_complexity() { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/dbg_macro/dbg_macro.stderr b/tests/ui-toml/dbg_macro/dbg_macro.stderr index 6042fa043f0db..8ffc426be2d9d 100644 --- a/tests/ui-toml/dbg_macro/dbg_macro.stderr +++ b/tests/ui-toml/dbg_macro/dbg_macro.stderr @@ -1,5 +1,5 @@ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:5:22 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:5:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:9:8 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:9:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if n <= 1 { | ~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:10:9 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:10:9 | LL | dbg!(1) | ^^^^^^^ @@ -34,7 +34,7 @@ LL | 1 | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:12:9 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:12:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | n * factorial(n - 1) | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:17:5 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:17:5 | LL | dbg!(42); | ^^^^^^^^ @@ -56,7 +56,7 @@ LL | 42; | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:18:5 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:18:5 | LL | dbg!(dbg!(dbg!(42))); | ^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:19:14 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:19:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:20:5 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:20:5 | LL | dbg!(1, 2, dbg!(3, 4)); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:21:5 + --> tests/ui-toml/dbg_macro/dbg_macro.rs:21:5 | LL | dbg!(1, 2, 3, 4, 5); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr index 57eae317e4f2b..861ba9e79a18e 100644 --- a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr +++ b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr @@ -1,5 +1,5 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation/decimal_literal_representation.rs:4:13 + --> tests/ui-toml/decimal_literal_representation/decimal_literal_representation.rs:4:13 | LL | let _ = 16777215; | ^^^^^^^^ help: consider: `0x00FF_FFFF` diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr index 8ccf567bba2bd..290cd3d0010bb 100644 --- a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr +++ b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr @@ -1,5 +1,5 @@ error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros/disallowed_macros.rs:13:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:13:5 | LL | println!("one"); | ^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | println!("one"); = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]` error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros/disallowed_macros.rs:14:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:14:5 | LL | println!("two"); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `std::cfg` - --> $DIR/disallowed_macros/disallowed_macros.rs:15:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:15:5 | LL | cfg!(unix); | ^^^^^^^^^^ error: use of a disallowed macro `std::vec` - --> $DIR/disallowed_macros/disallowed_macros.rs:16:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:16:5 | LL | vec![1, 2, 3]; | ^^^^^^^^^^^^^ error: use of a disallowed macro `serde::Serialize` - --> $DIR/disallowed_macros/disallowed_macros.rs:18:14 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:18:14 | LL | #[derive(Serialize)] | ^^^^^^^^^ @@ -34,43 +34,43 @@ LL | #[derive(Serialize)] = note: no serializing (from clippy.toml) error: use of a disallowed macro `macros::expr` - --> $DIR/disallowed_macros/disallowed_macros.rs:21:13 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:21:13 | LL | let _ = macros::expr!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::stmt` - --> $DIR/disallowed_macros/disallowed_macros.rs:22:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:22:5 | LL | macros::stmt!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::pat` - --> $DIR/disallowed_macros/disallowed_macros.rs:23:9 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:23:9 | LL | let macros::pat!() = 1; | ^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::ty` - --> $DIR/disallowed_macros/disallowed_macros.rs:24:12 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:24:12 | LL | let _: macros::ty!() = ""; | ^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros/disallowed_macros.rs:25:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:25:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::binop` - --> $DIR/disallowed_macros/disallowed_macros.rs:26:13 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:26:13 | LL | let _ = macros::binop!(1); | ^^^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::attr` - --> $DIR/disallowed_macros/disallowed_macros.rs:31:1 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:31:1 | LL | / macros::attr! { LL | | struct S; @@ -78,25 +78,25 @@ LL | | } | |_^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros/disallowed_macros.rs:36:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:36:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros/disallowed_macros.rs:40:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:40:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros/disallowed_macros.rs:44:5 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:44:5 | LL | macros::item!(); | ^^^^^^^^^^^^^^^ error: use of a disallowed macro `proc_macros::Derive` - --> $DIR/disallowed_macros/disallowed_macros.rs:47:10 + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:47:10 | LL | #[derive(Derive)] | ^^^^^^ diff --git a/tests/ui-toml/disallowed_names_append/disallowed_names.stderr b/tests/ui-toml/disallowed_names_append/disallowed_names.stderr index fdb6793e5ce6d..e6481c9cc63b5 100644 --- a/tests/ui-toml/disallowed_names_append/disallowed_names.stderr +++ b/tests/ui-toml/disallowed_names_append/disallowed_names.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names_append/disallowed_names.rs:5:9 + --> tests/ui-toml/disallowed_names_append/disallowed_names.rs:5:9 | LL | let foo = "bar"; | ^^^ @@ -8,7 +8,7 @@ LL | let foo = "bar"; = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `ducks` - --> $DIR/disallowed_names_append/disallowed_names.rs:7:9 + --> tests/ui-toml/disallowed_names_append/disallowed_names.rs:7:9 | LL | let ducks = ["quack", "quack"]; | ^^^^^ diff --git a/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr b/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr index cf1e493d2deb1..68cc9968902e3 100644 --- a/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr +++ b/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `ducks` - --> $DIR/disallowed_names_replace/disallowed_names.rs:7:9 + --> tests/ui-toml/disallowed_names_replace/disallowed_names.rs:7:9 | LL | let ducks = ["quack", "quack"]; | ^^^^^ diff --git a/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr index 2f7407e0b17a3..3a71b9bddbef0 100644 --- a/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr +++ b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr @@ -1,5 +1,5 @@ error: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana - --> $DIR/disallowed_script_idents/disallowed_script_idents.rs:4:9 + --> tests/ui-toml/disallowed_script_idents/disallowed_script_idents.rs:4:9 | LL | let カウンタ = 10; | ^^^^^^^^ diff --git a/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr b/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr index a0260fb16d812..a6e0ad0f804c8 100644 --- a/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr +++ b/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc_valid_idents_append/doc_markdown.rs:9:5 + --> tests/ui-toml/doc_valid_idents_append/doc_markdown.rs:9:5 | LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted. | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr b/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr index b3b801661af5a..d4d8a579798c8 100644 --- a/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr +++ b/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc_valid_idents_replace/doc_markdown.rs:6:5 + --> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:6:5 | LL | /// OAuth and LaTeX are inside Clippy's default list. | ^^^^^ @@ -12,7 +12,7 @@ LL | /// `OAuth` and LaTeX are inside Clippy's default list. | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc_valid_idents_replace/doc_markdown.rs:6:15 + --> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:6:15 | LL | /// OAuth and LaTeX are inside Clippy's default list. | ^^^^^ @@ -23,7 +23,7 @@ LL | /// OAuth and `LaTeX` are inside Clippy's default list. | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc_valid_idents_replace/doc_markdown.rs:9:5 + --> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:9:5 | LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted. | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr index b06f17acb1406..9f11c94ded2bc 100644 --- a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: duplicate key `cognitive-complexity-threshold` in document root - --> $DIR/$DIR/duplicated_keys/clippy.toml:2:1 + --> $DIR/tests/ui-toml/duplicated_keys/clippy.toml:2:1 | LL | cognitive-complexity-threshold = 4 | ^ diff --git a/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr index 89f1ed292e69a..80e700f514b57 100644 --- a/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr @@ -1,11 +1,11 @@ error: error reading Clippy's configuration file: duplicate field `cognitive_complexity_threshold` (provided as `cyclomatic_complexity_threshold`) - --> $DIR/$DIR/duplicated_keys_deprecated/clippy.toml:3:1 + --> $DIR/tests/ui-toml/duplicated_keys_deprecated/clippy.toml:3:1 | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - --> $DIR/$DIR/duplicated_keys_deprecated/clippy.toml:3:1 + --> $DIR/tests/ui-toml/duplicated_keys_deprecated/clippy.toml:3:1 | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr index ace7c5b6c23e2..2ca1e35c74498 100644 --- a/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr @@ -1,11 +1,11 @@ error: error reading Clippy's configuration file: duplicate field `cognitive-complexity-threshold` - --> $DIR/$DIR/duplicated_keys_deprecated_2/clippy.toml:4:1 + --> $DIR/tests/ui-toml/duplicated_keys_deprecated_2/clippy.toml:4:1 | LL | cognitive-complexity-threshold = 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - --> $DIR/$DIR/duplicated_keys_deprecated_2/clippy.toml:2:1 + --> $DIR/tests/ui-toml/duplicated_keys_deprecated_2/clippy.toml:2:1 | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/enum_variant_size/enum_variant_size.stderr b/tests/ui-toml/enum_variant_size/enum_variant_size.stderr index 8e6f9c8a9dab0..8f7ebbd9546ca 100644 --- a/tests/ui-toml/enum_variant_size/enum_variant_size.stderr +++ b/tests/ui-toml/enum_variant_size/enum_variant_size.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/enum_variant_size/enum_variant_size.rs:5:1 + --> tests/ui-toml/enum_variant_size/enum_variant_size.rs:5:1 | LL | / enum Bad { LL | | diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr b/tests/ui-toml/excessive_nesting/excessive_nesting.stderr index 856bbd93e0deb..dafcd4420554b 100644 --- a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr +++ b/tests/ui-toml/excessive_nesting/excessive_nesting.stderr @@ -1,5 +1,5 @@ error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:21:25 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:21:25 | LL | let w = { 3 }; | ^^^^^ @@ -9,7 +9,7 @@ LL | let w = { 3 }; = help: to override `-D warnings` add `#[allow(clippy::excessive_nesting)]` error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:67:17 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:67:17 | LL | / impl C { LL | | pub fn c() {} @@ -19,7 +19,7 @@ LL | | } = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:81:25 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:81:25 | LL | let x = { 1 }; // not a warning, but cc is | ^^^^^ @@ -27,7 +27,7 @@ LL | let x = { 1 }; // not a warning, but cc is = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:98:17 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:98:17 | LL | / pub mod e { LL | | pub mod f {} @@ -37,7 +37,7 @@ LL | | } // not here = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:111:18 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:111:18 | LL | a_but_not({{{{{{{{0}}}}}}}}); | ^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | a_but_not({{{{{{{{0}}}}}}}}); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:112:12 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:112:12 | LL | a.a({{{{{{{{{0}}}}}}}}}); | ^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | a.a({{{{{{{{{0}}}}}}}}}); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:113:12 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:113:12 | LL | (0, {{{{{{{1}}}}}}}); | ^^^^^^^^^ @@ -61,7 +61,7 @@ LL | (0, {{{{{{{1}}}}}}}); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:118:25 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:118:25 | LL | if true { | _________________________^ @@ -74,7 +74,7 @@ LL | | } = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:130:29 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:130:29 | LL | let z = (|| { | _____________________________^ @@ -86,7 +86,7 @@ LL | | })(); = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:149:13 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:149:13 | LL | y += {{{{{5}}}}}; | ^^^^^ @@ -94,7 +94,7 @@ LL | y += {{{{{5}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:150:20 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:150:20 | LL | let z = y + {{{{{{{{{5}}}}}}}}}; | ^^^^^^^^^^^^^ @@ -102,7 +102,7 @@ LL | let z = y + {{{{{{{{{5}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:151:12 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:151:12 | LL | [0, {{{{{{{{{{0}}}}}}}}}}]; | ^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ LL | [0, {{{{{{{{{{0}}}}}}}}}}]; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:152:25 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:152:25 | LL | let mut xx = [0; {{{{{{{{100}}}}}}}}]; | ^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | let mut xx = [0; {{{{{{{{100}}}}}}}}]; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:153:11 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:153:11 | LL | xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL | xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}]; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:154:13 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:154:13 | LL | &mut {{{{{{{{{{y}}}}}}}}}}; | ^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ LL | &mut {{{{{{{{{{y}}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:156:17 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:156:17 | LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} | ^^^^ @@ -142,7 +142,7 @@ LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:156:28 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:156:28 | LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} | ^^^^^^^^^^ @@ -150,7 +150,7 @@ LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:158:28 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:158:28 | LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} | ^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:158:48 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:158:48 | LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} | ^^^^^^^^ @@ -166,7 +166,7 @@ LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:160:14 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:160:14 | LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} | ^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:160:35 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:160:35 | LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} | ^^^^^^^^^^^^ @@ -182,7 +182,7 @@ LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:162:23 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:162:23 | LL | let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +190,7 @@ LL | let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} }; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:164:8 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:164:8 | LL | {{{{1;}}}}..{{{{{{3}}}}}}; | ^^^^ @@ -198,7 +198,7 @@ LL | {{{{1;}}}}..{{{{{{3}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:164:20 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:164:20 | LL | {{{{1;}}}}..{{{{{{3}}}}}}; | ^^^^^^^ @@ -206,7 +206,7 @@ LL | {{{{1;}}}}..{{{{{{3}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:165:8 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:165:8 | LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; | ^^^^ @@ -214,7 +214,7 @@ LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:165:21 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:165:21 | LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -222,7 +222,7 @@ LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:166:10 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:166:10 | LL | ..{{{{{{{5}}}}}}}; | ^^^^^^^^^ @@ -230,7 +230,7 @@ LL | ..{{{{{{{5}}}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:167:11 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:167:11 | LL | ..={{{{{3}}}}}; | ^^^^^ @@ -238,7 +238,7 @@ LL | ..={{{{{3}}}}}; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:168:8 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:168:8 | LL | {{{{{1;}}}}}..; | ^^^^^^ @@ -246,7 +246,7 @@ LL | {{{{{1;}}}}}..; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:170:20 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:170:20 | LL | loop { break {{{{1}}}} }; | ^^^^^ @@ -254,7 +254,7 @@ LL | loop { break {{{{1}}}} }; = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:171:13 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:171:13 | LL | loop {{{{{{}}}}}} | ^^^^^^ @@ -262,7 +262,7 @@ LL | loop {{{{{{}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:173:14 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:173:14 | LL | match {{{{{{true}}}}}} { | ^^^^^^^^^^ @@ -270,7 +270,7 @@ LL | match {{{{{{true}}}}}} { = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:174:20 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:174:20 | LL | true => {{{{}}}}, | ^^ @@ -278,7 +278,7 @@ LL | true => {{{{}}}}, = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:175:21 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:175:21 | LL | false => {{{{}}}}, | ^^ @@ -286,7 +286,7 @@ LL | false => {{{{}}}}, = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:181:17 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:181:17 | LL | / { LL | | println!("warning! :)"); @@ -296,7 +296,7 @@ LL | | } = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:190:28 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:190:28 | LL | async fn c() -> u32 {{{{{{{0}}}}}}} | ^^^^^^^^^ @@ -304,7 +304,7 @@ LL | async fn c() -> u32 {{{{{{{0}}}}}}} = help: try refactoring your code to minimize nesting error: this block is too nested - --> $DIR/excessive_nesting/excessive_nesting.rs:196:8 + --> tests/ui-toml/excessive_nesting/excessive_nesting.rs:196:8 | LL | {{{{b().await}}}}; | ^^^^^^^^^^^ diff --git a/tests/ui-toml/expect_used/expect_used.stderr b/tests/ui-toml/expect_used/expect_used.stderr index 8cfe6dde184c6..81691f8ac6c0a 100644 --- a/tests/ui-toml/expect_used/expect_used.stderr +++ b/tests/ui-toml/expect_used/expect_used.stderr @@ -1,5 +1,5 @@ error: used `expect()` on an `Option` value - --> $DIR/expect_used/expect_used.rs:7:13 + --> tests/ui-toml/expect_used/expect_used.rs:7:13 | LL | let _ = opt.expect(""); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = opt.expect(""); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value - --> $DIR/expect_used/expect_used.rs:12:13 + --> tests/ui-toml/expect_used/expect_used.rs:12:13 | LL | let _ = res.expect(""); | ^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr index d01077bbc0375..96b4736bbdf9c 100644 --- a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr +++ b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr @@ -1,5 +1,5 @@ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop/explicit_iter_loop.rs:6:14 + --> tests/ui-toml/explicit_iter_loop/explicit_iter_loop.rs:6:14 | LL | for _ in rmvec.iter() {} | ^^^^^^^^^^^^ help: to write this more concisely, try: `&*rmvec` @@ -8,7 +8,7 @@ LL | for _ in rmvec.iter() {} = help: to override `-D warnings` add `#[allow(clippy::explicit_iter_loop)]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop/explicit_iter_loop.rs:8:14 + --> tests/ui-toml/explicit_iter_loop/explicit_iter_loop.rs:8:14 | LL | for _ in rmvec.iter_mut() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *rmvec` diff --git a/tests/ui-toml/fn_params_excessive_bools/test.stderr b/tests/ui-toml/fn_params_excessive_bools/test.stderr index 975f1e831fe33..3de0686b6256f 100644 --- a/tests/ui-toml/fn_params_excessive_bools/test.stderr +++ b/tests/ui-toml/fn_params_excessive_bools/test.stderr @@ -1,5 +1,5 @@ error: more than 1 bools in function parameters - --> $DIR/fn_params_excessive_bools/test.rs:4:1 + --> tests/ui-toml/fn_params_excessive_bools/test.rs:4:1 | LL | fn g(_: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/functions_maxlines/test.stderr b/tests/ui-toml/functions_maxlines/test.stderr index f7aa96f0dfbd3..cb188a868c447 100644 --- a/tests/ui-toml/functions_maxlines/test.stderr +++ b/tests/ui-toml/functions_maxlines/test.stderr @@ -1,5 +1,5 @@ error: this function has too many lines (2/1) - --> $DIR/functions_maxlines/test.rs:19:1 + --> tests/ui-toml/functions_maxlines/test.rs:19:1 | LL | / fn too_many_lines() { LL | | println!("This is bad."); @@ -11,7 +11,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::too_many_lines)]` error: this function has too many lines (4/1) - --> $DIR/functions_maxlines/test.rs:25:1 + --> tests/ui-toml/functions_maxlines/test.rs:25:1 | LL | / async fn async_too_many_lines() { LL | | println!("This is bad."); @@ -20,7 +20,7 @@ LL | | } | |_^ error: this function has too many lines (4/1) - --> $DIR/functions_maxlines/test.rs:31:1 + --> tests/ui-toml/functions_maxlines/test.rs:31:1 | LL | / fn closure_too_many_lines() { LL | | let _ = { @@ -31,7 +31,7 @@ LL | | } | |_^ error: this function has too many lines (2/1) - --> $DIR/functions_maxlines/test.rs:53:1 + --> tests/ui-toml/functions_maxlines/test.rs:53:1 | LL | / fn comment_before_code() { LL | | let _ = "test"; diff --git a/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr b/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr index e7c75e84f74c3..d67e7fca6565b 100644 --- a/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr +++ b/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr @@ -1,11 +1,11 @@ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond/ifs_same_cond.rs:15:15 + --> tests/ui-toml/ifs_same_cond/ifs_same_cond.rs:15:15 | LL | } else if x.get() { | ^^^^^^^ | note: same as this - --> $DIR/ifs_same_cond/ifs_same_cond.rs:13:8 + --> tests/ui-toml/ifs_same_cond/ifs_same_cond.rs:13:8 | LL | if x.get() { | ^^^^^^^ diff --git a/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr b/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr index 6d67cf21c8d16..5073b2af48b99 100644 --- a/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr +++ b/tests/ui-toml/impl_trait_in_params/impl_trait_in_params.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params/impl_trait_in_params.rs:14:13 + --> tests/ui-toml/impl_trait_in_params/impl_trait_in_params.rs:14:13 | LL | fn t(_: impl Trait); | ^^^^^^^^^^ diff --git a/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr b/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr index b8c957e9d92cc..62df5554ccede 100644 --- a/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr +++ b/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr @@ -1,5 +1,5 @@ error: error reading Clippy's configuration file: not a valid Rust version - --> $DIR/$DIR/invalid_min_rust_version/clippy.toml:1:8 + --> $DIR/tests/ui-toml/invalid_min_rust_version/clippy.toml:1:8 | LL | msrv = "invalid.version" | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr b/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr index 096c93500e27e..49dc7664e7aa0 100644 --- a/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr +++ b/tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.stderr @@ -1,5 +1,5 @@ error: all fields have the same postfix: `data` - --> $DIR/item_name_repetitions/threshold5/item_name_repetitions.rs:9:1 + --> tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.rs:9:1 | LL | / struct Data2 { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::struct_field_names)]` error: all variants have the same postfix: `Foo` - --> $DIR/item_name_repetitions/threshold5/item_name_repetitions.rs:23:1 + --> tests/ui-toml/item_name_repetitions/threshold5/item_name_repetitions.rs:23:1 | LL | / enum Foo2 { LL | | diff --git a/tests/ui-toml/large_futures/large_futures.stderr b/tests/ui-toml/large_futures/large_futures.stderr index ef8adb86aff7b..7779bfeca5dd0 100644 --- a/tests/ui-toml/large_futures/large_futures.stderr +++ b/tests/ui-toml/large_futures/large_futures.stderr @@ -1,5 +1,5 @@ error: large future with a size of 1026 bytes - --> $DIR/large_futures/large_futures.rs:18:5 + --> tests/ui-toml/large_futures/large_futures.rs:18:5 | LL | should_warn().await; | ^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(should_warn())` diff --git a/tests/ui-toml/large_include_file/large_include_file.stderr b/tests/ui-toml/large_include_file/large_include_file.stderr index 3128964bba576..b45cb11939f0f 100644 --- a/tests/ui-toml/large_include_file/large_include_file.stderr +++ b/tests/ui-toml/large_include_file/large_include_file.stderr @@ -1,5 +1,5 @@ error: attempted to include a large file - --> $DIR/large_include_file/large_include_file.rs:13:43 + --> tests/ui-toml/large_include_file/large_include_file.rs:13:43 | LL | const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) error: attempted to include a large file - --> $DIR/large_include_file/large_include_file.rs:14:35 + --> tests/ui-toml/large_include_file/large_include_file.rs:14:35 | LL | const TOO_BIG_INCLUDE_STR: &str = include_str!("too_big.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr index fee4ae9903d13..c23fac1456469 100644 --- a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr +++ b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr @@ -1,5 +1,5 @@ error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames/large_stack_frames.rs:12:1 + --> tests/ui-toml/large_stack_frames/large_stack_frames.rs:12:1 | LL | / fn f2() { LL | | diff --git a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr index 091d7911c6699..848fe4ba2bbe2 100644 --- a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr +++ b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr @@ -1,5 +1,5 @@ error: this argument (513 byte) is passed by value, but might be more efficient if passed by reference (limit: 512 byte) - --> $DIR/large_types_passed_by_value/large_types_passed_by_value.rs:4:11 + --> tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.rs:4:11 | LL | fn f2(_v: [u8; 513]) {} | ^^^^^^^^^ help: consider passing by reference instead: `&[u8; 513]` diff --git a/tests/ui-toml/lint_decimal_readability/test.stderr b/tests/ui-toml/lint_decimal_readability/test.stderr index ef4dd582bea00..766722d35ab71 100644 --- a/tests/ui-toml/lint_decimal_readability/test.stderr +++ b/tests/ui-toml/lint_decimal_readability/test.stderr @@ -1,5 +1,5 @@ error: digits grouped inconsistently by underscores - --> $DIR/lint_decimal_readability/test.rs:19:18 + --> tests/ui-toml/lint_decimal_readability/test.rs:19:18 | LL | let _fail1 = 100_200_300.123456789; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789` @@ -8,7 +8,7 @@ LL | let _fail1 = 100_200_300.123456789; = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: long literal lacking separators - --> $DIR/lint_decimal_readability/test.rs:22:18 + --> tests/ui-toml/lint_decimal_readability/test.rs:22:18 | LL | let _fail2 = 100200300.300200100; | ^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.300_200_100` diff --git a/tests/ui-toml/manual_let_else/manual_let_else.stderr b/tests/ui-toml/manual_let_else/manual_let_else.stderr index 7685e63ec3644..30253cd0c943e 100644 --- a/tests/ui-toml/manual_let_else/manual_let_else.stderr +++ b/tests/ui-toml/manual_let_else/manual_let_else.stderr @@ -1,5 +1,5 @@ error: this could be rewritten as `let...else` - --> $DIR/manual_let_else/manual_let_else.rs:9:5 + --> tests/ui-toml/manual_let_else/manual_let_else.rs:9:5 | LL | / let x = match Foo::A(1) { LL | | diff --git a/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr b/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr index cc1faa28487fc..0b989e5cf0647 100644 --- a/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr +++ b/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/max_suggested_slice_pattern_length/index_refutable_slice.rs:5:17 + --> tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.rs:5:17 | LL | if let Some(slice) = slice { | ^^^^^ | note: the lint level is defined here - --> $DIR/max_suggested_slice_pattern_length/index_refutable_slice.rs:1:9 + --> tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr index dc02c9fbd732e..63a057aca279a 100644 --- a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr +++ b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr @@ -1,5 +1,5 @@ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:6:41 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:6:41 | LL | use extern_types::{Aaa, LONGER, M, N as W}; | ^ @@ -8,43 +8,43 @@ LL | use extern_types::{Aaa, LONGER, M, N as W}; = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:8:11 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:8:11 | LL | pub const N: u32 = 0; | ^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:13:5 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:13:5 | LL | aaa: Aaa, | ^^^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:18:9 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:18:9 | LL | let vvv = 1; | ^^^ error: this ident is too short (3 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:19:9 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:19:9 | LL | let uuu = 1; | ^^^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:20:14 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:20:14 | LL | let (mut a, mut b) = (1, 2); | ^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:20:21 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:20:21 | LL | let (mut a, mut b) = (1, 2); | ^ error: this ident is too short (1 <= 3) - --> $DIR/min_ident_chars/min_ident_chars.rs:21:9 + --> tests/ui-toml/min_ident_chars/min_ident_chars.rs:21:9 | LL | for i in 0..1000 {} | ^ diff --git a/tests/ui-toml/min_rust_version/min_rust_version.stderr b/tests/ui-toml/min_rust_version/min_rust_version.stderr index 9702a0881c1e1..81b0cda94af4a 100644 --- a/tests/ui-toml/min_rust_version/min_rust_version.stderr +++ b/tests/ui-toml/min_rust_version/min_rust_version.stderr @@ -1,5 +1,5 @@ error: you are using an explicit closure for cloning elements - --> $DIR/min_rust_version/min_rust_version.rs:74:26 + --> tests/ui-toml/min_rust_version/min_rust_version.rs:74:26 | LL | let _: Option = Some(&16).map(|b| *b); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()` diff --git a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr index 74b0308c84956..f66938c83fbf8 100644 --- a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr +++ b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr @@ -1,5 +1,5 @@ error: this import should be renamed - --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:5:20 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:5:20 | LL | use std::process::{exit as wrong_exit, Child as Kid}; | ^^^^^^^^^^^^^^^^^^ help: try: `exit as goodbye` @@ -8,31 +8,31 @@ LL | use std::process::{exit as wrong_exit, Child as Kid}; = help: to override `-D warnings` add `#[allow(clippy::missing_enforced_import_renames)]` error: this import should be renamed - --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:6:1 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:6:1 | LL | use std::thread::sleep; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::thread::sleep as thread_sleep` error: this import should be renamed - --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:9:11 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:9:11 | LL | any::{type_name, Any}, | ^^^^^^^^^ help: try: `type_name as ident` error: this import should be renamed - --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:10:5 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:10:5 | LL | clone, | ^^^^^ help: try: `clone as foo` error: this import should be renamed - --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:11:5 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:11:5 | LL | sync :: Mutex, | ^^^^^^^^^^^^^ help: try: `sync :: Mutex as StdMutie` error: this import should be renamed - --> $DIR/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:15:5 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:15:5 | LL | use std::collections::BTreeMap as OopsWrongRename; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::collections::BTreeMap as Map` diff --git a/tests/ui-toml/module_inception/module_inception.stderr b/tests/ui-toml/module_inception/module_inception.stderr index ab2b30349ed3e..75e78c829226d 100644 --- a/tests/ui-toml/module_inception/module_inception.stderr +++ b/tests/ui-toml/module_inception/module_inception.stderr @@ -1,5 +1,5 @@ error: module has the same name as its containing module - --> $DIR/module_inception/module_inception.rs:6:9 + --> tests/ui-toml/module_inception/module_inception.rs:6:9 | LL | / pub mod bar2 { LL | | pub mod foo2 {} @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::module_inception)]` error: module has the same name as its containing module - --> $DIR/module_inception/module_inception.rs:11:5 + --> tests/ui-toml/module_inception/module_inception.rs:11:5 | LL | / pub mod foo2 { LL | | pub mod bar2 {} diff --git a/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr index c079b1394ac5c..8d01b66522c61 100644 --- a/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr +++ b/tests/ui-toml/modulo_arithmetic/modulo_arithmetic.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:6:13 + --> tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs:6:13 | LL | let c = a % b == 0; | ^^^^^ @@ -10,7 +10,7 @@ LL | let c = a % b == 0; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:7:13 + --> tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs:7:13 | LL | let c = a % b != 0; | ^^^^^ @@ -19,7 +19,7 @@ LL | let c = a % b != 0; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:8:18 + --> tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs:8:18 | LL | let c = 0 == a % b; | ^^^^^ @@ -28,7 +28,7 @@ LL | let c = 0 == a % b; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic/modulo_arithmetic.rs:9:18 + --> tests/ui-toml/modulo_arithmetic/modulo_arithmetic.rs:9:18 | LL | let c = 0 != a % b; | ^^^^^ diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr index 2162ffe47f7ff..c2c76e444cfe0 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr @@ -1,5 +1,5 @@ error: use of irregular braces for `vec!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:43:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:43:13 | LL | let _ = vec! {1, 2, 3}; | ^^^^^^^^^^^^^^ help: consider writing: `vec![1, 2, 3]` @@ -8,31 +8,31 @@ LL | let _ = vec! {1, 2, 3}; = help: to override `-D warnings` add `#[allow(clippy::nonstandard_macro_braces)]` error: use of irregular braces for `format!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:44:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:44:13 | LL | let _ = format!["ugh {} stop being such a good compiler", "hello"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `format!("ugh {} stop being such a good compiler", "hello")` error: use of irregular braces for `matches!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:45:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:45:13 | LL | let _ = matches!{{}, ()}; | ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())` error: use of irregular braces for `quote!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:46:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:46:13 | LL | let _ = quote!(let x = 1;); | ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}` error: use of irregular braces for `quote::quote!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:47:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:47:13 | LL | let _ = quote::quote!(match match match); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}` error: use of irregular braces for `vec!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:18:9 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:18:9 | LL | vec!{0, 0, 0} | ^^^^^^^^^^^^^ help: consider writing: `vec![0, 0, 0]` @@ -43,13 +43,13 @@ LL | let _ = test!(); // trigger when macro def is inside our own crate = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) error: use of irregular braces for `type_pos!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:56:12 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:56:12 | LL | let _: type_pos!(usize) = vec![]; | ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]` error: use of irregular braces for `eprint!` macro - --> $DIR/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:58:5 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:58:5 | LL | eprint!("test if user config overrides defaults"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `eprint!["test if user config overrides defaults"]` diff --git a/tests/ui-toml/print_macro/print_macro.stderr b/tests/ui-toml/print_macro/print_macro.stderr index 3f0a3919bcb17..fea11107c7ca5 100644 --- a/tests/ui-toml/print_macro/print_macro.stderr +++ b/tests/ui-toml/print_macro/print_macro.stderr @@ -1,5 +1,5 @@ error: use of `print!` - --> $DIR/print_macro/print_macro.rs:6:5 + --> tests/ui-toml/print_macro/print_macro.rs:6:5 | LL | print!("{n}"); | ^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | print!("{n}"); = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `eprint!` - --> $DIR/print_macro/print_macro.rs:7:5 + --> tests/ui-toml/print_macro/print_macro.rs:7:5 | LL | eprint!("{n}"); | ^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/private-doc-errors/doc_lints.stderr b/tests/ui-toml/private-doc-errors/doc_lints.stderr index ef6262f22ebb4..65ec1a7bebbf1 100644 --- a/tests/ui-toml/private-doc-errors/doc_lints.stderr +++ b/tests/ui-toml/private-doc-errors/doc_lints.stderr @@ -1,58 +1,58 @@ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/private-doc-errors/doc_lints.rs:12:1 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:12:1 | LL | fn you_dont_see_me() { | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/private-doc-errors/doc_lints.rs:2:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:2:5 | LL | clippy::unnecessary_safety_doc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/private-doc-errors/doc_lints.rs:23:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:23:5 | LL | pub fn only_crate_wide_accessible() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/private-doc-errors/doc_lints.rs:23:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:23:5 | LL | pub fn only_crate_wide_accessible() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/private-doc-errors/doc_lints.rs:3:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:3:5 | LL | clippy::missing_errors_doc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/private-doc-errors/doc_lints.rs:38:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:38:5 | LL | fn private(&self) { | ^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/private-doc-errors/doc_lints.rs:38:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:38:5 | LL | fn private(&self) { | ^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/private-doc-errors/doc_lints.rs:41:9 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:41:9 | LL | panic!(); | ^^^^^^^^ note: the lint level is defined here - --> $DIR/private-doc-errors/doc_lints.rs:4:5 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:4:5 | LL | clippy::missing_panics_doc | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/private-doc-errors/doc_lints.rs:49:9 + --> tests/ui-toml/private-doc-errors/doc_lints.rs:49:9 | LL | pub unsafe fn f() {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr index f987ff6956948..9cf79fccb60bb 100644 --- a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr +++ b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr @@ -1,5 +1,5 @@ error: missing documentation for a function - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:13:5 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:13:5 | LL | pub(crate) fn crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | pub(crate) fn crate_no_docs() {} = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a function - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:16:5 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:16:5 | LL | pub(super) fn super_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:24:9 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:24:9 | LL | pub(crate) fn sub_crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:34:9 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:34:9 | LL | pub(crate) crate_field_no_docs: (), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:40:5 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:40:5 | LL | / pub(crate) struct CrateStructNoDocs { LL | | /// some docs @@ -38,13 +38,13 @@ LL | | } | |_____^ error: missing documentation for a struct field - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:43:9 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:43:9 | LL | pub(crate) crate_field_no_docs: (), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a type alias - --> $DIR/pub_crate_missing_docs/pub_crate_missing_doc.rs:52:1 + --> tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs:52:1 | LL | type CrateTypedefNoDocs = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr index 5949e7e0ffc3a..dd1035e53fa98 100644 --- a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr +++ b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.all_pub_fields.stderr @@ -1,5 +1,5 @@ error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:15:9 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:15:9 | LL | pub _b: u8, | ^^^^^^ @@ -9,7 +9,7 @@ LL | pub _b: u8, = help: to override `-D warnings` add `#[allow(clippy::pub_underscore_fields)]` error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:23:13 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:23:13 | LL | pub(in crate::inner) _f: Option<()>, | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | pub(in crate::inner) _f: Option<()>, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:27:13 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:27:13 | LL | pub _g: String, | ^^^^^^ @@ -25,7 +25,7 @@ LL | pub _g: String, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:34:9 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:34:9 | LL | pub _a: usize, | ^^^^^^ @@ -33,7 +33,7 @@ LL | pub _a: usize, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:41:9 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:41:9 | LL | pub _c: i64, | ^^^^^^ @@ -41,7 +41,7 @@ LL | pub _c: i64, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:44:9 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:44:9 | LL | pub _e: Option, | ^^^^^^ @@ -49,7 +49,7 @@ LL | pub _e: Option, = help: consider removing the underscore, or making the field private error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:57:9 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:57:9 | LL | pub(crate) _b: Option, | ^^^^^^^^^^^^^ diff --git a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr index e4474576f6957..b3831c6301811 100644 --- a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr +++ b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.exported.stderr @@ -1,5 +1,5 @@ error: field marked as public but also inferred as unused because it's prefixed with `_` - --> $DIR/pub_underscore_fields/pub_underscore_fields.rs:15:9 + --> tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs:15:9 | LL | pub _b: u8, | ^^^^^^ diff --git a/tests/ui-toml/result_large_err/result_large_err.stderr b/tests/ui-toml/result_large_err/result_large_err.stderr index ad29b3d1f5058..656ce7ab7f2fa 100644 --- a/tests/ui-toml/result_large_err/result_large_err.stderr +++ b/tests/ui-toml/result_large_err/result_large_err.stderr @@ -1,5 +1,5 @@ error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err/result_large_err.rs:6:12 + --> tests/ui-toml/result_large_err/result_large_err.rs:6:12 | LL | fn f2() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes diff --git a/tests/ui-toml/semicolon_block/both.stderr b/tests/ui-toml/semicolon_block/both.stderr index 8588b500d3e32..7d7749b282f0c 100644 --- a/tests/ui-toml/semicolon_block/both.stderr +++ b/tests/ui-toml/semicolon_block/both.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_block/both.rs:42:5 + --> tests/ui-toml/semicolon_block/both.rs:42:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_block/both.rs:43:5 + --> tests/ui-toml/semicolon_block/both.rs:43:5 | LL | unsafe { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block() }; | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_block/both.rs:48:5 + --> tests/ui-toml/semicolon_block/both.rs:48:5 | LL | / { LL | | unit_fn_block(); @@ -42,7 +42,7 @@ LL ~ } | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_block/both.rs:62:5 + --> tests/ui-toml/semicolon_block/both.rs:62:5 | LL | { m!(()); } | ^^^^^^^^^^^ diff --git a/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr b/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr index 14aadaeb93d7d..b1638e40206d9 100644 --- a/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr +++ b/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_block/semicolon_inside_block.rs:47:5 + --> tests/ui-toml/semicolon_block/semicolon_inside_block.rs:47:5 | LL | / { LL | | unit_fn_block(); diff --git a/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr b/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr index 3c10c9bdf6804..7bcb63a6abbb1 100644 --- a/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr +++ b/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_block/semicolon_outside_block.rs:41:5 + --> tests/ui-toml/semicolon_block/semicolon_outside_block.rs:41:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_block/semicolon_outside_block.rs:42:5 + --> tests/ui-toml/semicolon_block/semicolon_outside_block.rs:42:5 | LL | unsafe { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_block/semicolon_outside_block.rs:61:5 + --> tests/ui-toml/semicolon_block/semicolon_outside_block.rs:61:5 | LL | { m!(()); } | ^^^^^^^^^^^ diff --git a/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr index 1024ae1b9c228..bd1b75458fd13 100644 --- a/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr +++ b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr @@ -1,11 +1,11 @@ error: some fields in `NoGeneric` are not safe to be sent to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:11:1 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:11:1 | LL | unsafe impl Send for NoGeneric {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `rc_is_not_send` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:8:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:8:5 | LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,75 +14,75 @@ LL | rc_is_not_send: Rc, = help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]` error: some fields in `MultiField` are not safe to be sent to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:19:1 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:19:1 | LL | unsafe impl Send for MultiField {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:14:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:14:5 | LL | field1: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field2` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:15:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:15:5 | LL | field2: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field3` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:16:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:16:5 | LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `MyOption` are not safe to be sent to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:26:1 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:26:1 | LL | unsafe impl Send for MyOption {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:22:12 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:22:12 | LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `HeuristicTest` are not safe to be sent to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:41:1 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:41:1 | LL | unsafe impl Send for HeuristicTest {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:34:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:34:5 | LL | field1: Vec<*const NonSend>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field2` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:35:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:35:5 | LL | field2: [*const NonSend; 3], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field3` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:36:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:36:5 | LL | field3: (*const NonSend, *const NonSend, *const NonSend), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field4` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:37:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:37:5 | LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field5` to another thread - --> $DIR/strict_non_send_fields_in_send_ty/test.rs:38:5 + --> tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs:38:5 | LL | field5: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/struct_excessive_bools/test.stderr b/tests/ui-toml/struct_excessive_bools/test.stderr index c3ecfa1f91fae..ddf8ec0e52175 100644 --- a/tests/ui-toml/struct_excessive_bools/test.stderr +++ b/tests/ui-toml/struct_excessive_bools/test.stderr @@ -1,5 +1,5 @@ error: more than 0 bools in a struct - --> $DIR/struct_excessive_bools/test.rs:3:1 + --> tests/ui-toml/struct_excessive_bools/test.rs:3:1 | LL | / struct S { LL | | a: bool, diff --git a/tests/ui-toml/suppress_lint_in_const/test.stderr b/tests/ui-toml/suppress_lint_in_const/test.stderr index 39a22c4ae87a5..11d6d3a201dff 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/suppress_lint_in_const/test.rs:38:14 + --> tests/ui-toml/suppress_lint_in_const/test.rs:38:14 | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant encountered - --> $DIR/suppress_lint_in_const/test.rs:38:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:38:5 | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^^^^^^^^^^^^ error: indexing may panic - --> $DIR/suppress_lint_in_const/test.rs:29:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:29:5 | LL | x[index]; | ^^^^^^^^ @@ -21,7 +21,7 @@ LL | x[index]; = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic - --> $DIR/suppress_lint_in_const/test.rs:47:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:47:5 | LL | v[0]; | ^^^^ @@ -29,7 +29,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/suppress_lint_in_const/test.rs:48:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:48:5 | LL | v[10]; | ^^^^^ @@ -37,7 +37,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/suppress_lint_in_const/test.rs:49:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:49:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -45,7 +45,7 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/suppress_lint_in_const/test.rs:55:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:55:5 | LL | v[N]; | ^^^^ @@ -53,7 +53,7 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/suppress_lint_in_const/test.rs:56:5 + --> tests/ui-toml/suppress_lint_in_const/test.rs:56:5 | LL | v[M]; | ^^^^ @@ -61,7 +61,7 @@ LL | v[M]; = help: consider using `.get(n)` or `.get_mut(n)` instead error[E0080]: evaluation of constant value failed - --> $DIR/suppress_lint_in_const/test.rs:16:24 + --> tests/ui-toml/suppress_lint_in_const/test.rs:16:24 | LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 diff --git a/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr b/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr index 8b33c2794287b..6cd0f9b0d7cb9 100644 --- a/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr +++ b/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `toto` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:6:9 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:6:9 | LL | fn test(toto: ()) {} | ^^^^ @@ -8,37 +8,37 @@ LL | fn test(toto: ()) {} = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `toto` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:9:9 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:9:9 | LL | let toto = 42; | ^^^^ error: use of a disallowed/placeholder name `tata` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:10:9 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:10:9 | LL | let tata = 42; | ^^^^ error: use of a disallowed/placeholder name `titi` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:11:9 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:11:9 | LL | let titi = 42; | ^^^^ error: use of a disallowed/placeholder name `toto` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:17:10 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:17:10 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `tata` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:17:21 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:17:21 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `titi` - --> $DIR/toml_disallow/conf_french_disallowed_name.rs:17:28 + --> tests/ui-toml/toml_disallow/conf_french_disallowed_name.rs:17:28 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr index e68a8ebeaaa03..55e867d5f3938 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr @@ -1,5 +1,5 @@ error: use of a disallowed method `regex::Regex::new` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:35:14 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:35:14 | LL | let re = Regex::new(r"ab.*c").unwrap(); | ^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let re = Regex::new(r"ab.*c").unwrap(); = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]` error: use of a disallowed method `regex::Regex::is_match` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:36:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:36:5 | LL | re.is_match("abc"); | ^^^^^^^^^^^^^^^^^^ @@ -16,73 +16,73 @@ LL | re.is_match("abc"); = note: no matching allowed (from clippy.toml) error: use of a disallowed method `std::iter::Iterator::sum` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:39:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:39:5 | LL | a.iter().sum::(); | ^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `slice::sort_unstable` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:41:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:41:5 | LL | a.sort_unstable(); | ^^^^^^^^^^^^^^^^^ error: use of a disallowed method `f32::clamp` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:43:13 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:43:13 | LL | let _ = 2.0f32.clamp(3.0f32, 4.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `regex::Regex::new` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:46:61 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:46:61 | LL | let indirect: fn(&str) -> Result = Regex::new; | ^^^^^^^^^^ error: use of a disallowed method `f32::clamp` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:49:28 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:49:28 | LL | let in_call = Box::new(f32::clamp); | ^^^^^^^^^^ error: use of a disallowed method `regex::Regex::new` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:50:53 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:50:53 | LL | let in_method_call = ["^", "$"].into_iter().map(Regex::new); | ^^^^^^^^^^ error: use of a disallowed method `futures::stream::select_all` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:53:31 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:53:31 | LL | let same_name_as_module = select_all(vec![empty::<()>()]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::local_fn` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:55:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:55:5 | LL | local_fn(); | ^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::local_mod::f` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:56:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:56:5 | LL | local_mod::f(); | ^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Struct::method` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:58:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:58:5 | LL | s.method(); | ^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Trait::provided_method` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:59:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:59:5 | LL | s.provided_method(); | ^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Trait::implemented_method` - --> $DIR/toml_disallowed_methods/conf_disallowed_methods.rs:60:5 + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:60:5 | LL | s.implemented_method(); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr index 476456107d78b..20df8e88d36b5 100644 --- a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr +++ b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr @@ -1,5 +1,5 @@ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:7:1 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:7:1 | LL | use std::sync::atomic::AtomicU32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,61 +8,61 @@ LL | use std::sync::atomic::AtomicU32; = help: to override `-D warnings` add `#[allow(clippy::disallowed_types)]` error: `std::time::Instant` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:8:1 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:8:1 | LL | use std::time::Instant as Sneaky; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:12:33 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:12:33 | LL | fn bad_return_type() -> fn() -> Sneaky { | ^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:16:28 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:16:28 | LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} | ^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:16:39 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:16:39 | LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} | ^^^^^^^^^^^^^^^^^^^^^^ error: `std::io::Read` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:18:22 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:18:22 | LL | fn trait_obj(_: &dyn std::io::Read) {} | ^^^^^^^^^^^^^ error: `usize` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:20:33 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:20:33 | LL | fn full_and_single_path_prim(_: usize, _: bool) {} | ^^^^^ error: `bool` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:20:43 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:20:43 | LL | fn full_and_single_path_prim(_: usize, _: bool) {} | ^^^^ error: `usize` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:22:28 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:22:28 | LL | fn const_generics() {} | ^^^^^ error: `usize` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:24:24 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:24:24 | LL | struct GenArg([u8; U]); | ^^^^^ error: `std::net::Ipv4Addr` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:28:10 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:28:10 | LL | fn ip(_: std::net::Ipv4Addr) {} | ^^^^^^^^^^^^^^^^^^ @@ -70,61 +70,61 @@ LL | fn ip(_: std::net::Ipv4Addr) {} = note: no IPv4 allowed (from clippy.toml) error: `std::net::TcpListener` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:30:16 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:30:16 | LL | fn listener(_: std::net::TcpListener) {} | ^^^^^^^^^^^^^^^^^^^^^ error: `std::collections::HashMap` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:34:48 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:34:48 | LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::collections::HashMap` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:34:12 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:34:12 | LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:35:13 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:35:13 | LL | let _ = Sneaky::now(); | ^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:36:13 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:36:13 | LL | let _ = foo::atomic::AtomicU32::new(0); | ^^^^^^^^^^^^^^^^^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:37:17 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:37:17 | LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:37:48 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:37:48 | LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); | ^^^^^^^^^^^^^^^^^^^^^^ error: `syn::TypePath` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:38:43 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:38:43 | LL | let _: std::collections::BTreeMap<(), syn::TypePath> = Default::default(); | ^^^^^^^^^^^^^ error: `syn::Ident` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:39:13 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:39:13 | LL | let _ = syn::Ident::new("", todo!()); | ^^^^^^^^^^ error: `usize` is not allowed according to config - --> $DIR/toml_disallowed_types/conf_disallowed_types.rs:41:12 + --> tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs:41:12 | LL | let _: usize = 64_usize; | ^^^^^ diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index 664e87f3a0a9c..a631674526002 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,5 +1,5 @@ error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/toml_trivially_copy/test.rs:15:11 + --> tests/ui-toml/toml_trivially_copy/test.rs:15:11 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `u16` @@ -8,7 +8,7 @@ LL | fn bad(x: &u16, y: &Foo) {} = help: to override `-D warnings` add `#[allow(clippy::trivially_copy_pass_by_ref)]` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/toml_trivially_copy/test.rs:15:20 + --> tests/ui-toml/toml_trivially_copy/test.rs:15:20 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index c8dcc750237f3..737c062ea562d 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -72,7 +72,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports - --> $DIR/$DIR/toml_unknown_key/clippy.toml:2:1 + --> $DIR/tests/ui-toml/toml_unknown_key/clippy.toml:2:1 | LL | foobar = 42 | ^^^^^^ @@ -151,7 +151,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports - --> $DIR/$DIR/toml_unknown_key/clippy.toml:4:1 + --> $DIR/tests/ui-toml/toml_unknown_key/clippy.toml:4:1 | LL | barfoo = 53 | ^^^^^^ @@ -230,7 +230,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports - --> $DIR/$DIR/toml_unknown_key/clippy.toml:7:1 + --> $DIR/tests/ui-toml/toml_unknown_key/clippy.toml:7:1 | LL | allow_mixed_uninlined_format_args = true | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: perhaps you meant: `allow-mixed-uninlined-format-args` diff --git a/tests/ui-toml/too_large_for_stack/boxed_local.stderr b/tests/ui-toml/too_large_for_stack/boxed_local.stderr index 2898d0d02f788..5271a172807ed 100644 --- a/tests/ui-toml/too_large_for_stack/boxed_local.stderr +++ b/tests/ui-toml/too_large_for_stack/boxed_local.stderr @@ -1,5 +1,5 @@ error: local variable doesn't need to be boxed here - --> $DIR/too_large_for_stack/boxed_local.rs:1:6 + --> tests/ui-toml/too_large_for_stack/boxed_local.rs:1:6 | LL | fn f(x: Box<[u8; 500]>) {} | ^ diff --git a/tests/ui-toml/too_large_for_stack/useless_vec.stderr b/tests/ui-toml/too_large_for_stack/useless_vec.stderr index 00823f3623651..90c5cdb8aa711 100644 --- a/tests/ui-toml/too_large_for_stack/useless_vec.stderr +++ b/tests/ui-toml/too_large_for_stack/useless_vec.stderr @@ -1,5 +1,5 @@ error: useless use of `vec!` - --> $DIR/too_large_for_stack/useless_vec.rs:4:13 + --> tests/ui-toml/too_large_for_stack/useless_vec.rs:4:13 | LL | let x = vec![0u8; 500]; | ^^^^^^^^^^^^^^ help: you can use an array directly: `[0u8; 500]` diff --git a/tests/ui-toml/too_many_arguments/too_many_arguments.stderr b/tests/ui-toml/too_many_arguments/too_many_arguments.stderr index fb6fbef7c5c78..b32129432242d 100644 --- a/tests/ui-toml/too_many_arguments/too_many_arguments.stderr +++ b/tests/ui-toml/too_many_arguments/too_many_arguments.stderr @@ -1,5 +1,5 @@ error: this function has too many arguments (11/10) - --> $DIR/too_many_arguments/too_many_arguments.rs:4:1 + --> tests/ui-toml/too_many_arguments/too_many_arguments.rs:4:1 | LL | fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/type_complexity/type_complexity.stderr b/tests/ui-toml/type_complexity/type_complexity.stderr index 155ea6684ea49..6f099cb7cbf1b 100644 --- a/tests/ui-toml/type_complexity/type_complexity.stderr +++ b/tests/ui-toml/type_complexity/type_complexity.stderr @@ -1,5 +1,5 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity/type_complexity.rs:4:10 + --> tests/ui-toml/type_complexity/type_complexity.rs:4:10 | LL | fn f2(_: (u8, (u8, (u8, (u8, (u8, (u8, u8))))))) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/type_repetition_in_bounds/main.stderr b/tests/ui-toml/type_repetition_in_bounds/main.stderr index bab98d45a72b5..6005f76b94be8 100644 --- a/tests/ui-toml/type_repetition_in_bounds/main.stderr +++ b/tests/ui-toml/type_repetition_in_bounds/main.stderr @@ -1,5 +1,5 @@ error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds/main.rs:13:5 + --> tests/ui-toml/type_repetition_in_bounds/main.rs:13:5 | LL | T: Unpin + PartialEq, | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr index 7fecb7f37dc1d..87f84d8f7dd41 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:266:19 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:266:19 | LL | /* Safety: */ unsafe {} | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | /* Safety: */ unsafe {} = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:5 | LL | unsafe {} | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:14 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:29 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:29 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:48 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:48 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:18 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:18 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:37 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:37 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:14 | LL | let _ = *unsafe { &42 }; | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = *unsafe { &42 }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:19 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:19 | LL | let _ = match unsafe {} { | ^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = match unsafe {} { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:293:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:293:14 | LL | let _ = &unsafe {}; | ^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = &unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14 | LL | let _ = [unsafe {}; 5]; | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = [unsafe {}; 5]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:13 | LL | let _ = unsafe {}; | ^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _ = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:311:8 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:311:8 | LL | t!(unsafe {}); | ^^^^^^^^^ @@ -105,7 +105,7 @@ LL | t!(unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:317:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:317:13 | LL | unsafe {} | ^^^^^^^^^ @@ -117,7 +117,7 @@ LL | t!(); = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:325:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:325:5 | LL | unsafe {} // SAFETY: | ^^^^^^^^^ @@ -125,7 +125,7 @@ LL | unsafe {} // SAFETY: = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5 | LL | unsafe { | ^^^^^^^^ @@ -133,7 +133,7 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:339:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:339:5 | LL | unsafe {}; | ^^^^^^^^^ @@ -141,7 +141,7 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:20 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:20 | LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:350:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:350:5 | LL | unsafe impl A for () {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | unsafe impl A for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:357:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:357:9 | LL | unsafe impl B for (u32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | unsafe impl B for (u32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:378:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:378:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:411:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:411:5 | LL | unsafe impl T for (i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -197,7 +197,7 @@ LL | unsafe impl T for (i32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL | no_safety_comment!(u32); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:417:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:417:5 | LL | unsafe impl T for (bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | unsafe impl T for (bool) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:463:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:463:5 | LL | unsafe impl NoComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | unsafe impl NoComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:19 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:19 | LL | /* SAFETY: */ unsafe impl InlineComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:5 | LL | unsafe impl TrailingComment for () {} // SAFETY: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,13 +241,13 @@ LL | unsafe impl TrailingComment for () {} // SAFETY: = help: consider adding a safety comment on the preceding line error: constant item has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5 | LL | const BIG_NUMBER: i32 = 1000000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:474:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:474:5 | LL | // SAFETY: | ^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | // SAFETY: = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5 | LL | unsafe impl Interference for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | unsafe impl Interference for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:483:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:483:5 | LL | unsafe impl ImplInFn for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | unsafe impl ImplInFn for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:492:1 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:492:1 | LL | unsafe impl CrateRoot for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | unsafe impl CrateRoot for () {} = help: consider adding a safety comment on the preceding line error: statement has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:505:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:505:5 | LL | / let _ = { LL | | if unsafe { true } { @@ -291,13 +291,13 @@ LL | | }; | |______^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:504:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:504:5 | LL | // SAFETY: this is more than one level away, so it should warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:12 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:12 | LL | if unsafe { true } { | ^^^^^^^^^^^^^^^ @@ -305,7 +305,7 @@ LL | if unsafe { true } { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:23 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:23 | LL | let bar = unsafe {}; | ^^^^^^^^^ diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr index 03322de8be078..5ffe73f5a2f16 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:266:19 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:266:19 | LL | /* Safety: */ unsafe {} | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | /* Safety: */ unsafe {} = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:5 | LL | unsafe {} | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:14 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:29 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:29 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:48 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:48 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:18 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:18 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:37 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:37 | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:14 | LL | let _ = *unsafe { &42 }; | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = *unsafe { &42 }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:19 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:19 | LL | let _ = match unsafe {} { | ^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = match unsafe {} { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:293:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:293:14 | LL | let _ = &unsafe {}; | ^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = &unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14 | LL | let _ = [unsafe {}; 5]; | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = [unsafe {}; 5]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:13 | LL | let _ = unsafe {}; | ^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _ = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:311:8 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:311:8 | LL | t!(unsafe {}); | ^^^^^^^^^ @@ -105,7 +105,7 @@ LL | t!(unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:317:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:317:13 | LL | unsafe {} | ^^^^^^^^^ @@ -117,7 +117,7 @@ LL | t!(); = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:325:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:325:5 | LL | unsafe {} // SAFETY: | ^^^^^^^^^ @@ -125,7 +125,7 @@ LL | unsafe {} // SAFETY: = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5 | LL | unsafe { | ^^^^^^^^ @@ -133,7 +133,7 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:339:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:339:5 | LL | unsafe {}; | ^^^^^^^^^ @@ -141,7 +141,7 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:20 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:20 | LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:350:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:350:5 | LL | unsafe impl A for () {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | unsafe impl A for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:357:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:357:9 | LL | unsafe impl B for (u32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | unsafe impl B for (u32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:378:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:378:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:411:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:411:5 | LL | unsafe impl T for (i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -197,7 +197,7 @@ LL | unsafe impl T for (i32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:403:13 | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL | no_safety_comment!(u32); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:417:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:417:5 | LL | unsafe impl T for (bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | unsafe impl T for (bool) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:463:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:463:5 | LL | unsafe impl NoComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | unsafe impl NoComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:19 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:19 | LL | /* SAFETY: */ unsafe impl InlineComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:5 | LL | unsafe impl TrailingComment for () {} // SAFETY: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,13 +241,13 @@ LL | unsafe impl TrailingComment for () {} // SAFETY: = help: consider adding a safety comment on the preceding line error: constant item has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5 | LL | const BIG_NUMBER: i32 = 1000000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:474:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:474:5 | LL | // SAFETY: | ^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | // SAFETY: = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5 | LL | unsafe impl Interference for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | unsafe impl Interference for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:483:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:483:5 | LL | unsafe impl ImplInFn for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | unsafe impl ImplInFn for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:492:1 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:492:1 | LL | unsafe impl CrateRoot for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | unsafe impl CrateRoot for () {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:502:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:502:9 | LL | unsafe {}; | ^^^^^^^^^ @@ -287,7 +287,7 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: statement has unnecessary safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:505:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:505:5 | LL | / let _ = { LL | | if unsafe { true } { @@ -299,13 +299,13 @@ LL | | }; | |______^ | help: consider removing the safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:504:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:504:5 | LL | // SAFETY: this is more than one level away, so it should warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:12 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:12 | LL | if unsafe { true } { | ^^^^^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL | if unsafe { true } { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:23 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:23 | LL | let bar = unsafe {}; | ^^^^^^^^^ @@ -321,7 +321,7 @@ LL | let bar = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:527:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:527:9 | LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:531:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:531:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:535:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:535:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -345,7 +345,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:541:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:541:5 | LL | unsafe {} | ^^^^^^^^^ @@ -353,7 +353,7 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:545:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:545:5 | LL | unsafe { | ^^^^^^^^ @@ -361,7 +361,7 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:552:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:552:9 | LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -369,7 +369,7 @@ LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:557:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:557:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -377,7 +377,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:563:9 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:563:9 | LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment - --> $DIR/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:568:5 + --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:568:5 | LL | unsafe {} | ^^^^^^^^^ diff --git a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr index 2ee7dd2ea8ed7..f10b486464884 100644 --- a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr +++ b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr @@ -1,5 +1,5 @@ error: boxed return of the sized type `[u8; 64]` - --> $DIR/unnecessary_box_returns/unnecessary_box_returns.rs:3:11 + --> tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.rs:3:11 | LL | fn f() -> Box<[u8; 64]> { | ^^^^^^^^^^^^^ help: try: `[u8; 64]` diff --git a/tests/ui-toml/unwrap_used/unwrap_used.stderr b/tests/ui-toml/unwrap_used/unwrap_used.stderr index 964ace5cf987e..41d5afd3efeca 100644 --- a/tests/ui-toml/unwrap_used/unwrap_used.stderr +++ b/tests/ui-toml/unwrap_used/unwrap_used.stderr @@ -1,5 +1,5 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:38:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:38:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` @@ -8,7 +8,7 @@ LL | let _ = boxed_slice.get(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::get_unwrap)]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:38:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:38:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,13 +19,13 @@ LL | let _ = boxed_slice.get(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:39:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:39:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:39:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:39:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,13 +34,13 @@ LL | let _ = some_slice.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:40:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:40:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:40:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:40:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,13 +49,13 @@ LL | let _ = some_vec.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:41:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:41:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:41:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:41:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,13 +64,13 @@ LL | let _ = some_vecdeque.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:42:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:42:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_hashmap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:42:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:42:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,13 +79,13 @@ LL | let _ = some_hashmap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:43:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:43:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_btreemap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:43:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:43:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,13 +94,13 @@ LL | let _ = some_btreemap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:47:21 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:47:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:47:22 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:47:22 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,13 +109,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:52:9 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:52:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:52:10 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:52:10 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,13 +124,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:53:9 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:53:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:53:10 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:53:10 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:54:9 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:54:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:54:10 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:54:10 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,13 +154,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:55:9 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:55:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:55:10 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:55:10 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -169,13 +169,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:67:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:67:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:67:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:67:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -184,13 +184,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:68:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:68:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_used/unwrap_used.rs:68:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:68:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,13 +199,13 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:75:13 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:75:13 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/unwrap_used/unwrap_used.rs:93:17 + --> tests/ui-toml/unwrap_used/unwrap_used.rs:93:17 | LL | let _ = Box::new([0]).get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&Box::new([0])[1]` diff --git a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr index b7bf06850388a..88917603ff8ce 100644 --- a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr +++ b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr @@ -1,5 +1,5 @@ error: name `HTTPResponse` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:3:8 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:3:8 | LL | struct HTTPResponse; // not linted by default, but with cfg option | ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse` @@ -8,73 +8,73 @@ LL | struct HTTPResponse; // not linted by default, but with cfg option = help: to override `-D warnings` add `#[allow(clippy::upper_case_acronyms)]` error: name `NS` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:8:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:8:5 | LL | NS, // not linted | ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns` error: name `CWR` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:9:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:9:5 | LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` error: name `ECE` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:10:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:10:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` error: name `URG` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:11:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:11:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` error: name `ACK` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:12:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:12:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` error: name `PSH` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:13:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:13:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` error: name `RST` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:14:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:14:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` error: name `SYN` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:15:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:15:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` error: name `FIN` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:16:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:16:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` error: name `GCCLLVMSomething` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:21:8 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:21:8 | LL | struct GCCLLVMSomething; | ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething` error: name `WASD` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:38:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:38:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` error: name `WASDMixed` contains a capitalized acronym - --> $DIR/upper_case_acronyms_aggressive/upper_case_acronyms.rs:39:5 + --> tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs:39:5 | LL | WASDMixed(String), | ^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `WasdMixed` diff --git a/tests/ui-toml/vec_box_sized/test.stderr b/tests/ui-toml/vec_box_sized/test.stderr index c27d8b1df7b70..8c0750d866639 100644 --- a/tests/ui-toml/vec_box_sized/test.stderr +++ b/tests/ui-toml/vec_box_sized/test.stderr @@ -1,5 +1,5 @@ error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized/test.rs:9:12 + --> tests/ui-toml/vec_box_sized/test.rs:9:12 | LL | struct Foo(Vec>); | ^^^^^^^^^^^^ help: try: `Vec` @@ -8,13 +8,13 @@ LL | struct Foo(Vec>); = help: to override `-D warnings` add `#[allow(clippy::vec_box)]` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized/test.rs:10:12 + --> tests/ui-toml/vec_box_sized/test.rs:10:12 | LL | struct Bar(Vec>); | ^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized/test.rs:14:18 + --> tests/ui-toml/vec_box_sized/test.rs:14:18 | LL | struct FooBarBaz(Vec>); | ^^^^^^^^^^^ help: try: `Vec` diff --git a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr index cb9cfbf70c743..64500b858001e 100644 --- a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr +++ b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr @@ -1,5 +1,5 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/verbose_bit_mask/verbose_bit_mask.rs:5:13 + --> tests/ui-toml/verbose_bit_mask/verbose_bit_mask.rs:5:13 | LL | let _ = v & 0b111111 == 0; | ^^^^^^^^^^^^^^^^^ help: try: `v.trailing_zeros() >= 6` diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr index 731964cb8064e..3d3be965aa411 100644 --- a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports/wildcard_imports.rs:18:5 + --> tests/ui-toml/wildcard_imports/wildcard_imports.rs:18:5 | LL | use utils::*; | ^^^^^^^^ help: try: `utils::{BAR, print}` @@ -8,13 +8,13 @@ LL | use utils::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports/wildcard_imports.rs:20:5 + --> tests/ui-toml/wildcard_imports/wildcard_imports.rs:20:5 | LL | use my_crate::utils::*; | ^^^^^^^^^^^^^^^^^^ help: try: `my_crate::utils::my_util_fn` error: usage of wildcard import - --> $DIR/wildcard_imports/wildcard_imports.rs:22:5 + --> tests/ui-toml/wildcard_imports/wildcard_imports.rs:22:5 | LL | use prelude::*; | ^^^^^^^^^^ help: try: `prelude::FOO` diff --git a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr index de768260b7c1b..962337a73bdff 100644 --- a/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr +++ b/tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports_whitelist/wildcard_imports.rs:19:5 + --> tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.rs:19:5 | LL | use utils_plus::*; | ^^^^^^^^^^^^^ help: try: `utils_plus::do_something` diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 64d38e60dc63b..f98114c0000a6 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,5 +1,5 @@ error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:14:5 + --> tests/ui/absurd-extreme-comparisons.rs:14:5 | LL | u <= 0; | ^^^^^^ @@ -9,7 +9,7 @@ LL | u <= 0; = help: to override `-D warnings` add `#[allow(clippy::absurd_extreme_comparisons)]` error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:16:5 + --> tests/ui/absurd-extreme-comparisons.rs:16:5 | LL | u <= Z; | ^^^^^^ @@ -17,7 +17,7 @@ LL | u <= Z; = help: because `Z` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `u == Z` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:18:5 + --> tests/ui/absurd-extreme-comparisons.rs:18:5 | LL | u < Z; | ^^^^^ @@ -25,7 +25,7 @@ LL | u < Z; = help: because `Z` is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:20:5 + --> tests/ui/absurd-extreme-comparisons.rs:20:5 | LL | Z >= u; | ^^^^^^ @@ -33,7 +33,7 @@ LL | Z >= u; = help: because `Z` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `Z == u` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:22:5 + --> tests/ui/absurd-extreme-comparisons.rs:22:5 | LL | Z > u; | ^^^^^ @@ -41,7 +41,7 @@ LL | Z > u; = help: because `Z` is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:24:5 + --> tests/ui/absurd-extreme-comparisons.rs:24:5 | LL | u > u32::MAX; | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | u > u32::MAX; = help: because `u32::MAX` is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:26:5 + --> tests/ui/absurd-extreme-comparisons.rs:26:5 | LL | u >= u32::MAX; | ^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | u >= u32::MAX; = help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == u32::MAX` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:28:5 + --> tests/ui/absurd-extreme-comparisons.rs:28:5 | LL | u32::MAX < u; | ^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | u32::MAX < u; = help: because `u32::MAX` is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:30:5 + --> tests/ui/absurd-extreme-comparisons.rs:30:5 | LL | u32::MAX <= u; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | u32::MAX <= u; = help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u32::MAX == u` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:32:5 + --> tests/ui/absurd-extreme-comparisons.rs:32:5 | LL | 1-1 > u; | ^^^^^^^ @@ -81,7 +81,7 @@ LL | 1-1 > u; = help: because `1-1` is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:34:5 + --> tests/ui/absurd-extreme-comparisons.rs:34:5 | LL | u >= !0; | ^^^^^^^ @@ -89,7 +89,7 @@ LL | u >= !0; = help: because `!0` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == !0` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:36:5 + --> tests/ui/absurd-extreme-comparisons.rs:36:5 | LL | u <= 12 - 2*6; | ^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | u <= 12 - 2*6; = help: because `12 - 2*6` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `u == 12 - 2*6` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:39:5 + --> tests/ui/absurd-extreme-comparisons.rs:39:5 | LL | i < -127 - 1; | ^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | i < -127 - 1; = help: because `-127 - 1` is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:41:5 + --> tests/ui/absurd-extreme-comparisons.rs:41:5 | LL | i8::MAX >= i; | ^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | i8::MAX >= i; = help: because `i8::MAX` is the maximum value for this type, this comparison is always true error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:43:5 + --> tests/ui/absurd-extreme-comparisons.rs:43:5 | LL | 3-7 < i32::MIN; | ^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | 3-7 < i32::MIN; = help: because `i32::MIN` is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:46:5 + --> tests/ui/absurd-extreme-comparisons.rs:46:5 | LL | b >= true; | ^^^^^^^^^ @@ -129,7 +129,7 @@ LL | b >= true; = help: because `true` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `b == true` instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:48:5 + --> tests/ui/absurd-extreme-comparisons.rs:48:5 | LL | false > b; | ^^^^^^^^^ @@ -137,7 +137,7 @@ LL | false > b; = help: because `false` is the minimum value for this type, this comparison is always false error: <-comparison of unit values detected. This will always be false - --> $DIR/absurd-extreme-comparisons.rs:52:5 + --> tests/ui/absurd-extreme-comparisons.rs:52:5 | LL | () < {}; | ^^^^^^^ diff --git a/tests/ui/allow_attributes.stderr b/tests/ui/allow_attributes.stderr index 7ac0bd456847a..9c99e88c796a5 100644 --- a/tests/ui/allow_attributes.stderr +++ b/tests/ui/allow_attributes.stderr @@ -1,5 +1,5 @@ error: #[allow] attribute found - --> $DIR/allow_attributes.rs:13:3 + --> tests/ui/allow_attributes.rs:13:3 | LL | #[allow(dead_code)] | ^^^^^ help: replace it with: `expect` @@ -8,7 +8,7 @@ LL | #[allow(dead_code)] = help: to override `-D warnings` add `#[allow(clippy::allow_attributes)]` error: #[allow] attribute found - --> $DIR/allow_attributes.rs:22:30 + --> tests/ui/allow_attributes.rs:22:30 | LL | #[cfg_attr(panic = "unwind", allow(dead_code))] | ^^^^^ help: replace it with: `expect` diff --git a/tests/ui/allow_attributes_without_reason.stderr b/tests/ui/allow_attributes_without_reason.stderr index 96f747d0026df..3c81233bf7777 100644 --- a/tests/ui/allow_attributes_without_reason.stderr +++ b/tests/ui/allow_attributes_without_reason.stderr @@ -1,18 +1,18 @@ error: `allow` attribute without specifying a reason - --> $DIR/allow_attributes_without_reason.rs:4:1 + --> tests/ui/allow_attributes_without_reason.rs:4:1 | LL | #![allow(unfulfilled_lint_expectations)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try adding a reason at the end with `, reason = ".."` note: the lint level is defined here - --> $DIR/allow_attributes_without_reason.rs:3:9 + --> tests/ui/allow_attributes_without_reason.rs:3:9 | LL | #![deny(clippy::allow_attributes_without_reason)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `allow` attribute without specifying a reason - --> $DIR/allow_attributes_without_reason.rs:10:1 + --> tests/ui/allow_attributes_without_reason.rs:10:1 | LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | #[allow(dead_code)] = help: try adding a reason at the end with `, reason = ".."` error: `allow` attribute without specifying a reason - --> $DIR/allow_attributes_without_reason.rs:11:1 + --> tests/ui/allow_attributes_without_reason.rs:11:1 | LL | #[allow(dead_code, deprecated)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | #[allow(dead_code, deprecated)] = help: try adding a reason at the end with `, reason = ".."` error: `expect` attribute without specifying a reason - --> $DIR/allow_attributes_without_reason.rs:12:1 + --> tests/ui/allow_attributes_without_reason.rs:12:1 | LL | #[expect(dead_code)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/almost_complete_range.stderr b/tests/ui/almost_complete_range.stderr index 054a02c9c9021..0195e59226d51 100644 --- a/tests/ui/almost_complete_range.stderr +++ b/tests/ui/almost_complete_range.stderr @@ -1,5 +1,5 @@ error: almost complete ascii range - --> $DIR/almost_complete_range.rs:18:17 + --> tests/ui/almost_complete_range.rs:18:17 | LL | let _ = ('a') ..'z'; | ^^^^^^--^^^ @@ -10,7 +10,7 @@ LL | let _ = ('a') ..'z'; = help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:19:17 + --> tests/ui/almost_complete_range.rs:19:17 | LL | let _ = 'A' .. ('Z'); | ^^^^--^^^^^^ @@ -18,7 +18,7 @@ LL | let _ = 'A' .. ('Z'); | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:20:17 + --> tests/ui/almost_complete_range.rs:20:17 | LL | let _ = ((('0'))) .. ('9'); | ^^^^^^^^^^--^^^^^^ @@ -26,7 +26,7 @@ LL | let _ = ((('0'))) .. ('9'); | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:27:13 + --> tests/ui/almost_complete_range.rs:27:13 | LL | let _ = (b'a')..(b'z'); | ^^^^^^--^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = (b'a')..(b'z'); | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:28:13 + --> tests/ui/almost_complete_range.rs:28:13 | LL | let _ = b'A'..b'Z'; | ^^^^--^^^^ @@ -42,7 +42,7 @@ LL | let _ = b'A'..b'Z'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:29:13 + --> tests/ui/almost_complete_range.rs:29:13 | LL | let _ = b'0'..b'9'; | ^^^^--^^^^ @@ -50,7 +50,7 @@ LL | let _ = b'0'..b'9'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:35:13 + --> tests/ui/almost_complete_range.rs:35:13 | LL | let _ = inline!('a')..'z'; | ^^^^^^^^^^^^--^^^ @@ -58,7 +58,7 @@ LL | let _ = inline!('a')..'z'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:36:13 + --> tests/ui/almost_complete_range.rs:36:13 | LL | let _ = inline!('A')..'Z'; | ^^^^^^^^^^^^--^^^ @@ -66,7 +66,7 @@ LL | let _ = inline!('A')..'Z'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:37:13 + --> tests/ui/almost_complete_range.rs:37:13 | LL | let _ = inline!('0')..'9'; | ^^^^^^^^^^^^--^^^ @@ -74,7 +74,7 @@ LL | let _ = inline!('0')..'9'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:40:9 + --> tests/ui/almost_complete_range.rs:40:9 | LL | b'a'..b'z' if true => 1, | ^^^^--^^^^ @@ -82,7 +82,7 @@ LL | b'a'..b'z' if true => 1, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:41:9 + --> tests/ui/almost_complete_range.rs:41:9 | LL | b'A'..b'Z' if true => 2, | ^^^^--^^^^ @@ -90,7 +90,7 @@ LL | b'A'..b'Z' if true => 2, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:42:9 + --> tests/ui/almost_complete_range.rs:42:9 | LL | b'0'..b'9' if true => 3, | ^^^^--^^^^ @@ -98,7 +98,7 @@ LL | b'0'..b'9' if true => 3, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:50:9 + --> tests/ui/almost_complete_range.rs:50:9 | LL | 'a'..'z' if true => 1, | ^^^--^^^ @@ -106,7 +106,7 @@ LL | 'a'..'z' if true => 1, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:51:9 + --> tests/ui/almost_complete_range.rs:51:9 | LL | 'A'..'Z' if true => 2, | ^^^--^^^ @@ -114,7 +114,7 @@ LL | 'A'..'Z' if true => 2, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:52:9 + --> tests/ui/almost_complete_range.rs:52:9 | LL | '0'..'9' if true => 3, | ^^^--^^^ @@ -122,7 +122,7 @@ LL | '0'..'9' if true => 3, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:65:17 + --> tests/ui/almost_complete_range.rs:65:17 | LL | let _ = 'a'..'z'; | ^^^--^^^ @@ -132,7 +132,7 @@ LL | let _ = 'a'..'z'; = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: almost complete ascii range - --> $DIR/almost_complete_range.rs:66:17 + --> tests/ui/almost_complete_range.rs:66:17 | LL | let _ = 'A'..'Z'; | ^^^--^^^ @@ -142,7 +142,7 @@ LL | let _ = 'A'..'Z'; = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: almost complete ascii range - --> $DIR/almost_complete_range.rs:67:17 + --> tests/ui/almost_complete_range.rs:67:17 | LL | let _ = '0'..'9'; | ^^^--^^^ @@ -152,7 +152,7 @@ LL | let _ = '0'..'9'; = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: almost complete ascii range - --> $DIR/almost_complete_range.rs:74:9 + --> tests/ui/almost_complete_range.rs:74:9 | LL | 'a'..'z' => 1, | ^^^--^^^ @@ -160,7 +160,7 @@ LL | 'a'..'z' => 1, | help: use an inclusive range: `...` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:75:9 + --> tests/ui/almost_complete_range.rs:75:9 | LL | 'A'..'Z' => 2, | ^^^--^^^ @@ -168,7 +168,7 @@ LL | 'A'..'Z' => 2, | help: use an inclusive range: `...` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:76:9 + --> tests/ui/almost_complete_range.rs:76:9 | LL | '0'..'9' => 3, | ^^^--^^^ @@ -176,7 +176,7 @@ LL | '0'..'9' => 3, | help: use an inclusive range: `...` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:83:13 + --> tests/ui/almost_complete_range.rs:83:13 | LL | let _ = 'a'..'z'; | ^^^--^^^ @@ -184,7 +184,7 @@ LL | let _ = 'a'..'z'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:84:13 + --> tests/ui/almost_complete_range.rs:84:13 | LL | let _ = 'A'..'Z'; | ^^^--^^^ @@ -192,7 +192,7 @@ LL | let _ = 'A'..'Z'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:85:13 + --> tests/ui/almost_complete_range.rs:85:13 | LL | let _ = '0'..'9'; | ^^^--^^^ @@ -200,7 +200,7 @@ LL | let _ = '0'..'9'; | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:87:9 + --> tests/ui/almost_complete_range.rs:87:9 | LL | 'a'..'z' => 1, | ^^^--^^^ @@ -208,7 +208,7 @@ LL | 'a'..'z' => 1, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:88:9 + --> tests/ui/almost_complete_range.rs:88:9 | LL | 'A'..'Z' => 1, | ^^^--^^^ @@ -216,7 +216,7 @@ LL | 'A'..'Z' => 1, | help: use an inclusive range: `..=` error: almost complete ascii range - --> $DIR/almost_complete_range.rs:89:9 + --> tests/ui/almost_complete_range.rs:89:9 | LL | '0'..'9' => 3, | ^^^--^^^ diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index cb530eaf734a2..5e82d51edf208 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::E` found - --> $DIR/approx_const.rs:3:16 + --> tests/ui/approx_const.rs:3:16 | LL | let my_e = 2.7182; | ^^^^^^ @@ -9,7 +9,7 @@ LL | let my_e = 2.7182; = help: to override `-D warnings` add `#[allow(clippy::approx_constant)]` error: approximate value of `f{32, 64}::consts::E` found - --> $DIR/approx_const.rs:5:20 + --> tests/ui/approx_const.rs:5:20 | LL | let almost_e = 2.718; | ^^^^^ @@ -17,7 +17,7 @@ LL | let almost_e = 2.718; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found - --> $DIR/approx_const.rs:9:24 + --> tests/ui/approx_const.rs:9:24 | LL | let my_1_frac_pi = 0.3183; | ^^^^^^ @@ -25,7 +25,7 @@ LL | let my_1_frac_pi = 0.3183; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found - --> $DIR/approx_const.rs:13:28 + --> tests/ui/approx_const.rs:13:28 | LL | let my_frac_1_sqrt_2 = 0.70710678; | ^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let my_frac_1_sqrt_2 = 0.70710678; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found - --> $DIR/approx_const.rs:15:32 + --> tests/ui/approx_const.rs:15:32 | LL | let almost_frac_1_sqrt_2 = 0.70711; | ^^^^^^^ @@ -41,7 +41,7 @@ LL | let almost_frac_1_sqrt_2 = 0.70711; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found - --> $DIR/approx_const.rs:19:24 + --> tests/ui/approx_const.rs:19:24 | LL | let my_frac_2_pi = 0.63661977; | ^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let my_frac_2_pi = 0.63661977; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found - --> $DIR/approx_const.rs:23:27 + --> tests/ui/approx_const.rs:23:27 | LL | let my_frac_2_sq_pi = 1.128379; | ^^^^^^^^ @@ -57,7 +57,7 @@ LL | let my_frac_2_sq_pi = 1.128379; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found - --> $DIR/approx_const.rs:27:24 + --> tests/ui/approx_const.rs:27:24 | LL | let my_frac_pi_2 = 1.57079632679; | ^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let my_frac_pi_2 = 1.57079632679; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found - --> $DIR/approx_const.rs:31:24 + --> tests/ui/approx_const.rs:31:24 | LL | let my_frac_pi_3 = 1.04719755119; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let my_frac_pi_3 = 1.04719755119; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found - --> $DIR/approx_const.rs:35:24 + --> tests/ui/approx_const.rs:35:24 | LL | let my_frac_pi_4 = 0.785398163397; | ^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let my_frac_pi_4 = 0.785398163397; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found - --> $DIR/approx_const.rs:39:24 + --> tests/ui/approx_const.rs:39:24 | LL | let my_frac_pi_6 = 0.523598775598; | ^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let my_frac_pi_6 = 0.523598775598; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found - --> $DIR/approx_const.rs:43:24 + --> tests/ui/approx_const.rs:43:24 | LL | let my_frac_pi_8 = 0.3926990816987; | ^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let my_frac_pi_8 = 0.3926990816987; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LN_10` found - --> $DIR/approx_const.rs:47:20 + --> tests/ui/approx_const.rs:47:20 | LL | let my_ln_10 = 2.302585092994046; | ^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | let my_ln_10 = 2.302585092994046; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LN_2` found - --> $DIR/approx_const.rs:51:19 + --> tests/ui/approx_const.rs:51:19 | LL | let my_ln_2 = 0.6931471805599453; | ^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | let my_ln_2 = 0.6931471805599453; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG10_E` found - --> $DIR/approx_const.rs:55:22 + --> tests/ui/approx_const.rs:55:22 | LL | let my_log10_e = 0.4342944819032518; | ^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | let my_log10_e = 0.4342944819032518; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_E` found - --> $DIR/approx_const.rs:59:21 + --> tests/ui/approx_const.rs:59:21 | LL | let my_log2_e = 1.4426950408889634; | ^^^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | let my_log2_e = 1.4426950408889634; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/approx_const.rs:63:19 + --> tests/ui/approx_const.rs:63:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG10_2` found - --> $DIR/approx_const.rs:67:19 + --> tests/ui/approx_const.rs:67:19 | LL | let log10_2 = 0.301029995663981; | ^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | let log10_2 = 0.301029995663981; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::PI` found - --> $DIR/approx_const.rs:71:17 + --> tests/ui/approx_const.rs:71:17 | LL | let my_pi = 3.1415; | ^^^^^^ @@ -153,7 +153,7 @@ LL | let my_pi = 3.1415; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::PI` found - --> $DIR/approx_const.rs:73:21 + --> tests/ui/approx_const.rs:73:21 | LL | let almost_pi = 3.14; | ^^^^ @@ -161,7 +161,7 @@ LL | let almost_pi = 3.14; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::SQRT_2` found - --> $DIR/approx_const.rs:77:18 + --> tests/ui/approx_const.rs:77:18 | LL | let my_sq2 = 1.4142; | ^^^^^^ @@ -169,7 +169,7 @@ LL | let my_sq2 = 1.4142; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::TAU` found - --> $DIR/approx_const.rs:81:18 + --> tests/ui/approx_const.rs:81:18 | LL | let my_tau = 6.2832; | ^^^^^^ @@ -177,7 +177,7 @@ LL | let my_tau = 6.2832; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::TAU` found - --> $DIR/approx_const.rs:83:22 + --> tests/ui/approx_const.rs:83:22 | LL | let almost_tau = 6.28; | ^^^^ diff --git a/tests/ui/arc_with_non_send_sync.stderr b/tests/ui/arc_with_non_send_sync.stderr index a7f91abda4ebd..d4e6303762042 100644 --- a/tests/ui/arc_with_non_send_sync.stderr +++ b/tests/ui/arc_with_non_send_sync.stderr @@ -1,5 +1,5 @@ error: usage of an `Arc` that is not `Send` and `Sync` - --> $DIR/arc_with_non_send_sync.rs:35:13 + --> tests/ui/arc_with_non_send_sync.rs:35:13 | LL | let _ = Arc::new(RefCell::new(42)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | let _ = Arc::new(RefCell::new(42)); = help: to override `-D warnings` add `#[allow(clippy::arc_with_non_send_sync)]` error: usage of an `Arc` that is not `Send` and `Sync` - --> $DIR/arc_with_non_send_sync.rs:40:13 + --> tests/ui/arc_with_non_send_sync.rs:40:13 | LL | let _ = Arc::new(mutex.lock().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = Arc::new(mutex.lock().unwrap()); = note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `MutexGuard<'_, i32>` error: usage of an `Arc` that is not `Send` and `Sync` - --> $DIR/arc_with_non_send_sync.rs:44:13 + --> tests/ui/arc_with_non_send_sync.rs:44:13 | LL | let _ = Arc::new(&42 as *const i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/arithmetic_side_effects.stderr b/tests/ui/arithmetic_side_effects.stderr index 13729a6c5a334..741c892a52cfc 100644 --- a/tests/ui/arithmetic_side_effects.stderr +++ b/tests/ui/arithmetic_side_effects.stderr @@ -1,5 +1,5 @@ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:304:5 + --> tests/ui/arithmetic_side_effects.rs:304:5 | LL | _n += 1; | ^^^^^^^ @@ -8,709 +8,709 @@ LL | _n += 1; = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:305:5 + --> tests/ui/arithmetic_side_effects.rs:305:5 | LL | _n += &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:306:5 + --> tests/ui/arithmetic_side_effects.rs:306:5 | LL | _n -= 1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:307:5 + --> tests/ui/arithmetic_side_effects.rs:307:5 | LL | _n -= &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:308:5 + --> tests/ui/arithmetic_side_effects.rs:308:5 | LL | _n /= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:309:5 + --> tests/ui/arithmetic_side_effects.rs:309:5 | LL | _n /= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:310:5 + --> tests/ui/arithmetic_side_effects.rs:310:5 | LL | _n %= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:311:5 + --> tests/ui/arithmetic_side_effects.rs:311:5 | LL | _n %= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:312:5 + --> tests/ui/arithmetic_side_effects.rs:312:5 | LL | _n *= 2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:313:5 + --> tests/ui/arithmetic_side_effects.rs:313:5 | LL | _n *= &2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:314:5 + --> tests/ui/arithmetic_side_effects.rs:314:5 | LL | _n += -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:315:5 + --> tests/ui/arithmetic_side_effects.rs:315:5 | LL | _n += &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:316:5 + --> tests/ui/arithmetic_side_effects.rs:316:5 | LL | _n -= -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:317:5 + --> tests/ui/arithmetic_side_effects.rs:317:5 | LL | _n -= &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:318:5 + --> tests/ui/arithmetic_side_effects.rs:318:5 | LL | _n /= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:319:5 + --> tests/ui/arithmetic_side_effects.rs:319:5 | LL | _n /= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:320:5 + --> tests/ui/arithmetic_side_effects.rs:320:5 | LL | _n %= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:321:5 + --> tests/ui/arithmetic_side_effects.rs:321:5 | LL | _n %= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:322:5 + --> tests/ui/arithmetic_side_effects.rs:322:5 | LL | _n *= -2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:323:5 + --> tests/ui/arithmetic_side_effects.rs:323:5 | LL | _n *= &-2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:324:5 + --> tests/ui/arithmetic_side_effects.rs:324:5 | LL | _custom += Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:325:5 + --> tests/ui/arithmetic_side_effects.rs:325:5 | LL | _custom += &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:326:5 + --> tests/ui/arithmetic_side_effects.rs:326:5 | LL | _custom -= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:327:5 + --> tests/ui/arithmetic_side_effects.rs:327:5 | LL | _custom -= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:328:5 + --> tests/ui/arithmetic_side_effects.rs:328:5 | LL | _custom /= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:329:5 + --> tests/ui/arithmetic_side_effects.rs:329:5 | LL | _custom /= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:330:5 + --> tests/ui/arithmetic_side_effects.rs:330:5 | LL | _custom %= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:331:5 + --> tests/ui/arithmetic_side_effects.rs:331:5 | LL | _custom %= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:332:5 + --> tests/ui/arithmetic_side_effects.rs:332:5 | LL | _custom *= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:333:5 + --> tests/ui/arithmetic_side_effects.rs:333:5 | LL | _custom *= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:334:5 + --> tests/ui/arithmetic_side_effects.rs:334:5 | LL | _custom >>= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:335:5 + --> tests/ui/arithmetic_side_effects.rs:335:5 | LL | _custom >>= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:336:5 + --> tests/ui/arithmetic_side_effects.rs:336:5 | LL | _custom <<= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:337:5 + --> tests/ui/arithmetic_side_effects.rs:337:5 | LL | _custom <<= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:338:5 + --> tests/ui/arithmetic_side_effects.rs:338:5 | LL | _custom += -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:339:5 + --> tests/ui/arithmetic_side_effects.rs:339:5 | LL | _custom += &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:340:5 + --> tests/ui/arithmetic_side_effects.rs:340:5 | LL | _custom -= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:341:5 + --> tests/ui/arithmetic_side_effects.rs:341:5 | LL | _custom -= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:342:5 + --> tests/ui/arithmetic_side_effects.rs:342:5 | LL | _custom /= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:343:5 + --> tests/ui/arithmetic_side_effects.rs:343:5 | LL | _custom /= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:344:5 + --> tests/ui/arithmetic_side_effects.rs:344:5 | LL | _custom %= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:345:5 + --> tests/ui/arithmetic_side_effects.rs:345:5 | LL | _custom %= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:346:5 + --> tests/ui/arithmetic_side_effects.rs:346:5 | LL | _custom *= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:347:5 + --> tests/ui/arithmetic_side_effects.rs:347:5 | LL | _custom *= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:348:5 + --> tests/ui/arithmetic_side_effects.rs:348:5 | LL | _custom >>= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:349:5 + --> tests/ui/arithmetic_side_effects.rs:349:5 | LL | _custom >>= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:350:5 + --> tests/ui/arithmetic_side_effects.rs:350:5 | LL | _custom <<= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:351:5 + --> tests/ui/arithmetic_side_effects.rs:351:5 | LL | _custom <<= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:354:10 + --> tests/ui/arithmetic_side_effects.rs:354:10 | LL | _n = _n + 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:355:10 + --> tests/ui/arithmetic_side_effects.rs:355:10 | LL | _n = _n + &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:356:10 + --> tests/ui/arithmetic_side_effects.rs:356:10 | LL | _n = 1 + _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:357:10 + --> tests/ui/arithmetic_side_effects.rs:357:10 | LL | _n = &1 + _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:358:10 + --> tests/ui/arithmetic_side_effects.rs:358:10 | LL | _n = _n - 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:359:10 + --> tests/ui/arithmetic_side_effects.rs:359:10 | LL | _n = _n - &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:360:10 + --> tests/ui/arithmetic_side_effects.rs:360:10 | LL | _n = 1 - _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:361:10 + --> tests/ui/arithmetic_side_effects.rs:361:10 | LL | _n = &1 - _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:362:10 + --> tests/ui/arithmetic_side_effects.rs:362:10 | LL | _n = _n / 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:363:10 + --> tests/ui/arithmetic_side_effects.rs:363:10 | LL | _n = _n / &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:364:10 + --> tests/ui/arithmetic_side_effects.rs:364:10 | LL | _n = _n % 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:365:10 + --> tests/ui/arithmetic_side_effects.rs:365:10 | LL | _n = _n % &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:366:10 + --> tests/ui/arithmetic_side_effects.rs:366:10 | LL | _n = _n * 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:367:10 + --> tests/ui/arithmetic_side_effects.rs:367:10 | LL | _n = _n * &2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:368:10 + --> tests/ui/arithmetic_side_effects.rs:368:10 | LL | _n = 2 * _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:369:10 + --> tests/ui/arithmetic_side_effects.rs:369:10 | LL | _n = &2 * _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:370:10 + --> tests/ui/arithmetic_side_effects.rs:370:10 | LL | _n = 23 + &85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:371:10 + --> tests/ui/arithmetic_side_effects.rs:371:10 | LL | _n = &23 + 85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:372:10 + --> tests/ui/arithmetic_side_effects.rs:372:10 | LL | _n = &23 + &85; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:373:15 + --> tests/ui/arithmetic_side_effects.rs:373:15 | LL | _custom = _custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:374:15 + --> tests/ui/arithmetic_side_effects.rs:374:15 | LL | _custom = _custom + &_custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:375:15 + --> tests/ui/arithmetic_side_effects.rs:375:15 | LL | _custom = Custom + _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:376:15 + --> tests/ui/arithmetic_side_effects.rs:376:15 | LL | _custom = &Custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:377:15 + --> tests/ui/arithmetic_side_effects.rs:377:15 | LL | _custom = _custom - Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:378:15 + --> tests/ui/arithmetic_side_effects.rs:378:15 | LL | _custom = _custom - &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:379:15 + --> tests/ui/arithmetic_side_effects.rs:379:15 | LL | _custom = Custom - _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:380:15 + --> tests/ui/arithmetic_side_effects.rs:380:15 | LL | _custom = &Custom - _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:381:15 + --> tests/ui/arithmetic_side_effects.rs:381:15 | LL | _custom = _custom / Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:382:15 + --> tests/ui/arithmetic_side_effects.rs:382:15 | LL | _custom = _custom / &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:383:15 + --> tests/ui/arithmetic_side_effects.rs:383:15 | LL | _custom = _custom % Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:384:15 + --> tests/ui/arithmetic_side_effects.rs:384:15 | LL | _custom = _custom % &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:385:15 + --> tests/ui/arithmetic_side_effects.rs:385:15 | LL | _custom = _custom * Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:386:15 + --> tests/ui/arithmetic_side_effects.rs:386:15 | LL | _custom = _custom * &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:387:15 + --> tests/ui/arithmetic_side_effects.rs:387:15 | LL | _custom = Custom * _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:388:15 + --> tests/ui/arithmetic_side_effects.rs:388:15 | LL | _custom = &Custom * _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:389:15 + --> tests/ui/arithmetic_side_effects.rs:389:15 | LL | _custom = Custom + &Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:390:15 + --> tests/ui/arithmetic_side_effects.rs:390:15 | LL | _custom = &Custom + Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:391:15 + --> tests/ui/arithmetic_side_effects.rs:391:15 | LL | _custom = &Custom + &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:392:15 + --> tests/ui/arithmetic_side_effects.rs:392:15 | LL | _custom = _custom >> _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:393:15 + --> tests/ui/arithmetic_side_effects.rs:393:15 | LL | _custom = _custom >> &_custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:394:15 + --> tests/ui/arithmetic_side_effects.rs:394:15 | LL | _custom = Custom << _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:395:15 + --> tests/ui/arithmetic_side_effects.rs:395:15 | LL | _custom = &Custom << _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:398:23 + --> tests/ui/arithmetic_side_effects.rs:398:23 | LL | _n.saturating_div(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:399:21 + --> tests/ui/arithmetic_side_effects.rs:399:21 | LL | _n.wrapping_div(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:400:21 + --> tests/ui/arithmetic_side_effects.rs:400:21 | LL | _n.wrapping_rem(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:401:28 + --> tests/ui/arithmetic_side_effects.rs:401:28 | LL | _n.wrapping_rem_euclid(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:403:23 + --> tests/ui/arithmetic_side_effects.rs:403:23 | LL | _n.saturating_div(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:404:21 + --> tests/ui/arithmetic_side_effects.rs:404:21 | LL | _n.wrapping_div(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:405:21 + --> tests/ui/arithmetic_side_effects.rs:405:21 | LL | _n.wrapping_rem(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:406:28 + --> tests/ui/arithmetic_side_effects.rs:406:28 | LL | _n.wrapping_rem_euclid(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:409:10 + --> tests/ui/arithmetic_side_effects.rs:409:10 | LL | _n = -_n; | ^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:410:10 + --> tests/ui/arithmetic_side_effects.rs:410:10 | LL | _n = -&_n; | ^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:411:15 + --> tests/ui/arithmetic_side_effects.rs:411:15 | LL | _custom = -_custom; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:412:15 + --> tests/ui/arithmetic_side_effects.rs:412:15 | LL | _custom = -&_custom; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:421:5 + --> tests/ui/arithmetic_side_effects.rs:421:5 | LL | 1 + i; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:422:5 + --> tests/ui/arithmetic_side_effects.rs:422:5 | LL | i * 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:423:5 + --> tests/ui/arithmetic_side_effects.rs:423:5 | LL | 1 % i / 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:424:5 + --> tests/ui/arithmetic_side_effects.rs:424:5 | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:425:5 + --> tests/ui/arithmetic_side_effects.rs:425:5 | LL | -i; | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:436:5 + --> tests/ui/arithmetic_side_effects.rs:436:5 | LL | i += 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:437:5 + --> tests/ui/arithmetic_side_effects.rs:437:5 | LL | i -= 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:438:5 + --> tests/ui/arithmetic_side_effects.rs:438:5 | LL | i *= 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:440:5 + --> tests/ui/arithmetic_side_effects.rs:440:5 | LL | i /= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:442:5 + --> tests/ui/arithmetic_side_effects.rs:442:5 | LL | i /= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:443:5 + --> tests/ui/arithmetic_side_effects.rs:443:5 | LL | i /= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:445:5 + --> tests/ui/arithmetic_side_effects.rs:445:5 | LL | i %= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:447:5 + --> tests/ui/arithmetic_side_effects.rs:447:5 | LL | i %= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:448:5 + --> tests/ui/arithmetic_side_effects.rs:448:5 | LL | i %= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:458:5 + --> tests/ui/arithmetic_side_effects.rs:458:5 | LL | 10 / a | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:512:9 + --> tests/ui/arithmetic_side_effects.rs:512:9 | LL | x / maybe_zero | ^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:516:9 + --> tests/ui/arithmetic_side_effects.rs:516:9 | LL | x % maybe_zero | ^^^^^^^^^^^^^^ diff --git a/tests/ui/as_conversions.stderr b/tests/ui/as_conversions.stderr index 4bb964399e2da..0e4edd31e0179 100644 --- a/tests/ui/as_conversions.stderr +++ b/tests/ui/as_conversions.stderr @@ -1,5 +1,5 @@ error: using a potentially dangerous silent `as` conversion - --> $DIR/as_conversions.rs:10:13 + --> tests/ui/as_conversions.rs:10:13 | LL | let i = 0u32 as u64; | ^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let i = 0u32 as u64; = help: to override `-D warnings` add `#[allow(clippy::as_conversions)]` error: using a potentially dangerous silent `as` conversion - --> $DIR/as_conversions.rs:12:13 + --> tests/ui/as_conversions.rs:12:13 | LL | let j = &i as *const u64 as *mut u64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let j = &i as *const u64 as *mut u64; = help: consider using a safe wrapper for this conversion error: using a potentially dangerous silent `as` conversion - --> $DIR/as_conversions.rs:12:13 + --> tests/ui/as_conversions.rs:12:13 | LL | let j = &i as *const u64 as *mut u64; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/as_ptr_cast_mut.stderr b/tests/ui/as_ptr_cast_mut.stderr index 92cdf911538df..b3fc223ccdba1 100644 --- a/tests/ui/as_ptr_cast_mut.stderr +++ b/tests/ui/as_ptr_cast_mut.stderr @@ -1,5 +1,5 @@ error: casting the result of `as_ptr` to *mut u8 - --> $DIR/as_ptr_cast_mut.rs:22:13 + --> tests/ui/as_ptr_cast_mut.rs:22:13 | LL | let _ = string.as_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` @@ -8,7 +8,7 @@ LL | let _ = string.as_ptr() as *mut u8; = help: to override `-D warnings` add `#[allow(clippy::as_ptr_cast_mut)]` error: casting the result of `as_ptr` to *mut i8 - --> $DIR/as_ptr_cast_mut.rs:25:22 + --> tests/ui/as_ptr_cast_mut.rs:25:22 | LL | let _: *mut i8 = string.as_ptr() as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` diff --git a/tests/ui/as_underscore.stderr b/tests/ui/as_underscore.stderr index 1842eeeacecb1..dba56a2a8af38 100644 --- a/tests/ui/as_underscore.stderr +++ b/tests/ui/as_underscore.stderr @@ -1,5 +1,5 @@ error: using `as _` conversion - --> $DIR/as_underscore.rs:7:9 + --> tests/ui/as_underscore.rs:7:9 | LL | foo(n as _); | ^^^^^- @@ -10,7 +10,7 @@ LL | foo(n as _); = help: to override `-D warnings` add `#[allow(clippy::as_underscore)]` error: using `as _` conversion - --> $DIR/as_underscore.rs:10:18 + --> tests/ui/as_underscore.rs:10:18 | LL | let _n: u8 = n as _; | ^^^^^- diff --git a/tests/ui/asm_syntax_x86.i686.stderr b/tests/ui/asm_syntax_x86.i686.stderr index dee78f97e68a0..3caca42b4f672 100644 --- a/tests/ui/asm_syntax_x86.i686.stderr +++ b/tests/ui/asm_syntax_x86.i686.stderr @@ -1,5 +1,5 @@ error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:10:9 + --> tests/ui/asm_syntax_x86.rs:10:9 | LL | asm!(""); | ^^^^^^^^ @@ -9,7 +9,7 @@ LL | asm!(""); = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]` error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:12:9 + --> tests/ui/asm_syntax_x86.rs:12:9 | LL | asm!("", options()); | ^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | asm!("", options()); = help: use AT&T x86 assembly syntax error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:14:9 + --> tests/ui/asm_syntax_x86.rs:14:9 | LL | asm!("", options(nostack)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | asm!("", options(nostack)); = help: use AT&T x86 assembly syntax error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:20:5 + --> tests/ui/asm_syntax_x86.rs:20:5 | LL | global_asm!(""); | ^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | global_asm!(""); = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:22:5 + --> tests/ui/asm_syntax_x86.rs:22:5 | LL | global_asm!("", options()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | global_asm!("", options()); = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:35:9 + --> tests/ui/asm_syntax_x86.rs:35:9 | LL | asm!("", options(att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | asm!("", options(att_syntax)); = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]` error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:37:9 + --> tests/ui/asm_syntax_x86.rs:37:9 | LL | asm!("", options(nostack, att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | asm!("", options(nostack, att_syntax)); = help: use Intel x86 assembly syntax error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:43:5 + --> tests/ui/asm_syntax_x86.rs:43:5 | LL | global_asm!("", options(att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm_syntax_x86.x86_64.stderr b/tests/ui/asm_syntax_x86.x86_64.stderr index dee78f97e68a0..3caca42b4f672 100644 --- a/tests/ui/asm_syntax_x86.x86_64.stderr +++ b/tests/ui/asm_syntax_x86.x86_64.stderr @@ -1,5 +1,5 @@ error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:10:9 + --> tests/ui/asm_syntax_x86.rs:10:9 | LL | asm!(""); | ^^^^^^^^ @@ -9,7 +9,7 @@ LL | asm!(""); = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]` error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:12:9 + --> tests/ui/asm_syntax_x86.rs:12:9 | LL | asm!("", options()); | ^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | asm!("", options()); = help: use AT&T x86 assembly syntax error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:14:9 + --> tests/ui/asm_syntax_x86.rs:14:9 | LL | asm!("", options(nostack)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | asm!("", options(nostack)); = help: use AT&T x86 assembly syntax error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:20:5 + --> tests/ui/asm_syntax_x86.rs:20:5 | LL | global_asm!(""); | ^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | global_asm!(""); = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) error: Intel x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:22:5 + --> tests/ui/asm_syntax_x86.rs:22:5 | LL | global_asm!("", options()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | global_asm!("", options()); = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info) error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:35:9 + --> tests/ui/asm_syntax_x86.rs:35:9 | LL | asm!("", options(att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | asm!("", options(att_syntax)); = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]` error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:37:9 + --> tests/ui/asm_syntax_x86.rs:37:9 | LL | asm!("", options(nostack, att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | asm!("", options(nostack, att_syntax)); = help: use Intel x86 assembly syntax error: AT&T x86 assembly syntax used - --> $DIR/asm_syntax_x86.rs:43:5 + --> tests/ui/asm_syntax_x86.rs:43:5 | LL | global_asm!("", options(att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr index 099be4ed35542..00f117c949206 100644 --- a/tests/ui/assertions_on_constants.stderr +++ b/tests/ui/assertions_on_constants.stderr @@ -1,5 +1,5 @@ error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:10:5 + --> tests/ui/assertions_on_constants.rs:10:5 | LL | assert!(true); | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | assert!(true); = help: to override `-D warnings` add `#[allow(clippy::assertions_on_constants)]` error: `assert!(false)` should probably be replaced - --> $DIR/assertions_on_constants.rs:12:5 + --> tests/ui/assertions_on_constants.rs:12:5 | LL | assert!(false); | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | assert!(false); = help: use `panic!()` or `unreachable!()` error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:14:5 + --> tests/ui/assertions_on_constants.rs:14:5 | LL | assert!(true, "true message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | assert!(true, "true message"); = help: remove it error: `assert!(false, ..)` should probably be replaced - --> $DIR/assertions_on_constants.rs:16:5 + --> tests/ui/assertions_on_constants.rs:16:5 | LL | assert!(false, "false message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | assert!(false, "false message"); = help: use `panic!(..)` or `unreachable!(..)` error: `assert!(false, ..)` should probably be replaced - --> $DIR/assertions_on_constants.rs:20:5 + --> tests/ui/assertions_on_constants.rs:20:5 | LL | assert!(false, "{}", msg.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | assert!(false, "{}", msg.to_uppercase()); = help: use `panic!(..)` or `unreachable!(..)` error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:24:5 + --> tests/ui/assertions_on_constants.rs:24:5 | LL | assert!(B); | ^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | assert!(B); = help: remove it error: `assert!(false)` should probably be replaced - --> $DIR/assertions_on_constants.rs:28:5 + --> tests/ui/assertions_on_constants.rs:28:5 | LL | assert!(C); | ^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | assert!(C); = help: use `panic!()` or `unreachable!()` error: `assert!(false, ..)` should probably be replaced - --> $DIR/assertions_on_constants.rs:30:5 + --> tests/ui/assertions_on_constants.rs:30:5 | LL | assert!(C, "C message"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | assert!(C, "C message"); = help: use `panic!(..)` or `unreachable!(..)` error: `debug_assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:33:5 + --> tests/ui/assertions_on_constants.rs:33:5 | LL | debug_assert!(true); | ^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | debug_assert!(true); = help: remove it error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:49:19 + --> tests/ui/assertions_on_constants.rs:49:19 | LL | const _: () = assert!(true); | ^^^^^^^^^^^^^ diff --git a/tests/ui/assertions_on_result_states.stderr b/tests/ui/assertions_on_result_states.stderr index 23af51cfe6fd0..a2bddc7025a97 100644 --- a/tests/ui/assertions_on_result_states.stderr +++ b/tests/ui/assertions_on_result_states.stderr @@ -1,5 +1,5 @@ error: called `assert!` with `Result::is_ok` - --> $DIR/assertions_on_result_states.rs:24:5 + --> tests/ui/assertions_on_result_states.rs:24:5 | LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` @@ -8,37 +8,37 @@ LL | assert!(r.is_ok()); = help: to override `-D warnings` add `#[allow(clippy::assertions_on_result_states)]` error: called `assert!` with `Result::is_ok` - --> $DIR/assertions_on_result_states.rs:42:5 + --> tests/ui/assertions_on_result_states.rs:42:5 | LL | assert!(get_ok().is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()` error: called `assert!` with `Result::is_ok` - --> $DIR/assertions_on_result_states.rs:45:5 + --> tests/ui/assertions_on_result_states.rs:45:5 | LL | assert!(get_ok_macro!().is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()` error: called `assert!` with `Result::is_ok` - --> $DIR/assertions_on_result_states.rs:58:5 + --> tests/ui/assertions_on_result_states.rs:58:5 | LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` error: called `assert!` with `Result::is_ok` - --> $DIR/assertions_on_result_states.rs:64:9 + --> tests/ui/assertions_on_result_states.rs:64:9 | LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` error: called `assert!` with `Result::is_err` - --> $DIR/assertions_on_result_states.rs:72:5 + --> tests/ui/assertions_on_result_states.rs:72:5 | LL | assert!(r.is_err()); | ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()` error: called `assert!` with `Result::is_err` - --> $DIR/assertions_on_result_states.rs:82:5 + --> tests/ui/assertions_on_result_states.rs:82:5 | LL | assert!(res.is_err()) | ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();` diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index e021e1bab4c43..4975ac5911fdd 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,5 +1,5 @@ error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:7:5 + --> tests/ui/assign_ops.rs:7:5 | LL | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` @@ -8,61 +8,61 @@ LL | a = a + 1; = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:8:5 + --> tests/ui/assign_ops.rs:8:5 | LL | a = 1 + a; | ^^^^^^^^^ help: replace it with: `a += 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:9:5 + --> tests/ui/assign_ops.rs:9:5 | LL | a = a - 1; | ^^^^^^^^^ help: replace it with: `a -= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:10:5 + --> tests/ui/assign_ops.rs:10:5 | LL | a = a * 99; | ^^^^^^^^^^ help: replace it with: `a *= 99` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:11:5 + --> tests/ui/assign_ops.rs:11:5 | LL | a = 42 * a; | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:12:5 + --> tests/ui/assign_ops.rs:12:5 | LL | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:13:5 + --> tests/ui/assign_ops.rs:13:5 | LL | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:14:5 + --> tests/ui/assign_ops.rs:14:5 | LL | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:20:5 + --> tests/ui/assign_ops.rs:20:5 | LL | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:24:5 + --> tests/ui/assign_ops.rs:24:5 | LL | a = a + Wrapping(1u32); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a += Wrapping(1u32)` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:26:5 + --> tests/ui/assign_ops.rs:26:5 | LL | v[0] = v[0] + v[1]; | ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]` diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 6e9b96c0a644a..ddeba2b2ff8f3 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,5 +1,5 @@ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:8:5 + --> tests/ui/assign_ops2.rs:8:5 | LL | a += a + 1; | ^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | a = a + a + 1; | ~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:11:5 + --> tests/ui/assign_ops2.rs:11:5 | LL | a += 1 + a; | ^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | a = a + 1 + a; | ~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:13:5 + --> tests/ui/assign_ops2.rs:13:5 | LL | a -= a - 1; | ^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | a = a - (a - 1); | ~~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:15:5 + --> tests/ui/assign_ops2.rs:15:5 | LL | a *= a * 99; | ^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | a = a * a * 99; | ~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:17:5 + --> tests/ui/assign_ops2.rs:17:5 | LL | a *= 42 * a; | ^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | a = a * 42 * a; | ~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:19:5 + --> tests/ui/assign_ops2.rs:19:5 | LL | a /= a / 2; | ^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | a = a / (a / 2); | ~~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:21:5 + --> tests/ui/assign_ops2.rs:21:5 | LL | a %= a % 5; | ^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | a = a % (a % 5); | ~~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:23:5 + --> tests/ui/assign_ops2.rs:23:5 | LL | a &= a & 1; | ^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | a = a & a & 1; | ~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:25:5 + --> tests/ui/assign_ops2.rs:25:5 | LL | a *= a * a; | ^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | a = a * a * a; | ~~~~~~~~~~~~~ error: manual implementation of an assign operation - --> $DIR/assign_ops2.rs:63:5 + --> tests/ui/assign_ops2.rs:63:5 | LL | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` diff --git a/tests/ui/async_yields_async.stderr b/tests/ui/async_yields_async.stderr index c29e3c734b75b..f1fae6549de4c 100644 --- a/tests/ui/async_yields_async.stderr +++ b/tests/ui/async_yields_async.stderr @@ -1,5 +1,5 @@ error: an async construct yields a type which is itself awaitable - --> $DIR/async_yields_async.rs:39:9 + --> tests/ui/async_yields_async.rs:39:9 | LL | let _h = async { | _____________________- @@ -20,7 +20,7 @@ LL + }.await | error: an async construct yields a type which is itself awaitable - --> $DIR/async_yields_async.rs:44:9 + --> tests/ui/async_yields_async.rs:44:9 | LL | let _i = async { | ____________________- @@ -33,7 +33,7 @@ LL | | }; | |_____- outer async construct error: an async construct yields a type which is itself awaitable - --> $DIR/async_yields_async.rs:50:9 + --> tests/ui/async_yields_async.rs:50:9 | LL | let _j = async || { | ________________________- @@ -52,7 +52,7 @@ LL + }.await | error: an async construct yields a type which is itself awaitable - --> $DIR/async_yields_async.rs:55:9 + --> tests/ui/async_yields_async.rs:55:9 | LL | let _k = async || { | _______________________- @@ -65,7 +65,7 @@ LL | | }; | |_____- outer async construct error: an async construct yields a type which is itself awaitable - --> $DIR/async_yields_async.rs:57:23 + --> tests/ui/async_yields_async.rs:57:23 | LL | let _l = async || CustomFutureType; | ^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL | let _l = async || CustomFutureType; | help: consider awaiting this value: `CustomFutureType.await` error: an async construct yields a type which is itself awaitable - --> $DIR/async_yields_async.rs:63:9 + --> tests/ui/async_yields_async.rs:63:9 | LL | let _m = async || { | _______________________- diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index 16402a4ddfeff..cd409fc8701b6 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,5 +1,5 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea - --> $DIR/attrs.rs:5:1 + --> tests/ui/attrs.rs:5:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #[inline(always)] = help: to override `-D warnings` add `#[allow(clippy::inline_always)]` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:27:14 + --> tests/ui/attrs.rs:27:14 | LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | #[deprecated(since = "forever")] = help: to override `-D warnings` add `#[allow(clippy::deprecated_semver)]` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:32:14 + --> tests/ui/attrs.rs:32:14 | LL | #[deprecated(since = "1")] | ^^^^^^^^^^^ diff --git a/tests/ui/await_holding_lock.stderr b/tests/ui/await_holding_lock.stderr index 4782104000228..e58436345b5c7 100644 --- a/tests/ui/await_holding_lock.stderr +++ b/tests/ui/await_holding_lock.stderr @@ -1,12 +1,12 @@ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:9:13 + --> tests/ui/await_holding_lock.rs:9:13 | LL | let guard = x.lock().unwrap(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:11:15 + --> tests/ui/await_holding_lock.rs:11:15 | LL | baz().await | ^^^^^ @@ -14,40 +14,40 @@ LL | baz().await = help: to override `-D warnings` add `#[allow(clippy::await_holding_lock)]` error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:25:13 + --> tests/ui/await_holding_lock.rs:25:13 | LL | let guard = x.read().unwrap(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:27:15 + --> tests/ui/await_holding_lock.rs:27:15 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:31:13 + --> tests/ui/await_holding_lock.rs:31:13 | LL | let mut guard = x.write().unwrap(); | ^^^^^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:33:15 + --> tests/ui/await_holding_lock.rs:33:15 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:53:13 + --> tests/ui/await_holding_lock.rs:53:13 | LL | let guard = x.lock().unwrap(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:56:28 + --> tests/ui/await_holding_lock.rs:56:28 | LL | let second = baz().await; | ^^^^^ @@ -56,79 +56,79 @@ LL | let third = baz().await; | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:67:17 + --> tests/ui/await_holding_lock.rs:67:17 | LL | let guard = x.lock().unwrap(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:69:19 + --> tests/ui/await_holding_lock.rs:69:19 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:80:17 + --> tests/ui/await_holding_lock.rs:80:17 | LL | let guard = x.lock().unwrap(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:82:19 + --> tests/ui/await_holding_lock.rs:82:19 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:93:13 + --> tests/ui/await_holding_lock.rs:93:13 | LL | let guard = x.lock(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:95:15 + --> tests/ui/await_holding_lock.rs:95:15 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:109:13 + --> tests/ui/await_holding_lock.rs:109:13 | LL | let guard = x.read(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:111:15 + --> tests/ui/await_holding_lock.rs:111:15 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:115:13 + --> tests/ui/await_holding_lock.rs:115:13 | LL | let mut guard = x.write(); | ^^^^^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:117:15 + --> tests/ui/await_holding_lock.rs:117:15 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:137:13 + --> tests/ui/await_holding_lock.rs:137:13 | LL | let guard = x.lock(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:140:28 + --> tests/ui/await_holding_lock.rs:140:28 | LL | let second = baz().await; | ^^^^^ @@ -137,40 +137,40 @@ LL | let third = baz().await; | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:151:17 + --> tests/ui/await_holding_lock.rs:151:17 | LL | let guard = x.lock(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:153:19 + --> tests/ui/await_holding_lock.rs:153:19 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:164:17 + --> tests/ui/await_holding_lock.rs:164:17 | LL | let guard = x.lock(); | ^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:166:19 + --> tests/ui/await_holding_lock.rs:166:19 | LL | baz().await | ^^^^^ error: this `MutexGuard` is held across an `await` point - --> $DIR/await_holding_lock.rs:185:9 + --> tests/ui/await_holding_lock.rs:185:9 | LL | let mut guard = x.lock().unwrap(); | ^^^^^^^^^ | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:189:11 + --> tests/ui/await_holding_lock.rs:189:11 | LL | baz().await; | ^^^^^ diff --git a/tests/ui/await_holding_refcell_ref.stderr b/tests/ui/await_holding_refcell_ref.stderr index 9264af93dc168..6b474c27ddc18 100644 --- a/tests/ui/await_holding_refcell_ref.stderr +++ b/tests/ui/await_holding_refcell_ref.stderr @@ -1,12 +1,12 @@ error: this `RefCell` reference is held across an `await` point - --> $DIR/await_holding_refcell_ref.rs:6:9 + --> tests/ui/await_holding_refcell_ref.rs:6:9 | LL | let b = x.borrow(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:8:11 + --> tests/ui/await_holding_refcell_ref.rs:8:11 | LL | baz().await | ^^^^^ @@ -14,27 +14,27 @@ LL | baz().await = help: to override `-D warnings` add `#[allow(clippy::await_holding_refcell_ref)]` error: this `RefCell` reference is held across an `await` point - --> $DIR/await_holding_refcell_ref.rs:12:9 + --> tests/ui/await_holding_refcell_ref.rs:12:9 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:14:11 + --> tests/ui/await_holding_refcell_ref.rs:14:11 | LL | baz().await | ^^^^^ error: this `RefCell` reference is held across an `await` point - --> $DIR/await_holding_refcell_ref.rs:34:9 + --> tests/ui/await_holding_refcell_ref.rs:34:9 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:37:24 + --> tests/ui/await_holding_refcell_ref.rs:37:24 | LL | let second = baz().await; | ^^^^^ @@ -43,40 +43,40 @@ LL | let third = baz().await; | ^^^^^ error: this `RefCell` reference is held across an `await` point - --> $DIR/await_holding_refcell_ref.rs:47:9 + --> tests/ui/await_holding_refcell_ref.rs:47:9 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:50:24 + --> tests/ui/await_holding_refcell_ref.rs:50:24 | LL | let second = baz().await; | ^^^^^ error: this `RefCell` reference is held across an `await` point - --> $DIR/await_holding_refcell_ref.rs:63:13 + --> tests/ui/await_holding_refcell_ref.rs:63:13 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:65:15 + --> tests/ui/await_holding_refcell_ref.rs:65:15 | LL | baz().await | ^^^^^ error: this `RefCell` reference is held across an `await` point - --> $DIR/await_holding_refcell_ref.rs:76:13 + --> tests/ui/await_holding_refcell_ref.rs:76:13 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:78:15 + --> tests/ui/await_holding_refcell_ref.rs:78:15 | LL | baz().await | ^^^^^ diff --git a/tests/ui/bind_instead_of_map.stderr b/tests/ui/bind_instead_of_map.stderr index 3af61e6d43b63..57e0e4fb84752 100644 --- a/tests/ui/bind_instead_of_map.stderr +++ b/tests/ui/bind_instead_of_map.stderr @@ -1,23 +1,23 @@ error: using `Option.and_then(Some)`, which is a no-op - --> $DIR/bind_instead_of_map.rs:8:13 + --> tests/ui/bind_instead_of_map.rs:8:13 | LL | let _ = x.and_then(Some); | ^^^^^^^^^^^^^^^^ help: use the expression directly: `x` | note: the lint level is defined here - --> $DIR/bind_instead_of_map.rs:1:9 + --> tests/ui/bind_instead_of_map.rs:1:9 | LL | #![deny(clippy::bind_instead_of_map)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` - --> $DIR/bind_instead_of_map.rs:9:13 + --> tests/ui/bind_instead_of_map.rs:9:13 | LL | let _ = x.and_then(|o| Some(o + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)` error: using `Result.and_then(Ok)`, which is a no-op - --> $DIR/bind_instead_of_map.rs:15:13 + --> tests/ui/bind_instead_of_map.rs:15:13 | LL | let _ = x.and_then(Ok); | ^^^^^^^^^^^^^^ help: use the expression directly: `x` diff --git a/tests/ui/bind_instead_of_map_multipart.stderr b/tests/ui/bind_instead_of_map_multipart.stderr index 63f25f26f2401..73255651abea7 100644 --- a/tests/ui/bind_instead_of_map_multipart.stderr +++ b/tests/ui/bind_instead_of_map_multipart.stderr @@ -1,11 +1,11 @@ error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` - --> $DIR/bind_instead_of_map_multipart.rs:5:13 + --> tests/ui/bind_instead_of_map_multipart.rs:5:13 | LL | let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/bind_instead_of_map_multipart.rs:1:9 + --> tests/ui/bind_instead_of_map_multipart.rs:1:9 | LL | #![deny(clippy::bind_instead_of_map)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() }); | ~~~ ~ ~~~~~~~ error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)` - --> $DIR/bind_instead_of_map_multipart.rs:8:13 + --> tests/ui/bind_instead_of_map_multipart.rs:8:13 | LL | let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len() | ~~~ ~ ~~~~~~~ error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)` - --> $DIR/bind_instead_of_map_multipart.rs:11:13 + --> tests/ui/bind_instead_of_map_multipart.rs:11:13 | LL | let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 } | ~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~ error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` - --> $DIR/bind_instead_of_map_multipart.rs:19:5 + --> tests/ui/bind_instead_of_map_multipart.rs:19:5 | LL | / Some("42").and_then(|s| { LL | | if { @@ -77,7 +77,7 @@ LL ~ _ => 1, | error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` - --> $DIR/bind_instead_of_map_multipart.rs:60:13 + --> tests/ui/bind_instead_of_map_multipart.rs:60:13 | LL | let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index 4423d15d79d4d..004f6ad94841b 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,5 +1,5 @@ error: &-masking with zero - --> $DIR/bit_masks.rs:14:5 + --> tests/ui/bit_masks.rs:14:5 | LL | x & 0 == 0; | ^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | x & 0 == 0; = help: to override `-D warnings` add `#[allow(clippy::bad_bit_mask)]` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:14:5 + --> tests/ui/bit_masks.rs:14:5 | LL | x & 0 == 0; | ^^^^^ @@ -16,73 +16,73 @@ LL | x & 0 == 0; = note: `#[deny(clippy::erasing_op)]` on by default error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:21:5 + --> tests/ui/bit_masks.rs:21:5 | LL | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:26:5 + --> tests/ui/bit_masks.rs:26:5 | LL | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` - --> $DIR/bit_masks.rs:29:5 + --> tests/ui/bit_masks.rs:29:5 | LL | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:34:5 + --> tests/ui/bit_masks.rs:34:5 | LL | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` - --> $DIR/bit_masks.rs:42:5 + --> tests/ui/bit_masks.rs:42:5 | LL | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` - --> $DIR/bit_masks.rs:44:5 + --> tests/ui/bit_masks.rs:44:5 | LL | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero - --> $DIR/bit_masks.rs:47:5 + --> tests/ui/bit_masks.rs:47:5 | LL | 0 & x == 0; | ^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:47:5 + --> tests/ui/bit_masks.rs:47:5 | LL | 0 & x == 0; | ^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:53:5 + --> tests/ui/bit_masks.rs:53:5 | LL | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:55:5 + --> tests/ui/bit_masks.rs:55:5 | LL | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:57:5 + --> tests/ui/bit_masks.rs:57:5 | LL | 1 == x & 2; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:69:5 + --> tests/ui/bit_masks.rs:69:5 | LL | x | 1 > 3; | ^^^^^^^^^ @@ -91,19 +91,19 @@ LL | x | 1 > 3; = help: to override `-D warnings` add `#[allow(clippy::ineffective_bit_mask)]` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly - --> $DIR/bit_masks.rs:72:5 + --> tests/ui/bit_masks.rs:72:5 | LL | x | 1 < 4; | ^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:74:5 + --> tests/ui/bit_masks.rs:74:5 | LL | x | 1 <= 3; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly - --> $DIR/bit_masks.rs:76:5 + --> tests/ui/bit_masks.rs:76:5 | LL | x | 1 >= 8; | ^^^^^^^^^^ diff --git a/tests/ui/blanket_clippy_restriction_lints.stderr b/tests/ui/blanket_clippy_restriction_lints.stderr index afb634f34b41a..d410f25b2c274 100644 --- a/tests/ui/blanket_clippy_restriction_lints.stderr +++ b/tests/ui/blanket_clippy_restriction_lints.stderr @@ -1,5 +1,5 @@ error: `clippy::restriction` is not meant to be enabled as a group - --> $DIR/blanket_clippy_restriction_lints.rs:6:9 + --> tests/ui/blanket_clippy_restriction_lints.rs:6:9 | LL | #![warn(clippy::restriction)] | ^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![warn(clippy::restriction)] = help: to override `-D warnings` add `#[allow(clippy::blanket_clippy_restriction_lints)]` error: `clippy::restriction` is not meant to be enabled as a group - --> $DIR/blanket_clippy_restriction_lints.rs:8:9 + --> tests/ui/blanket_clippy_restriction_lints.rs:8:9 | LL | #![deny(clippy::restriction)] | ^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | #![deny(clippy::restriction)] = help: enable the restriction lints you need individually error: `clippy::restriction` is not meant to be enabled as a group - --> $DIR/blanket_clippy_restriction_lints.rs:10:11 + --> tests/ui/blanket_clippy_restriction_lints.rs:10:11 | LL | #![forbid(clippy::restriction)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/blocks_in_conditions.stderr b/tests/ui/blocks_in_conditions.stderr index 4d3efb4ffd1fe..3641e71aae830 100644 --- a/tests/ui/blocks_in_conditions.stderr +++ b/tests/ui/blocks_in_conditions.stderr @@ -1,5 +1,5 @@ error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions.rs:25:5 + --> tests/ui/blocks_in_conditions.rs:25:5 | LL | / if { LL | | @@ -20,13 +20,13 @@ LL ~ }; if res { | error: omit braces around single expression condition - --> $DIR/blocks_in_conditions.rs:37:8 + --> tests/ui/blocks_in_conditions.rs:37:8 | LL | if { true } { 6 } else { 10 } | ^^^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/blocks_in_conditions.rs:43:8 + --> tests/ui/blocks_in_conditions.rs:43:8 | LL | if true && x == 3 { 6 } else { 10 } | ^^^^^^^^^^^^^^ help: try: `x == 3` @@ -35,7 +35,7 @@ LL | if true && x == 3 { 6 } else { 10 } = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions.rs:70:5 + --> tests/ui/blocks_in_conditions.rs:70:5 | LL | / match { LL | | diff --git a/tests/ui/blocks_in_conditions_closure.stderr b/tests/ui/blocks_in_conditions_closure.stderr index 08b98f1b4fc7e..2faae680ec021 100644 --- a/tests/ui/blocks_in_conditions_closure.stderr +++ b/tests/ui/blocks_in_conditions_closure.stderr @@ -1,5 +1,5 @@ error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions_closure.rs:23:17 + --> tests/ui/blocks_in_conditions_closure.rs:23:17 | LL | |x| { | _________________^ @@ -14,7 +14,7 @@ LL | | }, = help: to override `-D warnings` add `#[allow(clippy::blocks_in_conditions)]` error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions_closure.rs:34:13 + --> tests/ui/blocks_in_conditions_closure.rs:34:13 | LL | |x| { | _____________^ @@ -25,7 +25,7 @@ LL | | }, | |_________^ error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_conditions_closure.rs:67:13 + --> tests/ui/blocks_in_conditions_closure.rs:67:13 | LL | |x| { | _____________^ diff --git a/tests/ui/bool_assert_comparison.stderr b/tests/ui/bool_assert_comparison.stderr index 5969e4faa1aa5..41183c61ee01d 100644 --- a/tests/ui/bool_assert_comparison.stderr +++ b/tests/ui/bool_assert_comparison.stderr @@ -1,5 +1,5 @@ error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:87:5 + --> tests/ui/bool_assert_comparison.rs:87:5 | LL | assert_eq!("a".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + assert!(!"a".is_empty()); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:88:5 + --> tests/ui/bool_assert_comparison.rs:88:5 | LL | assert_eq!("".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + assert!("".is_empty()); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:89:5 + --> tests/ui/bool_assert_comparison.rs:89:5 | LL | assert_eq!(true, "".is_empty()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + assert!("".is_empty()); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:94:5 + --> tests/ui/bool_assert_comparison.rs:94:5 | LL | assert_eq!(b, true); | ^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + assert!(b); | error: used `assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:97:5 + --> tests/ui/bool_assert_comparison.rs:97:5 | LL | assert_ne!("a".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + assert!("a".is_empty()); | error: used `assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:98:5 + --> tests/ui/bool_assert_comparison.rs:98:5 | LL | assert_ne!("".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + assert!(!"".is_empty()); | error: used `assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:99:5 + --> tests/ui/bool_assert_comparison.rs:99:5 | LL | assert_ne!(true, "".is_empty()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + assert!(!"".is_empty()); | error: used `assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:104:5 + --> tests/ui/bool_assert_comparison.rs:104:5 | LL | assert_ne!(b, true); | ^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + assert!(!b); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:107:5 + --> tests/ui/bool_assert_comparison.rs:107:5 | LL | debug_assert_eq!("a".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + debug_assert!(!"a".is_empty()); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:108:5 + --> tests/ui/bool_assert_comparison.rs:108:5 | LL | debug_assert_eq!("".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + debug_assert!("".is_empty()); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:109:5 + --> tests/ui/bool_assert_comparison.rs:109:5 | LL | debug_assert_eq!(true, "".is_empty()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + debug_assert!("".is_empty()); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:114:5 + --> tests/ui/bool_assert_comparison.rs:114:5 | LL | debug_assert_eq!(b, true); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + debug_assert!(b); | error: used `debug_assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:117:5 + --> tests/ui/bool_assert_comparison.rs:117:5 | LL | debug_assert_ne!("a".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + debug_assert!("a".is_empty()); | error: used `debug_assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:118:5 + --> tests/ui/bool_assert_comparison.rs:118:5 | LL | debug_assert_ne!("".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL + debug_assert!(!"".is_empty()); | error: used `debug_assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:119:5 + --> tests/ui/bool_assert_comparison.rs:119:5 | LL | debug_assert_ne!(true, "".is_empty()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + debug_assert!(!"".is_empty()); | error: used `debug_assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:124:5 + --> tests/ui/bool_assert_comparison.rs:124:5 | LL | debug_assert_ne!(b, true); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL + debug_assert!(!b); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:129:5 + --> tests/ui/bool_assert_comparison.rs:129:5 | LL | assert_eq!("a".is_empty(), false, "tadam {}", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", 1); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:130:5 + --> tests/ui/bool_assert_comparison.rs:130:5 | LL | assert_eq!("a".is_empty(), false, "tadam {}", true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", true); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:131:5 + --> tests/ui/bool_assert_comparison.rs:131:5 | LL | assert_eq!(false, "a".is_empty(), "tadam {}", true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", true); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:136:5 + --> tests/ui/bool_assert_comparison.rs:136:5 | LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", 1); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:137:5 + --> tests/ui/bool_assert_comparison.rs:137:5 | LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", true); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:138:5 + --> tests/ui/bool_assert_comparison.rs:138:5 | LL | debug_assert_eq!(false, "a".is_empty(), "tadam {}", true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -265,7 +265,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", true); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:141:5 + --> tests/ui/bool_assert_comparison.rs:141:5 | LL | assert_eq!(a!(), true); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -277,7 +277,7 @@ LL + assert!(a!()); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:142:5 + --> tests/ui/bool_assert_comparison.rs:142:5 | LL | assert_eq!(true, b!()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -289,7 +289,7 @@ LL + assert!(b!()); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:146:5 + --> tests/ui/bool_assert_comparison.rs:146:5 | LL | renamed!(b, true); | ^^^^^^^^^^^^^^^^^ @@ -301,7 +301,7 @@ LL + debug_assert!(b); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:160:5 + --> tests/ui/bool_assert_comparison.rs:160:5 | LL | assert_eq!("".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL + assert!("".is_empty()); | error: used `assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:161:5 + --> tests/ui/bool_assert_comparison.rs:161:5 | LL | assert_ne!("".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -325,7 +325,7 @@ LL + assert!("".is_empty()); | error: used `assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:162:5 + --> tests/ui/bool_assert_comparison.rs:162:5 | LL | assert_ne!("requires negation".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL + assert!(!"requires negation".is_empty()); | error: used `assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:163:5 + --> tests/ui/bool_assert_comparison.rs:163:5 | LL | assert_eq!("requires negation".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -349,7 +349,7 @@ LL + assert!(!"requires negation".is_empty()); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:165:5 + --> tests/ui/bool_assert_comparison.rs:165:5 | LL | debug_assert_eq!("".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -361,7 +361,7 @@ LL + debug_assert!("".is_empty()); | error: used `debug_assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:166:5 + --> tests/ui/bool_assert_comparison.rs:166:5 | LL | debug_assert_ne!("".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -373,7 +373,7 @@ LL + debug_assert!("".is_empty()); | error: used `debug_assert_ne!` with a literal bool - --> $DIR/bool_assert_comparison.rs:167:5 + --> tests/ui/bool_assert_comparison.rs:167:5 | LL | debug_assert_ne!("requires negation".is_empty(), true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL + debug_assert!(!"requires negation".is_empty()); | error: used `debug_assert_eq!` with a literal bool - --> $DIR/bool_assert_comparison.rs:168:5 + --> tests/ui/bool_assert_comparison.rs:168:5 | LL | debug_assert_eq!("requires negation".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 6907dc0523fec..7c8b906221fa9 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -1,5 +1,5 @@ error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:7:8 + --> tests/ui/bool_comparison.rs:7:8 | LL | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -8,145 +8,145 @@ LL | if x == true { = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:12:8 + --> tests/ui/bool_comparison.rs:12:8 | LL | if x == false { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:17:8 + --> tests/ui/bool_comparison.rs:17:8 | LL | if true == x { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:22:8 + --> tests/ui/bool_comparison.rs:22:8 | LL | if false == x { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:27:8 + --> tests/ui/bool_comparison.rs:27:8 | LL | if x != true { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:32:8 + --> tests/ui/bool_comparison.rs:32:8 | LL | if x != false { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:37:8 + --> tests/ui/bool_comparison.rs:37:8 | LL | if true != x { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:42:8 + --> tests/ui/bool_comparison.rs:42:8 | LL | if false != x { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: less than comparison against true can be replaced by a negation - --> $DIR/bool_comparison.rs:47:8 + --> tests/ui/bool_comparison.rs:47:8 | LL | if x < true { | ^^^^^^^^ help: try simplifying it as shown: `!x` error: greater than checks against false are unnecessary - --> $DIR/bool_comparison.rs:52:8 + --> tests/ui/bool_comparison.rs:52:8 | LL | if false < x { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: greater than checks against false are unnecessary - --> $DIR/bool_comparison.rs:57:8 + --> tests/ui/bool_comparison.rs:57:8 | LL | if x > false { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: less than comparison against true can be replaced by a negation - --> $DIR/bool_comparison.rs:62:8 + --> tests/ui/bool_comparison.rs:62:8 | LL | if true > x { | ^^^^^^^^ help: try simplifying it as shown: `!x` error: order comparisons between booleans can be simplified - --> $DIR/bool_comparison.rs:68:8 + --> tests/ui/bool_comparison.rs:68:8 | LL | if x < y { | ^^^^^ help: try simplifying it as shown: `!x & y` error: order comparisons between booleans can be simplified - --> $DIR/bool_comparison.rs:73:8 + --> tests/ui/bool_comparison.rs:73:8 | LL | if x > y { | ^^^^^ help: try simplifying it as shown: `x & !y` error: this comparison might be written more concisely - --> $DIR/bool_comparison.rs:121:8 + --> tests/ui/bool_comparison.rs:121:8 | LL | if a == !b {}; | ^^^^^^^ help: try simplifying it as shown: `a != b` error: this comparison might be written more concisely - --> $DIR/bool_comparison.rs:122:8 + --> tests/ui/bool_comparison.rs:122:8 | LL | if !a == b {}; | ^^^^^^^ help: try simplifying it as shown: `a != b` error: this comparison might be written more concisely - --> $DIR/bool_comparison.rs:126:8 + --> tests/ui/bool_comparison.rs:126:8 | LL | if b == !a {}; | ^^^^^^^ help: try simplifying it as shown: `b != a` error: this comparison might be written more concisely - --> $DIR/bool_comparison.rs:127:8 + --> tests/ui/bool_comparison.rs:127:8 | LL | if !b == a {}; | ^^^^^^^ help: try simplifying it as shown: `b != a` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:151:8 + --> tests/ui/bool_comparison.rs:151:8 | LL | if false == m!(func) {} | ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:152:8 + --> tests/ui/bool_comparison.rs:152:8 | LL | if m!(func) == false {} | ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:153:8 + --> tests/ui/bool_comparison.rs:153:8 | LL | if true == m!(func) {} | ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:154:8 + --> tests/ui/bool_comparison.rs:154:8 | LL | if m!(func) == true {} | ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:171:14 + --> tests/ui/bool_comparison.rs:171:14 | LL | let _ = ((1 < 2) == false) as usize; | ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `1 >= 2` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:172:14 + --> tests/ui/bool_comparison.rs:172:14 | LL | let _ = (false == m!(func)) as usize; | ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)` error: this comparison might be written more concisely - --> $DIR/bool_comparison.rs:175:14 + --> tests/ui/bool_comparison.rs:175:14 | LL | let _ = ((1 < 2) == !m!(func)) as usize; | ^^^^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `(1 < 2) != m!(func)` diff --git a/tests/ui/bool_to_int_with_if.stderr b/tests/ui/bool_to_int_with_if.stderr index 714da8a416954..1e4a843071a1c 100644 --- a/tests/ui/bool_to_int_with_if.stderr +++ b/tests/ui/bool_to_int_with_if.stderr @@ -1,5 +1,5 @@ error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:14:5 + --> tests/ui/bool_to_int_with_if.rs:14:5 | LL | / if a { LL | | 1 @@ -13,7 +13,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::bool_to_int_with_if)]` error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:19:5 + --> tests/ui/bool_to_int_with_if.rs:19:5 | LL | / if a { LL | | 0 @@ -25,7 +25,7 @@ LL | | }; = note: `!a as i32` or `(!a).into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:24:5 + --> tests/ui/bool_to_int_with_if.rs:24:5 | LL | / if !a { LL | | 1 @@ -37,7 +37,7 @@ LL | | }; = note: `!a as i32` or `(!a).into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:29:5 + --> tests/ui/bool_to_int_with_if.rs:29:5 | LL | / if a || b { LL | | 1 @@ -49,7 +49,7 @@ LL | | }; = note: `(a || b) as i32` or `(a || b).into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:34:5 + --> tests/ui/bool_to_int_with_if.rs:34:5 | LL | / if cond(a, b) { LL | | 1 @@ -61,7 +61,7 @@ LL | | }; = note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:39:5 + --> tests/ui/bool_to_int_with_if.rs:39:5 | LL | / if x + y < 4 { LL | | 1 @@ -73,7 +73,7 @@ LL | | }; = note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:48:12 + --> tests/ui/bool_to_int_with_if.rs:48:12 | LL | } else if b { | ____________^ @@ -86,7 +86,7 @@ LL | | }; = note: `b as i32` or `b.into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:57:12 + --> tests/ui/bool_to_int_with_if.rs:57:12 | LL | } else if b { | ____________^ @@ -99,7 +99,7 @@ LL | | }; = note: `!b as i32` or `(!b).into()` can also be valid options error: boolean to int conversion using if - --> $DIR/bool_to_int_with_if.rs:122:5 + --> tests/ui/bool_to_int_with_if.rs:122:5 | LL | if a { 1 } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(a)` diff --git a/tests/ui/borrow_as_ptr.stderr b/tests/ui/borrow_as_ptr.stderr index b98618059050c..ea618b06e2c86 100644 --- a/tests/ui/borrow_as_ptr.stderr +++ b/tests/ui/borrow_as_ptr.stderr @@ -1,5 +1,5 @@ error: borrow as raw pointer - --> $DIR/borrow_as_ptr.rs:11:14 + --> tests/ui/borrow_as_ptr.rs:11:14 | LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)` @@ -8,7 +8,7 @@ LL | let _p = &val as *const i32; = help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]` error: borrow as raw pointer - --> $DIR/borrow_as_ptr.rs:18:18 + --> tests/ui/borrow_as_ptr.rs:18:18 | LL | let _p_mut = &mut val_mut as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)` diff --git a/tests/ui/borrow_as_ptr_no_std.stderr b/tests/ui/borrow_as_ptr_no_std.stderr index 1ef0a948a32a1..6802c86ec95a5 100644 --- a/tests/ui/borrow_as_ptr_no_std.stderr +++ b/tests/ui/borrow_as_ptr_no_std.stderr @@ -1,5 +1,5 @@ error: borrow as raw pointer - --> $DIR/borrow_as_ptr_no_std.rs:9:14 + --> tests/ui/borrow_as_ptr_no_std.rs:9:14 | LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of!(val)` @@ -8,7 +8,7 @@ LL | let _p = &val as *const i32; = help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]` error: borrow as raw pointer - --> $DIR/borrow_as_ptr_no_std.rs:12:18 + --> tests/ui/borrow_as_ptr_no_std.rs:12:18 | LL | let _p_mut = &mut val_mut as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of_mut!(val_mut)` diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index a9773958a3778..34e8f11dfd743 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -1,65 +1,65 @@ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:25:14 + --> tests/ui/borrow_box.rs:25:14 | LL | let foo: &Box; | ^^^^^^^^^^ help: try: `&bool` | note: the lint level is defined here - --> $DIR/borrow_box.rs:1:9 + --> tests/ui/borrow_box.rs:1:9 | LL | #![deny(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:30:10 + --> tests/ui/borrow_box.rs:30:10 | LL | foo: &'a Box, | ^^^^^^^^^^^^^ help: try: `&'a bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:35:17 + --> tests/ui/borrow_box.rs:35:17 | LL | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:102:25 + --> tests/ui/borrow_box.rs:102:25 | LL | pub fn test14(_display: &Box) {} | ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:104:25 + --> tests/ui/borrow_box.rs:104:25 | LL | pub fn test15(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:106:29 + --> tests/ui/borrow_box.rs:106:29 | LL | pub fn test16<'a>(_display: &'a Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:109:25 + --> tests/ui/borrow_box.rs:109:25 | LL | pub fn test17(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:111:25 + --> tests/ui/borrow_box.rs:111:25 | LL | pub fn test18(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:113:29 + --> tests/ui/borrow_box.rs:113:29 | LL | pub fn test19<'a>(_display: &'a Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:119:25 + --> tests/ui/borrow_box.rs:119:25 | LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` diff --git a/tests/ui/borrow_deref_ref.stderr b/tests/ui/borrow_deref_ref.stderr index c389d6797388b..7fa43ef49cf72 100644 --- a/tests/ui/borrow_deref_ref.stderr +++ b/tests/ui/borrow_deref_ref.stderr @@ -1,5 +1,5 @@ error: deref on an immutable reference - --> $DIR/borrow_deref_ref.rs:13:17 + --> tests/ui/borrow_deref_ref.rs:13:17 | LL | let b = &*a; | ^^^ help: if you would like to reborrow, try removing `&*`: `a` @@ -8,13 +8,13 @@ LL | let b = &*a; = help: to override `-D warnings` add `#[allow(clippy::borrow_deref_ref)]` error: deref on an immutable reference - --> $DIR/borrow_deref_ref.rs:15:22 + --> tests/ui/borrow_deref_ref.rs:15:22 | LL | let b = &mut &*bar(&12); | ^^^^^^^^^^ help: if you would like to reborrow, try removing `&*`: `bar(&12)` error: deref on an immutable reference - --> $DIR/borrow_deref_ref.rs:69:23 + --> tests/ui/borrow_deref_ref.rs:69:23 | LL | let addr_y = &&*x as *const _ as usize; // assert ok | ^^^ help: if you would like to reborrow, try removing `&*`: `x` diff --git a/tests/ui/borrow_deref_ref_unfixable.stderr b/tests/ui/borrow_deref_ref_unfixable.stderr index 296af6436934f..7d3a5c84a8202 100644 --- a/tests/ui/borrow_deref_ref_unfixable.stderr +++ b/tests/ui/borrow_deref_ref_unfixable.stderr @@ -1,5 +1,5 @@ error: deref on an immutable reference - --> $DIR/borrow_deref_ref_unfixable.rs:9:23 + --> tests/ui/borrow_deref_ref_unfixable.rs:9:23 | LL | let x: &str = &*s; | ^^^ diff --git a/tests/ui/borrow_interior_mutable_const/enums.stderr b/tests/ui/borrow_interior_mutable_const/enums.stderr index 4d035b493a898..43850384b9036 100644 --- a/tests/ui/borrow_interior_mutable_const/enums.stderr +++ b/tests/ui/borrow_interior_mutable_const/enums.stderr @@ -1,18 +1,18 @@ error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:22:14 + --> tests/ui/borrow_interior_mutable_const/enums.rs:22:14 | LL | let _ = &UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here - --> $DIR/borrow_interior_mutable_const/enums.rs:3:9 + --> tests/ui/borrow_interior_mutable_const/enums.rs:3:9 | LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:37:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:37:18 | LL | let _ = &Self::TO_BE_FROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | let _ = &Self::TO_BE_FROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:41:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:41:18 | LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:50:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:50:18 | LL | let _ = &::TO_BE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _ = &::TO_BE_UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:52:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:52:18 | LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:74:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:74:18 | LL | let _ = &::TO_BE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = &::TO_BE_UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:91:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:91:18 | LL | let _ = &Self::UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _ = &Self::UNFROZEN_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:92:18 + --> tests/ui/borrow_interior_mutable_const/enums.rs:92:18 | LL | let _ = &Self::GENERIC_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _ = &Self::GENERIC_VARIANT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/enums.rs:99:14 + --> tests/ui/borrow_interior_mutable_const/enums.rs:99:14 | LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/borrow_interior_mutable_const/others.stderr b/tests/ui/borrow_interior_mutable_const/others.stderr index 0120b59992991..33c774667f942 100644 --- a/tests/ui/borrow_interior_mutable_const/others.stderr +++ b/tests/ui/borrow_interior_mutable_const/others.stderr @@ -1,18 +1,18 @@ error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:54:5 + --> tests/ui/borrow_interior_mutable_const/others.rs:54:5 | LL | ATOMIC.store(1, Ordering::SeqCst); | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here - --> $DIR/borrow_interior_mutable_const/others.rs:1:9 + --> tests/ui/borrow_interior_mutable_const/others.rs:1:9 | LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:55:16 + --> tests/ui/borrow_interior_mutable_const/others.rs:55:16 | LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); | ^^^^^^ @@ -20,7 +20,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:58:22 + --> tests/ui/borrow_interior_mutable_const/others.rs:58:22 | LL | let _once_ref = &ONCE_INIT; | ^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _once_ref = &ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:59:25 + --> tests/ui/borrow_interior_mutable_const/others.rs:59:25 | LL | let _once_ref_2 = &&ONCE_INIT; | ^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _once_ref_2 = &&ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:60:27 + --> tests/ui/borrow_interior_mutable_const/others.rs:60:27 | LL | let _once_ref_4 = &&&&ONCE_INIT; | ^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:61:26 + --> tests/ui/borrow_interior_mutable_const/others.rs:61:26 | LL | let _once_mut = &mut ONCE_INIT; | ^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _once_mut = &mut ONCE_INIT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:72:14 + --> tests/ui/borrow_interior_mutable_const/others.rs:72:14 | LL | let _ = &ATOMIC_TUPLE; | ^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _ = &ATOMIC_TUPLE; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:73:14 + --> tests/ui/borrow_interior_mutable_const/others.rs:73:14 | LL | let _ = &ATOMIC_TUPLE.0; | ^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _ = &ATOMIC_TUPLE.0; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:74:19 + --> tests/ui/borrow_interior_mutable_const/others.rs:74:19 | LL | let _ = &(&&&&ATOMIC_TUPLE).0; | ^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:75:14 + --> tests/ui/borrow_interior_mutable_const/others.rs:75:14 | LL | let _ = &ATOMIC_TUPLE.0[0]; | ^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0]; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:76:13 + --> tests/ui/borrow_interior_mutable_const/others.rs:76:13 | LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); | ^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:82:13 + --> tests/ui/borrow_interior_mutable_const/others.rs:82:13 | LL | let _ = ATOMIC_TUPLE.0[0]; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _ = ATOMIC_TUPLE.0[0]; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:87:5 + --> tests/ui/borrow_interior_mutable_const/others.rs:87:5 | LL | CELL.set(2); | ^^^^ @@ -108,7 +108,7 @@ LL | CELL.set(2); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/others.rs:88:16 + --> tests/ui/borrow_interior_mutable_const/others.rs:88:16 | LL | assert_eq!(CELL.get(), 6); | ^^^^ diff --git a/tests/ui/borrow_interior_mutable_const/traits.stderr b/tests/ui/borrow_interior_mutable_const/traits.stderr index 5480811fde253..582b744b49ff8 100644 --- a/tests/ui/borrow_interior_mutable_const/traits.stderr +++ b/tests/ui/borrow_interior_mutable_const/traits.stderr @@ -1,18 +1,18 @@ error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:15:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:15:18 | LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here - --> $DIR/borrow_interior_mutable_const/traits.rs:1:9 + --> tests/ui/borrow_interior_mutable_const/traits.rs:1:9 | LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:26:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:26:18 | LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | let _ = &Self::ATOMIC; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:51:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:51:18 | LL | let _ = &Self::TO_BE_CONCRETE; | ^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _ = &Self::TO_BE_CONCRETE; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:86:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:86:18 | LL | let _ = &Self::TO_BE_UNFROZEN; | ^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _ = &Self::TO_BE_UNFROZEN; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:87:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:87:18 | LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:109:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:109:18 | LL | let _ = &Self::BOUNDED; | ^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = &Self::BOUNDED; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:122:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:122:18 | LL | let _ = &Self::BOUNDED; | ^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _ = &Self::BOUNDED; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:151:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:151:18 | LL | let _ = &Self::SELF; | ^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _ = &Self::SELF; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:152:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:152:18 | LL | let _ = &Self::WRAPPED_SELF; | ^^^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | let _ = &Self::WRAPPED_SELF; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:162:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:162:18 | LL | let _ = &Self::INDIRECT; | ^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | let _ = &Self::INDIRECT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:172:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:172:18 | LL | let _ = &Self::INDIRECT; | ^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | let _ = &Self::INDIRECT; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:191:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:191:18 | LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _ = &Self::ATOMIC; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:195:18 + --> tests/ui/borrow_interior_mutable_const/traits.rs:195:18 | LL | let _ = &Self::BOUNDED_ASSOC_TYPE; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | let _ = &Self::BOUNDED_ASSOC_TYPE; = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:200:5 + --> tests/ui/borrow_interior_mutable_const/traits.rs:200:5 | LL | u64::ATOMIC.store(5, Ordering::SeqCst); | ^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | u64::ATOMIC.store(5, Ordering::SeqCst); = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> $DIR/borrow_interior_mutable_const/traits.rs:201:16 + --> tests/ui/borrow_interior_mutable_const/traits.rs:201:16 | LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); | ^^^^^^^^^^^ diff --git a/tests/ui/box_collection.stderr b/tests/ui/box_collection.stderr index 1ae7c2a05e3dc..ebbc3d92b57f7 100644 --- a/tests/ui/box_collection.stderr +++ b/tests/ui/box_collection.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `Box>`. Consider using just `Vec<..>` - --> $DIR/box_collection.rs:21:15 + --> tests/ui/box_collection.rs:21:15 | LL | fn test1(foo: Box>) {} | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | fn test1(foo: Box>) {} = help: to override `-D warnings` add `#[allow(clippy::box_collection)]` error: you seem to be trying to use `Box`. Consider using just `String` - --> $DIR/box_collection.rs:29:15 + --> tests/ui/box_collection.rs:29:15 | LL | fn test3(foo: Box) {} | ^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn test3(foo: Box) {} = help: `String` is already on the heap, `Box` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `HashMap<..>` - --> $DIR/box_collection.rs:32:15 + --> tests/ui/box_collection.rs:32:15 | LL | fn test4(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn test4(foo: Box>) {} = help: `HashMap<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `HashSet<..>` - --> $DIR/box_collection.rs:35:15 + --> tests/ui/box_collection.rs:35:15 | LL | fn test5(foo: Box>) {} | ^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn test5(foo: Box>) {} = help: `HashSet<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `VecDeque<..>` - --> $DIR/box_collection.rs:38:15 + --> tests/ui/box_collection.rs:38:15 | LL | fn test6(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | fn test6(foo: Box>) {} = help: `VecDeque<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `LinkedList<..>` - --> $DIR/box_collection.rs:41:15 + --> tests/ui/box_collection.rs:41:15 | LL | fn test7(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn test7(foo: Box>) {} = help: `LinkedList<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `BTreeMap<..>` - --> $DIR/box_collection.rs:44:15 + --> tests/ui/box_collection.rs:44:15 | LL | fn test8(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn test8(foo: Box>) {} = help: `BTreeMap<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `BTreeSet<..>` - --> $DIR/box_collection.rs:47:15 + --> tests/ui/box_collection.rs:47:15 | LL | fn test9(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn test9(foo: Box>) {} = help: `BTreeSet<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `BinaryHeap<..>` - --> $DIR/box_collection.rs:50:16 + --> tests/ui/box_collection.rs:50:16 | LL | fn test10(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/box_default.stderr b/tests/ui/box_default.stderr index 004550c6c64a7..f727b377319b1 100644 --- a/tests/ui/box_default.stderr +++ b/tests/ui/box_default.stderr @@ -1,5 +1,5 @@ error: `Box::new(_)` of default value - --> $DIR/box_default.rs:22:32 + --> tests/ui/box_default.rs:22:32 | LL | let _string: Box = Box::new(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` @@ -8,91 +8,91 @@ LL | let _string: Box = Box::new(Default::default()); = help: to override `-D warnings` add `#[allow(clippy::box_default)]` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:23:17 + --> tests/ui/box_default.rs:23:17 | LL | let _byte = Box::new(u8::default()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:24:16 + --> tests/ui/box_default.rs:24:16 | LL | let _vec = Box::new(Vec::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::>::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:25:17 + --> tests/ui/box_default.rs:25:17 | LL | let _impl = Box::new(ImplementsDefault::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:26:18 + --> tests/ui/box_default.rs:26:18 | LL | let _impl2 = Box::new(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:27:42 + --> tests/ui/box_default.rs:27:42 | LL | let _impl3: Box = Box::new(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:29:28 + --> tests/ui/box_default.rs:29:28 | LL | let _in_macro = outer!(Box::new(String::new())); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:30:34 + --> tests/ui/box_default.rs:30:34 | LL | let _string_default = outer!(Box::new(String::from(""))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:31:46 + --> tests/ui/box_default.rs:31:46 | LL | let _vec2: Box> = Box::new(vec![]); | ^^^^^^^^^^^^^^^^ help: try: `Box::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:32:33 + --> tests/ui/box_default.rs:32:33 | LL | let _vec3: Box> = Box::new(Vec::from([])); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:33:25 + --> tests/ui/box_default.rs:33:25 | LL | let _vec4: Box<_> = Box::new(Vec::from([false; 0])); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::>::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:35:16 + --> tests/ui/box_default.rs:35:16 | LL | call_ty_fn(Box::new(u8::default())); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:47:5 + --> tests/ui/box_default.rs:47:5 | LL | Box::new(bool::default()) | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:64:28 + --> tests/ui/box_default.rs:64:28 | LL | let _: Box = Box::new(ImplementsDefault::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:73:17 + --> tests/ui/box_default.rs:73:17 | LL | let _ = Box::new(WeirdPathed::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` error: `Box::new(_)` of default value - --> $DIR/box_default.rs:85:18 + --> tests/ui/box_default.rs:85:18 | LL | Some(Box::new(Foo::default())) | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` diff --git a/tests/ui/boxed_local.stderr b/tests/ui/boxed_local.stderr index 187cc8fa18bac..d3156c820b2c5 100644 --- a/tests/ui/boxed_local.stderr +++ b/tests/ui/boxed_local.stderr @@ -1,5 +1,5 @@ error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:40:13 + --> tests/ui/boxed_local.rs:40:13 | LL | fn warn_arg(x: Box) { | ^ @@ -8,19 +8,19 @@ LL | fn warn_arg(x: Box) { = help: to override `-D warnings` add `#[allow(clippy::boxed_local)]` error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:123:12 + --> tests/ui/boxed_local.rs:123:12 | LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:188:44 + --> tests/ui/boxed_local.rs:188:44 | LL | fn default_impl_x(self: Box, x: Box) -> u32 { | ^ error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:196:16 + --> tests/ui/boxed_local.rs:196:16 | LL | fn foo(x: Box) {} | ^ diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_bottom.stderr index 52148987a87e0..68ebb6ad7811a 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -1,5 +1,5 @@ error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:35:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:35:5 | LL | / let result = false; LL | | @@ -11,7 +11,7 @@ LL | | }; | = note: the end suggestion probably needs some adjustments to use the expression result correctly note: the lint level is defined here - --> $DIR/branches_sharing_code/shared_at_bottom.rs:1:36 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:1:36 | LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL ~ result; | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:55:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:55:5 | LL | / println!("Same end of block"); LL | | @@ -40,7 +40,7 @@ LL + println!("Same end of block"); | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:73:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:73:5 | LL | / println!( LL | | @@ -61,7 +61,7 @@ LL + ); | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:86:9 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:86:9 | LL | / println!("Hello World"); LL | | @@ -75,7 +75,7 @@ LL + println!("Hello World"); | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:103:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:103:5 | LL | / let later_used_value = "A string value"; LL | | @@ -94,7 +94,7 @@ LL + println!("{}", later_used_value); | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:117:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:117:5 | LL | / let simple_examples = "I now identify as a &str :)"; LL | | @@ -112,7 +112,7 @@ LL + println!("This is the new simple_example: {}", simple_examples); | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:183:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:183:5 | LL | / x << 2 LL | | @@ -128,7 +128,7 @@ LL ~ x << 2; | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:192:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:192:5 | LL | / x * 4 LL | | @@ -144,7 +144,7 @@ LL + x * 4 | error: all if blocks contain the same code at the end - --> $DIR/branches_sharing_code/shared_at_bottom.rs:206:44 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:206:44 | LL | if x == 17 { b = 1; a = 0x99; } else { a = 0x99; } | ^^^^^^^^^^^ diff --git a/tests/ui/branches_sharing_code/shared_at_top.stderr b/tests/ui/branches_sharing_code/shared_at_top.stderr index b57f89542974d..0d4e19be1f523 100644 --- a/tests/ui/branches_sharing_code/shared_at_top.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top.stderr @@ -1,12 +1,12 @@ error: all if blocks contain the same code at the start - --> $DIR/branches_sharing_code/shared_at_top.rs:11:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:11:5 | LL | / if true { LL | | println!("Hello World!"); | |_________________________________^ | note: the lint level is defined here - --> $DIR/branches_sharing_code/shared_at_top.rs:1:9 + --> tests/ui/branches_sharing_code/shared_at_top.rs:1:9 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + if true { | error: all if blocks contain the same code at the start - --> $DIR/branches_sharing_code/shared_at_top.rs:21:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:21:5 | LL | / if x == 0 { LL | | let y = 9; @@ -35,7 +35,7 @@ LL + if x == 0 { | error: all if blocks contain the same code at the start - --> $DIR/branches_sharing_code/shared_at_top.rs:43:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:43:5 | LL | / let _ = if x == 7 { LL | | @@ -49,7 +49,7 @@ LL + let _ = if x == 7 { | error: all if blocks contain the same code at the start - --> $DIR/branches_sharing_code/shared_at_top.rs:62:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:62:5 | LL | / if x == 10 { LL | | let used_value_name = "Different type"; @@ -65,7 +65,7 @@ LL + if x == 10 { | error: all if blocks contain the same code at the start - --> $DIR/branches_sharing_code/shared_at_top.rs:77:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:77:5 | LL | / if x == 11 { LL | | @@ -82,7 +82,7 @@ LL + if x == 11 { | error: all if blocks contain the same code at the start - --> $DIR/branches_sharing_code/shared_at_top.rs:94:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:94:5 | LL | / if x == 2020 { LL | | @@ -98,7 +98,7 @@ LL + if x == 2020 { | error: this `if` has identical blocks - --> $DIR/branches_sharing_code/shared_at_top.rs:103:18 + --> tests/ui/branches_sharing_code/shared_at_top.rs:103:18 | LL | if x == 2019 { | __________________^ @@ -107,7 +107,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/branches_sharing_code/shared_at_top.rs:105:12 + --> tests/ui/branches_sharing_code/shared_at_top.rs:105:12 | LL | } else { | ____________^ @@ -115,7 +115,7 @@ LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual"); LL | | } | |_____^ note: the lint level is defined here - --> $DIR/branches_sharing_code/shared_at_top.rs:1:40 + --> tests/ui/branches_sharing_code/shared_at_top.rs:1:40 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr index 1d3a3d463e1bf..b79307f96778a 100644 --- a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr @@ -1,5 +1,5 @@ error: all if blocks contain the same code at both the start and the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:17:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:17:5 | LL | / if x == 7 { LL | | @@ -9,13 +9,13 @@ LL | | let _overlap_end = 2 * t; | |_________________________________^ | note: this code is shared at the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:30:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:30:5 | LL | / let _u = 9; LL | | } | |_____^ note: the lint level is defined here - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:1:9 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:1:9 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL + let _u = 9; | error: all if blocks contain the same code at both the start and the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:34:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:34:5 | LL | / if x == 99 { LL | | @@ -43,7 +43,7 @@ LL | | let _overlap_middle = r * r; | |____________________________________^ | note: this code is shared at the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:46:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:46:5 | LL | / let _overlap_end = r * r * r; LL | | let z = "end"; @@ -65,7 +65,7 @@ LL + let z = "end"; | error: all if blocks contain the same code at both the start and the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:64:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:64:5 | LL | / if (x > 7 && y < 13) || (x + y) % 2 == 1 { LL | | @@ -75,7 +75,7 @@ LL | | let e_id = gen_id(a, b); | |________________________________^ | note: this code is shared at the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:85:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:85:5 | LL | / let pack = DataPack { LL | | id: e_id, @@ -105,7 +105,7 @@ LL + process_data(pack); | error: all if blocks contain the same code at both the start and the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:98:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:98:5 | LL | / let _ = if x == 7 { LL | | @@ -113,7 +113,7 @@ LL | | let _ = 19; | |___________________^ | note: this code is shared at the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:108:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:108:5 | LL | / x << 2 LL | | }; @@ -131,7 +131,7 @@ LL ~ x << 2; | error: all if blocks contain the same code at both the start and the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:111:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:111:5 | LL | / if x == 9 { LL | | @@ -139,7 +139,7 @@ LL | | let _ = 17; | |___________________^ | note: this code is shared at the end - --> $DIR/branches_sharing_code/shared_at_top_and_bottom.rs:121:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:121:5 | LL | / x * 4 LL | | } diff --git a/tests/ui/branches_sharing_code/valid_if_blocks.stderr b/tests/ui/branches_sharing_code/valid_if_blocks.stderr index 151adba77c22b..4c7e4141b629c 100644 --- a/tests/ui/branches_sharing_code/valid_if_blocks.stderr +++ b/tests/ui/branches_sharing_code/valid_if_blocks.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/branches_sharing_code/valid_if_blocks.rs:109:14 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:109:14 | LL | if false { | ______________^ @@ -7,20 +7,20 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/branches_sharing_code/valid_if_blocks.rs:110:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:110:12 | LL | } else { | ____________^ LL | | } | |_____^ note: the lint level is defined here - --> $DIR/branches_sharing_code/valid_if_blocks.rs:1:40 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:1:40 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has identical blocks - --> $DIR/branches_sharing_code/valid_if_blocks.rs:121:15 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:121:15 | LL | if x == 0 { | _______________^ @@ -31,7 +31,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/branches_sharing_code/valid_if_blocks.rs:125:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:125:12 | LL | } else { | ____________^ @@ -42,19 +42,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/branches_sharing_code/valid_if_blocks.rs:133:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:133:23 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ | note: same as this - --> $DIR/branches_sharing_code/valid_if_blocks.rs:133:34 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:133:34 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ error: this `if` has identical blocks - --> $DIR/branches_sharing_code/valid_if_blocks.rs:140:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:140:23 | LL | } else if x == 68 { | _______________________^ @@ -65,7 +65,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/branches_sharing_code/valid_if_blocks.rs:144:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:144:12 | LL | } else { | ____________^ @@ -76,7 +76,7 @@ LL | | }; | |_____^ error: this `if` has identical blocks - --> $DIR/branches_sharing_code/valid_if_blocks.rs:153:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:153:23 | LL | } else if x == 68 { | _______________________^ @@ -85,7 +85,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/branches_sharing_code/valid_if_blocks.rs:155:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:155:12 | LL | } else { | ____________^ diff --git a/tests/ui/builtin_type_shadow.stderr b/tests/ui/builtin_type_shadow.stderr index e051c00eb8d2c..1e15cdee772a2 100644 --- a/tests/ui/builtin_type_shadow.stderr +++ b/tests/ui/builtin_type_shadow.stderr @@ -1,5 +1,5 @@ error: this generic shadows the built-in type `u32` - --> $DIR/builtin_type_shadow.rs:4:8 + --> tests/ui/builtin_type_shadow.rs:4:8 | LL | fn foo(a: u32) -> u32 { | ^^^ @@ -8,7 +8,7 @@ LL | fn foo(a: u32) -> u32 { = help: to override `-D warnings` add `#[allow(clippy::builtin_type_shadow)]` error[E0308]: mismatched types - --> $DIR/builtin_type_shadow.rs:5:5 + --> tests/ui/builtin_type_shadow.rs:5:5 | LL | fn foo(a: u32) -> u32 { | --- --- expected `u32` because of return type diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index 39007f9d10aa2..d1a73fe983584 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -1,23 +1,23 @@ error: you appear to be counting bytes the naive way - --> $DIR/bytecount.rs:10:13 + --> tests/ui/bytecount.rs:10:13 | LL | let _ = x.iter().filter(|&&a| a == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, 0)` | note: the lint level is defined here - --> $DIR/bytecount.rs:5:8 + --> tests/ui/bytecount.rs:5:8 | LL | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: you appear to be counting bytes the naive way - --> $DIR/bytecount.rs:14:13 + --> tests/ui/bytecount.rs:14:13 | LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count((&x[..]), 0)` error: you appear to be counting bytes the naive way - --> $DIR/bytecount.rs:32:13 + --> tests/ui/bytecount.rs:32:13 | LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, b + 1)` diff --git a/tests/ui/bytes_count_to_len.stderr b/tests/ui/bytes_count_to_len.stderr index db0bb4099de9f..b80f3af18f780 100644 --- a/tests/ui/bytes_count_to_len.stderr +++ b/tests/ui/bytes_count_to_len.stderr @@ -1,5 +1,5 @@ error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:7:13 + --> tests/ui/bytes_count_to_len.rs:7:13 | LL | let _ = String::from("foo").bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `String::from("foo").len()` @@ -8,19 +8,19 @@ LL | let _ = String::from("foo").bytes().count(); = help: to override `-D warnings` add `#[allow(clippy::bytes_count_to_len)]` error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:10:13 + --> tests/ui/bytes_count_to_len.rs:10:13 | LL | let _ = s1.bytes().count(); | ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s1.len()` error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:13:13 + --> tests/ui/bytes_count_to_len.rs:13:13 | LL | let _ = "foo".bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `"foo".len()` error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:16:13 + --> tests/ui/bytes_count_to_len.rs:16:13 | LL | let _ = s2.bytes().count(); | ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s2.len()` diff --git a/tests/ui/bytes_nth.stderr b/tests/ui/bytes_nth.stderr index 574bfaac193db..c6f21576c3dbf 100644 --- a/tests/ui/bytes_nth.stderr +++ b/tests/ui/bytes_nth.stderr @@ -1,5 +1,5 @@ error: called `.bytes().nth()` on a `String` - --> $DIR/bytes_nth.rs:6:13 + --> tests/ui/bytes_nth.rs:6:13 | LL | let _ = s.bytes().nth(3); | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3).copied()` @@ -8,13 +8,13 @@ LL | let _ = s.bytes().nth(3); = help: to override `-D warnings` add `#[allow(clippy::bytes_nth)]` error: called `.bytes().nth().unwrap()` on a `String` - --> $DIR/bytes_nth.rs:7:14 + --> tests/ui/bytes_nth.rs:7:14 | LL | let _ = &s.bytes().nth(3).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.as_bytes()[3]` error: called `.bytes().nth()` on a `str` - --> $DIR/bytes_nth.rs:8:13 + --> tests/ui/bytes_nth.rs:8:13 | LL | let _ = s[..].bytes().nth(3); | ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3).copied()` diff --git a/tests/ui/case_sensitive_file_extension_comparisons.stderr b/tests/ui/case_sensitive_file_extension_comparisons.stderr index 49c840bd76924..d203f91b8323f 100644 --- a/tests/ui/case_sensitive_file_extension_comparisons.stderr +++ b/tests/ui/case_sensitive_file_extension_comparisons.stderr @@ -1,5 +1,5 @@ error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:13:5 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:13:5 | LL | filename.ends_with(".rs") | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL + .map_or(false, |ext| ext.eq_ignore_ascii_case("rs")) | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:18:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:18:13 | LL | let _ = String::new().ends_with(".ext12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:19:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:19:13 | LL | let _ = "str".ends_with(".ext12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:23:17 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:23:17 | LL | let _ = "str".ends_with(".ext12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:30:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:30:13 | LL | let _ = String::new().ends_with(".EXT12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("EXT12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:31:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:31:13 | LL | let _ = "str".ends_with(".EXT12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 4e37af7f37891..e2bcf94734e9a 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,5 +1,5 @@ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:16:5 + --> tests/ui/cast.rs:16:5 | LL | x0 as f32; | ^^^^^^^^^ @@ -8,37 +8,37 @@ LL | x0 as f32; = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:20:5 + --> tests/ui/cast.rs:20:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast.rs:22:5 + --> tests/ui/cast.rs:22:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:25:5 + --> tests/ui/cast.rs:25:5 | LL | x2 as f32; | ^^^^^^^^^ error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:28:5 + --> tests/ui/cast.rs:28:5 | LL | x3 as f32; | ^^^^^^^^^ error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast.rs:30:5 + --> tests/ui/cast.rs:30:5 | LL | x3 as f64; | ^^^^^^^^^ error: casting `f32` to `i32` may truncate the value - --> $DIR/cast.rs:33:5 + --> tests/ui/cast.rs:33:5 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | 1f32 as i32; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]` error: casting `f32` to `u32` may truncate the value - --> $DIR/cast.rs:35:5 + --> tests/ui/cast.rs:35:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | 1f32 as u32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:35:5 + --> tests/ui/cast.rs:35:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | 1f32 as u32; = help: to override `-D warnings` add `#[allow(clippy::cast_sign_loss)]` error: casting `f64` to `f32` may truncate the value - --> $DIR/cast.rs:39:5 + --> tests/ui/cast.rs:39:5 | LL | 1f64 as f32; | ^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | 1f64 as f32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `i32` to `i8` may truncate the value - --> $DIR/cast.rs:41:5 + --> tests/ui/cast.rs:41:5 | LL | 1i32 as i8; | ^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | i8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u8` may truncate the value - --> $DIR/cast.rs:43:5 + --> tests/ui/cast.rs:43:5 | LL | 1i32 as u8; | ^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | u8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `f64` to `isize` may truncate the value - --> $DIR/cast.rs:45:5 + --> tests/ui/cast.rs:45:5 | LL | 1f64 as isize; | ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 1f64 as isize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may truncate the value - --> $DIR/cast.rs:47:5 + --> tests/ui/cast.rs:47:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ @@ -113,13 +113,13 @@ LL | 1f64 as usize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may lose the sign of the value - --> $DIR/cast.rs:47:5 + --> tests/ui/cast.rs:47:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting `u32` to `u16` may truncate the value - --> $DIR/cast.rs:50:5 + --> tests/ui/cast.rs:50:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL | u16::try_from(1f32 as u32); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `f32` to `u32` may truncate the value - --> $DIR/cast.rs:50:5 + --> tests/ui/cast.rs:50:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | 1f32 as u32 as u16; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:50:5 + --> tests/ui/cast.rs:50:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ error: casting `i32` to `i8` may truncate the value - --> $DIR/cast.rs:55:22 + --> tests/ui/cast.rs:55:22 | LL | let _x: i8 = 1i32 as _; | ^^^^^^^^^ @@ -157,7 +157,7 @@ LL | let _x: i8 = 1i32.try_into(); | ~~~~~~~~~~~~~~~ error: casting `f32` to `i32` may truncate the value - --> $DIR/cast.rs:57:9 + --> tests/ui/cast.rs:57:9 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | 1f32 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `i32` may truncate the value - --> $DIR/cast.rs:59:9 + --> tests/ui/cast.rs:59:9 | LL | 1f64 as i32; | ^^^^^^^^^^^ @@ -173,7 +173,7 @@ LL | 1f64 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may truncate the value - --> $DIR/cast.rs:61:9 + --> tests/ui/cast.rs:61:9 | LL | 1f32 as u8; | ^^^^^^^^^^ @@ -181,13 +181,13 @@ LL | 1f32 as u8; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may lose the sign of the value - --> $DIR/cast.rs:61:9 + --> tests/ui/cast.rs:61:9 | LL | 1f32 as u8; | ^^^^^^^^^^ error: casting `u8` to `i8` may wrap around the value - --> $DIR/cast.rs:66:5 + --> tests/ui/cast.rs:66:5 | LL | 1u8 as i8; | ^^^^^^^^^ @@ -196,31 +196,31 @@ LL | 1u8 as i8; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `u16` to `i16` may wrap around the value - --> $DIR/cast.rs:69:5 + --> tests/ui/cast.rs:69:5 | LL | 1u16 as i16; | ^^^^^^^^^^^ error: casting `u32` to `i32` may wrap around the value - --> $DIR/cast.rs:71:5 + --> tests/ui/cast.rs:71:5 | LL | 1u32 as i32; | ^^^^^^^^^^^ error: casting `u64` to `i64` may wrap around the value - --> $DIR/cast.rs:73:5 + --> tests/ui/cast.rs:73:5 | LL | 1u64 as i64; | ^^^^^^^^^^^ error: casting `usize` to `isize` may wrap around the value - --> $DIR/cast.rs:75:5 + --> tests/ui/cast.rs:75:5 | LL | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting `usize` to `i8` may truncate the value - --> $DIR/cast.rs:78:5 + --> tests/ui/cast.rs:78:5 | LL | 1usize as i8; | ^^^^^^^^^^^^ @@ -232,7 +232,7 @@ LL | i8::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may truncate the value - --> $DIR/cast.rs:81:5 + --> tests/ui/cast.rs:81:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -244,7 +244,7 @@ LL | i16::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may wrap around the value on targets with 16-bit wide pointers - --> $DIR/cast.rs:81:5 + --> tests/ui/cast.rs:81:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | 1usize as i16; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:86:5 + --> tests/ui/cast.rs:86:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -265,19 +265,19 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:86:5 + --> tests/ui/cast.rs:86:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ error: casting `usize` to `i64` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:90:5 + --> tests/ui/cast.rs:90:5 | LL | 1usize as i64; | ^^^^^^^^^^^^^ error: casting `u16` to `isize` may wrap around the value on targets with 16-bit wide pointers - --> $DIR/cast.rs:95:5 + --> tests/ui/cast.rs:95:5 | LL | 1u16 as isize; | ^^^^^^^^^^^^^ @@ -286,13 +286,13 @@ LL | 1u16 as isize; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:99:5 + --> tests/ui/cast.rs:99:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:102:5 + --> tests/ui/cast.rs:102:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -304,25 +304,25 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:102:5 + --> tests/ui/cast.rs:102:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:107:5 + --> tests/ui/cast.rs:107:5 | LL | -1i32 as u32; | ^^^^^^^^^^^^ error: casting `isize` to `usize` may lose the sign of the value - --> $DIR/cast.rs:110:5 + --> tests/ui/cast.rs:110:5 | LL | -1isize as usize; | ^^^^^^^^^^^^^^^^ error: casting `i64` to `i8` may truncate the value - --> $DIR/cast.rs:179:5 + --> tests/ui/cast.rs:179:5 | LL | (-99999999999i64).min(1) as i8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -334,7 +334,7 @@ LL | i8::try_from((-99999999999i64).min(1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `u8` may truncate the value - --> $DIR/cast.rs:193:5 + --> tests/ui/cast.rs:193:5 | LL | 999999u64.clamp(0, 256) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -346,7 +346,7 @@ LL | u8::try_from(999999u64.clamp(0, 256)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E2` to `u8` may truncate the value - --> $DIR/cast.rs:216:21 + --> tests/ui/cast.rs:216:21 | LL | let _ = self as u8; | ^^^^^^^^^^ @@ -358,7 +358,7 @@ LL | let _ = u8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E2::B` to `u8` will truncate the value - --> $DIR/cast.rs:218:21 + --> tests/ui/cast.rs:218:21 | LL | let _ = Self::B as u8; | ^^^^^^^^^^^^^ @@ -367,7 +367,7 @@ LL | let _ = Self::B as u8; = help: to override `-D warnings` add `#[allow(clippy::cast_enum_truncation)]` error: casting `main::E5` to `i8` may truncate the value - --> $DIR/cast.rs:260:21 + --> tests/ui/cast.rs:260:21 | LL | let _ = self as i8; | ^^^^^^^^^^ @@ -379,13 +379,13 @@ LL | let _ = i8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E5::A` to `i8` will truncate the value - --> $DIR/cast.rs:262:21 + --> tests/ui/cast.rs:262:21 | LL | let _ = Self::A as i8; | ^^^^^^^^^^^^^ error: casting `main::E6` to `i16` may truncate the value - --> $DIR/cast.rs:279:21 + --> tests/ui/cast.rs:279:21 | LL | let _ = self as i16; | ^^^^^^^^^^^ @@ -397,7 +397,7 @@ LL | let _ = i16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:298:21 + --> tests/ui/cast.rs:298:21 | LL | let _ = self as usize; | ^^^^^^^^^^^^^ @@ -409,7 +409,7 @@ LL | let _ = usize::try_from(self); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E10` to `u16` may truncate the value - --> $DIR/cast.rs:345:21 + --> tests/ui/cast.rs:345:21 | LL | let _ = self as u16; | ^^^^^^^^^^^ @@ -421,7 +421,7 @@ LL | let _ = u16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> $DIR/cast.rs:356:13 + --> tests/ui/cast.rs:356:13 | LL | let c = (q >> 16) as u8; | ^^^^^^^^^^^^^^^ @@ -433,7 +433,7 @@ LL | let c = u8::try_from(q >> 16); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> $DIR/cast.rs:360:13 + --> tests/ui/cast.rs:360:13 | LL | let c = (q / 1000) as u8; | ^^^^^^^^^^^^^^^^ @@ -445,73 +445,73 @@ LL | let c = u8::try_from(q / 1000); | ~~~~~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:379:5 + --> tests/ui/cast.rs:379:5 | LL | (-2_i32).pow(3) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:384:5 + --> tests/ui/cast.rs:384:5 | LL | (x * x * x) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> $DIR/cast.rs:388:5 + --> tests/ui/cast.rs:388:5 | LL | (y * y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> $DIR/cast.rs:391:5 + --> tests/ui/cast.rs:391:5 | LL | (y * y * y * 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> $DIR/cast.rs:393:5 + --> tests/ui/cast.rs:393:5 | LL | (y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:398:9 + --> tests/ui/cast.rs:398:9 | LL | (a * b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:400:9 + --> tests/ui/cast.rs:400:9 | LL | (a * -b * c) as u32; | ^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:403:9 + --> tests/ui/cast.rs:403:9 | LL | (a * -2) as u32; | ^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:405:9 + --> tests/ui/cast.rs:405:9 | LL | (a * b * c * -2) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:408:9 + --> tests/ui/cast.rs:408:9 | LL | (a / b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:410:9 + --> tests/ui/cast.rs:410:9 | LL | (a / b + b * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:412:9 + --> tests/ui/cast.rs:412:9 | LL | a.pow(3) as u32; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_abs_to_unsigned.stderr b/tests/ui/cast_abs_to_unsigned.stderr index fbdb559fc4219..96e5c1724a51b 100644 --- a/tests/ui/cast_abs_to_unsigned.stderr +++ b/tests/ui/cast_abs_to_unsigned.stderr @@ -1,5 +1,5 @@ error: casting the result of `i32::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:6:18 + --> tests/ui/cast_abs_to_unsigned.rs:6:18 | LL | let y: u32 = x.abs() as u32; | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` @@ -8,103 +8,103 @@ LL | let y: u32 = x.abs() as u32; = help: to override `-D warnings` add `#[allow(clippy::cast_abs_to_unsigned)]` error: casting the result of `i32::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:10:20 + --> tests/ui/cast_abs_to_unsigned.rs:10:20 | LL | let _: usize = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i32::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:11:20 + --> tests/ui/cast_abs_to_unsigned.rs:11:20 | LL | let _: usize = a.abs() as _; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i32::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:12:13 + --> tests/ui/cast_abs_to_unsigned.rs:12:13 | LL | let _ = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:15:13 + --> tests/ui/cast_abs_to_unsigned.rs:15:13 | LL | let _ = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u8 - --> $DIR/cast_abs_to_unsigned.rs:16:13 + --> tests/ui/cast_abs_to_unsigned.rs:16:13 | LL | let _ = a.abs() as u8; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u16 - --> $DIR/cast_abs_to_unsigned.rs:17:13 + --> tests/ui/cast_abs_to_unsigned.rs:17:13 | LL | let _ = a.abs() as u16; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:18:13 + --> tests/ui/cast_abs_to_unsigned.rs:18:13 | LL | let _ = a.abs() as u32; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u64 - --> $DIR/cast_abs_to_unsigned.rs:19:13 + --> tests/ui/cast_abs_to_unsigned.rs:19:13 | LL | let _ = a.abs() as u64; | ^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u128 - --> $DIR/cast_abs_to_unsigned.rs:20:13 + --> tests/ui/cast_abs_to_unsigned.rs:20:13 | LL | let _ = a.abs() as u128; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:23:13 + --> tests/ui/cast_abs_to_unsigned.rs:23:13 | LL | let _ = a.abs() as usize; | ^^^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u8 - --> $DIR/cast_abs_to_unsigned.rs:24:13 + --> tests/ui/cast_abs_to_unsigned.rs:24:13 | LL | let _ = a.abs() as u8; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u16 - --> $DIR/cast_abs_to_unsigned.rs:25:13 + --> tests/ui/cast_abs_to_unsigned.rs:25:13 | LL | let _ = a.abs() as u16; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:26:13 + --> tests/ui/cast_abs_to_unsigned.rs:26:13 | LL | let _ = a.abs() as u32; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u64 - --> $DIR/cast_abs_to_unsigned.rs:27:13 + --> tests/ui/cast_abs_to_unsigned.rs:27:13 | LL | let _ = a.abs() as u64; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u128 - --> $DIR/cast_abs_to_unsigned.rs:28:13 + --> tests/ui/cast_abs_to_unsigned.rs:28:13 | LL | let _ = a.abs() as u128; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:30:13 + --> tests/ui/cast_abs_to_unsigned.rs:30:13 | LL | let _ = (x as i64 - y as i64).abs() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `(x as i64 - y as i64).unsigned_abs()` error: casting the result of `i32::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:42:23 + --> tests/ui/cast_abs_to_unsigned.rs:42:23 | LL | assert_eq!(10u32, x.abs() as u32); | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index 49bd8dad9c241..b32624f958fc2 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,5 +1,5 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:19:5 + --> tests/ui/cast_alignment.rs:19:5 | LL | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | (&1u8 as *const u8) as *const u16; = help: to override `-D warnings` add `#[allow(clippy::cast_ptr_alignment)]` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:22:5 + --> tests/ui/cast_alignment.rs:22:5 | LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:26:5 + --> tests/ui/cast_alignment.rs:26:5 | LL | (&1u8 as *const u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:28:5 + --> tests/ui/cast_alignment.rs:28:5 | LL | (&mut 1u8 as *mut u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_enum_constructor.stderr b/tests/ui/cast_enum_constructor.stderr index b1bf61edeedbe..67cca68073152 100644 --- a/tests/ui/cast_enum_constructor.stderr +++ b/tests/ui/cast_enum_constructor.stderr @@ -1,5 +1,5 @@ error: cast of an enum tuple constructor to an integer - --> $DIR/cast_enum_constructor.rs:13:13 + --> tests/ui/cast_enum_constructor.rs:13:13 | LL | let _ = Foo::Y as usize; | ^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = Foo::Y as usize; = help: to override `-D warnings` add `#[allow(clippy::cast_enum_constructor)]` error: cast of an enum tuple constructor to an integer - --> $DIR/cast_enum_constructor.rs:16:13 + --> tests/ui/cast_enum_constructor.rs:16:13 | LL | let _ = Foo::Y as isize; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_lossless_bool.stderr b/tests/ui/cast_lossless_bool.stderr index e4a5b2e805c35..792b30b7a38b3 100644 --- a/tests/ui/cast_lossless_bool.stderr +++ b/tests/ui/cast_lossless_bool.stderr @@ -1,5 +1,5 @@ error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` - --> $DIR/cast_lossless_bool.rs:6:13 + --> tests/ui/cast_lossless_bool.rs:6:13 | LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` @@ -8,79 +8,79 @@ LL | let _ = true as u8; = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` - --> $DIR/cast_lossless_bool.rs:7:13 + --> tests/ui/cast_lossless_bool.rs:7:13 | LL | let _ = true as u16; | ^^^^^^^^^^^ help: try: `u16::from(true)` error: casting `bool` to `u32` is more cleanly stated with `u32::from(_)` - --> $DIR/cast_lossless_bool.rs:8:13 + --> tests/ui/cast_lossless_bool.rs:8:13 | LL | let _ = true as u32; | ^^^^^^^^^^^ help: try: `u32::from(true)` error: casting `bool` to `u64` is more cleanly stated with `u64::from(_)` - --> $DIR/cast_lossless_bool.rs:9:13 + --> tests/ui/cast_lossless_bool.rs:9:13 | LL | let _ = true as u64; | ^^^^^^^^^^^ help: try: `u64::from(true)` error: casting `bool` to `u128` is more cleanly stated with `u128::from(_)` - --> $DIR/cast_lossless_bool.rs:10:13 + --> tests/ui/cast_lossless_bool.rs:10:13 | LL | let _ = true as u128; | ^^^^^^^^^^^^ help: try: `u128::from(true)` error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)` - --> $DIR/cast_lossless_bool.rs:11:13 + --> tests/ui/cast_lossless_bool.rs:11:13 | LL | let _ = true as usize; | ^^^^^^^^^^^^^ help: try: `usize::from(true)` error: casting `bool` to `i8` is more cleanly stated with `i8::from(_)` - --> $DIR/cast_lossless_bool.rs:13:13 + --> tests/ui/cast_lossless_bool.rs:13:13 | LL | let _ = true as i8; | ^^^^^^^^^^ help: try: `i8::from(true)` error: casting `bool` to `i16` is more cleanly stated with `i16::from(_)` - --> $DIR/cast_lossless_bool.rs:14:13 + --> tests/ui/cast_lossless_bool.rs:14:13 | LL | let _ = true as i16; | ^^^^^^^^^^^ help: try: `i16::from(true)` error: casting `bool` to `i32` is more cleanly stated with `i32::from(_)` - --> $DIR/cast_lossless_bool.rs:15:13 + --> tests/ui/cast_lossless_bool.rs:15:13 | LL | let _ = true as i32; | ^^^^^^^^^^^ help: try: `i32::from(true)` error: casting `bool` to `i64` is more cleanly stated with `i64::from(_)` - --> $DIR/cast_lossless_bool.rs:16:13 + --> tests/ui/cast_lossless_bool.rs:16:13 | LL | let _ = true as i64; | ^^^^^^^^^^^ help: try: `i64::from(true)` error: casting `bool` to `i128` is more cleanly stated with `i128::from(_)` - --> $DIR/cast_lossless_bool.rs:17:13 + --> tests/ui/cast_lossless_bool.rs:17:13 | LL | let _ = true as i128; | ^^^^^^^^^^^^ help: try: `i128::from(true)` error: casting `bool` to `isize` is more cleanly stated with `isize::from(_)` - --> $DIR/cast_lossless_bool.rs:18:13 + --> tests/ui/cast_lossless_bool.rs:18:13 | LL | let _ = true as isize; | ^^^^^^^^^^^^^ help: try: `isize::from(true)` error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` - --> $DIR/cast_lossless_bool.rs:21:13 + --> tests/ui/cast_lossless_bool.rs:21:13 | LL | let _ = (true | false) as u16; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)` error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` - --> $DIR/cast_lossless_bool.rs:49:13 + --> tests/ui/cast_lossless_bool.rs:49:13 | LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 95e80b4e4a6e7..e70f81eb91fc7 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,5 +1,5 @@ error: casting `i8` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:7:13 + --> tests/ui/cast_lossless_float.rs:7:13 | LL | let _ = x0 as f32; | ^^^^^^^^^ help: try: `f32::from(x0)` @@ -8,61 +8,61 @@ LL | let _ = x0 as f32; = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: casting `i8` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:8:13 + --> tests/ui/cast_lossless_float.rs:8:13 | LL | let _ = x0 as f64; | ^^^^^^^^^ help: try: `f64::from(x0)` error: casting `u8` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:10:13 + --> tests/ui/cast_lossless_float.rs:10:13 | LL | let _ = x1 as f32; | ^^^^^^^^^ help: try: `f32::from(x1)` error: casting `u8` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:11:13 + --> tests/ui/cast_lossless_float.rs:11:13 | LL | let _ = x1 as f64; | ^^^^^^^^^ help: try: `f64::from(x1)` error: casting `i16` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:13:13 + --> tests/ui/cast_lossless_float.rs:13:13 | LL | let _ = x2 as f32; | ^^^^^^^^^ help: try: `f32::from(x2)` error: casting `i16` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:14:13 + --> tests/ui/cast_lossless_float.rs:14:13 | LL | let _ = x2 as f64; | ^^^^^^^^^ help: try: `f64::from(x2)` error: casting `u16` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:16:13 + --> tests/ui/cast_lossless_float.rs:16:13 | LL | let _ = x3 as f32; | ^^^^^^^^^ help: try: `f32::from(x3)` error: casting `u16` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:17:13 + --> tests/ui/cast_lossless_float.rs:17:13 | LL | let _ = x3 as f64; | ^^^^^^^^^ help: try: `f64::from(x3)` error: casting `i32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:19:13 + --> tests/ui/cast_lossless_float.rs:19:13 | LL | let _ = x4 as f64; | ^^^^^^^^^ help: try: `f64::from(x4)` error: casting `u32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:21:13 + --> tests/ui/cast_lossless_float.rs:21:13 | LL | let _ = x5 as f64; | ^^^^^^^^^ help: try: `f64::from(x5)` error: casting `f32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:24:13 + --> tests/ui/cast_lossless_float.rs:24:13 | LL | let _ = 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index f9f111a7c20f1..43d4ce3ce9161 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,5 +1,5 @@ error: casting `i8` to `i16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:6:13 + --> tests/ui/cast_lossless_integer.rs:6:13 | LL | let _ = 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` @@ -8,121 +8,121 @@ LL | let _ = 1i8 as i16; = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: casting `i8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:7:13 + --> tests/ui/cast_lossless_integer.rs:7:13 | LL | let _ = 1i8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1i8)` error: casting `i8` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:8:13 + --> tests/ui/cast_lossless_integer.rs:8:13 | LL | let _ = 1i8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1i8)` error: casting `u8` to `i16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:9:13 + --> tests/ui/cast_lossless_integer.rs:9:13 | LL | let _ = 1u8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1u8)` error: casting `u8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:10:13 + --> tests/ui/cast_lossless_integer.rs:10:13 | LL | let _ = 1u8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1u8)` error: casting `u8` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:11:13 + --> tests/ui/cast_lossless_integer.rs:11:13 | LL | let _ = 1u8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1u8)` error: casting `u8` to `u16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:12:13 + --> tests/ui/cast_lossless_integer.rs:12:13 | LL | let _ = 1u8 as u16; | ^^^^^^^^^^ help: try: `u16::from(1u8)` error: casting `u8` to `u32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:13:13 + --> tests/ui/cast_lossless_integer.rs:13:13 | LL | let _ = 1u8 as u32; | ^^^^^^^^^^ help: try: `u32::from(1u8)` error: casting `u8` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:14:13 + --> tests/ui/cast_lossless_integer.rs:14:13 | LL | let _ = 1u8 as u64; | ^^^^^^^^^^ help: try: `u64::from(1u8)` error: casting `i16` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:15:13 + --> tests/ui/cast_lossless_integer.rs:15:13 | LL | let _ = 1i16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1i16)` error: casting `i16` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:16:13 + --> tests/ui/cast_lossless_integer.rs:16:13 | LL | let _ = 1i16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i16)` error: casting `u16` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:17:13 + --> tests/ui/cast_lossless_integer.rs:17:13 | LL | let _ = 1u16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1u16)` error: casting `u16` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:18:13 + --> tests/ui/cast_lossless_integer.rs:18:13 | LL | let _ = 1u16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u16)` error: casting `u16` to `u32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:19:13 + --> tests/ui/cast_lossless_integer.rs:19:13 | LL | let _ = 1u16 as u32; | ^^^^^^^^^^^ help: try: `u32::from(1u16)` error: casting `u16` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:20:13 + --> tests/ui/cast_lossless_integer.rs:20:13 | LL | let _ = 1u16 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u16)` error: casting `i32` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:21:13 + --> tests/ui/cast_lossless_integer.rs:21:13 | LL | let _ = 1i32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i32)` error: casting `u32` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:22:13 + --> tests/ui/cast_lossless_integer.rs:22:13 | LL | let _ = 1u32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u32)` error: casting `u32` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:23:13 + --> tests/ui/cast_lossless_integer.rs:23:13 | LL | let _ = 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` error: casting `u8` to `u16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:26:13 + --> tests/ui/cast_lossless_integer.rs:26:13 | LL | let _ = (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: casting `i8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:60:13 + --> tests/ui/cast_lossless_integer.rs:60:13 | LL | let _ = sign_cast!(x, u8, i8) as i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::from(sign_cast!(x, u8, i8))` error: casting `i8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:61:13 + --> tests/ui/cast_lossless_integer.rs:61:13 | LL | let _ = (sign_cast!(x, u8, i8) + 1) as i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::from(sign_cast!(x, u8, i8) + 1)` diff --git a/tests/ui/cast_nan_to_int.stderr b/tests/ui/cast_nan_to_int.stderr index c0bb29448f2f8..3cb46d1e79bb7 100644 --- a/tests/ui/cast_nan_to_int.stderr +++ b/tests/ui/cast_nan_to_int.stderr @@ -1,5 +1,5 @@ error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:5:13 + --> tests/ui/cast_nan_to_int.rs:5:13 | LL | let _ = (0.0_f32 / -0.0) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = (0.0_f32 / -0.0) as usize; = help: to override `-D warnings` add `#[allow(clippy::cast_nan_to_int)]` error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:8:13 + --> tests/ui/cast_nan_to_int.rs:8:13 | LL | let _ = (f64::INFINITY * -0.0) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = (f64::INFINITY * -0.0) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:11:13 + --> tests/ui/cast_nan_to_int.rs:11:13 | LL | let _ = (0.0 * f32::INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = (0.0 * f32::INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:15:13 + --> tests/ui/cast_nan_to_int.rs:15:13 | LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:18:13 + --> tests/ui/cast_nan_to_int.rs:18:13 | LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:21:13 + --> tests/ui/cast_nan_to_int.rs:21:13 | LL | let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_raw_slice_pointer_cast.stderr b/tests/ui/cast_raw_slice_pointer_cast.stderr index 47dc39a30ef7d..2aedd320a4289 100644 --- a/tests/ui/cast_raw_slice_pointer_cast.stderr +++ b/tests/ui/cast_raw_slice_pointer_cast.stderr @@ -1,5 +1,5 @@ error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:8:35 + --> tests/ui/cast_raw_slice_pointer_cast.rs:8:35 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) as *const [u8] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` @@ -8,37 +8,37 @@ LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) as *co = help: to override `-D warnings` add `#[allow(clippy::cast_slice_from_raw_parts)]` error: casting the result of `from_raw_parts_mut` to *mut [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:9:35 + --> tests/ui/cast_raw_slice_pointer_cast.rs:9:35 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts_mut(mptr, 1) as *mut [u8] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts_mut(mptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:10:26 + --> tests/ui/cast_raw_slice_pointer_cast.rs:10:26 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:13:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:13:30 | LL | let _: *const [u8] = unsafe { slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:15:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:15:30 | LL | let _: *const [u8] = unsafe { one::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:19:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:19:30 | LL | let _: *const [u8] = unsafe { slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:21:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:21:30 | LL | let _: *const [u8] = unsafe { one::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` diff --git a/tests/ui/cast_size.32bit.stderr b/tests/ui/cast_size.32bit.stderr index 379ca60862b9c..eb6c59deabba2 100644 --- a/tests/ui/cast_size.32bit.stderr +++ b/tests/ui/cast_size.32bit.stderr @@ -1,5 +1,5 @@ error: casting `isize` to `i8` may truncate the value - --> $DIR/cast_size.rs:15:5 + --> tests/ui/cast_size.rs:15:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | i8::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:18:5 + --> tests/ui/cast_size.rs:18:5 | LL | x0 as f64; | ^^^^^^^^^ @@ -22,25 +22,25 @@ LL | x0 as f64; = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:19:5 + --> tests/ui/cast_size.rs:19:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:20:5 + --> tests/ui/cast_size.rs:20:5 | LL | x0 as f32; | ^^^^^^^^^ error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:21:5 + --> tests/ui/cast_size.rs:21:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:22:5 + --> tests/ui/cast_size.rs:22:5 | LL | 1isize as i32; | ^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | i32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:23:5 + --> tests/ui/cast_size.rs:23:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | u32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:24:5 + --> tests/ui/cast_size.rs:24:5 | LL | 1usize as u32; | ^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | u32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 1usize as i32; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:26:5 + --> tests/ui/cast_size.rs:26:5 | LL | 1i64 as isize; | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | isize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> tests/ui/cast_size.rs:27:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | usize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -133,13 +133,13 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> tests/ui/cast_size.rs:29:5 | LL | 1u64 as usize; | ^^^^^^^^^^^^^ @@ -151,25 +151,25 @@ LL | usize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> tests/ui/cast_size.rs:30:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:35:5 + --> tests/ui/cast_size.rs:35:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:36:5 + --> tests/ui/cast_size.rs:36:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: literal out of range for `usize` - --> $DIR/cast_size.rs:36:5 + --> tests/ui/cast_size.rs:36:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_size.64bit.stderr b/tests/ui/cast_size.64bit.stderr index 7fae92b12503d..0dc4ca91529c6 100644 --- a/tests/ui/cast_size.64bit.stderr +++ b/tests/ui/cast_size.64bit.stderr @@ -1,5 +1,5 @@ error: casting `isize` to `i8` may truncate the value - --> $DIR/cast_size.rs:15:5 + --> tests/ui/cast_size.rs:15:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | i8::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:18:5 + --> tests/ui/cast_size.rs:18:5 | LL | x0 as f64; | ^^^^^^^^^ @@ -22,25 +22,25 @@ LL | x0 as f64; = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:19:5 + --> tests/ui/cast_size.rs:19:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:20:5 + --> tests/ui/cast_size.rs:20:5 | LL | x0 as f32; | ^^^^^^^^^ error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:21:5 + --> tests/ui/cast_size.rs:21:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:22:5 + --> tests/ui/cast_size.rs:22:5 | LL | 1isize as i32; | ^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | i32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:23:5 + --> tests/ui/cast_size.rs:23:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | u32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:24:5 + --> tests/ui/cast_size.rs:24:5 | LL | 1usize as u32; | ^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | u32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 1usize as i32; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:26:5 + --> tests/ui/cast_size.rs:26:5 | LL | 1i64 as isize; | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | isize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> tests/ui/cast_size.rs:27:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | usize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -133,13 +133,13 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> tests/ui/cast_size.rs:29:5 | LL | 1u64 as usize; | ^^^^^^^^^^^^^ @@ -151,19 +151,19 @@ LL | usize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> tests/ui/cast_size.rs:30:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:35:5 + --> tests/ui/cast_size.rs:35:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:36:5 + --> tests/ui/cast_size.rs:36:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_slice_different_sizes.stderr b/tests/ui/cast_slice_different_sizes.stderr index a5c38e310f67a..625de4a8359ba 100644 --- a/tests/ui/cast_slice_different_sizes.stderr +++ b/tests/ui/cast_slice_different_sizes.stderr @@ -1,5 +1,5 @@ error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:10:13 + --> tests/ui/cast_slice_different_sizes.rs:10:13 | LL | let b = a as *const [u8]; | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(a as *const u8, ..)` @@ -7,25 +7,25 @@ LL | let b = a as *const [u8]; = note: `#[deny(clippy::cast_slice_different_sizes)]` on by default error: casting between raw pointers to `[u8]` (element size 1) and `[u32]` (element size 4) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:13:13 + --> tests/ui/cast_slice_different_sizes.rs:13:13 | LL | let c = b as *const [u32]; | ^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(b as *const u32, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:17:16 + --> tests/ui/cast_slice_different_sizes.rs:17:16 | LL | let loss = r_x as *const [i32] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:25:24 + --> tests/ui/cast_slice_different_sizes.rs:25:24 | LL | let loss_block_1 = { r_x as *const [i32] } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts({ r_x as *const [i32] } as *const u8, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:27:24 + --> tests/ui/cast_slice_different_sizes.rs:27:24 | LL | let loss_block_2 = { | ________________________^ @@ -45,13 +45,13 @@ LL ~ } as *const u8, ..); | error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:45:27 + --> tests/ui/cast_slice_different_sizes.rs:45:27 | LL | let long_chain_loss = r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:61:36 + --> tests/ui/cast_slice_different_sizes.rs:61:36 | LL | fn bar(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -61,7 +61,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:66:36 + --> tests/ui/cast_slice_different_sizes.rs:66:36 | LL | fn uwu(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -71,7 +71,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:71:37 + --> tests/ui/cast_slice_different_sizes.rs:71:37 | LL | fn bar2(x: *mut [u16]) -> *mut [u8] { | _____________________________________^ @@ -81,7 +81,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:77:39 + --> tests/ui/cast_slice_different_sizes.rs:77:39 | LL | fn bar3(x: *mut [u16]) -> *const [u8] { | _______________________________________^ @@ -91,7 +91,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(x as *const u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:83:39 + --> tests/ui/cast_slice_different_sizes.rs:83:39 | LL | fn bar4(x: *const [u16]) -> *mut [u8] { | _______________________________________^ @@ -101,7 +101,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:89:39 + --> tests/ui/cast_slice_different_sizes.rs:89:39 | LL | fn blocks(x: *mut [u16]) -> *mut [u8] { | _______________________________________^ @@ -111,7 +111,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:94:44 + --> tests/ui/cast_slice_different_sizes.rs:94:44 | LL | fn more_blocks(x: *mut [u16]) -> *mut [u8] { | ____________________________________________^ @@ -122,7 +122,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:96:5 + --> tests/ui/cast_slice_different_sizes.rs:96:5 | LL | { ({ x }) as _ } | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` diff --git a/tests/ui/cfg_attr_cargo_clippy.stderr b/tests/ui/cfg_attr_cargo_clippy.stderr index 0d67f8cd7bc3b..ddec0e648d10c 100644 --- a/tests/ui/cfg_attr_cargo_clippy.stderr +++ b/tests/ui/cfg_attr_cargo_clippy.stderr @@ -1,5 +1,5 @@ error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:5:12 + --> tests/ui/cfg_attr_cargo_clippy.rs:5:12 | LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` @@ -8,37 +8,37 @@ LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] = help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]` error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:6:16 + --> tests/ui/cfg_attr_cargo_clippy.rs:6:16 | LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:7:7 + --> tests/ui/cfg_attr_cargo_clippy.rs:7:7 | LL | #[cfg(feature = "cargo-clippy")] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:8:11 + --> tests/ui/cfg_attr_cargo_clippy.rs:8:11 | LL | #[cfg(not(feature = "cargo-clippy"))] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:9:11 + --> tests/ui/cfg_attr_cargo_clippy.rs:9:11 | LL | #[cfg(any(feature = "cargo-clippy"))] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:10:11 + --> tests/ui/cfg_attr_cargo_clippy.rs:10:11 | LL | #[cfg(all(feature = "cargo-clippy"))] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` error: `feature = "cargo-clippy"` was replaced by `clippy` - --> $DIR/cfg_attr_cargo_clippy.rs:3:13 + --> tests/ui/cfg_attr_cargo_clippy.rs:3:13 | LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` diff --git a/tests/ui/cfg_attr_rustfmt.stderr b/tests/ui/cfg_attr_rustfmt.stderr index 8816ce2d83749..24b6ed1b0458d 100644 --- a/tests/ui/cfg_attr_rustfmt.stderr +++ b/tests/ui/cfg_attr_rustfmt.stderr @@ -1,5 +1,5 @@ error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes - --> $DIR/cfg_attr_rustfmt.rs:18:5 + --> tests/ui/cfg_attr_rustfmt.rs:18:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` @@ -8,13 +8,13 @@ LL | #[cfg_attr(rustfmt, rustfmt::skip)] = help: to override `-D warnings` add `#[allow(clippy::deprecated_cfg_attr)]` error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes - --> $DIR/cfg_attr_rustfmt.rs:22:1 + --> tests/ui/cfg_attr_rustfmt.rs:22:1 | LL | #[cfg_attr(rustfmt, rustfmt_skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes - --> $DIR/cfg_attr_rustfmt.rs:41:5 + --> tests/ui/cfg_attr_rustfmt.rs:41:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` diff --git a/tests/ui/cfg_features.stderr b/tests/ui/cfg_features.stderr index e1593e2071b49..d576271f1a291 100644 --- a/tests/ui/cfg_features.stderr +++ b/tests/ui/cfg_features.stderr @@ -1,5 +1,5 @@ error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:4:11 + --> tests/ui/cfg_features.rs:4:11 | LL | #[cfg(features = "not-really-a-feature")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "not-really-a-feature"` @@ -8,43 +8,43 @@ LL | #[cfg(features = "not-really-a-feature")] = help: to override `-D warnings` add `#[allow(clippy::maybe_misused_cfg)]` error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:9:34 + --> tests/ui/cfg_features.rs:9:34 | LL | #[cfg(all(feature = "right", features = "wrong"))] | ^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong"` error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:13:15 + --> tests/ui/cfg_features.rs:13:15 | LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))] | ^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong1"` error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:13:59 + --> tests/ui/cfg_features.rs:13:59 | LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))] | ^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong2"` error: 'test' may be misspelled as 'tests' - --> $DIR/cfg_features.rs:18:11 + --> tests/ui/cfg_features.rs:18:11 | LL | #[cfg(tests)] | ^^^^^ help: did you mean: `test` error: 'test' may be misspelled as 'Test' - --> $DIR/cfg_features.rs:21:11 + --> tests/ui/cfg_features.rs:21:11 | LL | #[cfg(Test)] | ^^^^ help: did you mean: `test` error: 'test' may be misspelled as 'tests' - --> $DIR/cfg_features.rs:25:15 + --> tests/ui/cfg_features.rs:25:15 | LL | #[cfg(all(tests, Test))] | ^^^^^ help: did you mean: `test` error: 'test' may be misspelled as 'Test' - --> $DIR/cfg_features.rs:25:22 + --> tests/ui/cfg_features.rs:25:22 | LL | #[cfg(all(tests, Test))] | ^^^^ help: did you mean: `test` diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index 22774d2f9f6d0..ec02f1341c0a3 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -1,5 +1,5 @@ error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8.rs:5:13 + --> tests/ui/char_lit_as_u8.rs:5:13 | LL | let _ = '❤' as u8; | ^^^^^^^^^ diff --git a/tests/ui/char_lit_as_u8_suggestions.stderr b/tests/ui/char_lit_as_u8_suggestions.stderr index 359857119d09c..4826aca42e1c3 100644 --- a/tests/ui/char_lit_as_u8_suggestions.stderr +++ b/tests/ui/char_lit_as_u8_suggestions.stderr @@ -1,5 +1,5 @@ error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:4:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:4:13 | LL | let _ = 'a' as u8; | ^^^^^^^^^ help: use a byte literal instead: `b'a'` @@ -9,7 +9,7 @@ LL | let _ = 'a' as u8; = help: to override `-D warnings` add `#[allow(clippy::char_lit_as_u8)]` error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:5:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:5:13 | LL | let _ = '\n' as u8; | ^^^^^^^^^^ help: use a byte literal instead: `b'\n'` @@ -17,7 +17,7 @@ LL | let _ = '\n' as u8; = note: `char` is four bytes wide, but `u8` is a single byte error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:6:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:6:13 | LL | let _ = '\0' as u8; | ^^^^^^^^^^ help: use a byte literal instead: `b'\0'` @@ -25,7 +25,7 @@ LL | let _ = '\0' as u8; = note: `char` is four bytes wide, but `u8` is a single byte error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:7:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:7:13 | LL | let _ = '\x01' as u8; | ^^^^^^^^^^^^ help: use a byte literal instead: `b'\x01'` diff --git a/tests/ui/checked_conversions.stderr b/tests/ui/checked_conversions.stderr index 3e0169b74dabc..223e379cce960 100644 --- a/tests/ui/checked_conversions.stderr +++ b/tests/ui/checked_conversions.stderr @@ -1,5 +1,5 @@ error: checked cast can be simplified - --> $DIR/checked_conversions.rs:14:13 + --> tests/ui/checked_conversions.rs:14:13 | LL | let _ = value <= (u32::max_value() as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` @@ -8,97 +8,97 @@ LL | let _ = value <= (u32::max_value() as i64) && value >= 0; = help: to override `-D warnings` add `#[allow(clippy::checked_conversions)]` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:15:13 + --> tests/ui/checked_conversions.rs:15:13 | LL | let _ = value <= (u32::MAX as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:19:13 + --> tests/ui/checked_conversions.rs:19:13 | LL | let _ = value <= i64::from(u16::max_value()) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:20:13 + --> tests/ui/checked_conversions.rs:20:13 | LL | let _ = value <= i64::from(u16::MAX) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:24:13 + --> tests/ui/checked_conversions.rs:24:13 | LL | let _ = value <= (u8::max_value() as isize) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:25:13 + --> tests/ui/checked_conversions.rs:25:13 | LL | let _ = value <= (u8::MAX as isize) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:31:13 + --> tests/ui/checked_conversions.rs:31:13 | LL | let _ = value <= (i32::max_value() as i64) && value >= (i32::min_value() as i64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:32:13 + --> tests/ui/checked_conversions.rs:32:13 | LL | let _ = value <= (i32::MAX as i64) && value >= (i32::MIN as i64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:36:13 + --> tests/ui/checked_conversions.rs:36:13 | LL | let _ = value <= i64::from(i16::max_value()) && value >= i64::from(i16::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:37:13 + --> tests/ui/checked_conversions.rs:37:13 | LL | let _ = value <= i64::from(i16::MAX) && value >= i64::from(i16::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:43:13 + --> tests/ui/checked_conversions.rs:43:13 | LL | let _ = value <= i32::max_value() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:44:13 + --> tests/ui/checked_conversions.rs:44:13 | LL | let _ = value <= i32::MAX as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:48:13 + --> tests/ui/checked_conversions.rs:48:13 | LL | let _ = value <= isize::max_value() as usize && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:49:13 + --> tests/ui/checked_conversions.rs:49:13 | LL | let _ = value <= isize::MAX as usize && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:53:13 + --> tests/ui/checked_conversions.rs:53:13 | LL | let _ = value <= u16::max_value() as u32 && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:54:13 + --> tests/ui/checked_conversions.rs:54:13 | LL | let _ = value <= u16::MAX as u32 && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:87:13 + --> tests/ui/checked_conversions.rs:87:13 | LL | let _ = value <= (u32::MAX as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` diff --git a/tests/ui/checked_unwrap/complex_conditionals.stderr b/tests/ui/checked_unwrap/complex_conditionals.stderr index 72599db146f65..aa72e8cce590f 100644 --- a/tests/ui/checked_unwrap/complex_conditionals.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:13:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:13:9 | LL | if x.is_ok() && y.is_err() { | --------- the check is happening here @@ -9,13 +9,13 @@ LL | x.unwrap(); | = help: try using `if let` or `match` note: the lint level is defined here - --> $DIR/checked_unwrap/complex_conditionals.rs:1:35 + --> tests/ui/checked_unwrap/complex_conditionals.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:16:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:16:9 | LL | if x.is_ok() && y.is_err() { | --------- because of this check @@ -24,13 +24,13 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/checked_unwrap/complex_conditionals.rs:1:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:19:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:19:9 | LL | if x.is_ok() && y.is_err() { | ---------- because of this check @@ -39,7 +39,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_err` - --> $DIR/checked_unwrap/complex_conditionals.rs:22:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:22:9 | LL | if x.is_ok() && y.is_err() { | ---------- the check is happening here @@ -50,7 +50,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:38:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:38:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -59,7 +59,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:41:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:41:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -70,7 +70,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:44:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:44:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -79,7 +79,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:47:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:47:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -90,7 +90,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:53:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:53:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -101,7 +101,7 @@ LL | x.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:56:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:56:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -110,7 +110,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:59:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:59:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -119,7 +119,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:62:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:62:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -130,7 +130,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `z` after checking its variant with `is_err` - --> $DIR/checked_unwrap/complex_conditionals.rs:65:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:65:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here @@ -141,7 +141,7 @@ LL | z.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:68:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:68:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check @@ -150,7 +150,7 @@ LL | z.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:78:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:78:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -159,7 +159,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:81:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:81:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -170,7 +170,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `y` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/complex_conditionals.rs:84:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:84:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -181,7 +181,7 @@ LL | y.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:87:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:87:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -190,7 +190,7 @@ LL | y.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals.rs:90:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:90:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check @@ -199,7 +199,7 @@ LL | z.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `z` after checking its variant with `is_err` - --> $DIR/checked_unwrap/complex_conditionals.rs:93:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:93:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- the check is happening here diff --git a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr index 8d93ef6036414..f7e659b10de07 100644 --- a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/checked_unwrap/complex_conditionals_nested.rs:13:13 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:13:13 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -8,13 +8,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/checked_unwrap/complex_conditionals_nested.rs:1:35 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/complex_conditionals_nested.rs:17:13 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:17:13 | LL | if x.is_some() { | ----------- because of this check @@ -23,7 +23,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/checked_unwrap/complex_conditionals_nested.rs:1:9 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/checked_unwrap/simple_conditionals.stderr b/tests/ui/checked_unwrap/simple_conditionals.stderr index c3eba55402364..bae6213376012 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/checked_unwrap/simple_conditionals.rs:47:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:47:9 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -8,13 +8,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/checked_unwrap/simple_conditionals.rs:3:35 + --> tests/ui/checked_unwrap/simple_conditionals.rs:3:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_some` - --> $DIR/checked_unwrap/simple_conditionals.rs:50:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:50:9 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -23,7 +23,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:54:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:54:9 | LL | if x.is_some() { | ----------- because of this check @@ -32,13 +32,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/checked_unwrap/simple_conditionals.rs:3:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:3:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `expect()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:57:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:57:9 | LL | if x.is_some() { | ----------- because of this check @@ -47,7 +47,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:62:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:62:9 | LL | if x.is_none() { | ----------- because of this check @@ -56,7 +56,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_none` - --> $DIR/checked_unwrap/simple_conditionals.rs:66:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:66:9 | LL | if x.is_none() { | -------------- help: try: `if let Some(..) = x` @@ -65,7 +65,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/checked_unwrap/simple_conditionals.rs:14:13 + --> tests/ui/checked_unwrap/simple_conditionals.rs:14:13 | LL | if $a.is_some() { | --------------- help: try: `if let Some(..) = x` @@ -79,7 +79,7 @@ LL | m!(x); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/simple_conditionals.rs:79:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:79:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok(..) = x` @@ -88,7 +88,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/simple_conditionals.rs:82:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:82:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok(..) = x` @@ -97,7 +97,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:85:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9 | LL | if x.is_ok() { | --------- because of this check @@ -106,7 +106,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:89:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9 | LL | if x.is_ok() { | --------- because of this check @@ -115,7 +115,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `expect()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:92:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:92:9 | LL | if x.is_ok() { | --------- because of this check @@ -124,7 +124,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/simple_conditionals.rs:95:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:95:9 | LL | if x.is_ok() { | ------------ help: try: `if let Err(..) = x` @@ -133,7 +133,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:100:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:100:9 | LL | if x.is_err() { | ---------- because of this check @@ -142,7 +142,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_err` - --> $DIR/checked_unwrap/simple_conditionals.rs:103:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:103:9 | LL | if x.is_err() { | ------------- help: try: `if let Err(..) = x` @@ -151,7 +151,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_err` - --> $DIR/checked_unwrap/simple_conditionals.rs:107:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:107:9 | LL | if x.is_err() { | ------------- help: try: `if let Ok(..) = x` @@ -160,7 +160,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:110:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9 | LL | if x.is_err() { | ---------- because of this check @@ -169,7 +169,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> $DIR/checked_unwrap/simple_conditionals.rs:135:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:135:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some(..) = &option` @@ -177,7 +177,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:138:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:138:9 | LL | if option.is_some() { | ---------------- because of this check @@ -186,7 +186,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/simple_conditionals.rs:145:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:145:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok(..) = &result` @@ -194,7 +194,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:148:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:148:9 | LL | if result.is_ok() { | -------------- because of this check @@ -203,7 +203,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> $DIR/checked_unwrap/simple_conditionals.rs:154:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:154:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some(..) = &mut option` @@ -211,7 +211,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:157:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:157:9 | LL | if option.is_some() { | ---------------- because of this check @@ -220,7 +220,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> $DIR/checked_unwrap/simple_conditionals.rs:163:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:163:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok(..) = &mut result` @@ -228,7 +228,7 @@ LL | result.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/checked_unwrap/simple_conditionals.rs:166:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:166:9 | LL | if result.is_ok() { | -------------- because of this check diff --git a/tests/ui/clear_with_drain.stderr b/tests/ui/clear_with_drain.stderr index b1a3812563afa..3c7d22192dc77 100644 --- a/tests/ui/clear_with_drain.stderr +++ b/tests/ui/clear_with_drain.stderr @@ -1,5 +1,5 @@ error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:22:7 + --> tests/ui/clear_with_drain.rs:22:7 | LL | v.drain(0..v.len()); | ^^^^^^^^^^^^^^^^^ help: try: `clear()` @@ -8,121 +8,121 @@ LL | v.drain(0..v.len()); = help: to override `-D warnings` add `#[allow(clippy::clear_with_drain)]` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:26:7 + --> tests/ui/clear_with_drain.rs:26:7 | LL | v.drain(usize::MIN..v.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:45:7 + --> tests/ui/clear_with_drain.rs:45:7 | LL | v.drain(0..); | ^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:49:7 + --> tests/ui/clear_with_drain.rs:49:7 | LL | v.drain(usize::MIN..); | ^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:65:7 + --> tests/ui/clear_with_drain.rs:65:7 | LL | v.drain(..); | ^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:82:7 + --> tests/ui/clear_with_drain.rs:82:7 | LL | v.drain(..v.len()); | ^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:120:11 + --> tests/ui/clear_with_drain.rs:120:11 | LL | deque.drain(0..deque.len()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:124:11 + --> tests/ui/clear_with_drain.rs:124:11 | LL | deque.drain(usize::MIN..deque.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:143:11 + --> tests/ui/clear_with_drain.rs:143:11 | LL | deque.drain(0..); | ^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:147:11 + --> tests/ui/clear_with_drain.rs:147:11 | LL | deque.drain(usize::MIN..); | ^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:163:11 + --> tests/ui/clear_with_drain.rs:163:11 | LL | deque.drain(..); | ^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:180:11 + --> tests/ui/clear_with_drain.rs:180:11 | LL | deque.drain(..deque.len()); | ^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:218:7 + --> tests/ui/clear_with_drain.rs:218:7 | LL | s.drain(0..s.len()); | ^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:222:7 + --> tests/ui/clear_with_drain.rs:222:7 | LL | s.drain(usize::MIN..s.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:241:7 + --> tests/ui/clear_with_drain.rs:241:7 | LL | s.drain(0..); | ^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:245:7 + --> tests/ui/clear_with_drain.rs:245:7 | LL | s.drain(usize::MIN..); | ^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:261:7 + --> tests/ui/clear_with_drain.rs:261:7 | LL | s.drain(..); | ^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:278:7 + --> tests/ui/clear_with_drain.rs:278:7 | LL | s.drain(..s.len()); | ^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `HashSet` - --> $DIR/clear_with_drain.rs:316:9 + --> tests/ui/clear_with_drain.rs:316:9 | LL | set.drain(); | ^^^^^^^ help: try: `clear()` error: `drain` used to clear a `HashMap` - --> $DIR/clear_with_drain.rs:335:9 + --> tests/ui/clear_with_drain.rs:335:9 | LL | map.drain(); | ^^^^^^^ help: try: `clear()` error: `drain` used to clear a `BinaryHeap` - --> $DIR/clear_with_drain.rs:354:10 + --> tests/ui/clear_with_drain.rs:354:10 | LL | heap.drain(); | ^^^^^^^ help: try: `clear()` diff --git a/tests/ui/clone_on_copy.stderr b/tests/ui/clone_on_copy.stderr index 0526c2f5a28a4..314fd13afca43 100644 --- a/tests/ui/clone_on_copy.stderr +++ b/tests/ui/clone_on_copy.stderr @@ -1,5 +1,5 @@ error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:23:5 + --> tests/ui/clone_on_copy.rs:23:5 | LL | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` @@ -8,49 +8,49 @@ LL | 42.clone(); = help: to override `-D warnings` add `#[allow(clippy::clone_on_copy)]` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:27:5 + --> tests/ui/clone_on_copy.rs:27:5 | LL | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:30:5 + --> tests/ui/clone_on_copy.rs:30:5 | LL | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` error: using `clone` on type `u32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:33:5 + --> tests/ui/clone_on_copy.rs:33:5 | LL | x.clone().rotate_left(1); | ^^^^^^^^^ help: try removing the `clone` call: `x` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:47:5 + --> tests/ui/clone_on_copy.rs:47:5 | LL | m!(42).clone(); | ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)` error: using `clone` on type `[u32; 2]` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:57:5 + --> tests/ui/clone_on_copy.rs:57:5 | LL | x.clone()[0]; | ^^^^^^^^^ help: try dereferencing it: `(*x)` error: using `clone` on type `char` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:67:14 + --> tests/ui/clone_on_copy.rs:67:14 | LL | is_ascii('z'.clone()); | ^^^^^^^^^^^ help: try removing the `clone` call: `'z'` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:71:14 + --> tests/ui/clone_on_copy.rs:71:14 | LL | vec.push(42.clone()); | ^^^^^^^^^^ help: try removing the `clone` call: `42` error: using `clone` on type `Option` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:75:17 + --> tests/ui/clone_on_copy.rs:75:17 | LL | let value = opt.clone()?; // operator precedence needed (*opt)? | ^^^^^^^^^^^ help: try dereferencing it: `(*opt)` diff --git a/tests/ui/cloned_instead_of_copied.stderr b/tests/ui/cloned_instead_of_copied.stderr index 69a3738dd05b5..ad857c4ef7d0f 100644 --- a/tests/ui/cloned_instead_of_copied.stderr +++ b/tests/ui/cloned_instead_of_copied.stderr @@ -1,5 +1,5 @@ error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:7:24 + --> tests/ui/cloned_instead_of_copied.rs:7:24 | LL | let _ = [1].iter().cloned(); | ^^^^^^ help: try: `copied` @@ -8,43 +8,43 @@ LL | let _ = [1].iter().cloned(); = help: to override `-D warnings` add `#[allow(clippy::cloned_instead_of_copied)]` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:8:31 + --> tests/ui/cloned_instead_of_copied.rs:8:31 | LL | let _ = vec!["hi"].iter().cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:9:22 + --> tests/ui/cloned_instead_of_copied.rs:9:22 | LL | let _ = Some(&1).cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:10:34 + --> tests/ui/cloned_instead_of_copied.rs:10:34 | LL | let _ = Box::new([1].iter()).cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:11:32 + --> tests/ui/cloned_instead_of_copied.rs:11:32 | LL | let _ = Box::new(Some(&1)).cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:27:22 + --> tests/ui/cloned_instead_of_copied.rs:27:22 | LL | let _ = Some(&1).cloned(); // Option::copied needs 1.35 | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:32:24 + --> tests/ui/cloned_instead_of_copied.rs:32:24 | LL | let _ = [1].iter().cloned(); // Iterator::copied needs 1.36 | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:33:22 + --> tests/ui/cloned_instead_of_copied.rs:33:22 | LL | let _ = Some(&1).cloned(); | ^^^^^^ help: try: `copied` diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index d3b7c85b22935..8362904a5ba9d 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,5 +1,5 @@ error: comparing with null is better expressed by the `.is_null()` method - --> $DIR/cmp_null.rs:9:8 + --> tests/ui/cmp_null.rs:9:8 | LL | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | if p == ptr::null() { = help: to override `-D warnings` add `#[allow(clippy::cmp_null)]` error: comparing with null is better expressed by the `.is_null()` method - --> $DIR/cmp_null.rs:16:8 + --> tests/ui/cmp_null.rs:16:8 | LL | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmp_owned/asymmetric_partial_eq.stderr b/tests/ui/cmp_owned/asymmetric_partial_eq.stderr index bcefef81d1425..e230d5f06bb05 100644 --- a/tests/ui/cmp_owned/asymmetric_partial_eq.stderr +++ b/tests/ui/cmp_owned/asymmetric_partial_eq.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/asymmetric_partial_eq.rs:46:12 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:46:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` @@ -8,7 +8,7 @@ LL | if borrowed.to_owned() == owned {} = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/asymmetric_partial_eq.rs:47:21 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:47:21 | LL | if owned == borrowed.to_owned() {} | ---------^^^^^^^^^^^^^^^^^^^ @@ -16,13 +16,13 @@ LL | if owned == borrowed.to_owned() {} | help: try: `borrowed == owned` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/asymmetric_partial_eq.rs:65:21 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:65:21 | LL | if owned == borrowed.to_owned() {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/asymmetric_partial_eq.rs:66:12 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:66:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^--------- @@ -30,7 +30,7 @@ LL | if borrowed.to_owned() == owned {} | help: try: `owned == borrowed` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/asymmetric_partial_eq.rs:92:20 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:92:20 | LL | if "Hi" == borrowed.to_string() {} | --------^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | if "Hi" == borrowed.to_string() {} | help: try: `borrowed == "Hi"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/asymmetric_partial_eq.rs:93:12 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:93:12 | LL | if borrowed.to_string() == "Hi" {} | ^^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` diff --git a/tests/ui/cmp_owned/comparison_flip.stderr b/tests/ui/cmp_owned/comparison_flip.stderr index 400da925c21db..cfb6978158b37 100644 --- a/tests/ui/cmp_owned/comparison_flip.stderr +++ b/tests/ui/cmp_owned/comparison_flip.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/comparison_flip.rs:6:8 + --> tests/ui/cmp_owned/comparison_flip.rs:6:8 | LL | if a.to_string() != "bar" { | ^^^^^^^^^^^^^ help: try: `a` @@ -8,7 +8,7 @@ LL | if a.to_string() != "bar" { = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/comparison_flip.rs:10:17 + --> tests/ui/cmp_owned/comparison_flip.rs:10:17 | LL | if "bar" != a.to_string() { | ---------^^^^^^^^^^^^^ diff --git a/tests/ui/cmp_owned/with_suggestion.stderr b/tests/ui/cmp_owned/with_suggestion.stderr index f236ada648af7..41448e0120039 100644 --- a/tests/ui/cmp_owned/with_suggestion.stderr +++ b/tests/ui/cmp_owned/with_suggestion.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/with_suggestion.rs:5:14 + --> tests/ui/cmp_owned/with_suggestion.rs:5:14 | LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` @@ -8,31 +8,31 @@ LL | x != "foo".to_string(); = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/with_suggestion.rs:7:9 + --> tests/ui/cmp_owned/with_suggestion.rs:7:9 | LL | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/with_suggestion.rs:14:10 + --> tests/ui/cmp_owned/with_suggestion.rs:14:10 | LL | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/with_suggestion.rs:16:10 + --> tests/ui/cmp_owned/with_suggestion.rs:16:10 | LL | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/with_suggestion.rs:20:5 + --> tests/ui/cmp_owned/with_suggestion.rs:20:5 | LL | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/with_suggestion.rs:22:30 + --> tests/ui/cmp_owned/with_suggestion.rs:22:30 | LL | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` diff --git a/tests/ui/cmp_owned/without_suggestion.stderr b/tests/ui/cmp_owned/without_suggestion.stderr index 07d3b7fa6df1a..13ca699b9fd3b 100644 --- a/tests/ui/cmp_owned/without_suggestion.stderr +++ b/tests/ui/cmp_owned/without_suggestion.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/without_suggestion.rs:7:5 + --> tests/ui/cmp_owned/without_suggestion.rs:7:5 | LL | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating @@ -8,13 +8,13 @@ LL | y.to_owned() == *x; = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/without_suggestion.rs:13:5 + --> tests/ui/cmp_owned/without_suggestion.rs:13:5 | LL | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned/without_suggestion.rs:25:9 + --> tests/ui/cmp_owned/without_suggestion.rs:25:9 | LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating diff --git a/tests/ui/cognitive_complexity.stderr b/tests/ui/cognitive_complexity.stderr index 58c7455d11a69..1e60247e5f584 100644 --- a/tests/ui/cognitive_complexity.stderr +++ b/tests/ui/cognitive_complexity.stderr @@ -1,5 +1,5 @@ error: the function has a cognitive complexity of (28/25) - --> $DIR/cognitive_complexity.rs:6:4 + --> tests/ui/cognitive_complexity.rs:6:4 | LL | fn main() { | ^^^^ @@ -9,7 +9,7 @@ LL | fn main() { = help: to override `-D warnings` add `#[allow(clippy::cognitive_complexity)]` error: the function has a cognitive complexity of (7/1) - --> $DIR/cognitive_complexity.rs:92:4 + --> tests/ui/cognitive_complexity.rs:92:4 | LL | fn kaboom() { | ^^^^^^ @@ -17,7 +17,7 @@ LL | fn kaboom() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:151:4 + --> tests/ui/cognitive_complexity.rs:151:4 | LL | fn baa() { | ^^^ @@ -25,7 +25,7 @@ LL | fn baa() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:153:13 + --> tests/ui/cognitive_complexity.rs:153:13 | LL | let x = || match 99 { | ^^ @@ -33,7 +33,7 @@ LL | let x = || match 99 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:171:4 + --> tests/ui/cognitive_complexity.rs:171:4 | LL | fn bar() { | ^^^ @@ -41,7 +41,7 @@ LL | fn bar() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:183:4 + --> tests/ui/cognitive_complexity.rs:183:4 | LL | fn dont_warn_on_tests() { | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn dont_warn_on_tests() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:192:4 + --> tests/ui/cognitive_complexity.rs:192:4 | LL | fn barr() { | ^^^^ @@ -57,7 +57,7 @@ LL | fn barr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> $DIR/cognitive_complexity.rs:203:4 + --> tests/ui/cognitive_complexity.rs:203:4 | LL | fn barr2() { | ^^^^^ @@ -65,7 +65,7 @@ LL | fn barr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:220:4 + --> tests/ui/cognitive_complexity.rs:220:4 | LL | fn barrr() { | ^^^^^ @@ -73,7 +73,7 @@ LL | fn barrr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> $DIR/cognitive_complexity.rs:231:4 + --> tests/ui/cognitive_complexity.rs:231:4 | LL | fn barrr2() { | ^^^^^^ @@ -81,7 +81,7 @@ LL | fn barrr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:248:4 + --> tests/ui/cognitive_complexity.rs:248:4 | LL | fn barrrr() { | ^^^^^^ @@ -89,7 +89,7 @@ LL | fn barrrr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> $DIR/cognitive_complexity.rs:259:4 + --> tests/ui/cognitive_complexity.rs:259:4 | LL | fn barrrr2() { | ^^^^^^^ @@ -97,7 +97,7 @@ LL | fn barrrr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:276:4 + --> tests/ui/cognitive_complexity.rs:276:4 | LL | fn cake() { | ^^^^ @@ -105,7 +105,7 @@ LL | fn cake() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (4/1) - --> $DIR/cognitive_complexity.rs:287:8 + --> tests/ui/cognitive_complexity.rs:287:8 | LL | pub fn read_file(input_path: &str) -> String { | ^^^^^^^^^ @@ -113,7 +113,7 @@ LL | pub fn read_file(input_path: &str) -> String { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:319:4 + --> tests/ui/cognitive_complexity.rs:319:4 | LL | fn void(void: Void) { | ^^^^ @@ -121,7 +121,7 @@ LL | fn void(void: Void) { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (8/1) - --> $DIR/cognitive_complexity.rs:371:4 + --> tests/ui/cognitive_complexity.rs:371:4 | LL | fn early_ret() -> i32 { | ^^^^^^^^^ @@ -129,7 +129,7 @@ LL | fn early_ret() -> i32 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:393:13 + --> tests/ui/cognitive_complexity.rs:393:13 | LL | let x = |a: i32, b: i32| -> i32 { | ^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | let x = |a: i32, b: i32| -> i32 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:407:8 + --> tests/ui/cognitive_complexity.rs:407:8 | LL | fn moo(&self) { | ^^^ @@ -145,7 +145,7 @@ LL | fn moo(&self) { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:417:14 + --> tests/ui/cognitive_complexity.rs:417:14 | LL | async fn a() { | ^ @@ -153,7 +153,7 @@ LL | async fn a() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:425:22 + --> tests/ui/cognitive_complexity.rs:425:22 | LL | pub async fn async_method() { | ^^^^^^^^^^^^ diff --git a/tests/ui/cognitive_complexity_attr_used.stderr b/tests/ui/cognitive_complexity_attr_used.stderr index b9af72371e6a6..88de135409b5b 100644 --- a/tests/ui/cognitive_complexity_attr_used.stderr +++ b/tests/ui/cognitive_complexity_attr_used.stderr @@ -1,5 +1,5 @@ error: the function has a cognitive complexity of (3/0) - --> $DIR/cognitive_complexity_attr_used.rs:9:4 + --> tests/ui/cognitive_complexity_attr_used.rs:9:4 | LL | fn kaboom() { | ^^^^^^ diff --git a/tests/ui/collapsible_else_if.stderr b/tests/ui/collapsible_else_if.stderr index f0f840653f8ac..dc19d90b4d132 100644 --- a/tests/ui/collapsible_else_if.stderr +++ b/tests/ui/collapsible_else_if.stderr @@ -1,5 +1,5 @@ error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:13:12 + --> tests/ui/collapsible_else_if.rs:13:12 | LL | } else { | ____________^ @@ -19,7 +19,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:21:12 + --> tests/ui/collapsible_else_if.rs:21:12 | LL | } else { | ____________^ @@ -37,7 +37,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:29:12 + --> tests/ui/collapsible_else_if.rs:29:12 | LL | } else { | ____________^ @@ -60,7 +60,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:40:12 + --> tests/ui/collapsible_else_if.rs:40:12 | LL | } else { | ____________^ @@ -83,7 +83,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:51:12 + --> tests/ui/collapsible_else_if.rs:51:12 | LL | } else { | ____________^ @@ -106,7 +106,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:62:12 + --> tests/ui/collapsible_else_if.rs:62:12 | LL | } else { | ____________^ @@ -129,7 +129,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:73:12 + --> tests/ui/collapsible_else_if.rs:73:12 | LL | } else { | ____________^ @@ -152,7 +152,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:96:10 + --> tests/ui/collapsible_else_if.rs:96:10 | LL | }else{ | __________^ diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 16df3e433db49..5bcbdf2fd08da 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,5 +1,5 @@ error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:15:5 + --> tests/ui/collapsible_if.rs:15:5 | LL | / if x == "hello" { LL | | if y == "world" { @@ -18,7 +18,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:21:5 + --> tests/ui/collapsible_if.rs:21:5 | LL | / if x == "hello" || x == "world" { LL | | if y == "world" || y == "hello" { @@ -35,7 +35,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:27:5 + --> tests/ui/collapsible_if.rs:27:5 | LL | / if x == "hello" && x == "world" { LL | | if y == "world" || y == "hello" { @@ -52,7 +52,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:33:5 + --> tests/ui/collapsible_if.rs:33:5 | LL | / if x == "hello" || x == "world" { LL | | if y == "world" && y == "hello" { @@ -69,7 +69,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:39:5 + --> tests/ui/collapsible_if.rs:39:5 | LL | / if x == "hello" && x == "world" { LL | | if y == "world" && y == "hello" { @@ -86,7 +86,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:45:5 + --> tests/ui/collapsible_if.rs:45:5 | LL | / if 42 == 1337 { LL | | if 'a' != 'A' { @@ -103,7 +103,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:101:5 + --> tests/ui/collapsible_if.rs:101:5 | LL | / if x == "hello" { LL | | if y == "world" { // Collapsible @@ -120,7 +120,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:160:5 + --> tests/ui/collapsible_if.rs:160:5 | LL | / if matches!(true, true) { LL | | if matches!(true, true) {} @@ -128,7 +128,7 @@ LL | | } | |_____^ help: collapse nested if block: `if matches!(true, true) && matches!(true, true) {}` error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:165:5 + --> tests/ui/collapsible_if.rs:165:5 | LL | / if matches!(true, true) && truth() { LL | | if matches!(true, true) {} diff --git a/tests/ui/collapsible_match.stderr b/tests/ui/collapsible_match.stderr index ce7da1c16d30c..46b484ab05c4e 100644 --- a/tests/ui/collapsible_match.stderr +++ b/tests/ui/collapsible_match.stderr @@ -1,5 +1,5 @@ error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:13:20 + --> tests/ui/collapsible_match.rs:13:20 | LL | Ok(val) => match val { | ____________________^ @@ -10,7 +10,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:13:12 + --> tests/ui/collapsible_match.rs:13:12 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -21,7 +21,7 @@ LL | Some(n) => foo(n), = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]` error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:23:20 + --> tests/ui/collapsible_match.rs:23:20 | LL | Ok(val) => match val { | ____________________^ @@ -32,7 +32,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:23:12 + --> tests/ui/collapsible_match.rs:23:12 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -41,7 +41,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:33:9 + --> tests/ui/collapsible_match.rs:33:9 | LL | / if let Some(n) = val { LL | | @@ -50,7 +50,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:32:15 + --> tests/ui/collapsible_match.rs:32:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -58,7 +58,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:41:9 + --> tests/ui/collapsible_match.rs:41:9 | LL | / if let Some(n) = val { LL | | @@ -69,7 +69,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:40:15 + --> tests/ui/collapsible_match.rs:40:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -77,7 +77,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:53:9 + --> tests/ui/collapsible_match.rs:53:9 | LL | / match val { LL | | @@ -87,7 +87,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:52:15 + --> tests/ui/collapsible_match.rs:52:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -96,7 +96,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:63:13 + --> tests/ui/collapsible_match.rs:63:13 | LL | / if let Some(n) = val { LL | | @@ -105,7 +105,7 @@ LL | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:62:12 + --> tests/ui/collapsible_match.rs:62:12 | LL | Ok(val) => { | ^^^ replace this binding @@ -113,7 +113,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:73:9 + --> tests/ui/collapsible_match.rs:73:9 | LL | / match val { LL | | @@ -123,7 +123,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:72:15 + --> tests/ui/collapsible_match.rs:72:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -132,7 +132,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:85:13 + --> tests/ui/collapsible_match.rs:85:13 | LL | / if let Some(n) = val { LL | | @@ -143,7 +143,7 @@ LL | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:84:12 + --> tests/ui/collapsible_match.rs:84:12 | LL | Ok(val) => { | ^^^ replace this binding @@ -151,7 +151,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:97:20 + --> tests/ui/collapsible_match.rs:97:20 | LL | Ok(val) => match val { | ____________________^ @@ -162,7 +162,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:97:12 + --> tests/ui/collapsible_match.rs:97:12 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -171,7 +171,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:107:22 + --> tests/ui/collapsible_match.rs:107:22 | LL | Some(val) => match val { | ______________________^ @@ -182,7 +182,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:107:14 + --> tests/ui/collapsible_match.rs:107:14 | LL | Some(val) => match val { | ^^^ replace this binding @@ -191,7 +191,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:273:9 + --> tests/ui/collapsible_match.rs:273:9 | LL | / if let Some(u) = a { LL | | @@ -200,7 +200,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:272:27 + --> tests/ui/collapsible_match.rs:272:27 | LL | if let Issue9647::A { a, .. } = x { | ^ replace this binding @@ -208,7 +208,7 @@ LL | if let Some(u) = a { | ^^^^^^^ with this pattern, prefixed by a: error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:282:9 + --> tests/ui/collapsible_match.rs:282:9 | LL | / if let Some(u) = a { LL | | @@ -217,7 +217,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:281:35 + --> tests/ui/collapsible_match.rs:281:35 | LL | if let Issue9647::A { a: Some(a), .. } = x { | ^ replace this binding diff --git a/tests/ui/collapsible_match2.stderr b/tests/ui/collapsible_match2.stderr index e008355bec8aa..13caa78fbeb54 100644 --- a/tests/ui/collapsible_match2.stderr +++ b/tests/ui/collapsible_match2.stderr @@ -1,5 +1,5 @@ error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:13:34 + --> tests/ui/collapsible_match2.rs:13:34 | LL | Ok(val) if make() => match val { | __________________________________^ @@ -10,7 +10,7 @@ LL | | }, | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:13:16 + --> tests/ui/collapsible_match2.rs:13:16 | LL | Ok(val) if make() => match val { | ^^^ replace this binding @@ -21,7 +21,7 @@ LL | Some(n) => foo(n), = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]` error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:21:24 + --> tests/ui/collapsible_match2.rs:21:24 | LL | Ok(val) => match val { | ________________________^ @@ -32,7 +32,7 @@ LL | | }, | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:21:16 + --> tests/ui/collapsible_match2.rs:21:16 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -41,7 +41,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:36:29 + --> tests/ui/collapsible_match2.rs:36:29 | LL | $pat => match $e { | _____________________________^ @@ -54,7 +54,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ------------------------------------------------ in this macro invocation | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:48:28 + --> tests/ui/collapsible_match2.rs:48:28 | LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ^^^ ^^^^^^^ with this pattern @@ -63,7 +63,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:53:20 + --> tests/ui/collapsible_match2.rs:53:20 | LL | Some(s) => match *s { | ____________________^ @@ -74,7 +74,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:53:14 + --> tests/ui/collapsible_match2.rs:53:14 | LL | Some(s) => match *s { | ^ replace this binding @@ -83,7 +83,7 @@ LL | [n] => foo(n), | ^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:63:24 + --> tests/ui/collapsible_match2.rs:63:24 | LL | Some(ref s) => match s { | ________________________^ @@ -94,7 +94,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:63:14 + --> tests/ui/collapsible_match2.rs:63:14 | LL | Some(ref s) => match s { | ^^^^^ replace this binding diff --git a/tests/ui/collapsible_str_replace.stderr b/tests/ui/collapsible_str_replace.stderr index 4b0bd818d2f00..da681dffd8757 100644 --- a/tests/ui/collapsible_str_replace.stderr +++ b/tests/ui/collapsible_str_replace.stderr @@ -1,5 +1,5 @@ error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:18:27 + --> tests/ui/collapsible_str_replace.rs:18:27 | LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` @@ -8,19 +8,19 @@ LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l"); = help: to override `-D warnings` add `#[allow(clippy::collapsible_str_replace)]` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:20:27 + --> tests/ui/collapsible_str_replace.rs:20:27 | LL | let _ = "hesuo worpd".replace('s', l).replace('u', l); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], l)` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:22:27 + --> tests/ui/collapsible_str_replace.rs:22:27 | LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:25:10 + --> tests/ui/collapsible_str_replace.rs:25:10 | LL | .replace('s', "l") | __________^ @@ -30,61 +30,61 @@ LL | | .replace('d', "l"); | |__________________________^ help: replace with: `replace(['s', 'u', 'p', 'd'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:30:27 + --> tests/ui/collapsible_str_replace.rs:30:27 | LL | let _ = "hesuo world".replace(s, "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, 'u'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:32:27 + --> tests/ui/collapsible_str_replace.rs:32:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, 'u', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:34:27 + --> tests/ui/collapsible_str_replace.rs:34:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, u, 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:36:27 + --> tests/ui/collapsible_str_replace.rs:36:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace(p, "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, u, p], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:38:27 + --> tests/ui/collapsible_str_replace.rs:38:27 | LL | let _ = "hesuo worlp".replace('s', "l").replace('u', "l").replace('p', "d"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:40:45 + --> tests/ui/collapsible_str_replace.rs:40:45 | LL | let _ = "hesuo worpd".replace('s', "x").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['u', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:43:47 + --> tests/ui/collapsible_str_replace.rs:43:47 | LL | let _ = "hesudo worpd".replace("su", "l").replace('d', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['d', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:45:28 + --> tests/ui/collapsible_str_replace.rs:45:28 | LL | let _ = "hesudo worpd".replace(d, "l").replace('p', "l").replace("su", "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([d, 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:47:27 + --> tests/ui/collapsible_str_replace.rs:47:27 | LL | let _ = "hesuo world".replace(get_filter(), "l").replace('s', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([get_filter(), 's'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:84:16 + --> tests/ui/collapsible_str_replace.rs:84:16 | LL | let _ = "".replace('a', "1.58").replace('b', "1.58"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['a', 'b'], "1.58")` diff --git a/tests/ui/collection_is_never_read.stderr b/tests/ui/collection_is_never_read.stderr index acb9abff68e9b..f91ce07483c33 100644 --- a/tests/ui/collection_is_never_read.stderr +++ b/tests/ui/collection_is_never_read.stderr @@ -1,5 +1,5 @@ error: collection is never read - --> $DIR/collection_is_never_read.rs:21:5 + --> tests/ui/collection_is_never_read.rs:21:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,115 +8,115 @@ LL | let mut x = HashMap::new(); = help: to override `-D warnings` add `#[allow(clippy::collection_is_never_read)]` error: collection is never read - --> $DIR/collection_is_never_read.rs:62:5 + --> tests/ui/collection_is_never_read.rs:62:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:78:5 + --> tests/ui/collection_is_never_read.rs:78:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:84:5 + --> tests/ui/collection_is_never_read.rs:84:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:93:5 + --> tests/ui/collection_is_never_read.rs:93:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:100:5 + --> tests/ui/collection_is_never_read.rs:100:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:107:5 + --> tests/ui/collection_is_never_read.rs:107:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:115:5 + --> tests/ui/collection_is_never_read.rs:115:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:133:5 + --> tests/ui/collection_is_never_read.rs:133:5 | LL | let mut x = HashSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:148:5 + --> tests/ui/collection_is_never_read.rs:148:5 | LL | let x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:184:5 + --> tests/ui/collection_is_never_read.rs:184:5 | LL | let mut x = std::collections::BTreeMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:188:5 + --> tests/ui/collection_is_never_read.rs:188:5 | LL | let mut x = std::collections::BTreeSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:192:5 + --> tests/ui/collection_is_never_read.rs:192:5 | LL | let mut x = std::collections::BinaryHeap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:196:5 + --> tests/ui/collection_is_never_read.rs:196:5 | LL | let mut x = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:200:5 + --> tests/ui/collection_is_never_read.rs:200:5 | LL | let mut x = std::collections::HashSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:204:5 + --> tests/ui/collection_is_never_read.rs:204:5 | LL | let mut x = std::collections::LinkedList::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:208:5 + --> tests/ui/collection_is_never_read.rs:208:5 | LL | let mut x = Some(true); | ^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:212:5 + --> tests/ui/collection_is_never_read.rs:212:5 | LL | let mut x = String::from("hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:216:5 + --> tests/ui/collection_is_never_read.rs:216:5 | LL | let mut x = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:221:5 + --> tests/ui/collection_is_never_read.rs:221:5 | LL | let mut x = std::collections::VecDeque::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/comparison_chain.stderr b/tests/ui/comparison_chain.stderr index 3b41dcf55c623..96d8d819e6a55 100644 --- a/tests/ui/comparison_chain.stderr +++ b/tests/ui/comparison_chain.stderr @@ -1,5 +1,5 @@ error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:14:5 + --> tests/ui/comparison_chain.rs:14:5 | LL | / if x > y { LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::comparison_chain)]` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:28:5 + --> tests/ui/comparison_chain.rs:28:5 | LL | / if x > y { LL | | @@ -28,7 +28,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:37:5 + --> tests/ui/comparison_chain.rs:37:5 | LL | / if x > y { LL | | @@ -42,7 +42,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:46:5 + --> tests/ui/comparison_chain.rs:46:5 | LL | / if x > 1 { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:121:5 + --> tests/ui/comparison_chain.rs:121:5 | LL | / if x > y { LL | | @@ -69,7 +69,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:128:5 + --> tests/ui/comparison_chain.rs:128:5 | LL | / if x > y { LL | | @@ -83,7 +83,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:137:5 + --> tests/ui/comparison_chain.rs:137:5 | LL | / if x > y { LL | | diff --git a/tests/ui/comparison_to_empty.stderr b/tests/ui/comparison_to_empty.stderr index 83d431fd52b49..6b027459ed347 100644 --- a/tests/ui/comparison_to_empty.stderr +++ b/tests/ui/comparison_to_empty.stderr @@ -1,5 +1,5 @@ error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:8:13 + --> tests/ui/comparison_to_empty.rs:8:13 | LL | let _ = s == ""; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` @@ -8,49 +8,49 @@ LL | let _ = s == ""; = help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:9:13 + --> tests/ui/comparison_to_empty.rs:9:13 | LL | let _ = s != ""; | ^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!s.is_empty()` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:12:13 + --> tests/ui/comparison_to_empty.rs:12:13 | LL | let _ = v == []; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `v.is_empty()` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:13:13 + --> tests/ui/comparison_to_empty.rs:13:13 | LL | let _ = v != []; | ^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!v.is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:14:8 + --> tests/ui/comparison_to_empty.rs:14:8 | LL | if let [] = &*v {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(*v).is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:16:8 + --> tests/ui/comparison_to_empty.rs:16:8 | LL | if let [] = s {} | ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:17:8 + --> tests/ui/comparison_to_empty.rs:17:8 | LL | if let [] = &*s {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:18:8 + --> tests/ui/comparison_to_empty.rs:18:8 | LL | if let [] = &*s | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:19:12 + --> tests/ui/comparison_to_empty.rs:19:12 | LL | && s == [] | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` diff --git a/tests/ui/const_comparisons.stderr b/tests/ui/const_comparisons.stderr index f773ccbc711e9..1b8fd9733fae7 100644 --- a/tests/ui/const_comparisons.stderr +++ b/tests/ui/const_comparisons.stderr @@ -1,5 +1,5 @@ error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:45:5 + --> tests/ui/const_comparisons.rs:45:5 | LL | status_code <= 400 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | status_code <= 400 && status_code > 500; = help: to override `-D warnings` add `#[allow(clippy::impossible_comparisons)]` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:48:5 + --> tests/ui/const_comparisons.rs:48:5 | LL | status_code > 500 && status_code < 400; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | status_code > 500 && status_code < 400; = note: since `500` > `400`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:51:5 + --> tests/ui/const_comparisons.rs:51:5 | LL | status_code < 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | status_code < 500 && status_code > 500; = note: `status_code` cannot simultaneously be greater than and less than `500` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:56:5 + --> tests/ui/const_comparisons.rs:56:5 | LL | status_code < { 400 } && status_code > { 500 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | status_code < { 400 } && status_code > { 500 }; = note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:59:5 + --> tests/ui/const_comparisons.rs:59:5 | LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; = note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:62:5 + --> tests/ui/const_comparisons.rs:62:5 | LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; = note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:65:5 + --> tests/ui/const_comparisons.rs:65:5 | LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; = note: `status_code` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:70:5 + --> tests/ui/const_comparisons.rs:70:5 | LL | status < { 400 } && status > { 500 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | status < { 400 } && status > { 500 }; = note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:73:5 + --> tests/ui/const_comparisons.rs:73:5 | LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; = note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:76:5 + --> tests/ui/const_comparisons.rs:76:5 | LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; = note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:79:5 + --> tests/ui/const_comparisons.rs:79:5 | LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; = note: `status` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:89:5 + --> tests/ui/const_comparisons.rs:89:5 | LL | 500 >= status_code && 600 < status_code; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 500 >= status_code && 600 < status_code; = note: since `500` < `600`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:93:5 + --> tests/ui/const_comparisons.rs:93:5 | LL | 500 >= status_code && status_code > 600; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 500 >= status_code && status_code > 600; = note: since `500` < `600`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:103:5 + --> tests/ui/const_comparisons.rs:103:5 | LL | 500 >= status && 600 < status; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | 500 >= status && 600 < status; = note: since `500` < `600`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:107:5 + --> tests/ui/const_comparisons.rs:107:5 | LL | 500 >= status && status > 600; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,13 +121,13 @@ LL | 500 >= status && status > 600; = note: since `500` < `600`, the expression evaluates to false for any value of `status` error: right-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:112:5 + --> tests/ui/const_comparisons.rs:112:5 | LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 200` evaluates to true, status_code <= 299` will always evaluate to true as well - --> $DIR/const_comparisons.rs:112:23 + --> tests/ui/const_comparisons.rs:112:23 | LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^ @@ -135,67 +135,67 @@ LL | status_code < 200 && status_code <= 299; = help: to override `-D warnings` add `#[allow(clippy::redundant_comparisons)]` error: left-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:114:5 + --> tests/ui/const_comparisons.rs:114:5 | LL | status_code > 200 && status_code >= 299; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code >= 299` evaluates to true, status_code > 200` will always evaluate to true as well - --> $DIR/const_comparisons.rs:114:5 + --> tests/ui/const_comparisons.rs:114:5 | LL | status_code > 200 && status_code >= 299; | ^^^^^^^^^^^^^^^^^^^^^ error: left-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:118:5 + --> tests/ui/const_comparisons.rs:118:5 | LL | status_code >= 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:118:5 + --> tests/ui/const_comparisons.rs:118:5 | LL | status_code >= 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^ error: right-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:121:5 + --> tests/ui/const_comparisons.rs:121:5 | LL | status_code > 500 && status_code >= 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:121:23 + --> tests/ui/const_comparisons.rs:121:23 | LL | status_code > 500 && status_code >= 500; | ^^^^^^^^^^^^^^^^^^^^^ error: left-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:124:5 + --> tests/ui/const_comparisons.rs:124:5 | LL | status_code <= 500 && status_code < 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:124:5 + --> tests/ui/const_comparisons.rs:124:5 | LL | status_code <= 500 && status_code < 500; | ^^^^^^^^^^^^^^^^^^^^^^ error: right-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:127:5 + --> tests/ui/const_comparisons.rs:127:5 | LL | status_code < 500 && status_code <= 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:127:23 + --> tests/ui/const_comparisons.rs:127:23 | LL | status_code < 500 && status_code <= 500; | ^^^^^^^^^^^^^^^^^^^^^ error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:132:5 + --> tests/ui/const_comparisons.rs:132:5 | LL | name < "Jennifer" && name > "Shannon"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | name < "Jennifer" && name > "Shannon"; = note: since `"Jennifer"` < `"Shannon"`, the expression evaluates to false for any value of `name` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:137:5 + --> tests/ui/const_comparisons.rs:137:5 | LL | numbers < [3, 4] && numbers > [5, 6]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +211,7 @@ LL | numbers < [3, 4] && numbers > [5, 6]; = note: since `[3, 4]` < `[5, 6]`, the expression evaluates to false for any value of `numbers` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:142:5 + --> tests/ui/const_comparisons.rs:142:5 | LL | letter < 'b' && letter > 'c'; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | letter < 'b' && letter > 'c'; = note: since `'b'` < `'c'`, the expression evaluates to false for any value of `letter` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:147:5 + --> tests/ui/const_comparisons.rs:147:5 | LL | area < std::f32::consts::E && area > std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index 30535db50cc9a..533bddaadb5ec 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,5 +1,5 @@ error: you are implementing `Iterator` on a `Copy` type - --> $DIR/copy_iterator.rs:6:1 + --> tests/ui/copy_iterator.rs:6:1 | LL | / impl Iterator for Countdown { LL | | diff --git a/tests/ui/crashes/ice-10148.stderr b/tests/ui/crashes/ice-10148.stderr index 2451c496546b2..639cf2dd442b8 100644 --- a/tests/ui/crashes/ice-10148.stderr +++ b/tests/ui/crashes/ice-10148.stderr @@ -1,5 +1,5 @@ error: empty string literal in `println!` - --> $DIR/crashes/ice-10148.rs:8:5 + --> tests/ui/crashes/ice-10148.rs:8:5 | LL | println!(with_span!(""something "")); | ^^^^^^^^^^^^^^^^^^^^-----------^^^^^ diff --git a/tests/ui/crashes/ice-10645.stderr b/tests/ui/crashes/ice-10645.stderr index 47fa3d8530e9d..0269072b88bc1 100644 --- a/tests/ui/crashes/ice-10645.stderr +++ b/tests/ui/crashes/ice-10645.stderr @@ -1,11 +1,11 @@ warning: future cannot be sent between threads safely - --> $DIR/crashes/ice-10645.rs:5:1 + --> tests/ui/crashes/ice-10645.rs:5:1 | LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `bar` is not `Send` | note: captured value is not `Send` - --> $DIR/crashes/ice-10645.rs:5:29 + --> tests/ui/crashes/ice-10645.rs:5:29 | LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^ has type `T` which is not `Send` diff --git a/tests/ui/crashes/ice-10912.stderr b/tests/ui/crashes/ice-10912.stderr index d2f7b540e48d3..cc80354c7c626 100644 --- a/tests/ui/crashes/ice-10912.stderr +++ b/tests/ui/crashes/ice-10912.stderr @@ -1,11 +1,11 @@ error: expected at least one digit in exponent - --> $DIR/crashes/ice-10912.rs:3:28 + --> tests/ui/crashes/ice-10912.rs:3:28 | LL | fn f2() -> impl Sized { && 3.14159265358979323846E } | ^^^^^^^^^^^^^^^^^^^^^^^ error: long literal lacking separators - --> $DIR/crashes/ice-10912.rs:3:28 + --> tests/ui/crashes/ice-10912.rs:3:28 | LL | fn f2() -> impl Sized { && 3.14159265358979323846E } | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider: `3.141_592_653_589_793_238_46` diff --git a/tests/ui/crashes/ice-11422.stderr b/tests/ui/crashes/ice-11422.stderr index 0e940c4280a1d..a340977f4699d 100644 --- a/tests/ui/crashes/ice-11422.stderr +++ b/tests/ui/crashes/ice-11422.stderr @@ -1,5 +1,5 @@ error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/crashes/ice-11422.rs:6:31 + --> tests/ui/crashes/ice-11422.rs:6:31 | LL | fn gen() -> impl PartialOrd + PartialEq + Debug {} | ^^^^^^^^^ diff --git a/tests/ui/crashes/ice-11803.stderr b/tests/ui/crashes/ice-11803.stderr index 338ce6371c959..f62de8e2b9dbe 100644 --- a/tests/ui/crashes/ice-11803.stderr +++ b/tests/ui/crashes/ice-11803.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/crashes/ice-11803.rs:5:54 + --> tests/ui/crashes/ice-11803.rs:5:54 | LL | pub fn g>>() { | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | pub fn g>, { /* Gen | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/crashes/ice-11803.rs:5:33 + --> tests/ui/crashes/ice-11803.rs:5:33 | LL | pub fn g>>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-2774.stderr b/tests/ui/crashes/ice-2774.stderr index 7c5c3508fec8d..a8c92166358af 100644 --- a/tests/ui/crashes/ice-2774.stderr +++ b/tests/ui/crashes/ice-2774.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/crashes/ice-2774.rs:15:28 + --> tests/ui/crashes/ice-2774.rs:15:28 | LL | pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { | ^^ ^^ diff --git a/tests/ui/crashes/ice-360.stderr b/tests/ui/crashes/ice-360.stderr index 7a17706e870b9..50b245c65cde5 100644 --- a/tests/ui/crashes/ice-360.stderr +++ b/tests/ui/crashes/ice-360.stderr @@ -1,5 +1,5 @@ error: this loop never actually loops - --> $DIR/crashes/ice-360.rs:5:5 + --> tests/ui/crashes/ice-360.rs:5:5 | LL | / loop { LL | | @@ -13,7 +13,7 @@ LL | | } = note: `#[deny(clippy::never_loop)]` on by default error: this loop could be written as a `while let` loop - --> $DIR/crashes/ice-360.rs:5:5 + --> tests/ui/crashes/ice-360.rs:5:5 | LL | / loop { LL | | @@ -28,7 +28,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/crashes/ice-360.rs:13:9 + --> tests/ui/crashes/ice-360.rs:13:9 | LL | loop {} | ^^^^^^^ diff --git a/tests/ui/crashes/ice-3717.stderr b/tests/ui/crashes/ice-3717.stderr index 66d4341b3d70a..54b18a9641afc 100644 --- a/tests/ui/crashes/ice-3717.stderr +++ b/tests/ui/crashes/ice-3717.stderr @@ -1,11 +1,11 @@ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/crashes/ice-3717.rs:7:21 + --> tests/ui/crashes/ice-3717.rs:7:21 | LL | pub fn ice_3717(_: &HashSet) { | ^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/crashes/ice-3717.rs:1:9 + --> tests/ui/crashes/ice-3717.rs:1:9 | LL | #![deny(clippy::implicit_hasher)] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-3891.stderr b/tests/ui/crashes/ice-3891.stderr index f8c02a175eefe..b6a2c9d3de839 100644 --- a/tests/ui/crashes/ice-3891.stderr +++ b/tests/ui/crashes/ice-3891.stderr @@ -1,5 +1,5 @@ error: invalid suffix `x` for number literal - --> $DIR/crashes/ice-3891.rs:2:5 + --> tests/ui/crashes/ice-3891.rs:2:5 | LL | 1x; | ^^ invalid suffix `x` diff --git a/tests/ui/crashes/ice-3969.stderr b/tests/ui/crashes/ice-3969.stderr index d090d457237e6..285efee36bd85 100644 --- a/tests/ui/crashes/ice-3969.stderr +++ b/tests/ui/crashes/ice-3969.stderr @@ -1,5 +1,5 @@ error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/crashes/ice-3969.rs:20:10 + --> tests/ui/crashes/ice-3969.rs:20:10 | LL | str: Sized; | ^^^^^ @@ -8,25 +8,25 @@ LL | str: Sized; = help: to override `-D warnings` add `#[allow(trivial_bounds)]` error: trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/crashes/ice-3969.rs:26:30 + --> tests/ui/crashes/ice-3969.rs:26:30 | LL | for<'a> Dst: Sized, | ^^^^^ error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/crashes/ice-3969.rs:34:10 + --> tests/ui/crashes/ice-3969.rs:34:10 | LL | str: Sized, | ^^^^^ error: trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters - --> $DIR/crashes/ice-3969.rs:42:13 + --> tests/ui/crashes/ice-3969.rs:42:13 | LL | String: ::std::ops::Neg, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters - --> $DIR/crashes/ice-3969.rs:50:10 + --> tests/ui/crashes/ice-3969.rs:50:10 | LL | i32: Iterator, | ^^^^^^^^ diff --git a/tests/ui/crashes/ice-5497.stderr b/tests/ui/crashes/ice-5497.stderr index cb09fecdffcf3..2f7dd3bd563a4 100644 --- a/tests/ui/crashes/ice-5497.stderr +++ b/tests/ui/crashes/ice-5497.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/crashes/ice-5497.rs:11:22 + --> tests/ui/crashes/ice-5497.rs:11:22 | LL | const OOB: i32 = [1][1] + T::OOB; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/crashes/ice-5835.stderr b/tests/ui/crashes/ice-5835.stderr index 20ea1b37056b6..45e5e9a4b83d5 100644 --- a/tests/ui/crashes/ice-5835.stderr +++ b/tests/ui/crashes/ice-5835.stderr @@ -1,5 +1,5 @@ error: using tabs in doc comments is not recommended - --> $DIR/crashes/ice-5835.rs:3:10 + --> tests/ui/crashes/ice-5835.rs:3:10 | LL | /// 位 | ^^^^ help: consider using four spaces per tab diff --git a/tests/ui/crashes/ice-5872.stderr b/tests/ui/crashes/ice-5872.stderr index b6651966f202d..3f6568d34542b 100644 --- a/tests/ui/crashes/ice-5872.stderr +++ b/tests/ui/crashes/ice-5872.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/crashes/ice-5872.rs:4:39 + --> tests/ui/crashes/ice-5872.rs:4:39 | LL | let _ = vec![1, 2, 3].into_iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` diff --git a/tests/ui/crashes/ice-6250.stderr b/tests/ui/crashes/ice-6250.stderr index 8f34accea92c7..c126547611f36 100644 --- a/tests/ui/crashes/ice-6250.stderr +++ b/tests/ui/crashes/ice-6250.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/crashes/ice-6250.rs:12:14 + --> tests/ui/crashes/ice-6250.rs:12:14 | LL | for reference in vec![1, 2, 3] { | --------- expected due to the type of this binding @@ -8,7 +8,7 @@ LL | Some(reference) = cache.data.get(key) { | ^^^^^^^^^ expected integer, found `&i32` error[E0308]: mismatched types - --> $DIR/crashes/ice-6250.rs:12:9 + --> tests/ui/crashes/ice-6250.rs:12:9 | LL | Some(reference) = cache.data.get(key) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` diff --git a/tests/ui/crashes/ice-6251.stderr b/tests/ui/crashes/ice-6251.stderr index e4d7929f2cdb8..82e7d72358697 100644 --- a/tests/ui/crashes/ice-6251.stderr +++ b/tests/ui/crashes/ice-6251.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/crashes/ice-6251.rs:4:45 + --> tests/ui/crashes/ice-6251.rs:4:45 | LL | fn bug() -> impl Iterator { | ^ doesn't have a size known at compile-time @@ -12,7 +12,7 @@ LL | fn bug() -> impl Iterator { | + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/crashes/ice-6251.rs:4:54 + --> tests/ui/crashes/ice-6251.rs:4:54 | LL | fn bug() -> impl Iterator { | ^ doesn't have a size known at compile-time @@ -21,13 +21,13 @@ LL | fn bug() -> impl Iterator { = note: the return type of a function must have a statically known size error[E0308]: mismatched types - --> $DIR/crashes/ice-6251.rs:4:44 + --> tests/ui/crashes/ice-6251.rs:4:44 | LL | fn bug() -> impl Iterator { | ^^^^^^^^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/crashes/ice-6251.rs:4:44: 4:53}` + found closure `{closure@tests/ui/crashes/ice-6251.rs:4:44: 4:53}` error: aborting due to 3 previous errors diff --git a/tests/ui/crashes/ice-6252.stderr b/tests/ui/crashes/ice-6252.stderr index 91e31c81ead59..ce3b9495eb1ea 100644 --- a/tests/ui/crashes/ice-6252.stderr +++ b/tests/ui/crashes/ice-6252.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `PhantomData` in this scope - --> $DIR/crashes/ice-6252.rs:9:9 + --> tests/ui/crashes/ice-6252.rs:9:9 | LL | _n: PhantomData, | ^^^^^^^^^^^ not found in this scope @@ -12,7 +12,7 @@ LL + use std::marker::PhantomData; | error[E0412]: cannot find type `VAL` in this scope - --> $DIR/crashes/ice-6252.rs:11:63 + --> tests/ui/crashes/ice-6252.rs:11:63 | LL | impl TypeVal for Multiply where N: TypeVal {} | ^^^ not found in this scope @@ -23,7 +23,7 @@ LL | impl TypeVal for Multiply where N: TypeVal {} | +++++ error[E0046]: not all trait items implemented, missing: `VAL` - --> $DIR/crashes/ice-6252.rs:11:1 + --> tests/ui/crashes/ice-6252.rs:11:1 | LL | const VAL: T; | ------------ `VAL` from trait diff --git a/tests/ui/crashes/ice-6255.stderr b/tests/ui/crashes/ice-6255.stderr index 5599ef08c384c..738e9d1bd5cad 100644 --- a/tests/ui/crashes/ice-6255.stderr +++ b/tests/ui/crashes/ice-6255.stderr @@ -1,5 +1,5 @@ error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/crashes/ice-6255.rs:6:9 + --> tests/ui/crashes/ice-6255.rs:6:9 | LL | extern crate std as core; | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-6256.stderr b/tests/ui/crashes/ice-6256.stderr index 1f9cdd31f8795..922772a6147bc 100644 --- a/tests/ui/crashes/ice-6256.stderr +++ b/tests/ui/crashes/ice-6256.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/crashes/ice-6256.rs:13:26 + --> tests/ui/crashes/ice-6256.rs:13:26 | LL | let f = |x: &dyn TT| x.func(); | - - ^^^^^^^^ diff --git a/tests/ui/crashes/ice-7169.stderr b/tests/ui/crashes/ice-7169.stderr index 5f75802037f9d..ac7d2862d3ade 100644 --- a/tests/ui/crashes/ice-7169.stderr +++ b/tests/ui/crashes/ice-7169.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/crashes/ice-7169.rs:10:12 + --> tests/ui/crashes/ice-7169.rs:10:12 | LL | if let Ok(_) = Ok::<_, ()>(A::::default()) {} | -------^^^^^-------------------------------------- help: try: `if Ok::<_, ()>(A::::default()).is_ok()` diff --git a/tests/ui/crashes/ice-7868.stderr b/tests/ui/crashes/ice-7868.stderr index 4b0d992e61363..1aba43604ff18 100644 --- a/tests/ui/crashes/ice-7868.stderr +++ b/tests/ui/crashes/ice-7868.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/crashes/auxiliary/ice-7868-aux.rs:2:5 + --> tests/ui/crashes/auxiliary/ice-7868-aux.rs:2:5 | LL | unsafe { 0 }; | ^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-7869.stderr b/tests/ui/crashes/ice-7869.stderr index bf36749bc45b5..2377b4fd5b6bb 100644 --- a/tests/ui/crashes/ice-7869.stderr +++ b/tests/ui/crashes/ice-7869.stderr @@ -1,5 +1,5 @@ error: all variants have the same prefix: `Työ` - --> $DIR/crashes/ice-7869.rs:1:1 + --> tests/ui/crashes/ice-7869.rs:1:1 | LL | / enum Tila { LL | | diff --git a/tests/ui/crashes/ice-8250.stderr b/tests/ui/crashes/ice-8250.stderr index 169216f9f7b16..61576f13d1e1a 100644 --- a/tests/ui/crashes/ice-8250.stderr +++ b/tests/ui/crashes/ice-8250.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `splitn` - --> $DIR/crashes/ice-8250.rs:2:13 + --> tests/ui/crashes/ice-8250.rs:2:13 | LL | let _ = s[1..].splitn(2, '.').next()?; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s[1..].split('.')` diff --git a/tests/ui/crashes/ice-8850.stderr b/tests/ui/crashes/ice-8850.stderr index 0a6c70163343f..5a8f24ee8c0be 100644 --- a/tests/ui/crashes/ice-8850.stderr +++ b/tests/ui/crashes/ice-8850.stderr @@ -1,5 +1,5 @@ error: returning the result of a `let` binding from a block - --> $DIR/crashes/ice-8850.rs:4:5 + --> tests/ui/crashes/ice-8850.rs:4:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding @@ -15,7 +15,7 @@ LL ~ FN() + 1 | error: returning the result of a `let` binding from a block - --> $DIR/crashes/ice-8850.rs:12:5 + --> tests/ui/crashes/ice-8850.rs:12:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ FN() + 1 | error: returning the result of a `let` binding from a block - --> $DIR/crashes/ice-8850.rs:27:5 + --> tests/ui/crashes/ice-8850.rs:27:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding diff --git a/tests/ui/crashes/ice-9041.stderr b/tests/ui/crashes/ice-9041.stderr index e54a0196c7fe4..dd9db71c5de83 100644 --- a/tests/ui/crashes/ice-9041.stderr +++ b/tests/ui/crashes/ice-9041.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/crashes/ice-9041.rs:5:19 + --> tests/ui/crashes/ice-9041.rs:5:19 | LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|p| is_thing_ready(&p))` diff --git a/tests/ui/crashes/ice-9405.stderr b/tests/ui/crashes/ice-9405.stderr index 921190fbde71b..e8a73b9e782ef 100644 --- a/tests/ui/crashes/ice-9405.stderr +++ b/tests/ui/crashes/ice-9405.stderr @@ -1,5 +1,5 @@ warning: multiple lines skipped by escaped newline - --> $DIR/crashes/ice-9405.rs:6:10 + --> tests/ui/crashes/ice-9405.rs:6:10 | LL | "\ | __________^ diff --git a/tests/ui/crashes/ice-9445.stderr b/tests/ui/crashes/ice-9445.stderr index fd3c3e69512dc..d6957e9549d69 100644 --- a/tests/ui/crashes/ice-9445.stderr +++ b/tests/ui/crashes/ice-9445.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/crashes/ice-9445.rs:1:1 + --> tests/ui/crashes/ice-9445.rs:1:1 | LL | const UNINIT: core::mem::MaybeUninit> = core::mem::MaybeUninit::uninit(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-9463.stderr b/tests/ui/crashes/ice-9463.stderr index e03a971aabbae..9a3a5e444ade8 100644 --- a/tests/ui/crashes/ice-9463.stderr +++ b/tests/ui/crashes/ice-9463.stderr @@ -1,23 +1,23 @@ error: this arithmetic operation will overflow - --> $DIR/crashes/ice-9463.rs:3:14 + --> tests/ui/crashes/ice-9463.rs:3:14 | LL | let _x = -1_i32 >> -1; | ^^^^^^^^^^^^ attempt to shift right by `-1_i32`, which would overflow | note: the lint level is defined here - --> $DIR/crashes/ice-9463.rs:1:9 + --> tests/ui/crashes/ice-9463.rs:1:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ error: this arithmetic operation will overflow - --> $DIR/crashes/ice-9463.rs:5:14 + --> tests/ui/crashes/ice-9463.rs:5:14 | LL | let _y = 1u32 >> 10000000000000u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift right by `1316134912_u32`, which would overflow error: literal out of range for `u32` - --> $DIR/crashes/ice-9463.rs:5:22 + --> tests/ui/crashes/ice-9463.rs:5:22 | LL | let _y = 1u32 >> 10000000000000u32; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-96721.stderr b/tests/ui/crashes/ice-96721.stderr index 2bbcf9c84557a..f0778a4b32b3e 100644 --- a/tests/ui/crashes/ice-96721.stderr +++ b/tests/ui/crashes/ice-96721.stderr @@ -1,5 +1,5 @@ error: malformed `path` attribute input - --> $DIR/crashes/ice-96721.rs:7:1 + --> tests/ui/crashes/ice-96721.rs:7:1 | LL | #[path = foo!()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` diff --git a/tests/ui/crashes/needless_lifetimes_impl_trait.stderr b/tests/ui/crashes/needless_lifetimes_impl_trait.stderr index 737587cc05a7e..3a2d1f4410ef1 100644 --- a/tests/ui/crashes/needless_lifetimes_impl_trait.stderr +++ b/tests/ui/crashes/needless_lifetimes_impl_trait.stderr @@ -1,11 +1,11 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/crashes/needless_lifetimes_impl_trait.rs:15:12 + --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:15:12 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { | ^^ ^^ ^^ | note: the lint level is defined here - --> $DIR/crashes/needless_lifetimes_impl_trait.rs:1:9 + --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:1:9 | LL | #![deny(clippy::needless_lifetimes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr index b4141c864f138..90076d4338a47 100644 --- a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr +++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr @@ -1,11 +1,11 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/crashes/needless_pass_by_value-w-late-bound.rs:7:12 + --> tests/ui/crashes/needless_pass_by_value-w-late-bound.rs:7:12 | LL | fn test(x: Foo<'_>) {} | ^^^^^^^ help: consider taking a reference instead: `&Foo<'_>` | help: consider marking this type as `Copy` - --> $DIR/crashes/needless_pass_by_value-w-late-bound.rs:5:1 + --> tests/ui/crashes/needless_pass_by_value-w-late-bound.rs:5:1 | LL | struct Foo<'a>(&'a [(); 100]); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/crate_in_macro_def.stderr b/tests/ui/crate_in_macro_def.stderr index 1a21d4e92f24a..4202e9bc10357 100644 --- a/tests/ui/crate_in_macro_def.stderr +++ b/tests/ui/crate_in_macro_def.stderr @@ -1,5 +1,5 @@ error: `crate` references the macro call's crate - --> $DIR/crate_in_macro_def.rs:18:28 + --> tests/ui/crate_in_macro_def.rs:18:28 | LL | println!("{}", crate::unhygienic::MESSAGE); | ^^^^^ help: to reference the macro definition's crate, use: `$crate` diff --git a/tests/ui/crate_level_checks/no_std_swap.stderr b/tests/ui/crate_level_checks/no_std_swap.stderr index 29a6341a90709..7d7922ae8cac7 100644 --- a/tests/ui/crate_level_checks/no_std_swap.stderr +++ b/tests/ui/crate_level_checks/no_std_swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to swap `a` and `b` - --> $DIR/crate_level_checks/no_std_swap.rs:12:5 + --> tests/ui/crate_level_checks/no_std_swap.rs:12:5 | LL | / a = b; LL | | diff --git a/tests/ui/crate_level_checks/std_main_recursion.stderr b/tests/ui/crate_level_checks/std_main_recursion.stderr index 9452cc0d4b5a4..319ab783d5591 100644 --- a/tests/ui/crate_level_checks/std_main_recursion.stderr +++ b/tests/ui/crate_level_checks/std_main_recursion.stderr @@ -1,5 +1,5 @@ error: recursing into entrypoint `main` - --> $DIR/crate_level_checks/std_main_recursion.rs:5:5 + --> tests/ui/crate_level_checks/std_main_recursion.rs:5:5 | LL | main(); | ^^^^ diff --git a/tests/ui/create_dir.stderr b/tests/ui/create_dir.stderr index 037e6ff173ac0..9c6e640ca784c 100644 --- a/tests/ui/create_dir.stderr +++ b/tests/ui/create_dir.stderr @@ -1,5 +1,5 @@ error: calling `std::fs::create_dir` where there may be a better way - --> $DIR/create_dir.rs:10:5 + --> tests/ui/create_dir.rs:10:5 | LL | std::fs::create_dir("foo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("foo")` @@ -8,7 +8,7 @@ LL | std::fs::create_dir("foo"); = help: to override `-D warnings` add `#[allow(clippy::create_dir)]` error: calling `std::fs::create_dir` where there may be a better way - --> $DIR/create_dir.rs:11:5 + --> tests/ui/create_dir.rs:11:5 | LL | std::fs::create_dir("bar").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("bar")` diff --git a/tests/ui/dbg_macro/dbg_macro.stderr b/tests/ui/dbg_macro/dbg_macro.stderr index 70d832f2ac5bc..5ad0bbfed9422 100644 --- a/tests/ui/dbg_macro/dbg_macro.stderr +++ b/tests/ui/dbg_macro/dbg_macro.stderr @@ -1,5 +1,5 @@ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/auxiliary/submodule.rs:2:5 + --> tests/ui/dbg_macro/auxiliary/submodule.rs:2:5 | LL | dbg!(); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:9:22 + --> tests/ui/dbg_macro/dbg_macro.rs:9:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:15:8 + --> tests/ui/dbg_macro/dbg_macro.rs:15:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | if n <= 1 { | ~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:17:9 + --> tests/ui/dbg_macro/dbg_macro.rs:17:9 | LL | dbg!(1) | ^^^^^^^ @@ -46,7 +46,7 @@ LL | 1 | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:20:9 + --> tests/ui/dbg_macro/dbg_macro.rs:20:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | n * factorial(n - 1) | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:26:5 + --> tests/ui/dbg_macro/dbg_macro.rs:26:5 | LL | dbg!(42); | ^^^^^^^^ @@ -68,7 +68,7 @@ LL | 42; | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:28:5 + --> tests/ui/dbg_macro/dbg_macro.rs:28:5 | LL | dbg!(dbg!(dbg!(42))); | ^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:30:14 + --> tests/ui/dbg_macro/dbg_macro.rs:30:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:32:5 + --> tests/ui/dbg_macro/dbg_macro.rs:32:5 | LL | dbg!(1, 2, dbg!(3, 4)); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:34:5 + --> tests/ui/dbg_macro/dbg_macro.rs:34:5 | LL | dbg!(1, 2, 3, 4, 5); | ^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:55:5 + --> tests/ui/dbg_macro/dbg_macro.rs:55:5 | LL | dbg!(); | ^^^^^^^ @@ -124,7 +124,7 @@ LL + | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:58:13 + --> tests/ui/dbg_macro/dbg_macro.rs:58:13 | LL | let _ = dbg!(); | ^^^^^^ @@ -135,7 +135,7 @@ LL | let _ = (); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:60:9 + --> tests/ui/dbg_macro/dbg_macro.rs:60:9 | LL | bar(dbg!()); | ^^^^^^ @@ -146,7 +146,7 @@ LL | bar(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:62:10 + --> tests/ui/dbg_macro/dbg_macro.rs:62:10 | LL | foo!(dbg!()); | ^^^^^^ @@ -157,7 +157,7 @@ LL | foo!(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:64:16 + --> tests/ui/dbg_macro/dbg_macro.rs:64:16 | LL | foo2!(foo!(dbg!())); | ^^^^^^ @@ -168,7 +168,7 @@ LL | foo2!(foo!(())); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:86:9 + --> tests/ui/dbg_macro/dbg_macro.rs:86:9 | LL | dbg!(2); | ^^^^^^^ @@ -179,7 +179,7 @@ LL | 2; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:93:5 + --> tests/ui/dbg_macro/dbg_macro.rs:93:5 | LL | dbg!(1); | ^^^^^^^ @@ -190,7 +190,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:99:5 + --> tests/ui/dbg_macro/dbg_macro.rs:99:5 | LL | dbg!(1); | ^^^^^^^ @@ -201,7 +201,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro/dbg_macro.rs:106:9 + --> tests/ui/dbg_macro/dbg_macro.rs:106:9 | LL | dbg!(1); | ^^^^^^^ diff --git a/tests/ui/debug_assert_with_mut_call.stderr b/tests/ui/debug_assert_with_mut_call.stderr index b993bbf5526dd..83e1105a07dff 100644 --- a/tests/ui/debug_assert_with_mut_call.stderr +++ b/tests/ui/debug_assert_with_mut_call.stderr @@ -1,5 +1,5 @@ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:42:19 + --> tests/ui/debug_assert_with_mut_call.rs:42:19 | LL | debug_assert!(bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ @@ -8,163 +8,163 @@ LL | debug_assert!(bool_mut(&mut 3)); = help: to override `-D warnings` add `#[allow(clippy::debug_assert_with_mut_call)]` error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:45:20 + --> tests/ui/debug_assert_with_mut_call.rs:45:20 | LL | debug_assert!(!bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:48:25 + --> tests/ui/debug_assert_with_mut_call.rs:48:25 | LL | debug_assert_eq!(0, u32_mut(&mut 3)); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:50:22 + --> tests/ui/debug_assert_with_mut_call.rs:50:22 | LL | debug_assert_eq!(u32_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:53:25 + --> tests/ui/debug_assert_with_mut_call.rs:53:25 | LL | debug_assert_ne!(1, u32_mut(&mut 3)); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:55:22 + --> tests/ui/debug_assert_with_mut_call.rs:55:22 | LL | debug_assert_ne!(u32_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:71:19 + --> tests/ui/debug_assert_with_mut_call.rs:71:19 | LL | debug_assert!(S.bool_self_mut()); | ^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:73:20 + --> tests/ui/debug_assert_with_mut_call.rs:73:20 | LL | debug_assert!(!S.bool_self_mut()); | ^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:75:19 + --> tests/ui/debug_assert_with_mut_call.rs:75:19 | LL | debug_assert!(S.bool_self_ref_arg_mut(&mut 3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:77:19 + --> tests/ui/debug_assert_with_mut_call.rs:77:19 | LL | debug_assert!(S.bool_self_mut_arg_ref(&3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:79:19 + --> tests/ui/debug_assert_with_mut_call.rs:79:19 | LL | debug_assert!(S.bool_self_mut_arg_mut(&mut 3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:82:22 + --> tests/ui/debug_assert_with_mut_call.rs:82:22 | LL | debug_assert_eq!(S.u32_self_mut(), 0); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:84:22 + --> tests/ui/debug_assert_with_mut_call.rs:84:22 | LL | debug_assert_eq!(S.u32_self_mut_arg_ref(&3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:86:22 + --> tests/ui/debug_assert_with_mut_call.rs:86:22 | LL | debug_assert_eq!(S.u32_self_ref_arg_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:88:22 + --> tests/ui/debug_assert_with_mut_call.rs:88:22 | LL | debug_assert_eq!(S.u32_self_mut_arg_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:91:22 + --> tests/ui/debug_assert_with_mut_call.rs:91:22 | LL | debug_assert_ne!(S.u32_self_mut(), 1); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:93:22 + --> tests/ui/debug_assert_with_mut_call.rs:93:22 | LL | debug_assert_ne!(S.u32_self_mut_arg_ref(&3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:95:22 + --> tests/ui/debug_assert_with_mut_call.rs:95:22 | LL | debug_assert_ne!(S.u32_self_ref_arg_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:97:22 + --> tests/ui/debug_assert_with_mut_call.rs:97:22 | LL | debug_assert_ne!(S.u32_self_mut_arg_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:106:22 + --> tests/ui/debug_assert_with_mut_call.rs:106:22 | LL | debug_assert_eq!(v.pop(), Some(1)); | ^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:108:31 + --> tests/ui/debug_assert_with_mut_call.rs:108:31 | LL | debug_assert_ne!(Some(3), v.pop()); | ^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:112:19 + --> tests/ui/debug_assert_with_mut_call.rs:112:19 | LL | debug_assert!(bool_mut(a)); | ^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:116:31 + --> tests/ui/debug_assert_with_mut_call.rs:116:31 | LL | debug_assert!(!(bool_ref(&u32_mut(&mut 3)))); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:120:22 + --> tests/ui/debug_assert_with_mut_call.rs:120:22 | LL | debug_assert_eq!(v.pop().unwrap(), 3); | ^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:125:19 + --> tests/ui/debug_assert_with_mut_call.rs:125:19 | LL | debug_assert!(bool_mut(&mut 3), "w/o format"); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:128:19 + --> tests/ui/debug_assert_with_mut_call.rs:128:19 | LL | debug_assert!(bool_mut(&mut 3), "{} format", "w/"); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:134:9 + --> tests/ui/debug_assert_with_mut_call.rs:134:9 | LL | bool_mut(&mut x); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:142:9 + --> tests/ui/debug_assert_with_mut_call.rs:142:9 | LL | bool_mut(&mut x); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index f1d4d744e7312..824e7ec85ee00 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,5 +1,5 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:16:9 + --> tests/ui/decimal_literal_representation.rs:16:9 | LL | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` @@ -8,37 +8,37 @@ LL | 32_773, // 0x8005 = help: to override `-D warnings` add `#[allow(clippy::decimal_literal_representation)]` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:17:9 + --> tests/ui/decimal_literal_representation.rs:17:9 | LL | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:18:9 + --> tests/ui/decimal_literal_representation.rs:18:9 | LL | 2_131_750_927, // 0x7F0F_F00F | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:19:9 + --> tests/ui/decimal_literal_representation.rs:19:9 | LL | 2_147_483_647, // 0x7FFF_FFFF | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:21:9 + --> tests/ui/decimal_literal_representation.rs:21:9 | LL | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:22:9 + --> tests/ui/decimal_literal_representation.rs:22:9 | LL | 32_773usize, // 0x8005_usize | ^^^^^^^^^^^ help: consider: `0x8005_usize` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:23:9 + --> tests/ui/decimal_literal_representation.rs:23:9 | LL | 2_131_750_927isize, // 0x7F0F_F00F_isize | ^^^^^^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F_isize` diff --git a/tests/ui/declare_interior_mutable_const/enums.stderr b/tests/ui/declare_interior_mutable_const/enums.stderr index 94e61a13ee7a7..6c0dce6b5eafb 100644 --- a/tests/ui/declare_interior_mutable_const/enums.stderr +++ b/tests/ui/declare_interior_mutable_const/enums.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:12:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:12:1 | LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(tru = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:23:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:23:1 | LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:45:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:45:1 | LL | const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { | ^---- @@ -33,56 +33,56 @@ LL | | }; | |__^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:60:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:60:5 | LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:61:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:61:5 | LL | const TO_BE_FROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:64:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:64:5 | LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:90:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:90:5 | LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:102:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:102:5 | LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:105:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:105:5 | LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:111:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:111:5 | LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:118:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:118:5 | LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric = LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | |____________________________________________________________________^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/enums.rs:120:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:120:5 | LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/declare_interior_mutable_const/others.stderr b/tests/ui/declare_interior_mutable_const/others.stderr index c79f143df3619..0a3be77b275ee 100644 --- a/tests/ui/declare_interior_mutable_const/others.stderr +++ b/tests/ui/declare_interior_mutable_const/others.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/others.rs:9:1 + --> tests/ui/declare_interior_mutable_const/others.rs:9:1 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/others.rs:10:1 + --> tests/ui/declare_interior_mutable_const/others.rs:10:1 | LL | const CELL: Cell = Cell::new(6); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | const CELL: Cell = Cell::new(6); | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/others.rs:11:1 + --> tests/ui/declare_interior_mutable_const/others.rs:11:1 | LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], V | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/others.rs:16:9 + --> tests/ui/declare_interior_mutable_const/others.rs:16:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | declare_const!(_ONCE: Once = Once::new()); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/others.rs:43:13 + --> tests/ui/declare_interior_mutable_const/others.rs:43:13 | LL | const _BAZ: Cell = Cell::new(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/declare_interior_mutable_const/traits.stderr b/tests/ui/declare_interior_mutable_const/traits.stderr index 925a54b9a5955..82c89d0e9dcbe 100644 --- a/tests/ui/declare_interior_mutable_const/traits.stderr +++ b/tests/ui/declare_interior_mutable_const/traits.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:15:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:15:5 | LL | const ATOMIC: AtomicUsize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | const ATOMIC: AtomicUsize; = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:9:9 + --> tests/ui/declare_interior_mutable_const/traits.rs:9:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -19,55 +19,55 @@ LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:43:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:43:5 | LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:68:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:68:5 | LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:69:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:69:5 | LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:88:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:88:5 | LL | const BOUNDED: T::ToBeBounded; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:116:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:116:5 | LL | const SELF: Self = AtomicUsize::new(17); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:117:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:117:5 | LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:125:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:125:5 | LL | const INDIRECT: Cell<*const T>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:141:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:141:5 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/declare_interior_mutable_const/traits.rs:147:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:147:5 | LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/def_id_nocore.stderr b/tests/ui/def_id_nocore.stderr index 6a00331ec69f0..2718217313ff9 100644 --- a/tests/ui/def_id_nocore.stderr +++ b/tests/ui/def_id_nocore.stderr @@ -1,5 +1,5 @@ error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/def_id_nocore.rs:27:19 + --> tests/ui/def_id_nocore.rs:27:19 | LL | pub fn as_ref(self) -> &'static str { | ^^^^ diff --git a/tests/ui/default_constructed_unit_structs.stderr b/tests/ui/default_constructed_unit_structs.stderr index 434c72aa9b174..c0fa73515c034 100644 --- a/tests/ui/default_constructed_unit_structs.stderr +++ b/tests/ui/default_constructed_unit_structs.stderr @@ -1,5 +1,5 @@ error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:11:13 + --> tests/ui/default_constructed_unit_structs.rs:11:13 | LL | Self::default() | ^^^^^^^^^^^ help: remove this call to `default` @@ -8,31 +8,31 @@ LL | Self::default() = help: to override `-D warnings` add `#[allow(clippy::default_constructed_unit_structs)]` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:53:31 + --> tests/ui/default_constructed_unit_structs.rs:53:31 | LL | inner: PhantomData::default(), | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:126:33 + --> tests/ui/default_constructed_unit_structs.rs:126:33 | LL | let _ = PhantomData::::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:127:42 + --> tests/ui/default_constructed_unit_structs.rs:127:42 | LL | let _: PhantomData = PhantomData::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:128:55 + --> tests/ui/default_constructed_unit_structs.rs:128:55 | LL | let _: PhantomData = std::marker::PhantomData::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:129:23 + --> tests/ui/default_constructed_unit_structs.rs:129:23 | LL | let _ = UnitStruct::default(); | ^^^^^^^^^^^ help: remove this call to `default` diff --git a/tests/ui/default_instead_of_iter_empty.stderr b/tests/ui/default_instead_of_iter_empty.stderr index 48d6c02d150d8..4bd4d060a3f75 100644 --- a/tests/ui/default_instead_of_iter_empty.stderr +++ b/tests/ui/default_instead_of_iter_empty.stderr @@ -1,5 +1,5 @@ error: `std::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty.rs:12:13 + --> tests/ui/default_instead_of_iter_empty.rs:12:13 | LL | let _ = std::iter::Empty::::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::()` @@ -8,13 +8,13 @@ LL | let _ = std::iter::Empty::::default(); = help: to override `-D warnings` add `#[allow(clippy::default_instead_of_iter_empty)]` error: `std::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty.rs:13:13 + --> tests/ui/default_instead_of_iter_empty.rs:13:13 | LL | let _ = std::iter::Empty::>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::>()` error: `std::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty.rs:14:41 + --> tests/ui/default_instead_of_iter_empty.rs:14:41 | LL | let _foo: std::iter::Empty = std::iter::Empty::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` diff --git a/tests/ui/default_instead_of_iter_empty_no_std.stderr b/tests/ui/default_instead_of_iter_empty_no_std.stderr index 747a31ecbf366..eb80da13e8506 100644 --- a/tests/ui/default_instead_of_iter_empty_no_std.stderr +++ b/tests/ui/default_instead_of_iter_empty_no_std.stderr @@ -1,5 +1,5 @@ error: `core::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty_no_std.rs:23:13 + --> tests/ui/default_instead_of_iter_empty_no_std.rs:23:13 | LL | let _ = core::iter::Empty::::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::iter::empty::()` @@ -8,7 +8,7 @@ LL | let _ = core::iter::Empty::::default(); = help: to override `-D warnings` add `#[allow(clippy::default_instead_of_iter_empty)]` error: `core::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty_no_std.rs:24:42 + --> tests/ui/default_instead_of_iter_empty_no_std.rs:24:42 | LL | let _foo: core::iter::Empty = core::iter::Empty::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::iter::empty()` diff --git a/tests/ui/default_numeric_fallback_f64.stderr b/tests/ui/default_numeric_fallback_f64.stderr index c95679c9eb81b..d7e4dbd637715 100644 --- a/tests/ui/default_numeric_fallback_f64.stderr +++ b/tests/ui/default_numeric_fallback_f64.stderr @@ -1,5 +1,5 @@ error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:21:17 + --> tests/ui/default_numeric_fallback_f64.rs:21:17 | LL | let x = 0.12; | ^^^^ help: consider adding suffix: `0.12_f64` @@ -8,133 +8,133 @@ LL | let x = 0.12; = help: to override `-D warnings` add `#[allow(clippy::default_numeric_fallback)]` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:22:18 + --> tests/ui/default_numeric_fallback_f64.rs:22:18 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:22:22 + --> tests/ui/default_numeric_fallback_f64.rs:22:22 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `2.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:22:26 + --> tests/ui/default_numeric_fallback_f64.rs:22:26 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `3.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:28 + --> tests/ui/default_numeric_fallback_f64.rs:23:28 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:32 + --> tests/ui/default_numeric_fallback_f64.rs:23:32 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `2.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:46 + --> tests/ui/default_numeric_fallback_f64.rs:23:46 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `3.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:50 + --> tests/ui/default_numeric_fallback_f64.rs:23:50 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `4.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:24:23 + --> tests/ui/default_numeric_fallback_f64.rs:24:23 | LL | let x = match 1. { | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:25:18 + --> tests/ui/default_numeric_fallback_f64.rs:25:18 | LL | _ => 1., | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:44:21 + --> tests/ui/default_numeric_fallback_f64.rs:44:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:52:21 + --> tests/ui/default_numeric_fallback_f64.rs:52:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:58:21 + --> tests/ui/default_numeric_fallback_f64.rs:58:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:66:21 + --> tests/ui/default_numeric_fallback_f64.rs:66:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:82:27 + --> tests/ui/default_numeric_fallback_f64.rs:82:27 | LL | let f = || -> _ { 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:86:29 + --> tests/ui/default_numeric_fallback_f64.rs:86:29 | LL | let f = || -> f64 { 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:100:21 + --> tests/ui/default_numeric_fallback_f64.rs:100:21 | LL | generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:103:32 + --> tests/ui/default_numeric_fallback_f64.rs:103:32 | LL | let x: _ = generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:121:28 + --> tests/ui/default_numeric_fallback_f64.rs:121:28 | LL | GenericStruct { x: 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:124:36 + --> tests/ui/default_numeric_fallback_f64.rs:124:36 | LL | let _ = GenericStruct { x: 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:142:24 + --> tests/ui/default_numeric_fallback_f64.rs:142:24 | LL | GenericEnum::X(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:162:23 + --> tests/ui/default_numeric_fallback_f64.rs:162:23 | LL | s.generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:172:25 + --> tests/ui/default_numeric_fallback_f64.rs:172:25 | LL | inline!(let x = 22.;); | ^^^ help: consider adding suffix: `22.0_f64` diff --git a/tests/ui/default_numeric_fallback_i32.stderr b/tests/ui/default_numeric_fallback_i32.stderr index 7663977fb65a4..9961a3669ef2b 100644 --- a/tests/ui/default_numeric_fallback_i32.stderr +++ b/tests/ui/default_numeric_fallback_i32.stderr @@ -1,5 +1,5 @@ error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:21:17 + --> tests/ui/default_numeric_fallback_i32.rs:21:17 | LL | let x = 22; | ^^ help: consider adding suffix: `22_i32` @@ -8,145 +8,145 @@ LL | let x = 22; = help: to override `-D warnings` add `#[allow(clippy::default_numeric_fallback)]` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:22:18 + --> tests/ui/default_numeric_fallback_i32.rs:22:18 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:22:21 + --> tests/ui/default_numeric_fallback_i32.rs:22:21 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:22:24 + --> tests/ui/default_numeric_fallback_i32.rs:22:24 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `3_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:28 + --> tests/ui/default_numeric_fallback_i32.rs:23:28 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:31 + --> tests/ui/default_numeric_fallback_i32.rs:23:31 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:44 + --> tests/ui/default_numeric_fallback_i32.rs:23:44 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `3_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:47 + --> tests/ui/default_numeric_fallback_i32.rs:23:47 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `4_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:24:23 + --> tests/ui/default_numeric_fallback_i32.rs:24:23 | LL | let x = match 1 { | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:25:13 + --> tests/ui/default_numeric_fallback_i32.rs:25:13 | LL | 1 => 1, | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:25:18 + --> tests/ui/default_numeric_fallback_i32.rs:25:18 | LL | 1 => 1, | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:26:18 + --> tests/ui/default_numeric_fallback_i32.rs:26:18 | LL | _ => 2, | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:45:21 + --> tests/ui/default_numeric_fallback_i32.rs:45:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:53:21 + --> tests/ui/default_numeric_fallback_i32.rs:53:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:59:21 + --> tests/ui/default_numeric_fallback_i32.rs:59:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:67:21 + --> tests/ui/default_numeric_fallback_i32.rs:67:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:83:27 + --> tests/ui/default_numeric_fallback_i32.rs:83:27 | LL | let f = || -> _ { 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:87:29 + --> tests/ui/default_numeric_fallback_i32.rs:87:29 | LL | let f = || -> i32 { 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:101:21 + --> tests/ui/default_numeric_fallback_i32.rs:101:21 | LL | generic_arg(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:104:32 + --> tests/ui/default_numeric_fallback_i32.rs:104:32 | LL | let x: _ = generic_arg(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:122:28 + --> tests/ui/default_numeric_fallback_i32.rs:122:28 | LL | GenericStruct { x: 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:125:36 + --> tests/ui/default_numeric_fallback_i32.rs:125:36 | LL | let _ = GenericStruct { x: 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:143:24 + --> tests/ui/default_numeric_fallback_i32.rs:143:24 | LL | GenericEnum::X(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:163:23 + --> tests/ui/default_numeric_fallback_i32.rs:163:23 | LL | s.generic_arg(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:173:25 + --> tests/ui/default_numeric_fallback_i32.rs:173:25 | LL | inline!(let x = 22;); | ^^ help: consider adding suffix: `22_i32` @@ -154,19 +154,19 @@ LL | inline!(let x = 22;); = note: this error originates in the macro `__inline_mac_fn_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:215:29 + --> tests/ui/default_numeric_fallback_i32.rs:215:29 | LL | let data_i32 = vec![1, 2, 3]; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:215:32 + --> tests/ui/default_numeric_fallback_i32.rs:215:32 | LL | let data_i32 = vec![1, 2, 3]; | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:215:35 + --> tests/ui/default_numeric_fallback_i32.rs:215:35 | LL | let data_i32 = vec![1, 2, 3]; | ^ help: consider adding suffix: `3_i32` diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index e53c8e2c79ff1..276f03d79df1d 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,53 +1,53 @@ error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:13:22 + --> tests/ui/default_trait_access.rs:13:22 | LL | let s1: String = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `String::default()` | note: the lint level is defined here - --> $DIR/default_trait_access.rs:2:9 + --> tests/ui/default_trait_access.rs:2:9 | LL | #![deny(clippy::default_trait_access)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:17:22 + --> tests/ui/default_trait_access.rs:17:22 | LL | let s3: String = D2::default(); | ^^^^^^^^^^^^^ help: try: `String::default()` error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:19:22 + --> tests/ui/default_trait_access.rs:19:22 | LL | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()` error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:23:22 + --> tests/ui/default_trait_access.rs:23:22 | LL | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()` error: calling `GenericDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:33:46 + --> tests/ui/default_trait_access.rs:33:46 | LL | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` error: calling `TupleDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:39:36 + --> tests/ui/default_trait_access.rs:39:36 | LL | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` error: calling `ArrayDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:41:36 + --> tests/ui/default_trait_access.rs:41:36 | LL | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` error: calling `TupleStructDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:45:42 + --> tests/ui/default_trait_access.rs:45:42 | LL | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` diff --git a/tests/ui/default_union_representation.stderr b/tests/ui/default_union_representation.stderr index 82f69ffeec373..c7ef70a0b8e7b 100644 --- a/tests/ui/default_union_representation.stderr +++ b/tests/ui/default_union_representation.stderr @@ -1,5 +1,5 @@ error: this union has the default representation - --> $DIR/default_union_representation.rs:4:1 + --> tests/ui/default_union_representation.rs:4:1 | LL | / union NoAttribute { LL | | @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::default_union_representation)]` error: this union has the default representation - --> $DIR/default_union_representation.rs:17:1 + --> tests/ui/default_union_representation.rs:17:1 | LL | / union ReprPacked { LL | | @@ -25,7 +25,7 @@ LL | | } = help: consider annotating `ReprPacked` with `#[repr(C)]` to explicitly specify memory layout error: this union has the default representation - --> $DIR/default_union_representation.rs:36:1 + --> tests/ui/default_union_representation.rs:36:1 | LL | / union ReprAlign { LL | | @@ -37,7 +37,7 @@ LL | | } = help: consider annotating `ReprAlign` with `#[repr(C)]` to explicitly specify memory layout error: this union has the default representation - --> $DIR/default_union_representation.rs:57:1 + --> tests/ui/default_union_representation.rs:57:1 | LL | / union ZSTAndTwoFields { LL | | diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index 388fcc2384668..a9cf04bea5257 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -1,5 +1,5 @@ error: lint `clippy::should_assert_eq` has been removed: `assert!()` will be more flexible with RFC 2011 - --> $DIR/deprecated.rs:5:9 + --> tests/ui/deprecated.rs:5:9 | LL | #![warn(clippy::should_assert_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,91 +8,91 @@ LL | #![warn(clippy::should_assert_eq)] = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `clippy::extend_from_slice` has been removed: `.extend_from_slice(_)` is a faster way to extend a Vec by a slice - --> $DIR/deprecated.rs:6:9 + --> tests/ui/deprecated.rs:6:9 | LL | #![warn(clippy::extend_from_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::range_step_by_zero` has been removed: `iterator.step_by(0)` panics nowadays - --> $DIR/deprecated.rs:7:9 + --> tests/ui/deprecated.rs:7:9 | LL | #![warn(clippy::range_step_by_zero)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 - --> $DIR/deprecated.rs:8:9 + --> tests/ui/deprecated.rs:8:9 | LL | #![warn(clippy::unstable_as_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 - --> $DIR/deprecated.rs:9:9 + --> tests/ui/deprecated.rs:9:9 | LL | #![warn(clippy::unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr - --> $DIR/deprecated.rs:10:9 + --> tests/ui/deprecated.rs:10:9 | LL | #![warn(clippy::misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::assign_ops` has been removed: using compound assignment operators (e.g., `+=`) is harmless - --> $DIR/deprecated.rs:11:9 + --> tests/ui/deprecated.rs:11:9 | LL | #![warn(clippy::assign_ops)] | ^^^^^^^^^^^^^^^^^^ error: lint `clippy::if_let_redundant_pattern_matching` has been removed: this lint has been changed to redundant_pattern_matching - --> $DIR/deprecated.rs:12:9 + --> tests/ui/deprecated.rs:12:9 | LL | #![warn(clippy::if_let_redundant_pattern_matching)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unsafe_vector_initialization` has been removed: the replacement suggested by this lint had substantially different behavior - --> $DIR/deprecated.rs:13:9 + --> tests/ui/deprecated.rs:13:9 | LL | #![warn(clippy::unsafe_vector_initialization)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unused_collect` has been removed: `collect` has been marked as #[must_use] in rustc and that covers all cases of this lint - --> $DIR/deprecated.rs:14:9 + --> tests/ui/deprecated.rs:14:9 | LL | #![warn(clippy::unused_collect)] | ^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::replace_consts` has been removed: associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants - --> $DIR/deprecated.rs:15:9 + --> tests/ui/deprecated.rs:15:9 | LL | #![warn(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::regex_macro` has been removed: the regex! macro has been removed from the regex crate in 2018 - --> $DIR/deprecated.rs:16:9 + --> tests/ui/deprecated.rs:16:9 | LL | #![warn(clippy::regex_macro)] | ^^^^^^^^^^^^^^^^^^^ error: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint - --> $DIR/deprecated.rs:17:9 + --> tests/ui/deprecated.rs:17:9 | LL | #![warn(clippy::find_map)] | ^^^^^^^^^^^^^^^^ error: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint - --> $DIR/deprecated.rs:18:9 + --> tests/ui/deprecated.rs:18:9 | LL | #![warn(clippy::filter_map)] | ^^^^^^^^^^^^^^^^^^ error: lint `clippy::pub_enum_variant_names` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items - --> $DIR/deprecated.rs:19:9 + --> tests/ui/deprecated.rs:19:9 | LL | #![warn(clippy::pub_enum_variant_names)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items - --> $DIR/deprecated.rs:20:9 + --> tests/ui/deprecated.rs:20:9 | LL | #![warn(clippy::wrong_pub_self_convention)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/deprecated_old.stderr b/tests/ui/deprecated_old.stderr index d27ad852f97ff..685bca64df59a 100644 --- a/tests/ui/deprecated_old.stderr +++ b/tests/ui/deprecated_old.stderr @@ -1,5 +1,5 @@ error: lint `unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 - --> $DIR/deprecated_old.rs:1:8 + --> tests/ui/deprecated_old.rs:1:8 | LL | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | #[warn(unstable_as_slice)] = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 - --> $DIR/deprecated_old.rs:4:8 + --> tests/ui/deprecated_old.rs:4:8 | LL | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ error: lint `misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr - --> $DIR/deprecated_old.rs:6:8 + --> tests/ui/deprecated_old.rs:6:8 | LL | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/deref_addrof.stderr b/tests/ui/deref_addrof.stderr index b01fa4df6b1f5..5e3cb417aa0e1 100644 --- a/tests/ui/deref_addrof.stderr +++ b/tests/ui/deref_addrof.stderr @@ -1,5 +1,5 @@ error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:23:13 + --> tests/ui/deref_addrof.rs:23:13 | LL | let b = *&a; | ^^^ help: try: `a` @@ -8,49 +8,49 @@ LL | let b = *&a; = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:25:13 + --> tests/ui/deref_addrof.rs:25:13 | LL | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try: `get_number()` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:30:13 + --> tests/ui/deref_addrof.rs:30:13 | LL | let b = *&bytes[1..2][0]; | ^^^^^^^^^^^^^^^^ help: try: `bytes[1..2][0]` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:34:13 + --> tests/ui/deref_addrof.rs:34:13 | LL | let b = *&(a); | ^^^^^ help: try: `(a)` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:36:13 + --> tests/ui/deref_addrof.rs:36:13 | LL | let b = *(&a); | ^^^^^ help: try: `a` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:39:13 + --> tests/ui/deref_addrof.rs:39:13 | LL | let b = *((&a)); | ^^^^^^^ help: try: `a` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:41:13 + --> tests/ui/deref_addrof.rs:41:13 | LL | let b = *&&a; | ^^^^ help: try: `&a` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:43:14 + --> tests/ui/deref_addrof.rs:43:14 | LL | let b = **&aref; | ^^^^^^ help: try: `aref` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:53:17 + --> tests/ui/deref_addrof.rs:53:17 | LL | inline!(*& $(@expr self)) | ^^^^^^^^^^^^^^^^ help: try: `$(@expr self)` @@ -58,7 +58,7 @@ LL | inline!(*& $(@expr self)) = note: this error originates in the macro `__inline_mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:57:17 + --> tests/ui/deref_addrof.rs:57:17 | LL | inline!(*&mut $(@expr self)) | ^^^^^^^^^^^^^^^^^^^ help: try: `$(@expr self)` diff --git a/tests/ui/deref_addrof_double_trigger.stderr b/tests/ui/deref_addrof_double_trigger.stderr index 78ec73400162e..8905b14246740 100644 --- a/tests/ui/deref_addrof_double_trigger.stderr +++ b/tests/ui/deref_addrof_double_trigger.stderr @@ -1,5 +1,5 @@ error: immediately dereferencing a reference - --> $DIR/deref_addrof_double_trigger.rs:10:14 + --> tests/ui/deref_addrof_double_trigger.rs:10:14 | LL | let b = **&&a; | ^^^^ help: try: `&a` @@ -8,13 +8,13 @@ LL | let b = **&&a; = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference - --> $DIR/deref_addrof_double_trigger.rs:16:17 + --> tests/ui/deref_addrof_double_trigger.rs:16:17 | LL | let y = *&mut x; | ^^^^^^^ help: try: `x` error: immediately dereferencing a reference - --> $DIR/deref_addrof_double_trigger.rs:24:18 + --> tests/ui/deref_addrof_double_trigger.rs:24:18 | LL | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try: `&mut x` diff --git a/tests/ui/deref_by_slicing.stderr b/tests/ui/deref_by_slicing.stderr index 7b8144a9a6e19..17b00610899d6 100644 --- a/tests/ui/deref_by_slicing.stderr +++ b/tests/ui/deref_by_slicing.stderr @@ -1,5 +1,5 @@ error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:8:13 + --> tests/ui/deref_by_slicing.rs:8:13 | LL | let _ = &vec[..]; | ^^^^^^^^ help: dereference the original value instead: `&*vec` @@ -8,49 +8,49 @@ LL | let _ = &vec[..]; = help: to override `-D warnings` add `#[allow(clippy::deref_by_slicing)]` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:9:13 + --> tests/ui/deref_by_slicing.rs:9:13 | LL | let _ = &mut vec[..]; | ^^^^^^^^^^^^ help: dereference the original value instead: `&mut *vec` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:12:13 + --> tests/ui/deref_by_slicing.rs:12:13 | LL | let _ = &ref_vec[..]; | ^^^^^^^^^^^^ help: dereference the original value instead: `&**ref_vec` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:13:21 + --> tests/ui/deref_by_slicing.rs:13:21 | LL | let mut_slice = &mut ref_vec[..]; | ^^^^^^^^^^^^^^^^ help: dereference the original value instead: `&mut **ref_vec` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:14:13 + --> tests/ui/deref_by_slicing.rs:14:13 | LL | let _ = &mut mut_slice[..]; // Err, re-borrows slice | ^^^^^^^^^^^^^^^^^^ help: reborrow the original value instead: `&mut *mut_slice` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:17:13 + --> tests/ui/deref_by_slicing.rs:17:13 | LL | let _ = &s[..]; | ^^^^^^ help: dereference the original value instead: `&*s` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:20:18 + --> tests/ui/deref_by_slicing.rs:20:18 | LL | let _ = &mut &S[..]; // Err, re-borrows slice | ^^^^^^ help: reborrow the original value instead: `&*S` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:24:13 + --> tests/ui/deref_by_slicing.rs:24:13 | LL | let _ = &slice_ref[..]; // Err, derefs slice | ^^^^^^^^^^^^^^ help: dereference the original value instead: `*slice_ref` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:27:13 + --> tests/ui/deref_by_slicing.rs:27:13 | LL | let _ = (&bytes[..]).read_to_end(&mut vec![]).unwrap(); // Err, re-borrows slice | ^^^^^^^^^^^^ help: reborrow the original value instead: `(&*bytes)` diff --git a/tests/ui/derivable_impls.stderr b/tests/ui/derivable_impls.stderr index 98e2f3612904a..0adb422373d86 100644 --- a/tests/ui/derivable_impls.stderr +++ b/tests/ui/derivable_impls.stderr @@ -1,5 +1,5 @@ error: this `impl` can be derived - --> $DIR/derivable_impls.rs:20:1 + --> tests/ui/derivable_impls.rs:20:1 | LL | / impl std::default::Default for FooDefault<'_> { LL | | fn default() -> Self { @@ -20,7 +20,7 @@ LL | struct FooDefault<'a> { | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:41:1 + --> tests/ui/derivable_impls.rs:41:1 | LL | / impl std::default::Default for TupleDefault { LL | | fn default() -> Self { @@ -37,7 +37,7 @@ LL | struct TupleDefault(bool, i32, u64); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:93:1 + --> tests/ui/derivable_impls.rs:93:1 | LL | / impl Default for StrDefault<'_> { LL | | fn default() -> Self { @@ -54,7 +54,7 @@ LL | struct StrDefault<'a>(&'a str); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:119:1 + --> tests/ui/derivable_impls.rs:119:1 | LL | / impl Default for Y { LL | | fn default() -> Self { @@ -71,7 +71,7 @@ LL | struct Y(u32); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:158:1 + --> tests/ui/derivable_impls.rs:158:1 | LL | / impl Default for WithoutSelfCurly { LL | | fn default() -> Self { @@ -88,7 +88,7 @@ LL | struct WithoutSelfCurly { | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:166:1 + --> tests/ui/derivable_impls.rs:166:1 | LL | / impl Default for WithoutSelfParan { LL | | fn default() -> Self { @@ -105,7 +105,7 @@ LL | struct WithoutSelfParan(bool); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:216:1 + --> tests/ui/derivable_impls.rs:216:1 | LL | / impl Default for RepeatDefault1 { LL | | fn default() -> Self { @@ -122,7 +122,7 @@ LL | pub struct RepeatDefault1 { | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:250:1 + --> tests/ui/derivable_impls.rs:250:1 | LL | / impl Default for SimpleEnum { LL | | fn default() -> Self { diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index d9093038b093f..486e6dc1b6baf 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -1,5 +1,5 @@ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:7:1 + --> tests/ui/derive.rs:7:1 | LL | / impl Clone for Qux { LL | | @@ -10,7 +10,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:7:1 + --> tests/ui/derive.rs:7:1 | LL | / impl Clone for Qux { LL | | @@ -23,7 +23,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::expl_impl_clone_on_copy)]` error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:32:1 + --> tests/ui/derive.rs:32:1 | LL | / impl<'a> Clone for Lt<'a> { LL | | @@ -34,7 +34,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:32:1 + --> tests/ui/derive.rs:32:1 | LL | / impl<'a> Clone for Lt<'a> { LL | | @@ -45,7 +45,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:44:1 + --> tests/ui/derive.rs:44:1 | LL | / impl Clone for BigArray { LL | | @@ -56,7 +56,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:44:1 + --> tests/ui/derive.rs:44:1 | LL | / impl Clone for BigArray { LL | | @@ -67,7 +67,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:56:1 + --> tests/ui/derive.rs:56:1 | LL | / impl Clone for FnPtr { LL | | @@ -78,7 +78,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:56:1 + --> tests/ui/derive.rs:56:1 | LL | / impl Clone for FnPtr { LL | | @@ -89,7 +89,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:77:1 + --> tests/ui/derive.rs:77:1 | LL | / impl Clone for Generic2 { LL | | @@ -100,7 +100,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:77:1 + --> tests/ui/derive.rs:77:1 | LL | / impl Clone for Generic2 { LL | | diff --git a/tests/ui/derive_ord_xor_partial_ord.stderr b/tests/ui/derive_ord_xor_partial_ord.stderr index 7555c12b196d9..dcf32419baa29 100644 --- a/tests/ui/derive_ord_xor_partial_ord.stderr +++ b/tests/ui/derive_ord_xor_partial_ord.stderr @@ -1,11 +1,11 @@ error: you are deriving `Ord` but have implemented `PartialOrd` explicitly - --> $DIR/derive_ord_xor_partial_ord.rs:22:10 + --> tests/ui/derive_ord_xor_partial_ord.rs:22:10 | LL | #[derive(Ord, PartialEq, Eq)] | ^^^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:26:1 + --> tests/ui/derive_ord_xor_partial_ord.rs:26:1 | LL | impl PartialOrd for DeriveOrd { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,20 +14,20 @@ LL | impl PartialOrd for DeriveOrd { = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `Ord` but have implemented `PartialOrd` explicitly - --> $DIR/derive_ord_xor_partial_ord.rs:32:10 + --> tests/ui/derive_ord_xor_partial_ord.rs:32:10 | LL | #[derive(Ord, PartialEq, Eq)] | ^^^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:36:1 + --> tests/ui/derive_ord_xor_partial_ord.rs:36:1 | LL | impl PartialOrd for DeriveOrdWithExplicitTypeVariable { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are implementing `Ord` explicitly but have derived `PartialOrd` - --> $DIR/derive_ord_xor_partial_ord.rs:45:1 + --> tests/ui/derive_ord_xor_partial_ord.rs:45:1 | LL | / impl std::cmp::Ord for DerivePartialOrd { LL | | @@ -38,14 +38,14 @@ LL | | } | |_^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:42:10 + --> tests/ui/derive_ord_xor_partial_ord.rs:42:10 | LL | #[derive(PartialOrd, PartialEq, Eq)] | ^^^^^^^^^^ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are implementing `Ord` explicitly but have derived `PartialOrd` - --> $DIR/derive_ord_xor_partial_ord.rs:66:5 + --> tests/ui/derive_ord_xor_partial_ord.rs:66:5 | LL | / impl Ord for DerivePartialOrdInUseOrd { LL | | @@ -56,7 +56,7 @@ LL | | } | |_____^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:63:14 + --> tests/ui/derive_ord_xor_partial_ord.rs:63:14 | LL | #[derive(PartialOrd, PartialEq, Eq)] | ^^^^^^^^^^ diff --git a/tests/ui/derive_partial_eq_without_eq.stderr b/tests/ui/derive_partial_eq_without_eq.stderr index abfd70e8c3d50..42b9895121ff5 100644 --- a/tests/ui/derive_partial_eq_without_eq.stderr +++ b/tests/ui/derive_partial_eq_without_eq.stderr @@ -1,5 +1,5 @@ error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:11:17 + --> tests/ui/derive_partial_eq_without_eq.rs:11:17 | LL | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` @@ -8,61 +8,61 @@ LL | #[derive(Debug, PartialEq)] = help: to override `-D warnings` add `#[allow(clippy::derive_partial_eq_without_eq)]` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:53:10 + --> tests/ui/derive_partial_eq_without_eq.rs:53:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:59:10 + --> tests/ui/derive_partial_eq_without_eq.rs:59:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:65:10 + --> tests/ui/derive_partial_eq_without_eq.rs:65:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:68:10 + --> tests/ui/derive_partial_eq_without_eq.rs:68:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:74:10 + --> tests/ui/derive_partial_eq_without_eq.rs:74:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:80:10 + --> tests/ui/derive_partial_eq_without_eq.rs:80:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:93:17 + --> tests/ui/derive_partial_eq_without_eq.rs:93:17 | LL | #[derive(Debug, PartialEq, Clone)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:96:10 + --> tests/ui/derive_partial_eq_without_eq.rs:96:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:103:14 + --> tests/ui/derive_partial_eq_without_eq.rs:103:14 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:106:14 + --> tests/ui/derive_partial_eq_without_eq.rs:106:14 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` diff --git a/tests/ui/derived_hash_with_manual_eq.stderr b/tests/ui/derived_hash_with_manual_eq.stderr index 8ef08f9fa5cbb..af4d247f95ba9 100644 --- a/tests/ui/derived_hash_with_manual_eq.stderr +++ b/tests/ui/derived_hash_with_manual_eq.stderr @@ -1,11 +1,11 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derived_hash_with_manual_eq.rs:12:10 + --> tests/ui/derived_hash_with_manual_eq.rs:12:10 | LL | #[derive(Hash)] | ^^^^ | note: `PartialEq` implemented here - --> $DIR/derived_hash_with_manual_eq.rs:16:1 + --> tests/ui/derived_hash_with_manual_eq.rs:16:1 | LL | impl PartialEq for Bar { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ LL | impl PartialEq for Bar { = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derived_hash_with_manual_eq.rs:22:10 + --> tests/ui/derived_hash_with_manual_eq.rs:22:10 | LL | #[derive(Hash)] | ^^^^ | note: `PartialEq` implemented here - --> $DIR/derived_hash_with_manual_eq.rs:26:1 + --> tests/ui/derived_hash_with_manual_eq.rs:26:1 | LL | impl PartialEq for Baz { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/disallowed_names.stderr b/tests/ui/disallowed_names.stderr index 3387906a0e5c2..d131cad8e11e9 100644 --- a/tests/ui/disallowed_names.stderr +++ b/tests/ui/disallowed_names.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:12:9 + --> tests/ui/disallowed_names.rs:12:9 | LL | fn test(foo: ()) {} | ^^^ @@ -8,79 +8,79 @@ LL | fn test(foo: ()) {} = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:17:9 + --> tests/ui/disallowed_names.rs:17:9 | LL | let foo = 42; | ^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:19:9 + --> tests/ui/disallowed_names.rs:19:9 | LL | let baz = 42; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:21:9 + --> tests/ui/disallowed_names.rs:21:9 | LL | let quux = 42; | ^^^^ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:33:10 + --> tests/ui/disallowed_names.rs:33:10 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:33:20 + --> tests/ui/disallowed_names.rs:33:20 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:33:26 + --> tests/ui/disallowed_names.rs:33:26 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:41:19 + --> tests/ui/disallowed_names.rs:41:19 | LL | fn issue_1647(mut foo: u8) { | ^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:43:13 + --> tests/ui/disallowed_names.rs:43:13 | LL | let mut baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:45:21 + --> tests/ui/disallowed_names.rs:45:21 | LL | if let Some(mut quux) = Some(42) {} | ^^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:50:13 + --> tests/ui/disallowed_names.rs:50:13 | LL | let ref baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:52:21 + --> tests/ui/disallowed_names.rs:52:21 | LL | if let Some(ref quux) = Some(42) {} | ^^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:57:17 + --> tests/ui/disallowed_names.rs:57:17 | LL | let ref mut baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:59:25 + --> tests/ui/disallowed_names.rs:59:25 | LL | if let Some(ref mut quux) = Some(42) {} | ^^^^ diff --git a/tests/ui/disallowed_script_idents.stderr b/tests/ui/disallowed_script_idents.stderr index bf5cbe306c681..c11655ab6021e 100644 --- a/tests/ui/disallowed_script_idents.stderr +++ b/tests/ui/disallowed_script_idents.stderr @@ -1,17 +1,17 @@ error: identifier `счётчик` has a Unicode script that is not allowed by configuration: Cyrillic - --> $DIR/disallowed_script_idents.rs:11:9 + --> tests/ui/disallowed_script_idents.rs:11:9 | LL | let счётчик = 10; | ^^^^^^^ | note: the lint level is defined here - --> $DIR/disallowed_script_idents.rs:1:9 + --> tests/ui/disallowed_script_idents.rs:1:9 | LL | #![deny(clippy::disallowed_script_idents)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana - --> $DIR/disallowed_script_idents.rs:14:9 + --> tests/ui/disallowed_script_idents.rs:14:9 | LL | let カウンタ = 10; | ^^^^^^^^ diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index d8021c5d7ba83..f90c95696a9cc 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -1,5 +1,5 @@ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:20:10 + --> tests/ui/diverging_sub_expression.rs:20:10 | LL | b || diverge(); | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | b || diverge(); = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:23:10 + --> tests/ui/diverging_sub_expression.rs:23:10 | LL | b || A.foo(); | ^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:34:26 + --> tests/ui/diverging_sub_expression.rs:34:26 | LL | 6 => true || return, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:36:26 + --> tests/ui/diverging_sub_expression.rs:36:26 | LL | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:40:26 + --> tests/ui/diverging_sub_expression.rs:40:26 | LL | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:44:30 + --> tests/ui/diverging_sub_expression.rs:44:30 | LL | _ => true || panic!("boo"), | ^^^^^^^^^^^^^ @@ -40,31 +40,31 @@ LL | _ => true || panic!("boo"), = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:48:29 + --> tests/ui/diverging_sub_expression.rs:48:29 | LL | 15 => true || { return; }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:50:30 + --> tests/ui/diverging_sub_expression.rs:50:30 | LL | 16 => false || { return; }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:53:29 + --> tests/ui/diverging_sub_expression.rs:53:29 | LL | 17 => true || { return }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:55:30 + --> tests/ui/diverging_sub_expression.rs:55:30 | LL | 18 => false || { return }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:65:26 + --> tests/ui/diverging_sub_expression.rs:65:26 | LL | _ => true || break, | ^^^^^ diff --git a/tests/ui/doc/doc-fixable.stderr b/tests/ui/doc/doc-fixable.stderr index 8d2ef481eb100..7db9ff2b83b69 100644 --- a/tests/ui/doc/doc-fixable.stderr +++ b/tests/ui/doc/doc-fixable.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:9:9 + --> tests/ui/doc/doc-fixable.rs:9:9 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^ @@ -12,7 +12,7 @@ LL | /// The `foo_bar` function does _nothing_. See also foo::bar. (note the dot | ~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:9:51 + --> tests/ui/doc/doc-fixable.rs:9:51 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^^ @@ -23,7 +23,7 @@ LL | /// The foo_bar function does _nothing_. See also `foo::bar`. (note the dot | ~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:10:83 + --> tests/ui/doc/doc-fixable.rs:10:83 | LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun | ^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. B | ~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:12:13 + --> tests/ui/doc/doc-fixable.rs:12:13 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. | ^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | /// Here be `::a::global:path`, and _::another::global::path_. :: is not a | ~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:12:36 + --> tests/ui/doc/doc-fixable.rs:12:36 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | /// Here be ::a::global:path, and _`::another::global::path`_. :: is not a | ~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:13:25 + --> tests/ui/doc/doc-fixable.rs:13:25 | LL | /// Import an item from ::awesome::global::blob:: (Intended postfix) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | /// Import an item from `::awesome::global::blob::` (Intended postfix) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:14:31 + --> tests/ui/doc/doc-fixable.rs:14:31 | LL | /// These are the options for ::Cat: (Intended trailing single colon, shouldn't be linted) | ^^^^^ @@ -78,7 +78,7 @@ LL | /// These are the options for `::Cat`: (Intended trailing single colon, sho | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:15:22 + --> tests/ui/doc/doc-fixable.rs:15:22 | LL | /// That's not code ~NotInCodeBlock~. | ^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | /// That's not code ~`NotInCodeBlock`~. | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:16:5 + --> tests/ui/doc/doc-fixable.rs:16:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:30:5 + --> tests/ui/doc/doc-fixable.rs:30:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:37:5 + --> tests/ui/doc/doc-fixable.rs:37:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:51:5 + --> tests/ui/doc/doc-fixable.rs:51:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:75:5 + --> tests/ui/doc/doc-fixable.rs:75:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:92:5 + --> tests/ui/doc/doc-fixable.rs:92:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:100:8 + --> tests/ui/doc/doc-fixable.rs:100:8 | LL | /// ## CamelCaseThing | ^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | /// ## `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:103:7 + --> tests/ui/doc/doc-fixable.rs:103:7 | LL | /// # CamelCaseThing | ^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | /// # `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:105:22 + --> tests/ui/doc/doc-fixable.rs:105:22 | LL | /// Not a title #897 CamelCaseThing | ^^^^^^^^^^^^^^ @@ -188,7 +188,7 @@ LL | /// Not a title #897 `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:106:5 + --> tests/ui/doc/doc-fixable.rs:106:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:113:5 + --> tests/ui/doc/doc-fixable.rs:113:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -210,7 +210,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:126:5 + --> tests/ui/doc/doc-fixable.rs:126:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -221,7 +221,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:137:43 + --> tests/ui/doc/doc-fixable.rs:137:43 | LL | /** E.g., serialization of an empty list: FooBar | ^^^^^^ @@ -232,7 +232,7 @@ LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:142:5 + --> tests/ui/doc/doc-fixable.rs:142:5 | LL | And BarQuz too. | ^^^^^^ @@ -243,7 +243,7 @@ LL | And `BarQuz` too. | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:143:1 + --> tests/ui/doc/doc-fixable.rs:143:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -254,7 +254,7 @@ LL | `be_sure_we_got_to_the_end_of_it` | error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:148:43 + --> tests/ui/doc/doc-fixable.rs:148:43 | LL | /** E.g., serialization of an empty list: FooBar | ^^^^^^ @@ -265,7 +265,7 @@ LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:153:5 + --> tests/ui/doc/doc-fixable.rs:153:5 | LL | And BarQuz too. | ^^^^^^ @@ -276,7 +276,7 @@ LL | And `BarQuz` too. | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:154:1 + --> tests/ui/doc/doc-fixable.rs:154:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -287,7 +287,7 @@ LL | `be_sure_we_got_to_the_end_of_it` | error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:165:5 + --> tests/ui/doc/doc-fixable.rs:165:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -298,7 +298,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:184:22 + --> tests/ui/doc/doc-fixable.rs:184:22 | LL | /// An iterator over mycrate::Collection's values. | ^^^^^^^^^^^^^^^^^^^ @@ -309,7 +309,7 @@ LL | /// An iterator over `mycrate::Collection`'s values. | ~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:208:34 + --> tests/ui/doc/doc-fixable.rs:208:34 | LL | /// Foo \[bar\] \[baz\] \[qux\]. DocMarkdownLint | ^^^^^^^^^^^^^^^ @@ -320,7 +320,7 @@ LL | /// Foo \[bar\] \[baz\] \[qux\]. `DocMarkdownLint` | ~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:231:22 + --> tests/ui/doc/doc-fixable.rs:231:22 | LL | /// There is no try (do() or do_not()). | ^^^^ @@ -331,7 +331,7 @@ LL | /// There is no try (`do()` or do_not()). | ~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc/doc-fixable.rs:231:30 + --> tests/ui/doc/doc-fixable.rs:231:30 | LL | /// There is no try (do() or do_not()). | ^^^^^^^^ diff --git a/tests/ui/doc/unbalanced_ticks.stderr b/tests/ui/doc/unbalanced_ticks.stderr index b14dbdd945bac..56ef291362318 100644 --- a/tests/ui/doc/unbalanced_ticks.stderr +++ b/tests/ui/doc/unbalanced_ticks.stderr @@ -1,5 +1,5 @@ error: backticks are unbalanced - --> $DIR/doc/unbalanced_ticks.rs:7:5 + --> tests/ui/doc/unbalanced_ticks.rs:7:5 | LL | /// This is a doc comment with `unbalanced_tick marks and several words that | _____^ @@ -14,7 +14,7 @@ LL | | /// very `confusing_and_misleading`. = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` error: backticks are unbalanced - --> $DIR/doc/unbalanced_ticks.rs:14:5 + --> tests/ui/doc/unbalanced_ticks.rs:14:5 | LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/doc/unbalanced_ticks.rs:17:32 + --> tests/ui/doc/unbalanced_ticks.rs:17:32 | LL | /// This paragraph is fine and should_be linted normally. | ^^^^^^^^^ @@ -33,7 +33,7 @@ LL | /// This paragraph is fine and `should_be` linted normally. | ~~~~~~~~~~~ error: backticks are unbalanced - --> $DIR/doc/unbalanced_ticks.rs:20:5 + --> tests/ui/doc/unbalanced_ticks.rs:20:5 | LL | /// Double unbalanced backtick from ``here to here` should lint. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | /// Double unbalanced backtick from ``here to here` should lint. = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/doc/unbalanced_ticks.rs:34:8 + --> tests/ui/doc/unbalanced_ticks.rs:34:8 | LL | /// ## not_fine | ^^^^^^^^ @@ -52,7 +52,7 @@ LL | /// ## `not_fine` | ~~~~~~~~~~ error: backticks are unbalanced - --> $DIR/doc/unbalanced_ticks.rs:37:5 + --> tests/ui/doc/unbalanced_ticks.rs:37:5 | LL | /// ### `unbalanced | ^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | /// ### `unbalanced = help: a backtick may be missing a pair error: backticks are unbalanced - --> $DIR/doc/unbalanced_ticks.rs:40:5 + --> tests/ui/doc/unbalanced_ticks.rs:40:5 | LL | /// - This `item has unbalanced tick marks | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | /// - This `item has unbalanced tick marks = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/doc/unbalanced_ticks.rs:42:23 + --> tests/ui/doc/unbalanced_ticks.rs:42:23 | LL | /// - This item needs backticks_here | ^^^^^^^^^^^^^^ diff --git a/tests/ui/doc_errors.stderr b/tests/ui/doc_errors.stderr index dc59675b9e5f2..c5b9479adace4 100644 --- a/tests/ui/doc_errors.stderr +++ b/tests/ui/doc_errors.stderr @@ -1,5 +1,5 @@ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:7:1 + --> tests/ui/doc_errors.rs:7:1 | LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,37 +8,37 @@ LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { = help: to override `-D warnings` add `#[allow(clippy::missing_errors_doc)]` error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:13:1 + --> tests/ui/doc_errors.rs:13:1 | LL | pub async fn async_pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:19:1 + --> tests/ui/doc_errors.rs:19:1 | LL | pub fn pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:25:1 + --> tests/ui/doc_errors.rs:25:1 | LL | pub async fn async_pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:56:5 + --> tests/ui/doc_errors.rs:56:5 | LL | pub fn pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:62:5 + --> tests/ui/doc_errors.rs:62:5 | LL | pub async fn async_pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:113:5 + --> tests/ui/doc_errors.rs:113:5 | LL | fn trait_method_missing_errors_header() -> Result<(), ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/doc_link_with_quotes.stderr b/tests/ui/doc_link_with_quotes.stderr index cd4f87c56b42d..e4be59c65719c 100644 --- a/tests/ui/doc_link_with_quotes.stderr +++ b/tests/ui/doc_link_with_quotes.stderr @@ -1,5 +1,5 @@ error: possible intra-doc link using quotes instead of backticks - --> $DIR/doc_link_with_quotes.rs:7:12 + --> tests/ui/doc_link_with_quotes.rs:7:12 | LL | /// Calls ['bar'] uselessly | ^^^^^ @@ -8,7 +8,7 @@ LL | /// Calls ['bar'] uselessly = help: to override `-D warnings` add `#[allow(clippy::doc_link_with_quotes)]` error: possible intra-doc link using quotes instead of backticks - --> $DIR/doc_link_with_quotes.rs:14:12 + --> tests/ui/doc_link_with_quotes.rs:14:12 | LL | /// Calls ["bar"] uselessly | ^^^^^ diff --git a/tests/ui/doc_unsafe.stderr b/tests/ui/doc_unsafe.stderr index ab3fb3c029dd3..4fcbe716951f6 100644 --- a/tests/ui/doc_unsafe.stderr +++ b/tests/ui/doc_unsafe.stderr @@ -1,5 +1,5 @@ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:9:1 + --> tests/ui/doc_unsafe.rs:9:1 | LL | pub unsafe fn destroy_the_planet() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | pub unsafe fn destroy_the_planet() { = help: to override `-D warnings` add `#[allow(clippy::missing_safety_doc)]` error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:32:5 + --> tests/ui/doc_unsafe.rs:32:5 | LL | pub unsafe fn republished() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:40:5 + --> tests/ui/doc_unsafe.rs:40:5 | LL | unsafe fn woefully_underdocumented(self); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for unsafe trait missing `# Safety` section - --> $DIR/doc_unsafe.rs:46:1 + --> tests/ui/doc_unsafe.rs:46:1 | LL | pub unsafe trait UnsafeTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:76:5 + --> tests/ui/doc_unsafe.rs:76:5 | LL | pub unsafe fn more_undocumented_unsafe() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:92:9 + --> tests/ui/doc_unsafe.rs:92:9 | LL | pub unsafe fn whee() { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index 02f0a960974b8..01ba7a8ee1083 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -1,5 +1,5 @@ error: this binary expression can be simplified - --> $DIR/double_comparison.rs:6:8 + --> tests/ui/double_comparison.rs:6:8 | LL | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` @@ -8,43 +8,43 @@ LL | if x == y || x < y { = help: to override `-D warnings` add `#[allow(clippy::double_comparisons)]` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:9:8 + --> tests/ui/double_comparison.rs:9:8 | LL | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:12:8 + --> tests/ui/double_comparison.rs:12:8 | LL | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:15:8 + --> tests/ui/double_comparison.rs:15:8 | LL | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:18:8 + --> tests/ui/double_comparison.rs:18:8 | LL | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:21:8 + --> tests/ui/double_comparison.rs:21:8 | LL | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:24:8 + --> tests/ui/double_comparison.rs:24:8 | LL | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:27:8 + --> tests/ui/double_comparison.rs:27:8 | LL | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` diff --git a/tests/ui/double_must_use.stderr b/tests/ui/double_must_use.stderr index a2d87c59ecf8a..0f2154ecbcfab 100644 --- a/tests/ui/double_must_use.stderr +++ b/tests/ui/double_must_use.stderr @@ -1,5 +1,5 @@ error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:5:1 + --> tests/ui/double_must_use.rs:5:1 | LL | pub fn must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | pub fn must_use_result() -> Result<(), ()> { = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]` error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:11:1 + --> tests/ui/double_must_use.rs:11:1 | LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { = help: either add some descriptive text or remove the attribute error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:17:1 + --> tests/ui/double_must_use.rs:17:1 | LL | pub fn must_use_array() -> [Result<(), ()>; 1] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | pub fn must_use_array() -> [Result<(), ()>; 1] { = help: either add some descriptive text or remove the attribute error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:34:1 + --> tests/ui/double_must_use.rs:34:1 | LL | async fn async_must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index a4fa1688d577b..9a902d1323ccd 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,5 +1,5 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op - --> $DIR/double_neg.rs:7:5 + --> tests/ui/double_neg.rs:7:5 | LL | --x; | ^^^ diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index 8a010d8ccc045..aba301e9f072f 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -1,5 +1,5 @@ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:15:5 + --> tests/ui/double_parens.rs:15:5 | LL | ((0)) | ^^^^^ @@ -8,31 +8,31 @@ LL | ((0)) = help: to override `-D warnings` add `#[allow(clippy::double_parens)]` error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:21:14 + --> tests/ui/double_parens.rs:21:14 | LL | dummy_fn((0)); | ^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:26:20 + --> tests/ui/double_parens.rs:26:20 | LL | x.dummy_method((0)); | ^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:31:5 + --> tests/ui/double_parens.rs:31:5 | LL | ((1, 2)) | ^^^^^^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:36:5 + --> tests/ui/double_parens.rs:36:5 | LL | (()) | ^^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:59:16 + --> tests/ui/double_parens.rs:59:16 | LL | assert_eq!(((1, 2)), (1, 2), "Error"); | ^^^^^^^^ diff --git a/tests/ui/drain_collect.stderr b/tests/ui/drain_collect.stderr index 3364466ec80be..1dfd0f1e3463e 100644 --- a/tests/ui/drain_collect.stderr +++ b/tests/ui/drain_collect.stderr @@ -1,65 +1,65 @@ error: you seem to be trying to move all elements into a new `BinaryHeap` - --> $DIR/drain_collect.rs:7:5 + --> tests/ui/drain_collect.rs:7:5 | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` | note: the lint level is defined here - --> $DIR/drain_collect.rs:1:9 + --> tests/ui/drain_collect.rs:1:9 | LL | #![deny(clippy::drain_collect)] | ^^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to move all elements into a new `HashMap` - --> $DIR/drain_collect.rs:15:5 + --> tests/ui/drain_collect.rs:15:5 | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `HashSet` - --> $DIR/drain_collect.rs:23:5 + --> tests/ui/drain_collect.rs:23:5 | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:31:5 + --> tests/ui/drain_collect.rs:31:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:39:5 + --> tests/ui/drain_collect.rs:39:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:43:5 + --> tests/ui/drain_collect.rs:43:5 | LL | b.drain(0..).collect() | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:47:5 + --> tests/ui/drain_collect.rs:47:5 | LL | b.drain(..b.len()).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:51:5 + --> tests/ui/drain_collect.rs:51:5 | LL | b.drain(0..b.len()).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:56:5 + --> tests/ui/drain_collect.rs:56:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(&mut b)` error: you seem to be trying to move all elements into a new `String` - --> $DIR/drain_collect.rs:64:5 + --> tests/ui/drain_collect.rs:64:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` diff --git a/tests/ui/drop_non_drop.stderr b/tests/ui/drop_non_drop.stderr index a571076f68cd2..fac89bf1f26a7 100644 --- a/tests/ui/drop_non_drop.stderr +++ b/tests/ui/drop_non_drop.stderr @@ -1,11 +1,11 @@ error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes - --> $DIR/drop_non_drop.rs:22:5 + --> tests/ui/drop_non_drop.rs:22:5 | LL | drop(Foo); | ^^^^^^^^^ | note: argument has type `main::Foo` - --> $DIR/drop_non_drop.rs:22:10 + --> tests/ui/drop_non_drop.rs:22:10 | LL | drop(Foo); | ^^^ @@ -13,13 +13,13 @@ LL | drop(Foo); = help: to override `-D warnings` add `#[allow(clippy::drop_non_drop)]` error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes - --> $DIR/drop_non_drop.rs:38:5 + --> tests/ui/drop_non_drop.rs:38:5 | LL | drop(Baz(Foo)); | ^^^^^^^^^^^^^^ | note: argument has type `main::Baz` - --> $DIR/drop_non_drop.rs:38:10 + --> tests/ui/drop_non_drop.rs:38:10 | LL | drop(Baz(Foo)); | ^^^^^^^^ diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index 53ee0c4e8c895..40a24b823d115 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -1,5 +1,5 @@ error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult - --> $DIR/duplicate_underscore_argument.rs:4:23 + --> tests/ui/duplicate_underscore_argument.rs:4:23 | LL | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index 705683837123e..55e44f149cf1e 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,5 +1,5 @@ error: calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:9:24 + --> tests/ui/duration_subsec.rs:9:24 | LL | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` @@ -8,25 +8,25 @@ LL | let bad_millis_1 = dur.subsec_micros() / 1_000; = help: to override `-D warnings` add `#[allow(clippy::duration_subsec)]` error: calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:10:24 + --> tests/ui/duration_subsec.rs:10:24 | LL | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` error: calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:15:22 + --> tests/ui/duration_subsec.rs:15:22 | LL | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:20:13 + --> tests/ui/duration_subsec.rs:20:13 | LL | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` error: calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:24:13 + --> tests/ui/duration_subsec.rs:24:13 | LL | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` diff --git a/tests/ui/eager_transmute.stderr b/tests/ui/eager_transmute.stderr index 5f42eec544fae..b9a4321d99efe 100644 --- a/tests/ui/eager_transmute.stderr +++ b/tests/ui/eager_transmute.stderr @@ -1,5 +1,5 @@ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:21:33 + --> tests/ui/eager_transmute.rs:21:33 | LL | (op < 4).then_some(unsafe { std::mem::transmute(op) }) | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | (op < 4).then(|| unsafe { std::mem::transmute(op) }) | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:27:33 + --> tests/ui/eager_transmute.rs:27:33 | LL | (op < 4).then_some(unsafe { std::mem::transmute::<_, Opcode>(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | (op < 4).then(|| unsafe { std::mem::transmute::<_, Opcode>(op) }); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:28:33 + --> tests/ui/eager_transmute.rs:28:33 | LL | (op > 4).then_some(unsafe { std::mem::transmute::<_, Opcode>(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | (op > 4).then(|| unsafe { std::mem::transmute::<_, Opcode>(op) }); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:29:34 + --> tests/ui/eager_transmute.rs:29:34 | LL | (op == 0).then_some(unsafe { std::mem::transmute::<_, Opcode>(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | (op == 0).then(|| unsafe { std::mem::transmute::<_, Opcode>(op) }); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:31:68 + --> tests/ui/eager_transmute.rs:31:68 | LL | let _: Option = (op > 0 && op < 10).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | let _: Option = (op > 0 && op < 10).then(|| unsafe { std::mem:: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:32:86 + --> tests/ui/eager_transmute.rs:32:86 | LL | let _: Option = (op > 0 && op < 10 && unrelated == 0).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | let _: Option = (op > 0 && op < 10 && unrelated == 0).then(|| u | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:35:84 + --> tests/ui/eager_transmute.rs:35:84 | LL | let _: Option = (op2.foo[0] > 0 && op2.foo[0] < 10).then_some(unsafe { std::mem::transmute(op2.foo[0]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _: Option = (op2.foo[0] > 0 && op2.foo[0] < 10).then(|| uns | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:47:70 + --> tests/ui/eager_transmute.rs:47:70 | LL | let _: Option = (1..=3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: Option = (1..=3).contains(&op).then(|| unsafe { std::mem | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:48:83 + --> tests/ui/eager_transmute.rs:48:83 | LL | let _: Option = ((1..=3).contains(&op) || op == 4).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _: Option = ((1..=3).contains(&op) || op == 4).then(|| unsa | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:49:69 + --> tests/ui/eager_transmute.rs:49:69 | LL | let _: Option = (1..3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | let _: Option = (1..3).contains(&op).then(|| unsafe { std::mem: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:50:68 + --> tests/ui/eager_transmute.rs:50:68 | LL | let _: Option = (1..).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | let _: Option = (1..).contains(&op).then(|| unsafe { std::mem:: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:51:68 + --> tests/ui/eager_transmute.rs:51:68 | LL | let _: Option = (..3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | let _: Option = (..3).contains(&op).then(|| unsafe { std::mem:: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:52:69 + --> tests/ui/eager_transmute.rs:52:69 | LL | let _: Option = (..=3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | let _: Option = (..=3).contains(&op).then(|| unsafe { std::mem: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:61:24 + --> tests/ui/eager_transmute.rs:61:24 | LL | (op < 4).then_some(std::mem::transmute::<_, Opcode>(op)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | (op < 4).then(|| std::mem::transmute::<_, Opcode>(op)); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:90:60 + --> tests/ui/eager_transmute.rs:90:60 | LL | let _: Option = (v1 > 0).then_some(unsafe { std::mem::transmute(v1) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | let _: Option = (v1 > 0).then(|| unsafe { std::mem::transmut | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:96:86 + --> tests/ui/eager_transmute.rs:96:86 | LL | let _: Option = (v2 < NonZeroU8::new(255).unwrap()).then_some(unsafe { std::mem::transmute(v2) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | let _: Option = (v2 < NonZeroU8::new(255).unwrap()).then(|| u | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:102:93 + --> tests/ui/eager_transmute.rs:102:93 | LL | let _: Option = (v2 < NonZeroU8::new(255).unwrap()).then_some(unsafe { std::mem::transmute(v2) }); | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index b2bf4ac4d1b12..80355cb2dba6a 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -1,5 +1,5 @@ error: `if` expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:45:12 + --> tests/ui/else_if_without_else.rs:45:12 | LL | } else if bla2() { | ____________^ @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::else_if_without_else)]` error: `if` expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:54:12 + --> tests/ui/else_if_without_else.rs:54:12 | LL | } else if bla3() { | ____________^ diff --git a/tests/ui/empty_drop.stderr b/tests/ui/empty_drop.stderr index 5848eab744740..4223ddaf3fba5 100644 --- a/tests/ui/empty_drop.stderr +++ b/tests/ui/empty_drop.stderr @@ -1,5 +1,5 @@ error: empty drop implementation - --> $DIR/empty_drop.rs:7:1 + --> tests/ui/empty_drop.rs:7:1 | LL | / impl Drop for Foo { LL | | fn drop(&mut self) {} @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::empty_drop)]` error: empty drop implementation - --> $DIR/empty_drop.rs:23:1 + --> tests/ui/empty_drop.rs:23:1 | LL | / impl Drop for Baz { LL | | fn drop(&mut self) { diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index c9bd887643e90..6a1ded9298ed7 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,5 +1,5 @@ error: enum with no variants - --> $DIR/empty_enum.rs:5:1 + --> tests/ui/empty_enum.rs:5:1 | LL | enum Empty {} | ^^^^^^^^^^^^^ diff --git a/tests/ui/empty_enum_variants_with_brackets.stderr b/tests/ui/empty_enum_variants_with_brackets.stderr index 6b2f286147fab..2b187b8f755b4 100644 --- a/tests/ui/empty_enum_variants_with_brackets.stderr +++ b/tests/ui/empty_enum_variants_with_brackets.stderr @@ -1,5 +1,5 @@ error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:7:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:7:16 | LL | EmptyBraces {}, | ^^^ @@ -9,7 +9,7 @@ LL | EmptyBraces {}, = help: remove the brackets error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:8:21 + --> tests/ui/empty_enum_variants_with_brackets.rs:8:21 | LL | EmptyParentheses(), | ^^ @@ -17,7 +17,7 @@ LL | EmptyParentheses(), = help: remove the brackets error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:14:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:14:16 | LL | EmptyBraces {}, | ^^^ @@ -25,7 +25,7 @@ LL | EmptyBraces {}, = help: remove the brackets error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:15:21 + --> tests/ui/empty_enum_variants_with_brackets.rs:15:21 | LL | EmptyParentheses(), | ^^ diff --git a/tests/ui/empty_line_after_doc_comments.stderr b/tests/ui/empty_line_after_doc_comments.stderr index 2cf5b5b0f5494..889ccf6ba19dd 100644 --- a/tests/ui/empty_line_after_doc_comments.stderr +++ b/tests/ui/empty_line_after_doc_comments.stderr @@ -1,5 +1,5 @@ error: found an empty line after a doc comment. Perhaps you need to use `//!` to make a comment on a module, remove the empty line, or make a regular comment with `//`? - --> $DIR/empty_line_after_doc_comments.rs:18:1 + --> tests/ui/empty_line_after_doc_comments.rs:18:1 | LL | / /// This should produce a warning LL | | @@ -10,7 +10,7 @@ LL | | fn with_doc_and_newline() { assert!(true)} = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]` error: found an empty line after a doc comment. Perhaps you need to use `//!` to make a comment on a module, remove the empty line, or make a regular comment with `//`? - --> $DIR/empty_line_after_doc_comments.rs:68:1 + --> tests/ui/empty_line_after_doc_comments.rs:68:1 | LL | / /// This doc comment should produce a warning LL | | @@ -22,7 +22,7 @@ LL | | fn three_attributes() { assert!(true) } | |_ error: found an empty line after a doc comment. Perhaps you need to use `//!` to make a comment on a module, remove the empty line, or make a regular comment with `//`? - --> $DIR/empty_line_after_doc_comments.rs:70:1 + --> tests/ui/empty_line_after_doc_comments.rs:70:1 | LL | / /** This is also a doc comment and should produce a warning LL | | */ diff --git a/tests/ui/empty_line_after_outer_attribute.stderr b/tests/ui/empty_line_after_outer_attribute.stderr index 0cb848c20dde7..1b5b00a4a83bb 100644 --- a/tests/ui/empty_line_after_outer_attribute.stderr +++ b/tests/ui/empty_line_after_outer_attribute.stderr @@ -1,5 +1,5 @@ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:11:1 + --> tests/ui/empty_line_after_outer_attribute.rs:11:1 | LL | / #[crate_type = "lib"] LL | | @@ -11,7 +11,7 @@ LL | | fn with_one_newline_and_comment() { assert!(true) } = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]` error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:23:1 + --> tests/ui/empty_line_after_outer_attribute.rs:23:1 | LL | / #[crate_type = "lib"] LL | | @@ -19,7 +19,7 @@ LL | | fn with_one_newline() { assert!(true) } | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:28:1 + --> tests/ui/empty_line_after_outer_attribute.rs:28:1 | LL | / #[crate_type = "lib"] LL | | @@ -28,7 +28,7 @@ LL | | fn with_two_newlines() { assert!(true) } | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:35:1 + --> tests/ui/empty_line_after_outer_attribute.rs:35:1 | LL | / #[crate_type = "lib"] LL | | @@ -36,7 +36,7 @@ LL | | enum Baz { | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:43:1 + --> tests/ui/empty_line_after_outer_attribute.rs:43:1 | LL | / #[crate_type = "lib"] LL | | @@ -44,7 +44,7 @@ LL | | struct Foo { | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:51:1 + --> tests/ui/empty_line_after_outer_attribute.rs:51:1 | LL | / #[crate_type = "lib"] LL | | diff --git a/tests/ui/empty_loop.stderr b/tests/ui/empty_loop.stderr index 113556f673c8c..3ac93f4ece0cc 100644 --- a/tests/ui/empty_loop.stderr +++ b/tests/ui/empty_loop.stderr @@ -1,5 +1,5 @@ error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop.rs:9:5 + --> tests/ui/empty_loop.rs:9:5 | LL | loop {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | loop {} = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop.rs:12:9 + --> tests/ui/empty_loop.rs:12:9 | LL | loop {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | loop {} = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop.rs:17:9 + --> tests/ui/empty_loop.rs:17:9 | LL | 'inner: loop {} | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/empty_loop_no_std.stderr b/tests/ui/empty_loop_no_std.stderr index 90200826472b1..f4a18204c3cef 100644 --- a/tests/ui/empty_loop_no_std.stderr +++ b/tests/ui/empty_loop_no_std.stderr @@ -1,5 +1,5 @@ error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop_no_std.rs:13:5 + --> tests/ui/empty_loop_no_std.rs:13:5 | LL | loop {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | loop {} = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop_no_std.rs:26:5 + --> tests/ui/empty_loop_no_std.rs:26:5 | LL | loop {} | ^^^^^^^ diff --git a/tests/ui/empty_structs_with_brackets.stderr b/tests/ui/empty_structs_with_brackets.stderr index 4b8572d5c9ef6..e57249aec0238 100644 --- a/tests/ui/empty_structs_with_brackets.stderr +++ b/tests/ui/empty_structs_with_brackets.stderr @@ -1,5 +1,5 @@ error: found empty brackets on struct declaration - --> $DIR/empty_structs_with_brackets.rs:4:25 + --> tests/ui/empty_structs_with_brackets.rs:4:25 | LL | pub struct MyEmptyStruct {} // should trigger lint | ^^^ @@ -9,7 +9,7 @@ LL | pub struct MyEmptyStruct {} // should trigger lint = help: remove the brackets error: found empty brackets on struct declaration - --> $DIR/empty_structs_with_brackets.rs:5:26 + --> tests/ui/empty_structs_with_brackets.rs:5:26 | LL | struct MyEmptyTupleStruct(); // should trigger lint | ^^^ diff --git a/tests/ui/endian_bytes.stderr b/tests/ui/endian_bytes.stderr index a458c46fa69ac..3fc26dcab8869 100644 --- a/tests/ui/endian_bytes.stderr +++ b/tests/ui/endian_bytes.stderr @@ -1,5 +1,5 @@ error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:7:9 + --> tests/ui/endian_bytes.rs:7:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:8:9 + --> tests/ui/endian_bytes.rs:8:9 | LL | 2i8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u16::to_ne_bytes` method - --> $DIR/endian_bytes.rs:9:9 + --> tests/ui/endian_bytes.rs:9:9 | LL | 2u16.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i16::to_ne_bytes` method - --> $DIR/endian_bytes.rs:10:9 + --> tests/ui/endian_bytes.rs:10:9 | LL | 2i16.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u32::to_ne_bytes` method - --> $DIR/endian_bytes.rs:11:9 + --> tests/ui/endian_bytes.rs:11:9 | LL | 2u32.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i32::to_ne_bytes` method - --> $DIR/endian_bytes.rs:12:9 + --> tests/ui/endian_bytes.rs:12:9 | LL | 2i32.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u64::to_ne_bytes` method - --> $DIR/endian_bytes.rs:13:9 + --> tests/ui/endian_bytes.rs:13:9 | LL | 2u64.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i64::to_ne_bytes` method - --> $DIR/endian_bytes.rs:14:9 + --> tests/ui/endian_bytes.rs:14:9 | LL | 2i64.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u128::to_ne_bytes` method - --> $DIR/endian_bytes.rs:15:9 + --> tests/ui/endian_bytes.rs:15:9 | LL | 2u128.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i128::to_ne_bytes` method - --> $DIR/endian_bytes.rs:16:9 + --> tests/ui/endian_bytes.rs:16:9 | LL | 2i128.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f32::to_ne_bytes` method - --> $DIR/endian_bytes.rs:17:9 + --> tests/ui/endian_bytes.rs:17:9 | LL | 2.0f32.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f64::to_ne_bytes` method - --> $DIR/endian_bytes.rs:18:9 + --> tests/ui/endian_bytes.rs:18:9 | LL | 2.0f64.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `usize::to_ne_bytes` method - --> $DIR/endian_bytes.rs:19:9 + --> tests/ui/endian_bytes.rs:19:9 | LL | 2usize.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `isize::to_ne_bytes` method - --> $DIR/endian_bytes.rs:20:9 + --> tests/ui/endian_bytes.rs:20:9 | LL | 2isize.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:21:9 + --> tests/ui/endian_bytes.rs:21:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i8::from_ne_bytes` - --> $DIR/endian_bytes.rs:22:9 + --> tests/ui/endian_bytes.rs:22:9 | LL | i8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u16::from_ne_bytes` - --> $DIR/endian_bytes.rs:23:9 + --> tests/ui/endian_bytes.rs:23:9 | LL | u16::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i16::from_ne_bytes` - --> $DIR/endian_bytes.rs:24:9 + --> tests/ui/endian_bytes.rs:24:9 | LL | i16::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u32::from_ne_bytes` - --> $DIR/endian_bytes.rs:25:9 + --> tests/ui/endian_bytes.rs:25:9 | LL | u32::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i32::from_ne_bytes` - --> $DIR/endian_bytes.rs:26:9 + --> tests/ui/endian_bytes.rs:26:9 | LL | i32::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u64::from_ne_bytes` - --> $DIR/endian_bytes.rs:27:9 + --> tests/ui/endian_bytes.rs:27:9 | LL | u64::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i64::from_ne_bytes` - --> $DIR/endian_bytes.rs:28:9 + --> tests/ui/endian_bytes.rs:28:9 | LL | i64::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -265,7 +265,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u128::from_ne_bytes` - --> $DIR/endian_bytes.rs:29:9 + --> tests/ui/endian_bytes.rs:29:9 | LL | u128::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -277,7 +277,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i128::from_ne_bytes` - --> $DIR/endian_bytes.rs:30:9 + --> tests/ui/endian_bytes.rs:30:9 | LL | i128::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -289,7 +289,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `usize::from_ne_bytes` - --> $DIR/endian_bytes.rs:31:9 + --> tests/ui/endian_bytes.rs:31:9 | LL | usize::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -301,7 +301,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `isize::from_ne_bytes` - --> $DIR/endian_bytes.rs:32:9 + --> tests/ui/endian_bytes.rs:32:9 | LL | isize::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f32::from_ne_bytes` - --> $DIR/endian_bytes.rs:33:9 + --> tests/ui/endian_bytes.rs:33:9 | LL | f32::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -325,7 +325,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f64::from_ne_bytes` - --> $DIR/endian_bytes.rs:34:9 + --> tests/ui/endian_bytes.rs:34:9 | LL | f64::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:36:9 + --> tests/ui/endian_bytes.rs:36:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -351,7 +351,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i8::to_le_bytes` method - --> $DIR/endian_bytes.rs:37:9 + --> tests/ui/endian_bytes.rs:37:9 | LL | 2i8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -363,7 +363,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u16::to_le_bytes` method - --> $DIR/endian_bytes.rs:38:9 + --> tests/ui/endian_bytes.rs:38:9 | LL | 2u16.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -375,7 +375,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i16::to_le_bytes` method - --> $DIR/endian_bytes.rs:39:9 + --> tests/ui/endian_bytes.rs:39:9 | LL | 2i16.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -387,7 +387,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u32::to_le_bytes` method - --> $DIR/endian_bytes.rs:40:9 + --> tests/ui/endian_bytes.rs:40:9 | LL | 2u32.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -399,7 +399,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i32::to_le_bytes` method - --> $DIR/endian_bytes.rs:41:9 + --> tests/ui/endian_bytes.rs:41:9 | LL | 2i32.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -411,7 +411,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u64::to_le_bytes` method - --> $DIR/endian_bytes.rs:42:9 + --> tests/ui/endian_bytes.rs:42:9 | LL | 2u64.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -423,7 +423,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i64::to_le_bytes` method - --> $DIR/endian_bytes.rs:43:9 + --> tests/ui/endian_bytes.rs:43:9 | LL | 2i64.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u128::to_le_bytes` method - --> $DIR/endian_bytes.rs:44:9 + --> tests/ui/endian_bytes.rs:44:9 | LL | 2u128.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -447,7 +447,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i128::to_le_bytes` method - --> $DIR/endian_bytes.rs:45:9 + --> tests/ui/endian_bytes.rs:45:9 | LL | 2i128.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f32::to_le_bytes` method - --> $DIR/endian_bytes.rs:46:9 + --> tests/ui/endian_bytes.rs:46:9 | LL | 2.0f32.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -471,7 +471,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f64::to_le_bytes` method - --> $DIR/endian_bytes.rs:47:9 + --> tests/ui/endian_bytes.rs:47:9 | LL | 2.0f64.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +483,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `usize::to_le_bytes` method - --> $DIR/endian_bytes.rs:48:9 + --> tests/ui/endian_bytes.rs:48:9 | LL | 2usize.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -495,7 +495,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `isize::to_le_bytes` method - --> $DIR/endian_bytes.rs:49:9 + --> tests/ui/endian_bytes.rs:49:9 | LL | 2isize.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:50:9 + --> tests/ui/endian_bytes.rs:50:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -519,7 +519,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i8::from_le_bytes` - --> $DIR/endian_bytes.rs:51:9 + --> tests/ui/endian_bytes.rs:51:9 | LL | i8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -531,7 +531,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u16::from_le_bytes` - --> $DIR/endian_bytes.rs:52:9 + --> tests/ui/endian_bytes.rs:52:9 | LL | u16::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i16::from_le_bytes` - --> $DIR/endian_bytes.rs:53:9 + --> tests/ui/endian_bytes.rs:53:9 | LL | i16::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u32::from_le_bytes` - --> $DIR/endian_bytes.rs:54:9 + --> tests/ui/endian_bytes.rs:54:9 | LL | u32::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -567,7 +567,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i32::from_le_bytes` - --> $DIR/endian_bytes.rs:55:9 + --> tests/ui/endian_bytes.rs:55:9 | LL | i32::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -579,7 +579,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u64::from_le_bytes` - --> $DIR/endian_bytes.rs:56:9 + --> tests/ui/endian_bytes.rs:56:9 | LL | u64::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -591,7 +591,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i64::from_le_bytes` - --> $DIR/endian_bytes.rs:57:9 + --> tests/ui/endian_bytes.rs:57:9 | LL | i64::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -603,7 +603,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u128::from_le_bytes` - --> $DIR/endian_bytes.rs:58:9 + --> tests/ui/endian_bytes.rs:58:9 | LL | u128::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -615,7 +615,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i128::from_le_bytes` - --> $DIR/endian_bytes.rs:59:9 + --> tests/ui/endian_bytes.rs:59:9 | LL | i128::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -627,7 +627,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `usize::from_le_bytes` - --> $DIR/endian_bytes.rs:60:9 + --> tests/ui/endian_bytes.rs:60:9 | LL | usize::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -639,7 +639,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `isize::from_le_bytes` - --> $DIR/endian_bytes.rs:61:9 + --> tests/ui/endian_bytes.rs:61:9 | LL | isize::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -651,7 +651,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f32::from_le_bytes` - --> $DIR/endian_bytes.rs:62:9 + --> tests/ui/endian_bytes.rs:62:9 | LL | f32::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -663,7 +663,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f64::from_le_bytes` - --> $DIR/endian_bytes.rs:63:9 + --> tests/ui/endian_bytes.rs:63:9 | LL | f64::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -675,7 +675,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -687,7 +687,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -699,7 +699,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -713,7 +713,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_be_bytes` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -725,7 +725,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -737,7 +737,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -749,7 +749,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -761,7 +761,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -773,7 +773,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -784,7 +784,7 @@ LL | fn no_help() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -795,7 +795,7 @@ LL | fn no_help() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -806,7 +806,7 @@ LL | fn no_help() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -817,7 +817,7 @@ LL | fn no_help() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -828,7 +828,7 @@ LL | fn no_help() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_be_bytes` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -839,7 +839,7 @@ LL | fn no_help() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -851,7 +851,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -863,7 +863,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -875,7 +875,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_be_bytes` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -887,7 +887,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -899,7 +899,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -911,7 +911,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -923,7 +923,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -935,7 +935,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -947,7 +947,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -959,7 +959,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -971,7 +971,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_be_bytes` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -983,7 +983,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -995,7 +995,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1007,7 +1007,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -1019,7 +1019,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_be_bytes` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index b01f0a9a0e56b..ef4c36bcf546c 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:24:5 + --> tests/ui/entry.rs:24:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::map_entry)]` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:29:5 + --> tests/ui/entry.rs:29:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -33,7 +33,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:38:5 + --> tests/ui/entry.rs:38:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -56,7 +56,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:47:5 + --> tests/ui/entry.rs:47:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -80,7 +80,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:57:5 + --> tests/ui/entry.rs:57:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -97,7 +97,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:63:5 + --> tests/ui/entry.rs:63:5 | LL | / if !m.contains_key(&k) { LL | | match 0 { @@ -123,7 +123,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:75:5 + --> tests/ui/entry.rs:75:5 | LL | / if !m.contains_key(&k) { LL | | match 0 { @@ -147,7 +147,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:85:5 + --> tests/ui/entry.rs:85:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -188,7 +188,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:119:5 + --> tests/ui/entry.rs:119:5 | LL | / if !m.contains_key(&m!(k)) { LL | | m.insert(m!(k), m!(v)); @@ -196,7 +196,7 @@ LL | | } | |_____^ help: try: `m.entry(m!(k)).or_insert_with(|| m!(v));` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:151:5 + --> tests/ui/entry.rs:151:5 | LL | / if !m.contains_key(&k) { LL | | let x = (String::new(), String::new()); diff --git a/tests/ui/entry_btree.stderr b/tests/ui/entry_btree.stderr index 63e9a0af8b6b3..290e6b7880541 100644 --- a/tests/ui/entry_btree.stderr +++ b/tests/ui/entry_btree.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `BTreeMap` - --> $DIR/entry_btree.rs:10:5 + --> tests/ui/entry_btree.rs:10:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); diff --git a/tests/ui/entry_with_else.stderr b/tests/ui/entry_with_else.stderr index 425e87122d57f..26b21b076b6c0 100644 --- a/tests/ui/entry_with_else.stderr +++ b/tests/ui/entry_with_else.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:14:5 + --> tests/ui/entry_with_else.rs:14:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -23,7 +23,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:20:5 + --> tests/ui/entry_with_else.rs:20:5 | LL | / if m.contains_key(&k) { LL | | m.insert(k, v); @@ -45,7 +45,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:26:5 + --> tests/ui/entry_with_else.rs:26:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -64,7 +64,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:32:5 + --> tests/ui/entry_with_else.rs:32:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -83,7 +83,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:38:5 + --> tests/ui/entry_with_else.rs:38:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -105,7 +105,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:44:5 + --> tests/ui/entry_with_else.rs:44:5 | LL | / if m.contains_key(&k) { LL | | if true { m.insert(k, v) } else { m.insert(k, v2) } @@ -128,7 +128,7 @@ LL ~ }; | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:50:5 + --> tests/ui/entry_with_else.rs:50:5 | LL | / if m.contains_key(&k) { LL | | foo(); diff --git a/tests/ui/enum_clike_unportable_variant.stderr b/tests/ui/enum_clike_unportable_variant.stderr index 93ad4daa97f77..741de179a497a 100644 --- a/tests/ui/enum_clike_unportable_variant.stderr +++ b/tests/ui/enum_clike_unportable_variant.stderr @@ -1,5 +1,5 @@ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:8:5 + --> tests/ui/enum_clike_unportable_variant.rs:8:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ @@ -8,49 +8,49 @@ LL | X = 0x1_0000_0000, = help: to override `-D warnings` add `#[allow(clippy::enum_clike_unportable_variant)]` error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:17:5 + --> tests/ui/enum_clike_unportable_variant.rs:17:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:21:5 + --> tests/ui/enum_clike_unportable_variant.rs:21:5 | LL | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:29:5 + --> tests/ui/enum_clike_unportable_variant.rs:29:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:31:5 + --> tests/ui/enum_clike_unportable_variant.rs:31:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:34:5 + --> tests/ui/enum_clike_unportable_variant.rs:34:5 | LL | C = (i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:41:5 + --> tests/ui/enum_clike_unportable_variant.rs:41:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:43:5 + --> tests/ui/enum_clike_unportable_variant.rs:43:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:49:5 + --> tests/ui/enum_clike_unportable_variant.rs:49:5 | LL | X = ::Number, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 8b94e67f87ea3..6825383b769d7 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import for enum variants - --> $DIR/enum_glob_use.rs:5:5 + --> tests/ui/enum_glob_use.rs:5:5 | LL | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::cmp::Ordering::Less` @@ -8,13 +8,13 @@ LL | use std::cmp::Ordering::*; = help: to override `-D warnings` add `#[allow(clippy::enum_glob_use)]` error: usage of wildcard import for enum variants - --> $DIR/enum_glob_use.rs:11:5 + --> tests/ui/enum_glob_use.rs:11:5 | LL | use self::Enum::*; | ^^^^^^^^^^^^^ help: try: `self::Enum::Foo` error: usage of wildcard import for enum variants - --> $DIR/enum_glob_use.rs:15:13 + --> tests/ui/enum_glob_use.rs:15:13 | LL | use crate::Enum::*; | ^^^^^^^^^^^^^^ help: try: `crate::Enum::Foo` diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index b1e88de0fcf1c..aaac3cbb82dc1 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,5 +1,5 @@ error: variant name ends with the enum's name - --> $DIR/enum_variants.rs:16:5 + --> tests/ui/enum_variants.rs:16:5 | LL | cFoo, | ^^^^ @@ -8,7 +8,7 @@ LL | cFoo, = help: to override `-D warnings` add `#[allow(clippy::enum_variant_names)]` error: all variants have the same prefix: `c` - --> $DIR/enum_variants.rs:14:1 + --> tests/ui/enum_variants.rs:14:1 | LL | / enum Foo { LL | | @@ -22,25 +22,25 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:30:5 + --> tests/ui/enum_variants.rs:30:5 | LL | FoodGood, | ^^^^^^^^ error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:32:5 + --> tests/ui/enum_variants.rs:32:5 | LL | FoodMiddle, | ^^^^^^^^^^ error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:34:5 + --> tests/ui/enum_variants.rs:34:5 | LL | FoodBad, | ^^^^^^^ error: all variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:28:1 + --> tests/ui/enum_variants.rs:28:1 | LL | / enum Food { LL | | @@ -54,7 +54,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `CallType` - --> $DIR/enum_variants.rs:42:1 + --> tests/ui/enum_variants.rs:42:1 | LL | / enum BadCallType { LL | | @@ -67,7 +67,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `Constant` - --> $DIR/enum_variants.rs:55:1 + --> tests/ui/enum_variants.rs:55:1 | LL | / enum Consts { LL | | @@ -80,7 +80,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `C` - --> $DIR/enum_variants.rs:68:1 + --> tests/ui/enum_variants.rs:68:1 | LL | / enum Something { LL | | @@ -93,7 +93,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `WithOut` - --> $DIR/enum_variants.rs:91:1 + --> tests/ui/enum_variants.rs:91:1 | LL | / enum Seallll { LL | | @@ -106,7 +106,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `IData` - --> $DIR/enum_variants.rs:147:1 + --> tests/ui/enum_variants.rs:147:1 | LL | / enum IDataRequest { LL | | @@ -119,7 +119,7 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `HIData` - --> $DIR/enum_variants.rs:154:1 + --> tests/ui/enum_variants.rs:154:1 | LL | / enum HIDataRequest { LL | | @@ -132,7 +132,7 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `_Type` - --> $DIR/enum_variants.rs:175:5 + --> tests/ui/enum_variants.rs:175:5 | LL | / enum DoLint { LL | | @@ -146,7 +146,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `Type` - --> $DIR/enum_variants.rs:183:5 + --> tests/ui/enum_variants.rs:183:5 | LL | / enum DoLintToo { LL | | @@ -159,13 +159,13 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:212:9 + --> tests/ui/enum_variants.rs:212:9 | LL | DataDependent, | ^^^^^^^^^^^^^ error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:217:9 + --> tests/ui/enum_variants.rs:217:9 | LL | DatasDependent, | ^^^^^^^^^^^^^^ diff --git a/tests/ui/eprint_with_newline.stderr b/tests/ui/eprint_with_newline.stderr index 674b4fdaed50e..de450090a66e5 100644 --- a/tests/ui/eprint_with_newline.stderr +++ b/tests/ui/eprint_with_newline.stderr @@ -1,5 +1,5 @@ error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:5:5 + --> tests/ui/eprint_with_newline.rs:5:5 | LL | eprint!("Hello\n"); | ^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + eprintln!("Hello"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:8:5 + --> tests/ui/eprint_with_newline.rs:8:5 | LL | eprint!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + eprintln!("Hello {}", "world"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:10:5 + --> tests/ui/eprint_with_newline.rs:10:5 | LL | eprint!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + eprintln!("Hello {} {}", "world", "#2"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:12:5 + --> tests/ui/eprint_with_newline.rs:12:5 | LL | eprint!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + eprintln!("{}", 1265); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:14:5 + --> tests/ui/eprint_with_newline.rs:14:5 | LL | eprint!("\n"); | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + eprintln!(); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:37:5 + --> tests/ui/eprint_with_newline.rs:37:5 | LL | eprint!("\\\n"); | ^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + eprintln!("\\"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:46:5 + --> tests/ui/eprint_with_newline.rs:46:5 | LL | / eprint!( LL | | @@ -90,7 +90,7 @@ LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:51:5 + --> tests/ui/eprint_with_newline.rs:51:5 | LL | / eprint!( LL | | @@ -107,7 +107,7 @@ LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:60:5 + --> tests/ui/eprint_with_newline.rs:60:5 | LL | eprint!("\\r\n"); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index 2427ac0dda55f..bd3c115d8b8bc 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -1,5 +1,5 @@ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:7:13 + --> tests/ui/eq_op.rs:7:13 | LL | let _ = 1 == 1; | ^^^^^^ @@ -8,31 +8,31 @@ LL | let _ = 1 == 1; = help: to override `-D warnings` add `#[allow(clippy::eq_op)]` error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:10:13 + --> tests/ui/eq_op.rs:10:13 | LL | let _ = "no" == "no"; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:13:13 + --> tests/ui/eq_op.rs:13:13 | LL | let _ = false != false; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> $DIR/eq_op.rs:15:13 + --> tests/ui/eq_op.rs:15:13 | LL | let _ = 1.5 < 1.5; | ^^^^^^^^^ error: equal expressions as operands to `>=` - --> $DIR/eq_op.rs:17:13 + --> tests/ui/eq_op.rs:17:13 | LL | let _ = 1u64 >= 1u64; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:20:13 + --> tests/ui/eq_op.rs:20:13 | LL | let _ = x != x; | ^^^^^^ @@ -40,139 +40,139 @@ LL | let _ = x != x; = note: if you intended to check if the operand is NaN, use `.is_nan()` instead error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:25:13 + --> tests/ui/eq_op.rs:25:13 | LL | let _ = (1u32 as u64) & (1u32 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `^` - --> $DIR/eq_op.rs:29:17 + --> tests/ui/eq_op.rs:29:17 | LL | let _ = 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> $DIR/eq_op.rs:34:13 + --> tests/ui/eq_op.rs:34:13 | LL | let _ = (-(2) < -(2)); | ^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:36:13 + --> tests/ui/eq_op.rs:36:13 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:36:14 + --> tests/ui/eq_op.rs:36:14 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:36:35 + --> tests/ui/eq_op.rs:36:35 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:40:13 + --> tests/ui/eq_op.rs:40:13 | LL | let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:44:13 + --> tests/ui/eq_op.rs:44:13 | LL | let _ = ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:46:13 + --> tests/ui/eq_op.rs:46:13 | LL | let _ = ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:51:13 + --> tests/ui/eq_op.rs:51:13 | LL | let _ = 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:53:13 + --> tests/ui/eq_op.rs:53:13 | LL | let _ = 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:53:13 + --> tests/ui/eq_op.rs:53:13 | LL | let _ = 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:57:13 + --> tests/ui/eq_op.rs:57:13 | LL | let _ = 1 - 1; | ^^^^^ error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:59:13 + --> tests/ui/eq_op.rs:59:13 | LL | let _ = 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:61:13 + --> tests/ui/eq_op.rs:61:13 | LL | let _ = true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` - --> $DIR/eq_op.rs:64:13 + --> tests/ui/eq_op.rs:64:13 | LL | let _ = true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:70:13 + --> tests/ui/eq_op.rs:70:13 | LL | let _ = a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:72:13 + --> tests/ui/eq_op.rs:72:13 | LL | let _ = a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:74:13 + --> tests/ui/eq_op.rs:74:13 | LL | let _ = a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:76:13 + --> tests/ui/eq_op.rs:76:13 | LL | let _ = a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:80:13 + --> tests/ui/eq_op.rs:80:13 | LL | let _ = a == a; | ^^^^^^ error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:91:20 + --> tests/ui/eq_op.rs:91:20 | LL | const D: u32 = A / A; | ^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:123:5 + --> tests/ui/eq_op.rs:123:5 | LL | (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/eq_op_macros.stderr b/tests/ui/eq_op_macros.stderr index 0df26607aa6e8..b114db0ca98e1 100644 --- a/tests/ui/eq_op_macros.stderr +++ b/tests/ui/eq_op_macros.stderr @@ -1,5 +1,5 @@ error: identical args used in this `assert_eq!` macro call - --> $DIR/eq_op_macros.rs:8:20 + --> tests/ui/eq_op_macros.rs:8:20 | LL | assert_eq!(a, a); | ^^^^ @@ -12,7 +12,7 @@ LL | assert_in_macro_def!(); = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: identical args used in this `assert_ne!` macro call - --> $DIR/eq_op_macros.rs:9:20 + --> tests/ui/eq_op_macros.rs:9:20 | LL | assert_ne!(a, a); | ^^^^ @@ -23,7 +23,7 @@ LL | assert_in_macro_def!(); = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: identical args used in this `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:10:26 + --> tests/ui/eq_op_macros.rs:10:26 | LL | debug_assert_eq!(a, a); | ^^^^ @@ -34,7 +34,7 @@ LL | assert_in_macro_def!(); = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: identical args used in this `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:11:26 + --> tests/ui/eq_op_macros.rs:11:26 | LL | debug_assert_ne!(a, a); | ^^^^ @@ -45,49 +45,49 @@ LL | assert_in_macro_def!(); = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: identical args used in this `assert_eq!` macro call - --> $DIR/eq_op_macros.rs:23:16 + --> tests/ui/eq_op_macros.rs:23:16 | LL | assert_eq!(a, a); | ^^^^ error: identical args used in this `assert_eq!` macro call - --> $DIR/eq_op_macros.rs:25:16 + --> tests/ui/eq_op_macros.rs:25:16 | LL | assert_eq!(a + 1, a + 1); | ^^^^^^^^^^^^ error: identical args used in this `assert_ne!` macro call - --> $DIR/eq_op_macros.rs:33:16 + --> tests/ui/eq_op_macros.rs:33:16 | LL | assert_ne!(a, a); | ^^^^ error: identical args used in this `assert_ne!` macro call - --> $DIR/eq_op_macros.rs:35:16 + --> tests/ui/eq_op_macros.rs:35:16 | LL | assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ error: identical args used in this `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:43:22 + --> tests/ui/eq_op_macros.rs:43:22 | LL | debug_assert_eq!(a, a); | ^^^^ error: identical args used in this `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:45:22 + --> tests/ui/eq_op_macros.rs:45:22 | LL | debug_assert_eq!(a + 1, a + 1); | ^^^^^^^^^^^^ error: identical args used in this `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:53:22 + --> tests/ui/eq_op_macros.rs:53:22 | LL | debug_assert_ne!(a, a); | ^^^^ error: identical args used in this `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:55:22 + --> tests/ui/eq_op_macros.rs:55:22 | LL | debug_assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ diff --git a/tests/ui/equatable_if_let.stderr b/tests/ui/equatable_if_let.stderr index 6cc19d829edc7..9e93a33cd7e21 100644 --- a/tests/ui/equatable_if_let.stderr +++ b/tests/ui/equatable_if_let.stderr @@ -1,5 +1,5 @@ error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:64:8 + --> tests/ui/equatable_if_let.rs:64:8 | LL | if let 2 = a {} | ^^^^^^^^^ help: try: `a == 2` @@ -8,79 +8,79 @@ LL | if let 2 = a {} = help: to override `-D warnings` add `#[allow(clippy::equatable_if_let)]` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:65:8 + --> tests/ui/equatable_if_let.rs:65:8 | LL | if let Ordering::Greater = a.cmp(&b) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.cmp(&b) == Ordering::Greater` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:66:8 + --> tests/ui/equatable_if_let.rs:66:8 | LL | if let Some(2) = c {} | ^^^^^^^^^^^^^^^ help: try: `c == Some(2)` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:67:8 + --> tests/ui/equatable_if_let.rs:67:8 | LL | if let Struct { a: 2, b: false } = d {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d == (Struct { a: 2, b: false })` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:68:8 + --> tests/ui/equatable_if_let.rs:68:8 | LL | if let Enum::TupleVariant(32, 64) = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::TupleVariant(32, 64)` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:69:8 + --> tests/ui/equatable_if_let.rs:69:8 | LL | if let Enum::RecordVariant { a: 64, b: 32 } = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == (Enum::RecordVariant { a: 64, b: 32 })` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:70:8 + --> tests/ui/equatable_if_let.rs:70:8 | LL | if let Enum::UnitVariant = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::UnitVariant` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:71:8 + --> tests/ui/equatable_if_let.rs:71:8 | LL | if let (Enum::UnitVariant, &Struct { a: 2, b: false }) = (e, &d) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(e, &d) == (Enum::UnitVariant, &Struct { a: 2, b: false })` error: this pattern matching can be expressed using `matches!` - --> $DIR/equatable_if_let.rs:80:8 + --> tests/ui/equatable_if_let.rs:80:8 | LL | if let NotPartialEq::A = f {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(f, NotPartialEq::A)` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:81:8 + --> tests/ui/equatable_if_let.rs:81:8 | LL | if let NotStructuralEq::A = g {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `g == NotStructuralEq::A` error: this pattern matching can be expressed using `matches!` - --> $DIR/equatable_if_let.rs:82:8 + --> tests/ui/equatable_if_let.rs:82:8 | LL | if let Some(NotPartialEq::A) = Some(f) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(Some(f), Some(NotPartialEq::A))` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:83:8 + --> tests/ui/equatable_if_let.rs:83:8 | LL | if let Some(NotStructuralEq::A) = Some(g) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(g) == Some(NotStructuralEq::A)` error: this pattern matching can be expressed using `matches!` - --> $DIR/equatable_if_let.rs:84:8 + --> tests/ui/equatable_if_let.rs:84:8 | LL | if let NoPartialEqStruct { a: 2, b: false } = h {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(h, NoPartialEqStruct { a: 2, b: false })` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:86:8 + --> tests/ui/equatable_if_let.rs:86:8 | LL | if let inline!("abc") = "abc" { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"abc" == inline!("abc")` diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 1b50a05cd228d..6ed8bffeb24d5 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,5 +1,5 @@ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:35:5 + --> tests/ui/erasing_op.rs:35:5 | LL | x * 0; | ^^^^^ @@ -8,25 +8,25 @@ LL | x * 0; = help: to override `-D warnings` add `#[allow(clippy::erasing_op)]` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:38:5 + --> tests/ui/erasing_op.rs:38:5 | LL | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:40:5 + --> tests/ui/erasing_op.rs:40:5 | LL | 0 / x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:43:5 + --> tests/ui/erasing_op.rs:43:5 | LL | 0 * Vec1 { x: 5 }; | ^^^^^^^^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:45:5 + --> tests/ui/erasing_op.rs:45:5 | LL | Vec1 { x: 5 } * 0; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/err_expect.stderr b/tests/ui/err_expect.stderr index da7cd47f0bb49..68f39cc45c5b1 100644 --- a/tests/ui/err_expect.stderr +++ b/tests/ui/err_expect.stderr @@ -1,5 +1,5 @@ error: called `.err().expect()` on a `Result` value - --> $DIR/err_expect.rs:10:16 + --> tests/ui/err_expect.rs:10:16 | LL | test_debug.err().expect("Testing debug type"); | ^^^^^^^^^^^^ help: try: `expect_err` @@ -8,7 +8,7 @@ LL | test_debug.err().expect("Testing debug type"); = help: to override `-D warnings` add `#[allow(clippy::err_expect)]` error: called `.err().expect()` on a `Result` value - --> $DIR/err_expect.rs:25:7 + --> tests/ui/err_expect.rs:25:7 | LL | x.err().expect("17"); | ^^^^^^^^^^^^ help: try: `expect_err` diff --git a/tests/ui/error_impl_error.stderr b/tests/ui/error_impl_error.stderr index d7a1aa829890c..087d43d1d083b 100644 --- a/tests/ui/error_impl_error.stderr +++ b/tests/ui/error_impl_error.stderr @@ -1,11 +1,11 @@ error: exported type named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:7:16 + --> tests/ui/error_impl_error.rs:7:16 | LL | pub struct Error; | ^^^^^ | note: `Error` was implemented here - --> $DIR/error_impl_error.rs:16:5 + --> tests/ui/error_impl_error.rs:16:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | impl std::error::Error for Error {} = help: to override `-D warnings` add `#[allow(clippy::error_impl_error)]` error: exported type named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:21:21 + --> tests/ui/error_impl_error.rs:21:21 | LL | pub(super) enum Error {} | ^^^^^ | note: `Error` was implemented here - --> $DIR/error_impl_error.rs:30:5 + --> tests/ui/error_impl_error.rs:30:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: exported type named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:34:15 + --> tests/ui/error_impl_error.rs:34:15 | LL | pub union Error { | ^^^^^ | note: `Error` was implemented here - --> $DIR/error_impl_error.rs:52:5 + --> tests/ui/error_impl_error.rs:52:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: exported type alias named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:56:14 + --> tests/ui/error_impl_error.rs:56:14 | LL | pub type Error = std::fmt::Error; | ^^^^^ diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 945de466d8322..d9a8768a68217 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,5 +1,5 @@ error: redundant closure - --> $DIR/eta.rs:29:27 + --> tests/ui/eta.rs:29:27 | LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: replace the closure with the function itself: `foo` @@ -8,31 +8,31 @@ LL | let a = Some(1u8).map(|a| foo(a)); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: redundant closure - --> $DIR/eta.rs:33:40 + --> tests/ui/eta.rs:33:40 | LL | let _: Option> = true.then(|| vec![]); // special case vec! | ^^^^^^^^^ help: replace the closure with `Vec::new`: `std::vec::Vec::new` error: redundant closure - --> $DIR/eta.rs:34:35 + --> tests/ui/eta.rs:34:35 | LL | let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? | ^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo2` error: redundant closure - --> $DIR/eta.rs:35:26 + --> tests/ui/eta.rs:35:26 | LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below` error: redundant closure - --> $DIR/eta.rs:42:27 + --> tests/ui/eta.rs:42:27 | LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic` error: redundant closure - --> $DIR/eta.rs:94:51 + --> tests/ui/eta.rs:94:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo` @@ -41,151 +41,151 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_for_method_calls)]` error: redundant closure - --> $DIR/eta.rs:95:51 + --> tests/ui/eta.rs:95:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo` error: redundant closure - --> $DIR/eta.rs:97:42 + --> tests/ui/eta.rs:97:42 | LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear()); | ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear` error: redundant closure - --> $DIR/eta.rs:101:29 + --> tests/ui/eta.rs:101:29 | LL | let e = Some("str").map(|s| s.to_string()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string` error: redundant closure - --> $DIR/eta.rs:102:27 + --> tests/ui/eta.rs:102:27 | LL | let e = Some('a').map(|s| s.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase` error: redundant closure - --> $DIR/eta.rs:104:65 + --> tests/ui/eta.rs:104:65 | LL | let e: std::vec::Vec = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase` error: redundant closure - --> $DIR/eta.rs:167:22 + --> tests/ui/eta.rs:167:22 | LL | requires_fn_once(|| x()); | ^^^^^^ help: replace the closure with the function itself: `x` error: redundant closure - --> $DIR/eta.rs:174:27 + --> tests/ui/eta.rs:174:27 | LL | let a = Some(1u8).map(|a| foo_ptr(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr` error: redundant closure - --> $DIR/eta.rs:179:27 + --> tests/ui/eta.rs:179:27 | LL | let a = Some(1u8).map(|a| closure(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure` error: redundant closure - --> $DIR/eta.rs:211:28 + --> tests/ui/eta.rs:211:28 | LL | x.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure - --> $DIR/eta.rs:212:28 + --> tests/ui/eta.rs:212:28 | LL | y.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure - --> $DIR/eta.rs:213:28 + --> tests/ui/eta.rs:213:28 | LL | z.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res` error: redundant closure - --> $DIR/eta.rs:220:21 + --> tests/ui/eta.rs:220:21 | LL | Some(1).map(|n| closure(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure` error: redundant closure - --> $DIR/eta.rs:224:21 + --> tests/ui/eta.rs:224:21 | LL | Some(1).map(|n| in_loop(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `in_loop` error: redundant closure - --> $DIR/eta.rs:317:18 + --> tests/ui/eta.rs:317:18 | LL | takes_fn_mut(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure - --> $DIR/eta.rs:320:19 + --> tests/ui/eta.rs:320:19 | LL | takes_fn_once(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure - --> $DIR/eta.rs:324:26 + --> tests/ui/eta.rs:324:26 | LL | move || takes_fn_mut(|| f_used_once()) | ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once` error: redundant closure - --> $DIR/eta.rs:336:19 + --> tests/ui/eta.rs:336:19 | LL | array_opt.map(|a| a.as_slice()); | ^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8; 3]>::as_slice` error: redundant closure - --> $DIR/eta.rs:339:19 + --> tests/ui/eta.rs:339:19 | LL | slice_opt.map(|s| s.len()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8]>::len` error: redundant closure - --> $DIR/eta.rs:342:17 + --> tests/ui/eta.rs:342:17 | LL | ptr_opt.map(|p| p.is_null()); | ^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<*const usize>::is_null` error: redundant closure - --> $DIR/eta.rs:346:17 + --> tests/ui/eta.rs:346:17 | LL | dyn_opt.map(|d| d.method_on_dyn()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `::method_on_dyn` error: redundant closure - --> $DIR/eta.rs:406:19 + --> tests/ui/eta.rs:406:19 | LL | let _ = f(&0, |x, y| f2(x, y)); | ^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `f2` error: redundant closure - --> $DIR/eta.rs:434:22 + --> tests/ui/eta.rs:434:22 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `Test::method` error: redundant closure - --> $DIR/eta.rs:438:22 + --> tests/ui/eta.rs:438:22 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `super::Outer::method` error: redundant closure - --> $DIR/eta.rs:451:18 + --> tests/ui/eta.rs:451:18 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `test_mod::Test::method` error: redundant closure - --> $DIR/eta.rs:458:30 + --> tests/ui/eta.rs:458:30 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `crate::issue_10854::d::Test::method` diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 5e7672e185af3..22dd96e53bdbe 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -1,5 +1,5 @@ error: float has excessive precision - --> $DIR/excessive_precision.rs:20:26 + --> tests/ui/excessive_precision.rs:20:26 | LL | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79_f32` @@ -8,85 +8,85 @@ LL | const BAD32_1: f32 = 0.123_456_789_f32; = help: to override `-D warnings` add `#[allow(clippy::excessive_precision)]` error: float has excessive precision - --> $DIR/excessive_precision.rs:21:26 + --> tests/ui/excessive_precision.rs:21:26 | LL | const BAD32_2: f32 = 0.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:22:26 + --> tests/ui/excessive_precision.rs:22:26 | LL | const BAD32_3: f32 = 0.100_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:23:29 + --> tests/ui/excessive_precision.rs:23:29 | LL | const BAD32_EDGE: f32 = 1.000_000_9; | ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` error: float has excessive precision - --> $DIR/excessive_precision.rs:27:26 + --> tests/ui/excessive_precision.rs:27:26 | LL | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:30:22 + --> tests/ui/excessive_precision.rs:30:22 | LL | println!("{:?}", 8.888_888_888_888_888_888_888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` error: float has excessive precision - --> $DIR/excessive_precision.rs:41:22 + --> tests/ui/excessive_precision.rs:41:22 | LL | let bad32: f32 = 1.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:42:26 + --> tests/ui/excessive_precision.rs:42:26 | LL | let bad32_suf: f32 = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` error: float has excessive precision - --> $DIR/excessive_precision.rs:43:21 + --> tests/ui/excessive_precision.rs:43:21 | LL | let bad32_inf = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` error: float has excessive precision - --> $DIR/excessive_precision.rs:53:36 + --> tests/ui/excessive_precision.rs:53:36 | LL | let bad_vec32: Vec = vec![0.123_456_789]; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:54:36 + --> tests/ui/excessive_precision.rs:54:36 | LL | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` error: float has excessive precision - --> $DIR/excessive_precision.rs:58:24 + --> tests/ui/excessive_precision.rs:58:24 | LL | let bad_e32: f32 = 1.123_456_788_888e-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:61:27 + --> tests/ui/excessive_precision.rs:61:27 | LL | let bad_bige32: f32 = 1.123_456_788_888E-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:70:13 + --> tests/ui/excessive_precision.rs:70:13 | LL | let _ = 2.225_073_858_507_201_1e-308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-308_f64` error: float has excessive precision - --> $DIR/excessive_precision.rs:73:13 + --> tests/ui/excessive_precision.rs:73:13 | LL | let _ = 1.000_000_000_000_001e-324_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0_f64` diff --git a/tests/ui/exhaustive_items.stderr b/tests/ui/exhaustive_items.stderr index ae43e81c0d31f..536fbe8d790f6 100644 --- a/tests/ui/exhaustive_items.stderr +++ b/tests/ui/exhaustive_items.stderr @@ -1,5 +1,5 @@ error: exported enums should not be exhaustive - --> $DIR/exhaustive_items.rs:9:5 + --> tests/ui/exhaustive_items.rs:9:5 | LL | / pub enum Exhaustive { LL | | Foo, @@ -10,7 +10,7 @@ LL | | } | |_____^ | note: the lint level is defined here - --> $DIR/exhaustive_items.rs:1:9 + --> tests/ui/exhaustive_items.rs:1:9 | LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL ~ pub enum Exhaustive { | error: exported enums should not be exhaustive - --> $DIR/exhaustive_items.rs:18:5 + --> tests/ui/exhaustive_items.rs:18:5 | LL | / pub enum ExhaustiveWithAttrs { LL | | Foo, @@ -38,7 +38,7 @@ LL ~ pub enum ExhaustiveWithAttrs { | error: exported structs should not be exhaustive - --> $DIR/exhaustive_items.rs:53:5 + --> tests/ui/exhaustive_items.rs:53:5 | LL | / pub struct Exhaustive { LL | | pub foo: u8, @@ -47,7 +47,7 @@ LL | | } | |_____^ | note: the lint level is defined here - --> $DIR/exhaustive_items.rs:1:35 + --> tests/ui/exhaustive_items.rs:1:35 | LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/exit1.stderr b/tests/ui/exit1.stderr index bbe0762c8d128..2158314b7c7b1 100644 --- a/tests/ui/exit1.stderr +++ b/tests/ui/exit1.stderr @@ -1,5 +1,5 @@ error: usage of `process::exit` - --> $DIR/exit1.rs:5:9 + --> tests/ui/exit1.rs:5:9 | LL | std::process::exit(4); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/exit2.stderr b/tests/ui/exit2.stderr index 19abbc6062a6e..ac782506c1923 100644 --- a/tests/ui/exit2.stderr +++ b/tests/ui/exit2.stderr @@ -1,5 +1,5 @@ error: usage of `process::exit` - --> $DIR/exit2.rs:4:5 + --> tests/ui/exit2.rs:4:5 | LL | std::process::exit(3); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/expect.stderr b/tests/ui/expect.stderr index 35a258a85e4e9..c0ba3390aac59 100644 --- a/tests/ui/expect.stderr +++ b/tests/ui/expect.stderr @@ -1,5 +1,5 @@ error: used `expect()` on an `Option` value - --> $DIR/expect.rs:6:13 + --> tests/ui/expect.rs:6:13 | LL | let _ = opt.expect(""); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = opt.expect(""); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value - --> $DIR/expect.rs:12:13 + --> tests/ui/expect.rs:12:13 | LL | let _ = res.expect(""); | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = res.expect(""); = note: if this value is an `Err`, it will panic error: used `expect_err()` on a `Result` value - --> $DIR/expect.rs:14:13 + --> tests/ui/expect.rs:14:13 | LL | let _ = res.expect_err(""); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr index dd3976f3624c6..b41904d04fa4c 100644 --- a/tests/ui/expect_fun_call.stderr +++ b/tests/ui/expect_fun_call.stderr @@ -1,5 +1,5 @@ error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:37:26 + --> tests/ui/expect_fun_call.rs:37:26 | LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` @@ -8,85 +8,85 @@ LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code = help: to override `-D warnings` add `#[allow(clippy::expect_fun_call)]` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:40:26 + --> tests/ui/expect_fun_call.rs:40:26 | LL | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:43:37 + --> tests/ui/expect_fun_call.rs:43:37 | LL | with_none_and_format_with_macro.expect(format!("Error {}: fake error", one!()).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", one!()))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:53:25 + --> tests/ui/expect_fun_call.rs:53:25 | LL | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:56:25 + --> tests/ui/expect_fun_call.rs:56:25 | LL | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:68:17 + --> tests/ui/expect_fun_call.rs:68:17 | LL | Some("foo").expect(format!("{} {}", 1, 2).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{} {}", 1, 2))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:89:21 + --> tests/ui/expect_fun_call.rs:89:21 | LL | Some("foo").expect(&get_string()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:90:21 + --> tests/ui/expect_fun_call.rs:90:21 | LL | Some("foo").expect(get_string().as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:91:21 + --> tests/ui/expect_fun_call.rs:91:21 | LL | Some("foo").expect(get_string().as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:93:21 + --> tests/ui/expect_fun_call.rs:93:21 | LL | Some("foo").expect(get_static_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_static_str()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:94:21 + --> tests/ui/expect_fun_call.rs:94:21 | LL | Some("foo").expect(get_non_static_str(&0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:98:16 + --> tests/ui/expect_fun_call.rs:98:16 | LL | Some(true).expect(&format!("key {}, {}", 1, 2)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:104:17 + --> tests/ui/expect_fun_call.rs:104:17 | LL | opt_ref.expect(&format!("{:?}", opt_ref)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{:?}", opt_ref))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:108:20 + --> tests/ui/expect_fun_call.rs:108:20 | LL | format_capture.expect(&format!("{error_code}")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{error_code}"))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:111:30 + --> tests/ui/expect_fun_call.rs:111:30 | LL | format_capture_and_value.expect(&format!("{error_code}, {}", 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{error_code}, {}", 1))` diff --git a/tests/ui/expect_tool_lint_rfc_2383.stderr b/tests/ui/expect_tool_lint_rfc_2383.stderr index 2a418d8456635..43e0b9279e4b1 100644 --- a/tests/ui/expect_tool_lint_rfc_2383.stderr +++ b/tests/ui/expect_tool_lint_rfc_2383.stderr @@ -1,5 +1,5 @@ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:31:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:31:14 | LL | #[expect(dead_code)] | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | #[expect(dead_code)] = help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]` error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:37:18 + --> tests/ui/expect_tool_lint_rfc_2383.rs:37:18 | LL | #[expect(invalid_nan_comparisons)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:108:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:108:14 | LL | #[expect(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:116:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:116:14 | LL | #[expect(clippy::bytes_nth)] | ^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:122:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:122:14 | LL | #[expect(clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:128:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:128:14 | LL | #[expect(clippy::overly_complex_bool_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/explicit_auto_deref.stderr b/tests/ui/explicit_auto_deref.stderr index cc9eeeb504290..56a183de3487f 100644 --- a/tests/ui/explicit_auto_deref.stderr +++ b/tests/ui/explicit_auto_deref.stderr @@ -1,5 +1,5 @@ error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:68:19 + --> tests/ui/explicit_auto_deref.rs:68:19 | LL | let _: &str = &*s; | ^^^ help: try: `&s` @@ -8,265 +8,265 @@ LL | let _: &str = &*s; = help: to override `-D warnings` add `#[allow(clippy::explicit_auto_deref)]` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:69:19 + --> tests/ui/explicit_auto_deref.rs:69:19 | LL | let _: &str = &*{ String::new() }; | ^^^^^^^^^^^^^^^^^^^ help: try: `&{ String::new() }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:70:19 + --> tests/ui/explicit_auto_deref.rs:70:19 | LL | let _: &str = &mut *{ String::new() }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut { String::new() }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:74:11 + --> tests/ui/explicit_auto_deref.rs:74:11 | LL | f_str(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:78:13 + --> tests/ui/explicit_auto_deref.rs:78:13 | LL | f_str_t(&*s, &*s); // Don't lint second param. | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:81:24 + --> tests/ui/explicit_auto_deref.rs:81:24 | LL | let _: &Box = &**b; | ^^^^ help: try: `&b` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:87:7 + --> tests/ui/explicit_auto_deref.rs:87:7 | LL | c(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:93:9 + --> tests/ui/explicit_auto_deref.rs:93:9 | LL | &**x | ^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:97:11 + --> tests/ui/explicit_auto_deref.rs:97:11 | LL | { &**x } | ^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:101:9 + --> tests/ui/explicit_auto_deref.rs:101:9 | LL | &**{ x } | ^^^^^^^^ help: try: `{ x }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:105:9 + --> tests/ui/explicit_auto_deref.rs:105:9 | LL | &***x | ^^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:122:12 + --> tests/ui/explicit_auto_deref.rs:122:12 | LL | f1(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:123:12 + --> tests/ui/explicit_auto_deref.rs:123:12 | LL | f2(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:124:12 + --> tests/ui/explicit_auto_deref.rs:124:12 | LL | f3(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:125:27 + --> tests/ui/explicit_auto_deref.rs:125:27 | LL | f4.callable_str()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:126:12 + --> tests/ui/explicit_auto_deref.rs:126:12 | LL | f5(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:127:12 + --> tests/ui/explicit_auto_deref.rs:127:12 | LL | f6(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:128:27 + --> tests/ui/explicit_auto_deref.rs:128:27 | LL | f7.callable_str()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:129:25 + --> tests/ui/explicit_auto_deref.rs:129:25 | LL | f8.callable_t()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:130:12 + --> tests/ui/explicit_auto_deref.rs:130:12 | LL | f9(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:131:13 + --> tests/ui/explicit_auto_deref.rs:131:13 | LL | f10(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:132:26 + --> tests/ui/explicit_auto_deref.rs:132:26 | LL | f11.callable_t()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:136:16 + --> tests/ui/explicit_auto_deref.rs:136:16 | LL | let _ = S1(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:141:21 + --> tests/ui/explicit_auto_deref.rs:141:21 | LL | let _ = S2 { s: &*s }; | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:157:30 + --> tests/ui/explicit_auto_deref.rs:157:30 | LL | let _ = Self::S1(&**s); | ^^^^ help: try: `s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:158:35 + --> tests/ui/explicit_auto_deref.rs:158:35 | LL | let _ = Self::S2 { s: &**s }; | ^^^^ help: try: `s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:161:20 + --> tests/ui/explicit_auto_deref.rs:161:20 | LL | let _ = E1::S1(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:162:25 + --> tests/ui/explicit_auto_deref.rs:162:25 | LL | let _ = E1::S2 { s: &*s }; | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:180:13 + --> tests/ui/explicit_auto_deref.rs:180:13 | LL | let _ = (*b).foo; | ^^^^ help: try: `b` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:181:13 + --> tests/ui/explicit_auto_deref.rs:181:13 | LL | let _ = (**b).foo; | ^^^^^ help: try: `b` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:196:19 + --> tests/ui/explicit_auto_deref.rs:196:19 | LL | let _ = f_str(*ref_str); | ^^^^^^^^ help: try: `ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:198:19 + --> tests/ui/explicit_auto_deref.rs:198:19 | LL | let _ = f_str(**ref_ref_str); | ^^^^^^^^^^^^^ help: try: `ref_ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:208:12 + --> tests/ui/explicit_auto_deref.rs:208:12 | LL | f_str(&&*ref_str); // `needless_borrow` will suggest removing both references | ^^^^^^^^^ help: try: `ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:209:12 + --> tests/ui/explicit_auto_deref.rs:209:12 | LL | f_str(&&**ref_str); // `needless_borrow` will suggest removing only one reference | ^^^^^^^^^^ help: try: `ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:218:41 + --> tests/ui/explicit_auto_deref.rs:218:41 | LL | let _ = || -> &'static str { return *s }; | ^^ help: try: `s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:237:9 + --> tests/ui/explicit_auto_deref.rs:237:9 | LL | &**x | ^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:260:8 + --> tests/ui/explicit_auto_deref.rs:260:8 | LL | c1(*x); | ^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:263:20 + --> tests/ui/explicit_auto_deref.rs:263:20 | LL | return *x; | ^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:265:9 + --> tests/ui/explicit_auto_deref.rs:265:9 | LL | *x | ^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:299:20 + --> tests/ui/explicit_auto_deref.rs:299:20 | LL | Some(x) => &mut *x, | ^^^^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:332:22 + --> tests/ui/explicit_auto_deref.rs:332:22 | LL | let _ = &mut (*{ x.u }).x; | ^^^^^^^^^^ help: try: `{ x.u }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:338:22 + --> tests/ui/explicit_auto_deref.rs:338:22 | LL | let _ = &mut (**x.u).x; | ^^^^^^^ help: try: `(*x.u)` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:339:22 + --> tests/ui/explicit_auto_deref.rs:339:22 | LL | let _ = &mut (**{ x.u }).x; | ^^^^^^^^^^^ help: try: `{ x.u }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:343:22 + --> tests/ui/explicit_auto_deref.rs:343:22 | LL | let _ = &mut (*x.u).x; | ^^^^^^ help: try: `x.u` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:344:22 + --> tests/ui/explicit_auto_deref.rs:344:22 | LL | let _ = &mut (*{ x.u }).x; | ^^^^^^^^^^ help: try: `{ x.u }` diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index aef979072525b..e28f8783f9c36 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -1,5 +1,5 @@ error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:7:5 + --> tests/ui/explicit_counter_loop.rs:7:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` @@ -8,49 +8,49 @@ LL | for _v in &vec { = help: to override `-D warnings` add `#[allow(clippy::explicit_counter_loop)]` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:15:5 + --> tests/ui/explicit_counter_loop.rs:15:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:21:5 + --> tests/ui/explicit_counter_loop.rs:21:5 | LL | for _v in &mut vec { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter_mut().enumerate()` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:27:5 + --> tests/ui/explicit_counter_loop.rs:27:5 | LL | for _v in vec { | ^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.into_iter().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:115:9 + --> tests/ui/explicit_counter_loop.rs:115:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:127:9 + --> tests/ui/explicit_counter_loop.rs:127:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:186:9 + --> tests/ui/explicit_counter_loop.rs:186:9 | LL | for _i in 3..10 { | ^^^^^^^^^^^^^^^ help: consider using: `for (count, _i) in (3..10).enumerate()` error: the variable `idx_usize` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:227:9 + --> tests/ui/explicit_counter_loop.rs:227:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_usize, _item) in slice.iter().enumerate()` error: the variable `idx_u32` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:240:9 + --> tests/ui/explicit_counter_loop.rs:240:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_u32, _item) in (0_u32..).zip(slice.iter())` diff --git a/tests/ui/explicit_deref_methods.stderr b/tests/ui/explicit_deref_methods.stderr index eb7059367a203..aab862baf5991 100644 --- a/tests/ui/explicit_deref_methods.stderr +++ b/tests/ui/explicit_deref_methods.stderr @@ -1,5 +1,5 @@ error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:54:19 + --> tests/ui/explicit_deref_methods.rs:54:19 | LL | let b: &str = a.deref(); | ^^^^^^^^^ help: try: `&*a` @@ -8,67 +8,67 @@ LL | let b: &str = a.deref(); = help: to override `-D warnings` add `#[allow(clippy::explicit_deref_methods)]` error: explicit `deref_mut` method call - --> $DIR/explicit_deref_methods.rs:56:23 + --> tests/ui/explicit_deref_methods.rs:56:23 | LL | let b: &mut str = a.deref_mut(); | ^^^^^^^^^^^^^ help: try: `&mut **a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:59:39 + --> tests/ui/explicit_deref_methods.rs:59:39 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:59:50 + --> tests/ui/explicit_deref_methods.rs:59:50 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:61:20 + --> tests/ui/explicit_deref_methods.rs:61:20 | LL | println!("{}", a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:64:11 + --> tests/ui/explicit_deref_methods.rs:64:11 | LL | match a.deref() { | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:68:28 + --> tests/ui/explicit_deref_methods.rs:68:28 | LL | let b: String = concat(a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:70:13 + --> tests/ui/explicit_deref_methods.rs:70:13 | LL | let b = just_return(a).deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:72:28 + --> tests/ui/explicit_deref_methods.rs:72:28 | LL | let b: String = concat(just_return(a).deref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:74:19 + --> tests/ui/explicit_deref_methods.rs:74:19 | LL | let b: &str = a.deref().deref(); | ^^^^^^^^^^^^^^^^^ help: try: `&**a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:77:13 + --> tests/ui/explicit_deref_methods.rs:77:13 | LL | let b = opt_a.unwrap().deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*opt_a.unwrap()` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:114:31 + --> tests/ui/explicit_deref_methods.rs:114:31 | LL | let b: &str = expr_deref!(a.deref()); | ^^^^^^^^^ help: try: `&*a` diff --git a/tests/ui/explicit_into_iter_loop.stderr b/tests/ui/explicit_into_iter_loop.stderr index c03647ab43367..ab48a76f52a7a 100644 --- a/tests/ui/explicit_into_iter_loop.stderr +++ b/tests/ui/explicit_into_iter_loop.stderr @@ -1,5 +1,5 @@ error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:9:18 + --> tests/ui/explicit_into_iter_loop.rs:9:18 | LL | for _ in iterator.into_iter() {} | ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator` @@ -8,31 +8,31 @@ LL | for _ in iterator.into_iter() {} = help: to override `-D warnings` add `#[allow(clippy::explicit_into_iter_loop)]` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:22:14 + --> tests/ui/explicit_into_iter_loop.rs:22:14 | LL | for _ in t.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:25:14 + --> tests/ui/explicit_into_iter_loop.rs:25:14 | LL | for _ in r.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `r` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:33:14 + --> tests/ui/explicit_into_iter_loop.rs:33:14 | LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&*mr` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:45:14 + --> tests/ui/explicit_into_iter_loop.rs:45:14 | LL | for _ in u.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut u` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:48:14 + --> tests/ui/explicit_into_iter_loop.rs:48:14 | LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *mr` diff --git a/tests/ui/explicit_iter_loop.stderr b/tests/ui/explicit_iter_loop.stderr index 725d9b63cf8d6..18167845134fd 100644 --- a/tests/ui/explicit_iter_loop.stderr +++ b/tests/ui/explicit_iter_loop.stderr @@ -1,113 +1,113 @@ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:17:14 + --> tests/ui/explicit_iter_loop.rs:17:14 | LL | for _ in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | note: the lint level is defined here - --> $DIR/explicit_iter_loop.rs:1:9 + --> tests/ui/explicit_iter_loop.rs:1:9 | LL | #![deny(clippy::explicit_iter_loop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:18:14 + --> tests/ui/explicit_iter_loop.rs:18:14 | LL | for _ in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:21:14 + --> tests/ui/explicit_iter_loop.rs:21:14 | LL | for _ in rvec.iter() {} | ^^^^^^^^^^^ help: to write this more concisely, try: `rvec` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:30:14 + --> tests/ui/explicit_iter_loop.rs:30:14 | LL | for _ in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:34:14 + --> tests/ui/explicit_iter_loop.rs:34:14 | LL | for _ in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:35:14 + --> tests/ui/explicit_iter_loop.rs:35:14 | LL | for _ in [0; 33].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 33]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:38:14 + --> tests/ui/explicit_iter_loop.rs:38:14 | LL | for _ in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:40:14 + --> tests/ui/explicit_iter_loop.rs:40:14 | LL | for _ in rll.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `rll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:43:14 + --> tests/ui/explicit_iter_loop.rs:43:14 | LL | for _ in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:45:14 + --> tests/ui/explicit_iter_loop.rs:45:14 | LL | for _ in rvd.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `rvd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:48:14 + --> tests/ui/explicit_iter_loop.rs:48:14 | LL | for _ in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:51:14 + --> tests/ui/explicit_iter_loop.rs:51:14 | LL | for _ in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:54:14 + --> tests/ui/explicit_iter_loop.rs:54:14 | LL | for _ in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:57:14 + --> tests/ui/explicit_iter_loop.rs:57:14 | LL | for _ in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:60:14 + --> tests/ui/explicit_iter_loop.rs:60:14 | LL | for _ in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:149:14 + --> tests/ui/explicit_iter_loop.rs:149:14 | LL | for _ in x.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `&x` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:150:14 + --> tests/ui/explicit_iter_loop.rs:150:14 | LL | for _ in x.iter_mut() {} | ^^^^^^^^^^^^ help: to write this more concisely, try: `&mut x` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:153:14 + --> tests/ui/explicit_iter_loop.rs:153:14 | LL | for _ in r.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `r` diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index 26aad266bbfc4..0d22f02c36f2e 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,5 +1,5 @@ error: use of `write!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:23:9 + --> tests/ui/explicit_write.rs:23:9 | LL | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")` @@ -8,73 +8,73 @@ LL | write!(std::io::stdout(), "test").unwrap(); = help: to override `-D warnings` add `#[allow(clippy::explicit_write)]` error: use of `write!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:24:9 + --> tests/ui/explicit_write.rs:24:9 | LL | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:25:9 + --> tests/ui/explicit_write.rs:25:9 | LL | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `println!("test")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:26:9 + --> tests/ui/explicit_write.rs:26:9 | LL | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("test")` error: use of `stdout().write_fmt(...).unwrap()` - --> $DIR/explicit_write.rs:27:9 + --> tests/ui/explicit_write.rs:27:9 | LL | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")` error: use of `stderr().write_fmt(...).unwrap()` - --> $DIR/explicit_write.rs:28:9 + --> tests/ui/explicit_write.rs:28:9 | LL | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:31:9 + --> tests/ui/explicit_write.rs:31:9 | LL | writeln!(std::io::stdout(), "test\ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `println!("test\ntest")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:32:9 + --> tests/ui/explicit_write.rs:32:9 | LL | writeln!(std::io::stderr(), "test\ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("test\ntest")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:35:9 + --> tests/ui/explicit_write.rs:35:9 | LL | writeln!(std::io::stderr(), "with {}", value).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {}", value)` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:36:9 + --> tests/ui/explicit_write.rs:36:9 | LL | writeln!(std::io::stderr(), "with {} {}", 2, value).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {} {}", 2, value)` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:37:9 + --> tests/ui/explicit_write.rs:37:9 | LL | writeln!(std::io::stderr(), "with {value}").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {value}")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:38:9 + --> tests/ui/explicit_write.rs:38:9 | LL | writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("macro arg {}", one!())` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:40:9 + --> tests/ui/explicit_write.rs:40:9 | LL | writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("{:w$}", value, w = width)` diff --git a/tests/ui/extend_with_drain.stderr b/tests/ui/extend_with_drain.stderr index e0bd5a620e78f..444cc82bbae7c 100644 --- a/tests/ui/extend_with_drain.stderr +++ b/tests/ui/extend_with_drain.stderr @@ -1,5 +1,5 @@ error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:8:5 + --> tests/ui/extend_with_drain.rs:8:5 | LL | vec2.extend(vec1.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec2.append(&mut vec1)` @@ -8,19 +8,19 @@ LL | vec2.extend(vec1.drain(..)); = help: to override `-D warnings` add `#[allow(clippy::extend_with_drain)]` error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:13:5 + --> tests/ui/extend_with_drain.rs:13:5 | LL | vec4.extend(vec3.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec4.append(&mut vec3)` error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:17:5 + --> tests/ui/extend_with_drain.rs:17:5 | LL | vec11.extend(return_vector().drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec11.append(&mut return_vector())` error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:48:5 + --> tests/ui/extend_with_drain.rs:48:5 | LL | y.extend(ref_x.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `y.append(ref_x)` diff --git a/tests/ui/extra_unused_lifetimes.stderr b/tests/ui/extra_unused_lifetimes.stderr index 8790fe5a5b1a5..56292cb5d1a51 100644 --- a/tests/ui/extra_unused_lifetimes.stderr +++ b/tests/ui/extra_unused_lifetimes.stderr @@ -1,5 +1,5 @@ error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:19:14 + --> tests/ui/extra_unused_lifetimes.rs:19:14 | LL | fn unused_lt<'a>(x: u8) {} | ^^ @@ -8,31 +8,31 @@ LL | fn unused_lt<'a>(x: u8) {} = help: to override `-D warnings` add `#[allow(clippy::extra_unused_lifetimes)]` error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:46:10 + --> tests/ui/extra_unused_lifetimes.rs:46:10 | LL | fn x<'a>(&self) {} | ^^ error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:72:22 + --> tests/ui/extra_unused_lifetimes.rs:72:22 | LL | fn unused_lt<'a>(x: u8) {} | ^^ error: this lifetime isn't used in the impl - --> $DIR/extra_unused_lifetimes.rs:83:10 + --> tests/ui/extra_unused_lifetimes.rs:83:10 | LL | impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar { | ^^ error: this lifetime isn't used in the impl - --> $DIR/extra_unused_lifetimes.rs:89:10 + --> tests/ui/extra_unused_lifetimes.rs:89:10 | LL | impl<'b> Scalar { | ^^ error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:90:26 + --> tests/ui/extra_unused_lifetimes.rs:90:26 | LL | pub fn something<'c>() -> Self { | ^^ diff --git a/tests/ui/extra_unused_type_parameters.stderr b/tests/ui/extra_unused_type_parameters.stderr index 9a179076c4824..928c0038c2c3d 100644 --- a/tests/ui/extra_unused_type_parameters.stderr +++ b/tests/ui/extra_unused_type_parameters.stderr @@ -1,5 +1,5 @@ error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:9:13 + --> tests/ui/extra_unused_type_parameters.rs:9:13 | LL | fn unused_ty(x: u8) { | ^^^ help: consider removing the parameter @@ -8,19 +8,19 @@ LL | fn unused_ty(x: u8) { = help: to override `-D warnings` add `#[allow(clippy::extra_unused_type_parameters)]` error: type parameters go unused in function definition: T, U - --> $DIR/extra_unused_type_parameters.rs:13:16 + --> tests/ui/extra_unused_type_parameters.rs:13:16 | LL | fn unused_multi(x: u8) { | ^^^^^^ help: consider removing the parameters error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:17:21 + --> tests/ui/extra_unused_type_parameters.rs:17:21 | LL | fn unused_with_lt<'a, T>(x: &'a u8) { | ^^^ help: consider removing the parameter error: type parameters go unused in function definition: T, V - --> $DIR/extra_unused_type_parameters.rs:29:19 + --> tests/ui/extra_unused_type_parameters.rs:29:19 | LL | fn unused_bounded(x: U) { | ^^^^^^^^^^^^ ^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL + fn unused_bounded(x: U) { | error: type parameters go unused in function definition: A, D, E - --> $DIR/extra_unused_type_parameters.rs:33:16 + --> tests/ui/extra_unused_type_parameters.rs:33:16 | LL | fn some_unused, E>(b: B, c: C) { | ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,19 +44,19 @@ LL + fn some_unused(b: B, c: C) { | error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:58:22 + --> tests/ui/extra_unused_type_parameters.rs:58:22 | LL | fn unused_ty_impl(&self) { | ^^^ help: consider removing the parameter error: type parameters go unused in function definition: A, B - --> $DIR/extra_unused_type_parameters.rs:80:17 + --> tests/ui/extra_unused_type_parameters.rs:80:17 | LL | fn unused_opaque(dummy: impl Default) { | ^^^^^^ help: consider removing the parameters error: type parameter `U` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:93:56 + --> tests/ui/extra_unused_type_parameters.rs:93:56 | LL | fn unused_with_priv_trait_bound() { | ^^^ help: consider removing the parameter diff --git a/tests/ui/extra_unused_type_parameters_unfixable.stderr b/tests/ui/extra_unused_type_parameters_unfixable.stderr index a216c4363075f..0765c41609368 100644 --- a/tests/ui/extra_unused_type_parameters_unfixable.stderr +++ b/tests/ui/extra_unused_type_parameters_unfixable.stderr @@ -1,5 +1,5 @@ error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters_unfixable.rs:3:24 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:3:24 | LL | fn unused_where_clause(x: U) | ^ @@ -9,7 +9,7 @@ LL | fn unused_where_clause(x: U) = help: to override `-D warnings` add `#[allow(clippy::extra_unused_type_parameters)]` error: type parameters go unused in function definition: T, V - --> $DIR/extra_unused_type_parameters_unfixable.rs:11:30 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:11:30 | LL | fn unused_multi_where_clause(x: U) | ^ ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn unused_multi_where_clause(x: U) = help: consider removing the parameters error: type parameters go unused in function definition: T, U, V - --> $DIR/extra_unused_type_parameters_unfixable.rs:19:28 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:19:28 | LL | fn unused_all_where_clause() | ^ ^^^^^^^^^^ ^^^^^^^^^^ diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 96074ca89ea0f..62496148924e1 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,5 +1,5 @@ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:6:1 + --> tests/ui/fallible_impl_from.rs:6:1 | LL | / impl From for Foo { LL | | @@ -11,18 +11,18 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:9:13 + --> tests/ui/fallible_impl_from.rs:9:13 | LL | Foo(s.parse().unwrap()) | ^^^^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/fallible_impl_from.rs:1:9 + --> tests/ui/fallible_impl_from.rs:1:9 | LL | #![deny(clippy::fallible_impl_from)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:28:1 + --> tests/ui/fallible_impl_from.rs:28:1 | LL | / impl From for Invalid { LL | | @@ -35,14 +35,14 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:32:13 + --> tests/ui/fallible_impl_from.rs:32:13 | LL | panic!(); | ^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:38:1 + --> tests/ui/fallible_impl_from.rs:38:1 | LL | / impl From> for Invalid { LL | | @@ -55,7 +55,7 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:41:17 + --> tests/ui/fallible_impl_from.rs:41:17 | LL | let s = s.unwrap(); | ^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | panic!("{:?}", s); = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:57:1 + --> tests/ui/fallible_impl_from.rs:57:1 | LL | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { LL | | @@ -82,7 +82,7 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:60:12 + --> tests/ui/fallible_impl_from.rs:60:12 | LL | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/field_reassign_with_default.stderr b/tests/ui/field_reassign_with_default.stderr index a8cf84bd4114a..bc03283492085 100644 --- a/tests/ui/field_reassign_with_default.stderr +++ b/tests/ui/field_reassign_with_default.stderr @@ -1,11 +1,11 @@ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:56:5 + --> tests/ui/field_reassign_with_default.rs:56:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:55:5 + --> tests/ui/field_reassign_with_default.rs:55:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,121 +13,121 @@ LL | let mut a: A = Default::default(); = help: to override `-D warnings` add `#[allow(clippy::field_reassign_with_default)]` error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:96:5 + --> tests/ui/field_reassign_with_default.rs:96:5 | LL | a.j = 43; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { j: 43, i: 42 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:95:5 + --> tests/ui/field_reassign_with_default.rs:95:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:101:5 + --> tests/ui/field_reassign_with_default.rs:101:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, j: 44 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:100:5 + --> tests/ui/field_reassign_with_default.rs:100:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:107:5 + --> tests/ui/field_reassign_with_default.rs:107:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:106:5 + --> tests/ui/field_reassign_with_default.rs:106:5 | LL | let mut a = A::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:117:5 + --> tests/ui/field_reassign_with_default.rs:117:5 | LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `main::A { i: Default::default(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:116:5 + --> tests/ui/field_reassign_with_default.rs:116:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:121:5 + --> tests/ui/field_reassign_with_default.rs:121:5 | LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `main::A { i: Default::default(), j: 45 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:120:5 + --> tests/ui/field_reassign_with_default.rs:120:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:143:5 + --> tests/ui/field_reassign_with_default.rs:143:5 | LL | a.i = vec![1]; | ^^^^^^^^^^^^^^ | note: consider initializing the variable with `C { i: vec![1], ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:142:5 + --> tests/ui/field_reassign_with_default.rs:142:5 | LL | let mut a: C = C::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:161:5 + --> tests/ui/field_reassign_with_default.rs:161:5 | LL | a.i = true; | ^^^^^^^^^^^ | note: consider initializing the variable with `Wrapper:: { i: true }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:160:5 + --> tests/ui/field_reassign_with_default.rs:160:5 | LL | let mut a: Wrapper = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:164:5 + --> tests/ui/field_reassign_with_default.rs:164:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `WrapperMulti:: { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:163:5 + --> tests/ui/field_reassign_with_default.rs:163:5 | LL | let mut a: WrapperMulti = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:235:13 + --> tests/ui/field_reassign_with_default.rs:235:13 | LL | f.name = name.len(); | ^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `issue6312::ImplDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:234:13 + --> tests/ui/field_reassign_with_default.rs:234:13 | LL | let mut f = ImplDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:251:13 + --> tests/ui/field_reassign_with_default.rs:251:13 | LL | f.name = name.len(); | ^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `issue6312::NoDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:250:13 + --> tests/ui/field_reassign_with_default.rs:250:13 | LL | let mut f = NoDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/filetype_is_file.stderr b/tests/ui/filetype_is_file.stderr index 8876ad5c9bbce..0c66910c1b616 100644 --- a/tests/ui/filetype_is_file.stderr +++ b/tests/ui/filetype_is_file.stderr @@ -1,5 +1,5 @@ error: `FileType::is_file()` only covers regular files - --> $DIR/filetype_is_file.rs:9:8 + --> tests/ui/filetype_is_file.rs:9:8 | LL | if fs::metadata("foo.txt")?.file_type().is_file() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | if fs::metadata("foo.txt")?.file_type().is_file() { = help: to override `-D warnings` add `#[allow(clippy::filetype_is_file)]` error: `!FileType::is_file()` only denies regular files - --> $DIR/filetype_is_file.rs:15:8 + --> tests/ui/filetype_is_file.rs:15:8 | LL | if !fs::metadata("foo.txt")?.file_type().is_file() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | if !fs::metadata("foo.txt")?.file_type().is_file() { = help: use `FileType::is_dir()` instead error: `FileType::is_file()` only covers regular files - --> $DIR/filetype_is_file.rs:21:9 + --> tests/ui/filetype_is_file.rs:21:9 | LL | if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/filter_map_bool_then.stderr b/tests/ui/filter_map_bool_then.stderr index fab6987913a10..088b9ba128675 100644 --- a/tests/ui/filter_map_bool_then.stderr +++ b/tests/ui/filter_map_bool_then.stderr @@ -1,5 +1,5 @@ error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:19:22 + --> tests/ui/filter_map_bool_then.rs:19:22 | LL | v.clone().iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` @@ -8,55 +8,55 @@ LL | v.clone().iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); = help: to override `-D warnings` add `#[allow(clippy::filter_map_bool_then)]` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:20:27 + --> tests/ui/filter_map_bool_then.rs:20:27 | LL | v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:23:10 + --> tests/ui/filter_map_bool_then.rs:23:10 | LL | .filter_map(|i| -> Option<_> { (i % 2 == 0).then(|| i + 1) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:27:10 + --> tests/ui/filter_map_bool_then.rs:27:10 | LL | .filter_map(|i| (i % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:31:10 + --> tests/ui/filter_map_bool_then.rs:31:10 | LL | .filter_map(|i| (i.clone() % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i.clone() % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:37:22 + --> tests/ui/filter_map_bool_then.rs:37:22 | LL | v.clone().iter().filter_map(|i| (i == &NonCopy).then(|| i)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i == &NonCopy)).map(|i| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:61:50 + --> tests/ui/filter_map_bool_then.rs:61:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| *b).map(|(i, b)| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:65:50 + --> tests/ui/filter_map_bool_then.rs:65:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| ***b).map(|(i, b)| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:69:50 + --> tests/ui/filter_map_bool_then.rs:69:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| **b).map(|(i, b)| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:80:50 + --> tests/ui/filter_map_bool_then.rs:80:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| ****b).map(|(i, b)| i)` diff --git a/tests/ui/filter_map_identity.stderr b/tests/ui/filter_map_identity.stderr index a08477695c931..5aa46ad6d2375 100644 --- a/tests/ui/filter_map_identity.stderr +++ b/tests/ui/filter_map_identity.stderr @@ -1,5 +1,5 @@ error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:6:22 + --> tests/ui/filter_map_identity.rs:6:22 | LL | let _ = iterator.filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` @@ -8,19 +8,19 @@ LL | let _ = iterator.filter_map(|x| x); = help: to override `-D warnings` add `#[allow(clippy::filter_map_identity)]` error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:9:22 + --> tests/ui/filter_map_identity.rs:9:22 | LL | let _ = iterator.filter_map(std::convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:13:22 + --> tests/ui/filter_map_identity.rs:13:22 | LL | let _ = iterator.filter_map(identity); | ^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:16:22 + --> tests/ui/filter_map_identity.rs:16:22 | LL | let _ = iterator.filter_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` diff --git a/tests/ui/filter_map_next.stderr b/tests/ui/filter_map_next.stderr index 07760d8837a39..cd3ffe3aa7f01 100644 --- a/tests/ui/filter_map_next.stderr +++ b/tests/ui/filter_map_next.stderr @@ -1,5 +1,5 @@ error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead - --> $DIR/filter_map_next.rs:7:26 + --> tests/ui/filter_map_next.rs:7:26 | LL | let _: Option = vec![1, 2, 3, 4, 5, 6] | __________________________^ diff --git a/tests/ui/filter_map_next_fixable.stderr b/tests/ui/filter_map_next_fixable.stderr index 0edf4e6e07d46..2c6148f3f4b6b 100644 --- a/tests/ui/filter_map_next_fixable.stderr +++ b/tests/ui/filter_map_next_fixable.stderr @@ -1,5 +1,5 @@ error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead - --> $DIR/filter_map_next_fixable.rs:7:32 + --> tests/ui/filter_map_next_fixable.rs:7:32 | LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())` @@ -8,7 +8,7 @@ LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next = help: to override `-D warnings` add `#[allow(clippy::filter_map_next)]` error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead - --> $DIR/filter_map_next_fixable.rs:20:26 + --> tests/ui/filter_map_next_fixable.rs:20:26 | LL | let _: Option = a.iter().filter_map(|s| s.parse().ok()).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())` diff --git a/tests/ui/flat_map_identity.stderr b/tests/ui/flat_map_identity.stderr index d6fcc14fc5630..496fd972a498f 100644 --- a/tests/ui/flat_map_identity.stderr +++ b/tests/ui/flat_map_identity.stderr @@ -1,5 +1,5 @@ error: use of `flat_map` with an identity function - --> $DIR/flat_map_identity.rs:8:22 + --> tests/ui/flat_map_identity.rs:8:22 | LL | let _ = iterator.flat_map(|x| x); | ^^^^^^^^^^^^^^^ help: try: `flatten()` @@ -8,13 +8,13 @@ LL | let _ = iterator.flat_map(|x| x); = help: to override `-D warnings` add `#[allow(clippy::flat_map_identity)]` error: use of `flat_map` with an identity function - --> $DIR/flat_map_identity.rs:11:22 + --> tests/ui/flat_map_identity.rs:11:22 | LL | let _ = iterator.flat_map(convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `flat_map` with an identity function - --> $DIR/flat_map_identity.rs:14:22 + --> tests/ui/flat_map_identity.rs:14:22 | LL | let _ = iterator.flat_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` diff --git a/tests/ui/flat_map_option.stderr b/tests/ui/flat_map_option.stderr index e0a59daf6a8f8..6e151965fad53 100644 --- a/tests/ui/flat_map_option.stderr +++ b/tests/ui/flat_map_option.stderr @@ -1,5 +1,5 @@ error: used `flat_map` where `filter_map` could be used instead - --> $DIR/flat_map_option.rs:7:24 + --> tests/ui/flat_map_option.rs:7:24 | LL | let _ = [1].iter().flat_map(c); | ^^^^^^^^ help: try: `filter_map` @@ -8,7 +8,7 @@ LL | let _ = [1].iter().flat_map(c); = help: to override `-D warnings` add `#[allow(clippy::flat_map_option)]` error: used `flat_map` where `filter_map` could be used instead - --> $DIR/flat_map_option.rs:8:24 + --> tests/ui/flat_map_option.rs:8:24 | LL | let _ = [1].iter().flat_map(Some); | ^^^^^^^^ help: try: `filter_map` diff --git a/tests/ui/float_arithmetic.stderr b/tests/ui/float_arithmetic.stderr index da4ca976792f5..66455f061455e 100644 --- a/tests/ui/float_arithmetic.stderr +++ b/tests/ui/float_arithmetic.stderr @@ -1,5 +1,5 @@ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:15:5 + --> tests/ui/float_arithmetic.rs:15:5 | LL | f * 2.0; | ^^^^^^^ @@ -8,97 +8,97 @@ LL | f * 2.0; = help: to override `-D warnings` add `#[allow(clippy::float_arithmetic)]` error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:19:5 + --> tests/ui/float_arithmetic.rs:19:5 | LL | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:21:5 + --> tests/ui/float_arithmetic.rs:21:5 | LL | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:23:5 + --> tests/ui/float_arithmetic.rs:23:5 | LL | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:25:5 + --> tests/ui/float_arithmetic.rs:25:5 | LL | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:27:5 + --> tests/ui/float_arithmetic.rs:27:5 | LL | -f; | ^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:30:5 + --> tests/ui/float_arithmetic.rs:30:5 | LL | f += 1.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:32:5 + --> tests/ui/float_arithmetic.rs:32:5 | LL | f -= 1.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:34:5 + --> tests/ui/float_arithmetic.rs:34:5 | LL | f *= 2.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:36:5 + --> tests/ui/float_arithmetic.rs:36:5 | LL | f /= 2.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:43:5 + --> tests/ui/float_arithmetic.rs:43:5 | LL | 3.1_f32 + &1.2_f32; | ^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:45:5 + --> tests/ui/float_arithmetic.rs:45:5 | LL | &3.4_f32 + 1.5_f32; | ^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:47:5 + --> tests/ui/float_arithmetic.rs:47:5 | LL | &3.5_f32 + &1.3_f32; | ^^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:53:5 + --> tests/ui/float_arithmetic.rs:53:5 | LL | a + f | ^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:58:5 + --> tests/ui/float_arithmetic.rs:58:5 | LL | f1 + f2 | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:63:5 + --> tests/ui/float_arithmetic.rs:63:5 | LL | f1 + f2 | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:68:5 + --> tests/ui/float_arithmetic.rs:68:5 | LL | (&f1 + &f2) | ^^^^^^^^^^^ diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 217e2987917ab..49b65184f7311 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,5 +1,5 @@ error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:70:5 + --> tests/ui/float_cmp.rs:70:5 | LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin` @@ -9,7 +9,7 @@ LL | ONE as f64 != 2.0; = help: to override `-D warnings` add `#[allow(clippy::float_cmp)]` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:77:5 + --> tests/ui/float_cmp.rs:77:5 | LL | x == 1.0; | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 1.0).abs() < error_margin` @@ -17,7 +17,7 @@ LL | x == 1.0; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:82:5 + --> tests/ui/float_cmp.rs:82:5 | LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin` @@ -25,7 +25,7 @@ LL | twice(x) != twice(ONE as f64); = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:104:5 + --> tests/ui/float_cmp.rs:104:5 | LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin` @@ -33,7 +33,7 @@ LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` arrays - --> $DIR/float_cmp.rs:111:5 + --> tests/ui/float_cmp.rs:111:5 | LL | a1 == a2; | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | a1 == a2; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:114:5 + --> tests/ui/float_cmp.rs:114:5 | LL | a1[0] == a2[0]; | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin` diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index 856aaa2ea716d..bffd2acc2e049 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -1,5 +1,5 @@ error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:16:5 + --> tests/ui/float_cmp_const.rs:16:5 | LL | 1f32 == ONE; | ^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1f32 - ONE).abs() < error_margin` @@ -9,7 +9,7 @@ LL | 1f32 == ONE; = help: to override `-D warnings` add `#[allow(clippy::float_cmp_const)]` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:19:5 + --> tests/ui/float_cmp_const.rs:19:5 | LL | TWO == ONE; | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() < error_margin` @@ -17,7 +17,7 @@ LL | TWO == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:22:5 + --> tests/ui/float_cmp_const.rs:22:5 | LL | TWO != ONE; | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() > error_margin` @@ -25,7 +25,7 @@ LL | TWO != ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:25:5 + --> tests/ui/float_cmp_const.rs:25:5 | LL | ONE + ONE == TWO; | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE + ONE - TWO).abs() < error_margin` @@ -33,7 +33,7 @@ LL | ONE + ONE == TWO; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:29:5 + --> tests/ui/float_cmp_const.rs:29:5 | LL | x as f32 == ONE; | ^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x as f32 - ONE).abs() < error_margin` @@ -41,7 +41,7 @@ LL | x as f32 == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:34:5 + --> tests/ui/float_cmp_const.rs:34:5 | LL | v == ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() < error_margin` @@ -49,7 +49,7 @@ LL | v == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:37:5 + --> tests/ui/float_cmp_const.rs:37:5 | LL | v != ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() > error_margin` @@ -57,7 +57,7 @@ LL | v != ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant arrays - --> $DIR/float_cmp_const.rs:71:5 + --> tests/ui/float_cmp_const.rs:71:5 | LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/float_equality_without_abs.stderr b/tests/ui/float_equality_without_abs.stderr index 155699f6fcf0e..0124dd983a391 100644 --- a/tests/ui/float_equality_without_abs.stderr +++ b/tests/ui/float_equality_without_abs.stderr @@ -1,5 +1,5 @@ error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:4:5 + --> tests/ui/float_equality_without_abs.rs:4:5 | LL | (a - b) < f32::EPSILON | -------^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | (a - b) < f32::EPSILON = help: to override `-D warnings` add `#[allow(clippy::float_equality_without_abs)]` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:15:13 + --> tests/ui/float_equality_without_abs.rs:15:13 | LL | let _ = (a - b) < f32::EPSILON; | -------^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | let _ = (a - b) < f32::EPSILON; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:17:13 + --> tests/ui/float_equality_without_abs.rs:17:13 | LL | let _ = a - b < f32::EPSILON; | -----^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _ = a - b < f32::EPSILON; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:19:13 + --> tests/ui/float_equality_without_abs.rs:19:13 | LL | let _ = a - b.abs() < f32::EPSILON; | -----------^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = a - b.abs() < f32::EPSILON; | help: add `.abs()`: `(a - b.abs()).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:21:13 + --> tests/ui/float_equality_without_abs.rs:21:13 | LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | ---------------------^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | help: add `.abs()`: `(a as f64 - b as f64).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:23:13 + --> tests/ui/float_equality_without_abs.rs:23:13 | LL | let _ = 1.0 - 2.0 < f32::EPSILON; | ---------^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | let _ = 1.0 - 2.0 < f32::EPSILON; | help: add `.abs()`: `(1.0 - 2.0).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:26:13 + --> tests/ui/float_equality_without_abs.rs:26:13 | LL | let _ = f32::EPSILON > (a - b); | ^^^^^^^^^^^^^^^------- @@ -58,7 +58,7 @@ LL | let _ = f32::EPSILON > (a - b); | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:28:13 + --> tests/ui/float_equality_without_abs.rs:28:13 | LL | let _ = f32::EPSILON > a - b; | ^^^^^^^^^^^^^^^----- @@ -66,7 +66,7 @@ LL | let _ = f32::EPSILON > a - b; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:30:13 + --> tests/ui/float_equality_without_abs.rs:30:13 | LL | let _ = f32::EPSILON > a - b.abs(); | ^^^^^^^^^^^^^^^----------- @@ -74,7 +74,7 @@ LL | let _ = f32::EPSILON > a - b.abs(); | help: add `.abs()`: `(a - b.abs()).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:32:13 + --> tests/ui/float_equality_without_abs.rs:32:13 | LL | let _ = f64::EPSILON > (a as f64 - b as f64); | ^^^^^^^^^^^^^^^--------------------- @@ -82,7 +82,7 @@ LL | let _ = f64::EPSILON > (a as f64 - b as f64); | help: add `.abs()`: `(a as f64 - b as f64).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:34:13 + --> tests/ui/float_equality_without_abs.rs:34:13 | LL | let _ = f32::EPSILON > 1.0 - 2.0; | ^^^^^^^^^^^^^^^--------- diff --git a/tests/ui/floating_point_abs.stderr b/tests/ui/floating_point_abs.stderr index fbc5783824d6f..f5a778c5b7650 100644 --- a/tests/ui/floating_point_abs.stderr +++ b/tests/ui/floating_point_abs.stderr @@ -1,5 +1,5 @@ error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:15:5 + --> tests/ui/floating_point_abs.rs:15:5 | LL | if num >= 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` @@ -8,43 +8,43 @@ LL | if num >= 0.0 { num } else { -num } = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:19:5 + --> tests/ui/floating_point_abs.rs:19:5 | LL | if 0.0 < num { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:23:5 + --> tests/ui/floating_point_abs.rs:23:5 | LL | if a.a > 0.0 { a.a } else { -a.a } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:27:5 + --> tests/ui/floating_point_abs.rs:27:5 | LL | if 0.0 >= num { -num } else { num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:31:5 + --> tests/ui/floating_point_abs.rs:31:5 | LL | if a.a < 0.0 { -a.a } else { a.a } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:35:5 + --> tests/ui/floating_point_abs.rs:35:5 | LL | if num < 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:39:5 + --> tests/ui/floating_point_abs.rs:39:5 | LL | if 0.0 >= num { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:44:12 + --> tests/ui/floating_point_abs.rs:44:12 | LL | a: if a.a >= 0.0 { -a.a } else { a.a }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()` diff --git a/tests/ui/floating_point_exp.stderr b/tests/ui/floating_point_exp.stderr index 6b64b9b600821..a19edf87e2448 100644 --- a/tests/ui/floating_point_exp.stderr +++ b/tests/ui/floating_point_exp.stderr @@ -1,5 +1,5 @@ error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:6:13 + --> tests/ui/floating_point_exp.rs:6:13 | LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` @@ -8,25 +8,25 @@ LL | let _ = x.exp() - 1.0; = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:7:13 + --> tests/ui/floating_point_exp.rs:7:13 | LL | let _ = x.exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:8:13 + --> tests/ui/floating_point_exp.rs:8:13 | LL | let _ = (x as f32).exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).exp_m1()` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:14:13 + --> tests/ui/floating_point_exp.rs:14:13 | LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:15:13 + --> tests/ui/floating_point_exp.rs:15:13 | LL | let _ = x.exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` diff --git a/tests/ui/floating_point_hypot.stderr b/tests/ui/floating_point_hypot.stderr index 21e0bd8b5810f..8942e86910da1 100644 --- a/tests/ui/floating_point_hypot.stderr +++ b/tests/ui/floating_point_hypot.stderr @@ -1,5 +1,5 @@ error: hypotenuse can be computed more accurately - --> $DIR/floating_point_hypot.rs:6:13 + --> tests/ui/floating_point_hypot.rs:6:13 | LL | let _ = (x * x + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` @@ -8,13 +8,13 @@ LL | let _ = (x * x + y * y).sqrt(); = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: hypotenuse can be computed more accurately - --> $DIR/floating_point_hypot.rs:7:13 + --> tests/ui/floating_point_hypot.rs:7:13 | LL | let _ = ((x + 1f32) * (x + 1f32) + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 1f32).hypot(y)` error: hypotenuse can be computed more accurately - --> $DIR/floating_point_hypot.rs:8:13 + --> tests/ui/floating_point_hypot.rs:8:13 | LL | let _ = (x.powi(2) + y.powi(2)).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` diff --git a/tests/ui/floating_point_log.stderr b/tests/ui/floating_point_log.stderr index a426f4c3dde81..3a449a98eadd5 100644 --- a/tests/ui/floating_point_log.stderr +++ b/tests/ui/floating_point_log.stderr @@ -1,5 +1,5 @@ error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:9:13 + --> tests/ui/floating_point_log.rs:9:13 | LL | let _ = x.log(2f32); | ^^^^^^^^^^^ help: consider using: `x.log2()` @@ -8,55 +8,55 @@ LL | let _ = x.log(2f32); = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:10:13 + --> tests/ui/floating_point_log.rs:10:13 | LL | let _ = x.log(10f32); | ^^^^^^^^^^^^ help: consider using: `x.log10()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:11:13 + --> tests/ui/floating_point_log.rs:11:13 | LL | let _ = x.log(std::f32::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:12:13 + --> tests/ui/floating_point_log.rs:12:13 | LL | let _ = x.log(TWO); | ^^^^^^^^^^ help: consider using: `x.log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:13:13 + --> tests/ui/floating_point_log.rs:13:13 | LL | let _ = x.log(E); | ^^^^^^^^ help: consider using: `x.ln()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:14:13 + --> tests/ui/floating_point_log.rs:14:13 | LL | let _ = (x as f32).log(2f32); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:17:13 + --> tests/ui/floating_point_log.rs:17:13 | LL | let _ = x.log(2f64); | ^^^^^^^^^^^ help: consider using: `x.log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:18:13 + --> tests/ui/floating_point_log.rs:18:13 | LL | let _ = x.log(10f64); | ^^^^^^^^^^^^ help: consider using: `x.log10()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:19:13 + --> tests/ui/floating_point_log.rs:19:13 | LL | let _ = x.log(std::f64::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:24:13 + --> tests/ui/floating_point_log.rs:24:13 | LL | let _ = (1f32 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` @@ -65,115 +65,115 @@ LL | let _ = (1f32 + 2.).ln(); = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:25:13 + --> tests/ui/floating_point_log.rs:25:13 | LL | let _ = (1f32 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:26:13 + --> tests/ui/floating_point_log.rs:26:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:27:13 + --> tests/ui/floating_point_log.rs:27:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:28:13 + --> tests/ui/floating_point_log.rs:28:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:29:13 + --> tests/ui/floating_point_log.rs:29:13 | LL | let _ = (1.0 + x.powi(3) / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(3) / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:30:13 + --> tests/ui/floating_point_log.rs:30:13 | LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(std::f32::consts::E - 1.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:31:13 + --> tests/ui/floating_point_log.rs:31:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:32:13 + --> tests/ui/floating_point_log.rs:32:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:33:13 + --> tests/ui/floating_point_log.rs:33:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:34:13 + --> tests/ui/floating_point_log.rs:34:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:42:13 + --> tests/ui/floating_point_log.rs:42:13 | LL | let _ = (1f64 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:43:13 + --> tests/ui/floating_point_log.rs:43:13 | LL | let _ = (1f64 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:44:13 + --> tests/ui/floating_point_log.rs:44:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:45:13 + --> tests/ui/floating_point_log.rs:45:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:46:13 + --> tests/ui/floating_point_log.rs:46:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:47:13 + --> tests/ui/floating_point_log.rs:47:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:48:13 + --> tests/ui/floating_point_log.rs:48:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:49:13 + --> tests/ui/floating_point_log.rs:49:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:50:13 + --> tests/ui/floating_point_log.rs:50:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` diff --git a/tests/ui/floating_point_logbase.stderr b/tests/ui/floating_point_logbase.stderr index 463bdb84c1595..8dfc57b133c68 100644 --- a/tests/ui/floating_point_logbase.stderr +++ b/tests/ui/floating_point_logbase.stderr @@ -1,5 +1,5 @@ error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:7:13 + --> tests/ui/floating_point_logbase.rs:7:13 | LL | let _ = x.ln() / y.ln(); | ^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` @@ -8,25 +8,25 @@ LL | let _ = x.ln() / y.ln(); = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:8:13 + --> tests/ui/floating_point_logbase.rs:8:13 | LL | let _ = (x as f32).ln() / y.ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log(y)` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:9:13 + --> tests/ui/floating_point_logbase.rs:9:13 | LL | let _ = x.log2() / y.log2(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:10:13 + --> tests/ui/floating_point_logbase.rs:10:13 | LL | let _ = x.log10() / y.log10(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:11:13 + --> tests/ui/floating_point_logbase.rs:11:13 | LL | let _ = x.log(5f32) / y.log(5f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` diff --git a/tests/ui/floating_point_mul_add.stderr b/tests/ui/floating_point_mul_add.stderr index 38dbefbe14c66..3e1a071de7377 100644 --- a/tests/ui/floating_point_mul_add.stderr +++ b/tests/ui/floating_point_mul_add.stderr @@ -1,5 +1,5 @@ error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:20:13 + --> tests/ui/floating_point_mul_add.rs:20:13 | LL | let _ = a * b + c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` @@ -8,73 +8,73 @@ LL | let _ = a * b + c; = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:21:13 + --> tests/ui/floating_point_mul_add.rs:21:13 | LL | let _ = a * b - c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, -c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:22:13 + --> tests/ui/floating_point_mul_add.rs:22:13 | LL | let _ = c + a * b; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:23:13 + --> tests/ui/floating_point_mul_add.rs:23:13 | LL | let _ = c - a * b; | ^^^^^^^^^ help: consider using: `a.mul_add(-b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:24:13 + --> tests/ui/floating_point_mul_add.rs:24:13 | LL | let _ = a + 2.0 * 4.0; | ^^^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4.0, a)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:25:13 + --> tests/ui/floating_point_mul_add.rs:25:13 | LL | let _ = a + 2. * 4.; | ^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4., a)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:27:13 + --> tests/ui/floating_point_mul_add.rs:27:13 | LL | let _ = (a * b) + c; | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:28:13 + --> tests/ui/floating_point_mul_add.rs:28:13 | LL | let _ = c + (a * b); | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:29:13 + --> tests/ui/floating_point_mul_add.rs:29:13 | LL | let _ = a * b * c + d; | ^^^^^^^^^^^^^ help: consider using: `(a * b).mul_add(c, d)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:31:13 + --> tests/ui/floating_point_mul_add.rs:31:13 | LL | let _ = a.mul_add(b, c) * a.mul_add(b, c) + a.mul_add(b, c) + c; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `a.mul_add(b, c).mul_add(a.mul_add(b, c), a.mul_add(b, c))` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:32:13 + --> tests/ui/floating_point_mul_add.rs:32:13 | LL | let _ = 1234.567_f64 * 45.67834_f64 + 0.0004_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1234.567_f64.mul_add(45.67834_f64, 0.0004_f64)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:34:13 + --> tests/ui/floating_point_mul_add.rs:34:13 | LL | let _ = (a * a + b).sqrt(); | ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:37:13 + --> tests/ui/floating_point_mul_add.rs:37:13 | LL | let _ = a - (b * u as f64); | ^^^^^^^^^^^^^^^^^^ help: consider using: `b.mul_add(-(u as f64), a)` diff --git a/tests/ui/floating_point_powf.stderr b/tests/ui/floating_point_powf.stderr index 0ff8f82d9a7dd..bd3fa771fe50e 100644 --- a/tests/ui/floating_point_powf.stderr +++ b/tests/ui/floating_point_powf.stderr @@ -1,5 +1,5 @@ error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:6:13 + --> tests/ui/floating_point_powf.rs:6:13 | LL | let _ = 2f32.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` @@ -8,43 +8,43 @@ LL | let _ = 2f32.powf(x); = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:7:13 + --> tests/ui/floating_point_powf.rs:7:13 | LL | let _ = 2f32.powf(3.1); | ^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:8:13 + --> tests/ui/floating_point_powf.rs:8:13 | LL | let _ = 2f32.powf(-3.1); | ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:9:13 + --> tests/ui/floating_point_powf.rs:9:13 | LL | let _ = std::f32::consts::E.powf(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:10:13 + --> tests/ui/floating_point_powf.rs:10:13 | LL | let _ = std::f32::consts::E.powf(3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:11:13 + --> tests/ui/floating_point_powf.rs:11:13 | LL | let _ = std::f32::consts::E.powf(-3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp()` error: square-root of a number can be computed more efficiently and accurately - --> $DIR/floating_point_powf.rs:12:13 + --> tests/ui/floating_point_powf.rs:12:13 | LL | let _ = x.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:13:13 + --> tests/ui/floating_point_powf.rs:13:13 | LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` @@ -53,139 +53,139 @@ LL | let _ = x.powf(1.0 / 3.0); = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:14:13 + --> tests/ui/floating_point_powf.rs:14:13 | LL | let _ = (x as f32).powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).cbrt()` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:15:13 + --> tests/ui/floating_point_powf.rs:15:13 | LL | let _ = x.powf(3.0); | ^^^^^^^^^^^ help: consider using: `x.powi(3)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:16:13 + --> tests/ui/floating_point_powf.rs:16:13 | LL | let _ = x.powf(-2.0); | ^^^^^^^^^^^^ help: consider using: `x.powi(-2)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:17:13 + --> tests/ui/floating_point_powf.rs:17:13 | LL | let _ = x.powf(16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(16_777_215)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:18:13 + --> tests/ui/floating_point_powf.rs:18:13 | LL | let _ = x.powf(-16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-16_777_215)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:19:13 + --> tests/ui/floating_point_powf.rs:19:13 | LL | let _ = (x as f32).powf(-16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(-16_777_215)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:20:13 + --> tests/ui/floating_point_powf.rs:20:13 | LL | let _ = (x as f32).powf(3.0); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(3)` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:21:13 + --> tests/ui/floating_point_powf.rs:21:13 | LL | let _ = (1.5_f32 + 1.0).powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(1.5_f32 + 1.0).cbrt()` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:22:13 + --> tests/ui/floating_point_powf.rs:22:13 | LL | let _ = 1.5_f64.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.cbrt()` error: square-root of a number can be computed more efficiently and accurately - --> $DIR/floating_point_powf.rs:23:13 + --> tests/ui/floating_point_powf.rs:23:13 | LL | let _ = 1.5_f64.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.sqrt()` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:24:13 + --> tests/ui/floating_point_powf.rs:24:13 | LL | let _ = 1.5_f64.powf(3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.powi(3)` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:33:13 + --> tests/ui/floating_point_powf.rs:33:13 | LL | let _ = 2f64.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:34:13 + --> tests/ui/floating_point_powf.rs:34:13 | LL | let _ = 2f64.powf(3.1); | ^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:35:13 + --> tests/ui/floating_point_powf.rs:35:13 | LL | let _ = 2f64.powf(-3.1); | ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:36:13 + --> tests/ui/floating_point_powf.rs:36:13 | LL | let _ = std::f64::consts::E.powf(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:37:13 + --> tests/ui/floating_point_powf.rs:37:13 | LL | let _ = std::f64::consts::E.powf(3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:38:13 + --> tests/ui/floating_point_powf.rs:38:13 | LL | let _ = std::f64::consts::E.powf(-3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp()` error: square-root of a number can be computed more efficiently and accurately - --> $DIR/floating_point_powf.rs:39:13 + --> tests/ui/floating_point_powf.rs:39:13 | LL | let _ = x.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:40:13 + --> tests/ui/floating_point_powf.rs:40:13 | LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:41:13 + --> tests/ui/floating_point_powf.rs:41:13 | LL | let _ = x.powf(3.0); | ^^^^^^^^^^^ help: consider using: `x.powi(3)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:42:13 + --> tests/ui/floating_point_powf.rs:42:13 | LL | let _ = x.powf(-2.0); | ^^^^^^^^^^^^ help: consider using: `x.powi(-2)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:43:13 + --> tests/ui/floating_point_powf.rs:43:13 | LL | let _ = x.powf(-2_147_483_648.0); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-2_147_483_648)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:44:13 + --> tests/ui/floating_point_powf.rs:44:13 | LL | let _ = x.powf(2_147_483_647.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2_147_483_647)` diff --git a/tests/ui/floating_point_powi.stderr b/tests/ui/floating_point_powi.stderr index ddf20ff40ba26..dfed20cb8c5a4 100644 --- a/tests/ui/floating_point_powi.stderr +++ b/tests/ui/floating_point_powi.stderr @@ -1,5 +1,5 @@ error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:9:13 + --> tests/ui/floating_point_powi.rs:9:13 | LL | let _ = x.powi(2) + y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` @@ -8,79 +8,79 @@ LL | let _ = x.powi(2) + y; = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:10:13 + --> tests/ui/floating_point_powi.rs:10:13 | LL | let _ = x.powi(2) - y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, -y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:11:13 + --> tests/ui/floating_point_powi.rs:11:13 | LL | let _ = x + y.powi(2); | ^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:12:13 + --> tests/ui/floating_point_powi.rs:12:13 | LL | let _ = x - y.powi(2); | ^^^^^^^^^^^^^ help: consider using: `y.mul_add(-y, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:13:13 + --> tests/ui/floating_point_powi.rs:13:13 | LL | let _ = x + (y as f32).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y as f32).mul_add(y as f32, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:14:13 + --> tests/ui/floating_point_powi.rs:14:13 | LL | let _ = (x.powi(2) + y).sqrt(); | ^^^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:15:13 + --> tests/ui/floating_point_powi.rs:15:13 | LL | let _ = (x + y.powi(2)).sqrt(); | ^^^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:17:13 + --> tests/ui/floating_point_powi.rs:17:13 | LL | let _ = (x - 1.0).powi(2) - y; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:18:13 + --> tests/ui/floating_point_powi.rs:18:13 | LL | let _ = (x - 1.0).powi(2) - y + 3.0; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:19:13 + --> tests/ui/floating_point_powi.rs:19:13 | LL | let _ = (x - 1.0).powi(2) - (y + 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -(y + 3.0))` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:20:13 + --> tests/ui/floating_point_powi.rs:20:13 | LL | let _ = x - (y + 1.0).powi(2); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0).mul_add(-(y + 1.0), x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:21:13 + --> tests/ui/floating_point_powi.rs:21:13 | LL | let _ = x - (3.0 * y).powi(2); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(3.0 * y).mul_add(-(3.0 * y), x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:22:13 + --> tests/ui/floating_point_powi.rs:22:13 | LL | let _ = x - (y + 1.0 + x).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0 + x).mul_add(-(y + 1.0 + x), x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:23:13 + --> tests/ui/floating_point_powi.rs:23:13 | LL | let _ = x - (y + 1.0 + 2.0).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0 + 2.0).mul_add(-(y + 1.0 + 2.0), x)` diff --git a/tests/ui/floating_point_rad.stderr b/tests/ui/floating_point_rad.stderr index e7b42de04bdfb..64674342c2b99 100644 --- a/tests/ui/floating_point_rad.stderr +++ b/tests/ui/floating_point_rad.stderr @@ -1,5 +1,5 @@ error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:11:13 + --> tests/ui/floating_point_rad.rs:11:13 | LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()` @@ -8,43 +8,43 @@ LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:12:13 + --> tests/ui/floating_point_rad.rs:12:13 | LL | let _ = degrees as f64 * 180.0 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:17:13 + --> tests/ui/floating_point_rad.rs:17:13 | LL | let _ = x * 180f32 / std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:18:13 + --> tests/ui/floating_point_rad.rs:18:13 | LL | let _ = 90. * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:19:13 + --> tests/ui/floating_point_rad.rs:19:13 | LL | let _ = 90.5 * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_degrees()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:20:13 + --> tests/ui/floating_point_rad.rs:20:13 | LL | let _ = x * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_radians()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:21:13 + --> tests/ui/floating_point_rad.rs:21:13 | LL | let _ = 90. * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_radians()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:22:13 + --> tests/ui/floating_point_rad.rs:22:13 | LL | let _ = 90.5 * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_radians()` diff --git a/tests/ui/fn_address_comparisons.stderr b/tests/ui/fn_address_comparisons.stderr index be7fa62f1b790..e6de7e358075d 100644 --- a/tests/ui/fn_address_comparisons.stderr +++ b/tests/ui/fn_address_comparisons.stderr @@ -1,5 +1,5 @@ error: comparing with a non-unique address of a function item - --> $DIR/fn_address_comparisons.rs:15:13 + --> tests/ui/fn_address_comparisons.rs:15:13 | LL | let _ = f == a; | ^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = f == a; = help: to override `-D warnings` add `#[allow(clippy::fn_address_comparisons)]` error: comparing with a non-unique address of a function item - --> $DIR/fn_address_comparisons.rs:18:13 + --> tests/ui/fn_address_comparisons.rs:18:13 | LL | let _ = f != a; | ^^^^^^ diff --git a/tests/ui/fn_params_excessive_bools.stderr b/tests/ui/fn_params_excessive_bools.stderr index f529d8cc4110b..f211a435af989 100644 --- a/tests/ui/fn_params_excessive_bools.stderr +++ b/tests/ui/fn_params_excessive_bools.stderr @@ -1,5 +1,5 @@ error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:19:1 + --> tests/ui/fn_params_excessive_bools.rs:19:1 | LL | fn g(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | fn g(_: bool, _: bool, _: bool, _: bool) {} = help: to override `-D warnings` add `#[allow(clippy::fn_params_excessive_bools)]` error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:23:1 + --> tests/ui/fn_params_excessive_bools.rs:23:1 | LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:29:5 + --> tests/ui/fn_params_excessive_bools.rs:29:5 | LL | fn f(_: bool, _: bool, _: bool, _: bool); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn f(_: bool, _: bool, _: bool, _: bool); = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:34:5 + --> tests/ui/fn_params_excessive_bools.rs:34:5 | LL | fn i(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn i(_: bool, _: bool, _: bool, _: bool) {} = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:39:5 + --> tests/ui/fn_params_excessive_bools.rs:39:5 | LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:55:5 + --> tests/ui/fn_params_excessive_bools.rs:55:5 | LL | / fn n(_: bool, _: u32, _: bool, _: Box, _: bool, _: bool) { LL | | @@ -53,7 +53,7 @@ LL | | } = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:57:9 + --> tests/ui/fn_params_excessive_bools.rs:57:9 | LL | fn nn(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/fn_to_numeric_cast.32bit.stderr b/tests/ui/fn_to_numeric_cast.32bit.stderr index ea08d8c9cc162..65991a3989ac6 100644 --- a/tests/ui/fn_to_numeric_cast.32bit.stderr +++ b/tests/ui/fn_to_numeric_cast.32bit.stderr @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:10:13 + --> tests/ui/fn_to_numeric_cast.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` @@ -8,13 +8,13 @@ LL | let _ = foo as i8; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]` error: casting function pointer `foo` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:11:13 + --> tests/ui/fn_to_numeric_cast.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i32` - --> $DIR/fn_to_numeric_cast.rs:12:13 + --> tests/ui/fn_to_numeric_cast.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` @@ -23,121 +23,121 @@ LL | let _ = foo as i32; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast.rs:13:13 + --> tests/ui/fn_to_numeric_cast.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i128` - --> $DIR/fn_to_numeric_cast.rs:14:13 + --> tests/ui/fn_to_numeric_cast.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast.rs:15:13 + --> tests/ui/fn_to_numeric_cast.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:17:13 + --> tests/ui/fn_to_numeric_cast.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:18:13 + --> tests/ui/fn_to_numeric_cast.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u32` - --> $DIR/fn_to_numeric_cast.rs:19:13 + --> tests/ui/fn_to_numeric_cast.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast.rs:20:13 + --> tests/ui/fn_to_numeric_cast.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast.rs:21:13 + --> tests/ui/fn_to_numeric_cast.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `abc` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:34:13 + --> tests/ui/fn_to_numeric_cast.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:35:13 + --> tests/ui/fn_to_numeric_cast.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i32` - --> $DIR/fn_to_numeric_cast.rs:36:13 + --> tests/ui/fn_to_numeric_cast.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i64` - --> $DIR/fn_to_numeric_cast.rs:37:13 + --> tests/ui/fn_to_numeric_cast.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i128` - --> $DIR/fn_to_numeric_cast.rs:38:13 + --> tests/ui/fn_to_numeric_cast.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `isize` - --> $DIR/fn_to_numeric_cast.rs:39:13 + --> tests/ui/fn_to_numeric_cast.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:41:13 + --> tests/ui/fn_to_numeric_cast.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:42:13 + --> tests/ui/fn_to_numeric_cast.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u32` - --> $DIR/fn_to_numeric_cast.rs:43:13 + --> tests/ui/fn_to_numeric_cast.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u64` - --> $DIR/fn_to_numeric_cast.rs:44:13 + --> tests/ui/fn_to_numeric_cast.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u128` - --> $DIR/fn_to_numeric_cast.rs:45:13 + --> tests/ui/fn_to_numeric_cast.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `f` to `i32` - --> $DIR/fn_to_numeric_cast.rs:52:5 + --> tests/ui/fn_to_numeric_cast.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` diff --git a/tests/ui/fn_to_numeric_cast.64bit.stderr b/tests/ui/fn_to_numeric_cast.64bit.stderr index 62f3bfa70ea50..58f55f19a745f 100644 --- a/tests/ui/fn_to_numeric_cast.64bit.stderr +++ b/tests/ui/fn_to_numeric_cast.64bit.stderr @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:10:13 + --> tests/ui/fn_to_numeric_cast.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` @@ -8,19 +8,19 @@ LL | let _ = foo as i8; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]` error: casting function pointer `foo` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:11:13 + --> tests/ui/fn_to_numeric_cast.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:12:13 + --> tests/ui/fn_to_numeric_cast.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast.rs:13:13 + --> tests/ui/fn_to_numeric_cast.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` @@ -29,115 +29,115 @@ LL | let _ = foo as i64; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]` error: casting function pointer `foo` to `i128` - --> $DIR/fn_to_numeric_cast.rs:14:13 + --> tests/ui/fn_to_numeric_cast.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast.rs:15:13 + --> tests/ui/fn_to_numeric_cast.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:17:13 + --> tests/ui/fn_to_numeric_cast.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:18:13 + --> tests/ui/fn_to_numeric_cast.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:19:13 + --> tests/ui/fn_to_numeric_cast.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast.rs:20:13 + --> tests/ui/fn_to_numeric_cast.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast.rs:21:13 + --> tests/ui/fn_to_numeric_cast.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `abc` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:34:13 + --> tests/ui/fn_to_numeric_cast.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:35:13 + --> tests/ui/fn_to_numeric_cast.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:36:13 + --> tests/ui/fn_to_numeric_cast.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i64` - --> $DIR/fn_to_numeric_cast.rs:37:13 + --> tests/ui/fn_to_numeric_cast.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i128` - --> $DIR/fn_to_numeric_cast.rs:38:13 + --> tests/ui/fn_to_numeric_cast.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `isize` - --> $DIR/fn_to_numeric_cast.rs:39:13 + --> tests/ui/fn_to_numeric_cast.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:41:13 + --> tests/ui/fn_to_numeric_cast.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:42:13 + --> tests/ui/fn_to_numeric_cast.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:43:13 + --> tests/ui/fn_to_numeric_cast.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u64` - --> $DIR/fn_to_numeric_cast.rs:44:13 + --> tests/ui/fn_to_numeric_cast.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u128` - --> $DIR/fn_to_numeric_cast.rs:45:13 + --> tests/ui/fn_to_numeric_cast.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `f` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:52:5 + --> tests/ui/fn_to_numeric_cast.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` diff --git a/tests/ui/fn_to_numeric_cast_any.stderr b/tests/ui/fn_to_numeric_cast_any.stderr index a1514c87b5ec8..e5bb8d1326975 100644 --- a/tests/ui/fn_to_numeric_cast_any.stderr +++ b/tests/ui/fn_to_numeric_cast_any.stderr @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8` - --> $DIR/fn_to_numeric_cast_any.rs:23:13 + --> tests/ui/fn_to_numeric_cast_any.rs:23:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i8` @@ -8,97 +8,97 @@ LL | let _ = foo as i8; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_any)]` error: casting function pointer `foo` to `i16` - --> $DIR/fn_to_numeric_cast_any.rs:26:13 + --> tests/ui/fn_to_numeric_cast_any.rs:26:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i16` error: casting function pointer `foo` to `i32` - --> $DIR/fn_to_numeric_cast_any.rs:28:13 + --> tests/ui/fn_to_numeric_cast_any.rs:28:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i32` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast_any.rs:30:13 + --> tests/ui/fn_to_numeric_cast_any.rs:30:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i64` error: casting function pointer `foo` to `i128` - --> $DIR/fn_to_numeric_cast_any.rs:32:13 + --> tests/ui/fn_to_numeric_cast_any.rs:32:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i128` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast_any.rs:34:13 + --> tests/ui/fn_to_numeric_cast_any.rs:34:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as isize` error: casting function pointer `foo` to `u8` - --> $DIR/fn_to_numeric_cast_any.rs:37:13 + --> tests/ui/fn_to_numeric_cast_any.rs:37:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u8` error: casting function pointer `foo` to `u16` - --> $DIR/fn_to_numeric_cast_any.rs:39:13 + --> tests/ui/fn_to_numeric_cast_any.rs:39:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u16` error: casting function pointer `foo` to `u32` - --> $DIR/fn_to_numeric_cast_any.rs:41:13 + --> tests/ui/fn_to_numeric_cast_any.rs:41:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u32` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast_any.rs:43:13 + --> tests/ui/fn_to_numeric_cast_any.rs:43:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u64` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast_any.rs:45:13 + --> tests/ui/fn_to_numeric_cast_any.rs:45:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u128` error: casting function pointer `foo` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:47:13 + --> tests/ui/fn_to_numeric_cast_any.rs:47:13 | LL | let _ = foo as usize; | ^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as usize` error: casting function pointer `Struct::static_method` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:52:13 + --> tests/ui/fn_to_numeric_cast_any.rs:52:13 | LL | let _ = Struct::static_method as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `Struct::static_method() as usize` error: casting function pointer `f` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:57:5 + --> tests/ui/fn_to_numeric_cast_any.rs:57:5 | LL | f as usize | ^^^^^^^^^^ help: did you mean to invoke the function?: `f() as usize` error: casting function pointer `T::static_method` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:62:5 + --> tests/ui/fn_to_numeric_cast_any.rs:62:5 | LL | T::static_method as usize | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `T::static_method() as usize` error: casting function pointer `(clos as fn(u32) -> u32)` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:69:13 + --> tests/ui/fn_to_numeric_cast_any.rs:69:13 | LL | let _ = (clos as fn(u32) -> u32) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `(clos as fn(u32) -> u32)() as usize` error: casting function pointer `foo` to `*const ()` - --> $DIR/fn_to_numeric_cast_any.rs:74:13 + --> tests/ui/fn_to_numeric_cast_any.rs:74:13 | LL | let _ = foo as *const (); | ^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as *const ()` diff --git a/tests/ui/for_kv_map.stderr b/tests/ui/for_kv_map.stderr index d29617e24f244..f4ce473d095bf 100644 --- a/tests/ui/for_kv_map.stderr +++ b/tests/ui/for_kv_map.stderr @@ -1,5 +1,5 @@ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:9:19 + --> tests/ui/for_kv_map.rs:9:19 | LL | for (_, v) in &m { | ^^ @@ -12,7 +12,7 @@ LL | for v in m.values() { | ~ ~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:16:19 + --> tests/ui/for_kv_map.rs:16:19 | LL | for (_, v) in &*m { | ^^^ @@ -23,7 +23,7 @@ LL | for v in (*m).values() { | ~ ~~~~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:25:19 + --> tests/ui/for_kv_map.rs:25:19 | LL | for (_, v) in &mut m { | ^^^^^^ @@ -34,7 +34,7 @@ LL | for v in m.values_mut() { | ~ ~~~~~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:31:19 + --> tests/ui/for_kv_map.rs:31:19 | LL | for (_, v) in &mut *m { | ^^^^^^^ @@ -45,7 +45,7 @@ LL | for v in (*m).values_mut() { | ~ ~~~~~~~~~~~~~~~~~ error: you seem to want to iterate on a map's keys - --> $DIR/for_kv_map.rs:38:24 + --> tests/ui/for_kv_map.rs:38:24 | LL | for (k, _value) in rm { | ^^ diff --git a/tests/ui/forget_non_drop.stderr b/tests/ui/forget_non_drop.stderr index c0fa433c479df..e121984154c73 100644 --- a/tests/ui/forget_non_drop.stderr +++ b/tests/ui/forget_non_drop.stderr @@ -1,11 +1,11 @@ error: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it - --> $DIR/forget_non_drop.rs:13:5 + --> tests/ui/forget_non_drop.rs:13:5 | LL | forget(Foo); | ^^^^^^^^^^^ | note: argument has type `main::Foo` - --> $DIR/forget_non_drop.rs:13:12 + --> tests/ui/forget_non_drop.rs:13:12 | LL | forget(Foo); | ^^^ @@ -13,13 +13,13 @@ LL | forget(Foo); = help: to override `-D warnings` add `#[allow(clippy::forget_non_drop)]` error: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it - --> $DIR/forget_non_drop.rs:25:5 + --> tests/ui/forget_non_drop.rs:25:5 | LL | forget(Baz(Foo)); | ^^^^^^^^^^^^^^^^ | note: argument has type `main::Baz` - --> $DIR/forget_non_drop.rs:25:12 + --> tests/ui/forget_non_drop.rs:25:12 | LL | forget(Baz(Foo)); | ^^^^^^^^ diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index e02fdb1e41519..faa80b48000f9 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -1,5 +1,5 @@ error: useless use of `format!` - --> $DIR/format.rs:19:5 + --> tests/ui/format.rs:19:5 | LL | format!("foo"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` @@ -8,19 +8,19 @@ LL | format!("foo"); = help: to override `-D warnings` add `#[allow(clippy::useless_format)]` error: useless use of `format!` - --> $DIR/format.rs:20:5 + --> tests/ui/format.rs:20:5 | LL | format!("{{}}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()` error: useless use of `format!` - --> $DIR/format.rs:21:5 + --> tests/ui/format.rs:21:5 | LL | format!("{{}} abc {{}}"); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()` error: useless use of `format!` - --> $DIR/format.rs:22:5 + --> tests/ui/format.rs:22:5 | LL | / format!( LL | | r##"foo {{}} @@ -35,67 +35,67 @@ LL ~ " bar"##.to_string(); | error: useless use of `format!` - --> $DIR/format.rs:27:13 + --> tests/ui/format.rs:27:13 | LL | let _ = format!(""); | ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()` error: useless use of `format!` - --> $DIR/format.rs:29:5 + --> tests/ui/format.rs:29:5 | LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` error: useless use of `format!` - --> $DIR/format.rs:37:5 + --> tests/ui/format.rs:37:5 | LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()` error: useless use of `format!` - --> $DIR/format.rs:67:5 + --> tests/ui/format.rs:67:5 | LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()` error: useless use of `format!` - --> $DIR/format.rs:69:5 + --> tests/ui/format.rs:69:5 | LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()` error: useless use of `format!` - --> $DIR/format.rs:73:18 + --> tests/ui/format.rs:73:18 | LL | let _ = Some(format!("{}", a + "bar")); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"` error: useless use of `format!` - --> $DIR/format.rs:77:22 + --> tests/ui/format.rs:77:22 | LL | let _s: String = format!("{}", &*v.join("\n")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("\n")).to_string()` error: useless use of `format!` - --> $DIR/format.rs:83:13 + --> tests/ui/format.rs:83:13 | LL | let _ = format!("{x}"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` - --> $DIR/format.rs:85:13 + --> tests/ui/format.rs:85:13 | LL | let _ = format!("{y}", y = x); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` - --> $DIR/format.rs:89:13 + --> tests/ui/format.rs:89:13 | LL | let _ = format!("{abc}"); | ^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `abc.to_string()` error: useless use of `format!` - --> $DIR/format.rs:91:13 + --> tests/ui/format.rs:91:13 | LL | let _ = format!("{xx}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `xx.to_string()` diff --git a/tests/ui/format_args.stderr b/tests/ui/format_args.stderr index 2f1714296d6c8..f20cf9eca2f9d 100644 --- a/tests/ui/format_args.stderr +++ b/tests/ui/format_args.stderr @@ -1,5 +1,5 @@ error: `to_string` applied to a type that implements `Display` in `format!` args - --> $DIR/format_args.rs:77:72 + --> tests/ui/format_args.rs:77:72 | LL | let _ = format!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this @@ -8,145 +8,145 @@ LL | let _ = format!("error: something failed at {}", Location::caller().to_ = help: to override `-D warnings` add `#[allow(clippy::to_string_in_format_args)]` error: `to_string` applied to a type that implements `Display` in `write!` args - --> $DIR/format_args.rs:81:27 + --> tests/ui/format_args.rs:81:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `writeln!` args - --> $DIR/format_args.rs:86:27 + --> tests/ui/format_args.rs:86:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:88:63 + --> tests/ui/format_args.rs:88:63 | LL | print!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:89:65 + --> tests/ui/format_args.rs:89:65 | LL | println!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `eprint!` args - --> $DIR/format_args.rs:90:64 + --> tests/ui/format_args.rs:90:64 | LL | eprint!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `eprintln!` args - --> $DIR/format_args.rs:91:66 + --> tests/ui/format_args.rs:91:66 | LL | eprintln!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `format_args!` args - --> $DIR/format_args.rs:92:77 + --> tests/ui/format_args.rs:92:77 | LL | let _ = format_args!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert!` args - --> $DIR/format_args.rs:93:70 + --> tests/ui/format_args.rs:93:70 | LL | assert!(true, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert_eq!` args - --> $DIR/format_args.rs:94:73 + --> tests/ui/format_args.rs:94:73 | LL | assert_eq!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert_ne!` args - --> $DIR/format_args.rs:95:73 + --> tests/ui/format_args.rs:95:73 | LL | assert_ne!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `panic!` args - --> $DIR/format_args.rs:96:63 + --> tests/ui/format_args.rs:96:63 | LL | panic!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:97:20 + --> tests/ui/format_args.rs:97:20 | LL | println!("{}", X(1).to_string()); | ^^^^^^^^^^^^^^^^ help: use this: `*X(1)` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:98:20 + --> tests/ui/format_args.rs:98:20 | LL | println!("{}", Y(&X(1)).to_string()); | ^^^^^^^^^^^^^^^^^^^^ help: use this: `***Y(&X(1))` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:99:24 + --> tests/ui/format_args.rs:99:24 | LL | println!("{}", Z(1).to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:100:20 + --> tests/ui/format_args.rs:100:20 | LL | println!("{}", x.to_string()); | ^^^^^^^^^^^^^ help: use this: `**x` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:101:20 + --> tests/ui/format_args.rs:101:20 | LL | println!("{}", x_ref.to_string()); | ^^^^^^^^^^^^^^^^^ help: use this: `***x_ref` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:103:39 + --> tests/ui/format_args.rs:103:39 | LL | println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:104:52 + --> tests/ui/format_args.rs:104:52 | LL | println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:105:39 + --> tests/ui/format_args.rs:105:39 | LL | println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:106:52 + --> tests/ui/format_args.rs:106:52 | LL | println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:118:37 + --> tests/ui/format_args.rs:118:37 | LL | print!("{}", (Location::caller().to_string())); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:119:39 + --> tests/ui/format_args.rs:119:39 | LL | print!("{}", ((Location::caller()).to_string())); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `format!` args - --> $DIR/format_args.rs:147:38 + --> tests/ui/format_args.rs:147:38 | LL | let x = format!("{} {}", a, b.to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:161:24 + --> tests/ui/format_args.rs:161:24 | LL | println!("{}", original[..10].to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use this: `&original[..10]` diff --git a/tests/ui/format_args_unfixable.stderr b/tests/ui/format_args_unfixable.stderr index 3ffe2f6c89440..20cd0bb8c5541 100644 --- a/tests/ui/format_args_unfixable.stderr +++ b/tests/ui/format_args_unfixable.stderr @@ -1,5 +1,5 @@ error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:26:5 + --> tests/ui/format_args_unfixable.rs:26:5 | LL | println!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | println!("error: {}", format!("something failed at {}", Location::calle = help: to override `-D warnings` add `#[allow(clippy::format_in_format_args)]` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:28:5 + --> tests/ui/format_args_unfixable.rs:28:5 | LL | println!("{}: {}", error, format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}: {}", error, format!("something failed at {}", Location::c = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:30:5 + --> tests/ui/format_args_unfixable.rs:30:5 | LL | println!("{:?}: {}", error, format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | println!("{:?}: {}", error, format!("something failed at {}", Location: = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:32:5 + --> tests/ui/format_args_unfixable.rs:32:5 | LL | println!("{{}}: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | println!("{{}}: {}", format!("something failed at {}", Location::caller = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:34:5 + --> tests/ui/format_args_unfixable.rs:34:5 | LL | println!(r#"error: "{}""#, format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | println!(r#"error: "{}""#, format!("something failed at {}", Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:36:5 + --> tests/ui/format_args_unfixable.rs:36:5 | LL | println!("error: {}", format!(r#"something failed at "{}""#, Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | println!("error: {}", format!(r#"something failed at "{}""#, Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:38:5 + --> tests/ui/format_args_unfixable.rs:38:5 | LL | println!("error: {}", format!("something failed at {} {0}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | println!("error: {}", format!("something failed at {} {0}", Location::c = help: or consider changing `format!` to `format_args!` error: `format!` in `format!` args - --> $DIR/format_args_unfixable.rs:40:13 + --> tests/ui/format_args_unfixable.rs:40:13 | LL | let _ = format!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = format!("error: {}", format!("something failed at {}", Location = help: or consider changing `format!` to `format_args!` error: `format!` in `write!` args - --> $DIR/format_args_unfixable.rs:42:13 + --> tests/ui/format_args_unfixable.rs:42:13 | LL | let _ = write!( | _____________^ @@ -88,7 +88,7 @@ LL | | ); = help: or consider changing `format!` to `format_args!` error: `format!` in `writeln!` args - --> $DIR/format_args_unfixable.rs:48:13 + --> tests/ui/format_args_unfixable.rs:48:13 | LL | let _ = writeln!( | _____________^ @@ -103,7 +103,7 @@ LL | | ); = help: or consider changing `format!` to `format_args!` error: `format!` in `print!` args - --> $DIR/format_args_unfixable.rs:54:5 + --> tests/ui/format_args_unfixable.rs:54:5 | LL | print!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | print!("error: {}", format!("something failed at {}", Location::caller( = help: or consider changing `format!` to `format_args!` error: `format!` in `eprint!` args - --> $DIR/format_args_unfixable.rs:56:5 + --> tests/ui/format_args_unfixable.rs:56:5 | LL | eprint!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | eprint!("error: {}", format!("something failed at {}", Location::caller = help: or consider changing `format!` to `format_args!` error: `format!` in `eprintln!` args - --> $DIR/format_args_unfixable.rs:58:5 + --> tests/ui/format_args_unfixable.rs:58:5 | LL | eprintln!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | eprintln!("error: {}", format!("something failed at {}", Location::call = help: or consider changing `format!` to `format_args!` error: `format!` in `format_args!` args - --> $DIR/format_args_unfixable.rs:60:13 + --> tests/ui/format_args_unfixable.rs:60:13 | LL | let _ = format_args!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | let _ = format_args!("error: {}", format!("something failed at {}", Loc = help: or consider changing `format!` to `format_args!` error: `format!` in `assert!` args - --> $DIR/format_args_unfixable.rs:62:5 + --> tests/ui/format_args_unfixable.rs:62:5 | LL | assert!(true, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | assert!(true, "error: {}", format!("something failed at {}", Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `assert_eq!` args - --> $DIR/format_args_unfixable.rs:64:5 + --> tests/ui/format_args_unfixable.rs:64:5 | LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: or consider changing `format!` to `format_args!` error: `format!` in `assert_ne!` args - --> $DIR/format_args_unfixable.rs:66:5 + --> tests/ui/format_args_unfixable.rs:66:5 | LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: or consider changing `format!` to `format_args!` error: `format!` in `panic!` args - --> $DIR/format_args_unfixable.rs:68:5 + --> tests/ui/format_args_unfixable.rs:68:5 | LL | panic!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/format_collect.stderr b/tests/ui/format_collect.stderr index 340218ccf2c9f..863b457a7905c 100644 --- a/tests/ui/format_collect.stderr +++ b/tests/ui/format_collect.stderr @@ -1,16 +1,16 @@ error: use of `format!` to build up a string from an iterator - --> $DIR/format_collect.rs:5:5 + --> tests/ui/format_collect.rs:5:5 | LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: call `fold` instead - --> $DIR/format_collect.rs:5:18 + --> tests/ui/format_collect.rs:5:18 | LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^ help: ... and use the `write!` macro here - --> $DIR/format_collect.rs:5:26 + --> tests/ui/format_collect.rs:5:26 | LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^^^^^^^^^^^^^^^^ @@ -19,25 +19,25 @@ LL | bytes.iter().map(|b| format!("{b:02X}")).collect() = help: to override `-D warnings` add `#[allow(clippy::format_collect)]` error: use of `format!` to build up a string from an iterator - --> $DIR/format_collect.rs:11:5 + --> tests/ui/format_collect.rs:11:5 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: call `fold` instead - --> $DIR/format_collect.rs:11:18 + --> tests/ui/format_collect.rs:11:18 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^ help: ... and use the `write!` macro here - --> $DIR/format_collect.rs:11:32 + --> tests/ui/format_collect.rs:11:32 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^^^^^^^^^^^^^^^^ = note: this can be written more efficiently by appending to a `String` directly error: use of `format!` to build up a string from an iterator - --> $DIR/format_collect.rs:26:5 + --> tests/ui/format_collect.rs:26:5 | LL | / (1..10) LL | | @@ -49,12 +49,12 @@ LL | | .collect() | |__________________^ | help: call `fold` instead - --> $DIR/format_collect.rs:28:10 + --> tests/ui/format_collect.rs:28:10 | LL | .map(|s| { | ^^^ help: ... and use the `write!` macro here - --> $DIR/format_collect.rs:30:13 + --> tests/ui/format_collect.rs:30:13 | LL | format!("{s} {y}") | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/format_push_string.stderr b/tests/ui/format_push_string.stderr index 545915b56b56b..a9520600f52a4 100644 --- a/tests/ui/format_push_string.stderr +++ b/tests/ui/format_push_string.stderr @@ -1,5 +1,5 @@ error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:5:5 + --> tests/ui/format_push_string.rs:5:5 | LL | string += &format!("{:?}", 1234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | string += &format!("{:?}", 1234); = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:7:5 + --> tests/ui/format_push_string.rs:7:5 | LL | string.push_str(&format!("{:?}", 5678)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | string.push_str(&format!("{:?}", 5678)); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:15:13 + --> tests/ui/format_push_string.rs:15:13 | LL | / hex += &(if upper { LL | | @@ -30,7 +30,7 @@ LL | | }); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:28:9 + --> tests/ui/format_push_string.rs:28:9 | LL | / s += &(if let Some(_a) = Some(1234) { LL | | @@ -43,7 +43,7 @@ LL | | }); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:35:9 + --> tests/ui/format_push_string.rs:35:9 | LL | / s += &(match Some(1234) { LL | | diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index d4eb8e511c8f9..e823e6512b8df 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:16:6 + --> tests/ui/formatting.rs:16:6 | LL | a =- 35; | ^^^^ @@ -9,7 +9,7 @@ LL | a =- 35; = help: to override `-D warnings` add `#[allow(clippy::suspicious_assignment_formatting)]` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:19:6 + --> tests/ui/formatting.rs:19:6 | LL | a =* &191; | ^^^^ @@ -17,7 +17,7 @@ LL | a =* &191; = note: to remove this lint, use either `*=` or `= *` error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:24:6 + --> tests/ui/formatting.rs:24:6 | LL | b =! false; | ^^^^ @@ -25,7 +25,7 @@ LL | b =! false; = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:35:19 + --> tests/ui/formatting.rs:35:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -35,7 +35,7 @@ LL | -1, -2, -3 // <= no comma here = help: to override `-D warnings` add `#[allow(clippy::possible_missing_comma)]` error: possibly missing a comma here - --> $DIR/formatting.rs:41:19 + --> tests/ui/formatting.rs:41:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -43,7 +43,7 @@ LL | -1, -2, -3 // <= no comma here = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:80:11 + --> tests/ui/formatting.rs:80:11 | LL | -1 | ^ diff --git a/tests/ui/four_forward_slashes.stderr b/tests/ui/four_forward_slashes.stderr index 6450c5f94601a..a2218ea4d10b0 100644 --- a/tests/ui/four_forward_slashes.stderr +++ b/tests/ui/four_forward_slashes.stderr @@ -1,5 +1,5 @@ error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:12:1 + --> tests/ui/four_forward_slashes.rs:12:1 | LL | / //// whoops LL | | fn a() {} @@ -13,7 +13,7 @@ LL + /// whoops | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:15:1 + --> tests/ui/four_forward_slashes.rs:15:1 | LL | / //// whoops LL | | #[allow(dead_code)] @@ -26,7 +26,7 @@ LL + /// whoops | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:19:1 + --> tests/ui/four_forward_slashes.rs:19:1 | LL | / //// whoops LL | | //// two borked comments! @@ -41,7 +41,7 @@ LL ~ /// two borked comments! | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:27:1 + --> tests/ui/four_forward_slashes.rs:27:1 | LL | / //// between attributes LL | | #[allow(dead_code)] @@ -54,7 +54,7 @@ LL + /// between attributes | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:31:1 + --> tests/ui/four_forward_slashes.rs:31:1 | LL | / //// not very start of contents LL | | fn h() {} diff --git a/tests/ui/four_forward_slashes_first_line.stderr b/tests/ui/four_forward_slashes_first_line.stderr index f49b7a0977fef..23937034b7e28 100644 --- a/tests/ui/four_forward_slashes_first_line.stderr +++ b/tests/ui/four_forward_slashes_first_line.stderr @@ -1,5 +1,5 @@ error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes_first_line.rs:1:1 + --> tests/ui/four_forward_slashes_first_line.rs:1:1 | LL | / //// borked doc comment on the first line. doesn't combust! LL | | fn a() {} diff --git a/tests/ui/from_iter_instead_of_collect.stderr b/tests/ui/from_iter_instead_of_collect.stderr index 6e86341d1574d..0824a526b793d 100644 --- a/tests/ui/from_iter_instead_of_collect.stderr +++ b/tests/ui/from_iter_instead_of_collect.stderr @@ -1,5 +1,5 @@ error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:17:9 + --> tests/ui/from_iter_instead_of_collect.rs:17:9 | LL | >::from_iter(iter.into_iter().copied()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter.into_iter().copied().collect::()` @@ -8,85 +8,85 @@ LL | >::from_iter(iter.into_iter().copied()) = help: to override `-D warnings` add `#[allow(clippy::from_iter_instead_of_collect)]` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:23:13 + --> tests/ui/from_iter_instead_of_collect.rs:23:13 | LL | let _ = Vec::from_iter(iter_expr); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter_expr.collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:25:13 + --> tests/ui/from_iter_instead_of_collect.rs:25:13 | LL | let _ = HashMap::::from_iter(vec![5, 5, 5, 5].iter().enumerate()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `vec![5, 5, 5, 5].iter().enumerate().collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:30:19 + --> tests/ui/from_iter_instead_of_collect.rs:30:19 | LL | assert_eq!(a, Vec::from_iter(0..3)); | ^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:31:19 + --> tests/ui/from_iter_instead_of_collect.rs:31:19 | LL | assert_eq!(a, Vec::::from_iter(0..3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:33:17 + --> tests/ui/from_iter_instead_of_collect.rs:33:17 | LL | let mut b = VecDeque::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:36:17 + --> tests/ui/from_iter_instead_of_collect.rs:36:17 | LL | let mut b = VecDeque::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:41:21 + --> tests/ui/from_iter_instead_of_collect.rs:41:21 | LL | let mut b = collections::VecDeque::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:46:14 + --> tests/ui/from_iter_instead_of_collect.rs:46:14 | LL | let bm = BTreeMap::from_iter(values.iter().cloned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `values.iter().cloned().collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:47:19 + --> tests/ui/from_iter_instead_of_collect.rs:47:19 | LL | let mut bar = BTreeMap::from_iter(bm.range(0..2)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `bm.range(0..2).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:50:19 + --> tests/ui/from_iter_instead_of_collect.rs:50:19 | LL | let mut bts = BTreeSet::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:54:17 + --> tests/ui/from_iter_instead_of_collect.rs:54:17 | LL | let _ = collections::BTreeSet::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:55:17 + --> tests/ui/from_iter_instead_of_collect.rs:55:17 | LL | let _ = collections::BTreeSet::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:58:15 + --> tests/ui/from_iter_instead_of_collect.rs:58:15 | LL | for _i in Vec::from_iter([1, 2, 3].iter()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `[1, 2, 3].iter().collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:59:15 + --> tests/ui/from_iter_instead_of_collect.rs:59:15 | LL | for _i in Vec::<&i32>::from_iter([1, 2, 3].iter()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `[1, 2, 3].iter().collect::>()` diff --git a/tests/ui/from_over_into.stderr b/tests/ui/from_over_into.stderr index f1370ed844fa9..f086dd9520bd8 100644 --- a/tests/ui/from_over_into.stderr +++ b/tests/ui/from_over_into.stderr @@ -1,5 +1,5 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:8:1 + --> tests/ui/from_over_into.rs:8:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL ~ StringWrapper(val) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:16:1 + --> tests/ui/from_over_into.rs:16:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL ~ SelfType(String::new()) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:31:1 + --> tests/ui/from_over_into.rs:31:1 | LL | impl Into for X { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL ~ let _: X = val; | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:43:1 + --> tests/ui/from_over_into.rs:43:1 | LL | impl core::convert::Into for crate::ExplicitPaths { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL ~ val.0 | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:63:1 + --> tests/ui/from_over_into.rs:63:1 | LL | impl Into for PathInExpansion { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL ~ fn from(val: PathInExpansion) -> Self { | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:85:5 + --> tests/ui/from_over_into.rs:85:5 | LL | impl Into> for Vec { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL ~ FromOverInto(val) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:95:5 + --> tests/ui/from_over_into.rs:95:5 | LL | impl Into<()> for Hello { | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/from_over_into_unfixable.stderr b/tests/ui/from_over_into_unfixable.stderr index 8ef36f082e0ef..1776b86e40dd3 100644 --- a/tests/ui/from_over_into_unfixable.stderr +++ b/tests/ui/from_over_into_unfixable.stderr @@ -1,5 +1,5 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into_unfixable.rs:11:1 + --> tests/ui/from_over_into_unfixable.rs:11:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | impl Into for String { = help: to override `-D warnings` add `#[allow(clippy::from_over_into)]` error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into_unfixable.rs:20:1 + --> tests/ui/from_over_into_unfixable.rs:20:1 | LL | impl Into for &'static [u8] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | impl Into for &'static [u8] { = help: replace the `Into` implementation with `From<&'static [u8]>` error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into_unfixable.rs:30:1 + --> tests/ui/from_over_into_unfixable.rs:30:1 | LL | impl Into for ContainsVal { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | impl Into for ContainsVal { = help: replace the `Into` implementation with `From` error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into_unfixable.rs:42:1 + --> tests/ui/from_over_into_unfixable.rs:42:1 | LL | impl Into> for Lval { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/from_raw_with_void_ptr.stderr b/tests/ui/from_raw_with_void_ptr.stderr index 6e1ad0d99c49f..e5bcb783d18b5 100644 --- a/tests/ui/from_raw_with_void_ptr.stderr +++ b/tests/ui/from_raw_with_void_ptr.stderr @@ -1,11 +1,11 @@ error: creating a `Box` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:11:22 + --> tests/ui/from_raw_with_void_ptr.rs:11:22 | LL | let _ = unsafe { Box::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:11:36 + --> tests/ui/from_raw_with_void_ptr.rs:11:36 | LL | let _ = unsafe { Box::from_raw(ptr) }; | ^^^ @@ -13,49 +13,49 @@ LL | let _ = unsafe { Box::from_raw(ptr) }; = help: to override `-D warnings` add `#[allow(clippy::from_raw_with_void_ptr)]` error: creating a `Rc` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:23:22 + --> tests/ui/from_raw_with_void_ptr.rs:23:22 | LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:23:35 + --> tests/ui/from_raw_with_void_ptr.rs:23:35 | LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^ error: creating a `Arc` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:28:22 + --> tests/ui/from_raw_with_void_ptr.rs:28:22 | LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:28:36 + --> tests/ui/from_raw_with_void_ptr.rs:28:36 | LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^ error: creating a `Weak` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:33:22 + --> tests/ui/from_raw_with_void_ptr.rs:33:22 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:33:46 + --> tests/ui/from_raw_with_void_ptr.rs:33:46 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^ error: creating a `Weak` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:38:22 + --> tests/ui/from_raw_with_void_ptr.rs:38:22 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:38:48 + --> tests/ui/from_raw_with_void_ptr.rs:38:48 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^ diff --git a/tests/ui/from_str_radix_10.stderr b/tests/ui/from_str_radix_10.stderr index 439dcff74d9c9..4aa84eca26120 100644 --- a/tests/ui/from_str_radix_10.stderr +++ b/tests/ui/from_str_radix_10.stderr @@ -1,5 +1,5 @@ error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:28:5 + --> tests/ui/from_str_radix_10.rs:28:5 | LL | u32::from_str_radix("30", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"30".parse::()` @@ -8,43 +8,43 @@ LL | u32::from_str_radix("30", 10)?; = help: to override `-D warnings` add `#[allow(clippy::from_str_radix_10)]` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:31:5 + --> tests/ui/from_str_radix_10.rs:31:5 | LL | i64::from_str_radix("24", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"24".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:33:5 + --> tests/ui/from_str_radix_10.rs:33:5 | LL | isize::from_str_radix("100", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"100".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:35:5 + --> tests/ui/from_str_radix_10.rs:35:5 | LL | u8::from_str_radix("7", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"7".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:37:5 + --> tests/ui/from_str_radix_10.rs:37:5 | LL | u16::from_str_radix(&("10".to_owned() + "5"), 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("10".to_owned() + "5").parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:39:5 + --> tests/ui/from_str_radix_10.rs:39:5 | LL | i128::from_str_radix(Test + Test, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(Test + Test).parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:43:5 + --> tests/ui/from_str_radix_10.rs:43:5 | LL | i32::from_str_radix(string, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:47:5 + --> tests/ui/from_str_radix_10.rs:47:5 | LL | i32::from_str_radix(&stringier, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `stringier.parse::()` diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 4b06cd0388990..8fdceb8d8cd07 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -1,5 +1,5 @@ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:8:1 + --> tests/ui/functions.rs:8:1 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]` error: this function has too many arguments (8/7) - --> $DIR/functions.rs:13:1 + --> tests/ui/functions.rs:13:1 | LL | / fn bad_multiline( LL | | @@ -20,19 +20,19 @@ LL | | ) { | |_^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:48:5 + --> tests/ui/functions.rs:48:5 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:58:5 + --> tests/ui/functions.rs:58:5 | LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:68:34 + --> tests/ui/functions.rs:68:34 | LL | println!("{}", unsafe { *p }); | ^ @@ -41,67 +41,67 @@ LL | println!("{}", unsafe { *p }); = help: to override `-D warnings` add `#[allow(clippy::not_unsafe_ptr_arg_deref)]` error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:71:35 + --> tests/ui/functions.rs:71:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:73:33 + --> tests/ui/functions.rs:73:33 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:85:30 + --> tests/ui/functions.rs:85:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:87:31 + --> tests/ui/functions.rs:87:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:89:29 + --> tests/ui/functions.rs:89:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:96:30 + --> tests/ui/functions.rs:96:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:98:31 + --> tests/ui/functions.rs:98:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:100:29 + --> tests/ui/functions.rs:100:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:110:34 + --> tests/ui/functions.rs:110:34 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:112:35 + --> tests/ui/functions.rs:112:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:114:33 + --> tests/ui/functions.rs:114:33 | LL | unsafe { std::ptr::read(p) }; | ^ diff --git a/tests/ui/functions_maxlines.stderr b/tests/ui/functions_maxlines.stderr index 497acc0a65ea0..f42a2b2a22a2f 100644 --- a/tests/ui/functions_maxlines.stderr +++ b/tests/ui/functions_maxlines.stderr @@ -1,5 +1,5 @@ error: this function has too many lines (102/100) - --> $DIR/functions_maxlines.rs:58:1 + --> tests/ui/functions_maxlines.rs:58:1 | LL | / fn bad_lines() { LL | | diff --git a/tests/ui/future_not_send.stderr b/tests/ui/future_not_send.stderr index 7ef4947f1d6c5..67677d6367aaa 100644 --- a/tests/ui/future_not_send.stderr +++ b/tests/ui/future_not_send.stderr @@ -1,11 +1,11 @@ error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:7:1 + --> tests/ui/future_not_send.rs:7:1 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:9:20 + --> tests/ui/future_not_send.rs:9:20 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { | -- has type `std::rc::Rc<[u8]>` which is not `Send` @@ -14,7 +14,7 @@ LL | async { true }.await | ^^^^^ await occurs here, with `rc` maybe used later = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/future_not_send.rs:7:39 + --> tests/ui/future_not_send.rs:7:39 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^ has type `&std::cell::Cell` which is not `Send`, because `std::cell::Cell` is not `Sync` @@ -23,13 +23,13 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { = help: to override `-D warnings` add `#[allow(clippy::future_not_send)]` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:12:1 + --> tests/ui/future_not_send.rs:12:1 | LL | pub async fn public_future(rc: Rc<[u8]>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:14:20 + --> tests/ui/future_not_send.rs:14:20 | LL | pub async fn public_future(rc: Rc<[u8]>) { | -- has type `std::rc::Rc<[u8]>` which is not `Send` @@ -39,45 +39,45 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:21:1 + --> tests/ui/future_not_send.rs:21:1 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future2` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:21:26 + --> tests/ui/future_not_send.rs:21:26 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^ has type `std::rc::Rc<[u8]>` which is not `Send` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/future_not_send.rs:21:40 + --> tests/ui/future_not_send.rs:21:40 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^ has type `&std::cell::Cell` which is not `Send`, because `std::cell::Cell` is not `Sync` = note: `std::cell::Cell` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:26:1 + --> tests/ui/future_not_send.rs:26:1 | LL | pub async fn public_future2(rc: Rc<[u8]>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future2` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:26:29 + --> tests/ui/future_not_send.rs:26:29 | LL | pub async fn public_future2(rc: Rc<[u8]>) {} | ^^ has type `std::rc::Rc<[u8]>` which is not `Send` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:38:5 + --> tests/ui/future_not_send.rs:38:5 | LL | async fn private_future(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:40:24 + --> tests/ui/future_not_send.rs:40:24 | LL | async fn private_future(&self) -> usize { | ----- has type `&Dummy` which is not `Send` @@ -87,20 +87,20 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:44:5 + --> tests/ui/future_not_send.rs:44:5 | LL | pub async fn public_future(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` | note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/future_not_send.rs:44:32 + --> tests/ui/future_not_send.rs:44:32 | LL | pub async fn public_future(&self) { | ^^^^^ has type `&Dummy` which is not `Send`, because `Dummy` is not `Sync` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:55:1 + --> tests/ui/future_not_send.rs:55:1 | LL | / async fn generic_future(t: T) -> T LL | | @@ -109,7 +109,7 @@ LL | | T: Send, | |____________^ future returned by `generic_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:61:20 + --> tests/ui/future_not_send.rs:61:20 | LL | let rt = &t; | -- has type `&T` which is not `Send` @@ -118,13 +118,13 @@ LL | async { true }.await; = note: `T` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:73:1 + --> tests/ui/future_not_send.rs:73:1 | LL | async fn unclear_future(t: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `unclear_future` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:73:28 + --> tests/ui/future_not_send.rs:73:28 | LL | async fn unclear_future(t: T) {} | ^ has type `T` which is not `Send` diff --git a/tests/ui/get_first.stderr b/tests/ui/get_first.stderr index 7474a2ada6691..155d341b5a77d 100644 --- a/tests/ui/get_first.stderr +++ b/tests/ui/get_first.stderr @@ -1,5 +1,5 @@ error: accessing first element with `x.get(0)` - --> $DIR/get_first.rs:17:13 + --> tests/ui/get_first.rs:17:13 | LL | let _ = x.get(0); | ^^^^^^^^ help: try: `x.first()` @@ -8,25 +8,25 @@ LL | let _ = x.get(0); = help: to override `-D warnings` add `#[allow(clippy::get_first)]` error: accessing first element with `y.get(0)` - --> $DIR/get_first.rs:23:13 + --> tests/ui/get_first.rs:23:13 | LL | let _ = y.get(0); | ^^^^^^^^ help: try: `y.first()` error: accessing first element with `z.get(0)` - --> $DIR/get_first.rs:29:13 + --> tests/ui/get_first.rs:29:13 | LL | let _ = z.get(0); | ^^^^^^^^ help: try: `z.first()` error: accessing first element with `vecdeque.get(0)` - --> $DIR/get_first.rs:35:13 + --> tests/ui/get_first.rs:35:13 | LL | let _ = vecdeque.get(0); | ^^^^^^^^^^^^^^^ help: try: `vecdeque.front()` error: accessing first element with `non_primitives.get(0)` - --> $DIR/get_first.rs:48:13 + --> tests/ui/get_first.rs:48:13 | LL | let _ = non_primitives.get(0); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `non_primitives.first()` diff --git a/tests/ui/get_last_with_len.stderr b/tests/ui/get_last_with_len.stderr index 0056adc57f22c..ba08f5db7cfae 100644 --- a/tests/ui/get_last_with_len.stderr +++ b/tests/ui/get_last_with_len.stderr @@ -1,5 +1,5 @@ error: accessing last element with `x.get(x.len() - 1)` - --> $DIR/get_last_with_len.rs:8:13 + --> tests/ui/get_last_with_len.rs:8:13 | LL | let _ = x.get(x.len() - 1); | ^^^^^^^^^^^^^^^^^^ help: try: `x.last()` @@ -8,31 +8,31 @@ LL | let _ = x.get(x.len() - 1); = help: to override `-D warnings` add `#[allow(clippy::get_last_with_len)]` error: accessing last element with `s.field.get(s.field.len() - 1)` - --> $DIR/get_last_with_len.rs:32:13 + --> tests/ui/get_last_with_len.rs:32:13 | LL | let _ = s.field.get(s.field.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.field.last()` error: accessing last element with `slice.get(slice.len() - 1)` - --> $DIR/get_last_with_len.rs:37:13 + --> tests/ui/get_last_with_len.rs:37:13 | LL | let _ = slice.get(slice.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice.last()` error: accessing last element with `array.get(array.len() - 1)` - --> $DIR/get_last_with_len.rs:40:13 + --> tests/ui/get_last_with_len.rs:40:13 | LL | let _ = array.get(array.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array.last()` error: accessing last element with `deq.get(deq.len() - 1)` - --> $DIR/get_last_with_len.rs:43:13 + --> tests/ui/get_last_with_len.rs:43:13 | LL | let _ = deq.get(deq.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `deq.back()` error: accessing last element with `nested[0].get(nested[0].len() - 1)` - --> $DIR/get_last_with_len.rs:46:13 + --> tests/ui/get_last_with_len.rs:46:13 | LL | let _ = nested[0].get(nested[0].len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `nested[0].last()` diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index 700f3cfec4e0b..a08b6657dcc7c 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -1,17 +1,17 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:37:17 + --> tests/ui/get_unwrap.rs:37:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` | note: the lint level is defined here - --> $DIR/get_unwrap.rs:9:9 + --> tests/ui/get_unwrap.rs:9:9 | LL | #![deny(clippy::get_unwrap)] | ^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:37:17 + --> tests/ui/get_unwrap.rs:37:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,13 +22,13 @@ LL | let _ = boxed_slice.get(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:38:17 + --> tests/ui/get_unwrap.rs:38:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:38:17 + --> tests/ui/get_unwrap.rs:38:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,13 +37,13 @@ LL | let _ = some_slice.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:39:17 + --> tests/ui/get_unwrap.rs:39:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:39:17 + --> tests/ui/get_unwrap.rs:39:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,13 +52,13 @@ LL | let _ = some_vec.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:40:17 + --> tests/ui/get_unwrap.rs:40:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:40:17 + --> tests/ui/get_unwrap.rs:40:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,13 +67,13 @@ LL | let _ = some_vecdeque.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:41:17 + --> tests/ui/get_unwrap.rs:41:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_hashmap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:41:17 + --> tests/ui/get_unwrap.rs:41:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -82,13 +82,13 @@ LL | let _ = some_hashmap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:42:17 + --> tests/ui/get_unwrap.rs:42:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_btreemap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:42:17 + --> tests/ui/get_unwrap.rs:42:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,13 +97,13 @@ LL | let _ = some_btreemap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:46:21 + --> tests/ui/get_unwrap.rs:46:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:46:22 + --> tests/ui/get_unwrap.rs:46:22 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,13 +112,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:51:9 + --> tests/ui/get_unwrap.rs:51:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:51:10 + --> tests/ui/get_unwrap.rs:51:10 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,13 +127,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:52:9 + --> tests/ui/get_unwrap.rs:52:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:52:10 + --> tests/ui/get_unwrap.rs:52:10 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,13 +142,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:53:9 + --> tests/ui/get_unwrap.rs:53:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:53:10 + --> tests/ui/get_unwrap.rs:53:10 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,13 +157,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:54:9 + --> tests/ui/get_unwrap.rs:54:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:54:10 + --> tests/ui/get_unwrap.rs:54:10 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -172,13 +172,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:66:17 + --> tests/ui/get_unwrap.rs:66:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:66:17 + --> tests/ui/get_unwrap.rs:66:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -187,13 +187,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:67:17 + --> tests/ui/get_unwrap.rs:67:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:67:17 + --> tests/ui/get_unwrap.rs:67:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -202,25 +202,25 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:77:24 + --> tests/ui/get_unwrap.rs:77:24 | LL | let _x: &i32 = f.get(1 + 2).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `&f[1 + 2]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:80:18 + --> tests/ui/get_unwrap.rs:80:18 | LL | let _x = f.get(1 + 2).unwrap().to_string(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `f[1 + 2]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:83:18 + --> tests/ui/get_unwrap.rs:83:18 | LL | let _x = f.get(1 + 2).unwrap().abs(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `f[1 + 2]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:100:33 + --> tests/ui/get_unwrap.rs:100:33 | LL | let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut rest[linidx(j, k) - linidx(i, k) - 1]` diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 6bb980035c1a4..9fff86b86f9f6 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,5 +1,5 @@ error: this operation has no effect - --> $DIR/identity_op.rs:44:5 + --> tests/ui/identity_op.rs:44:5 | LL | x + 0; | ^^^^^ help: consider reducing it to: `x` @@ -8,307 +8,307 @@ LL | x + 0; = help: to override `-D warnings` add `#[allow(clippy::identity_op)]` error: this operation has no effect - --> $DIR/identity_op.rs:46:5 + --> tests/ui/identity_op.rs:46:5 | LL | x + (1 - 1); | ^^^^^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:49:5 + --> tests/ui/identity_op.rs:49:5 | LL | 0 + x; | ^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:53:5 + --> tests/ui/identity_op.rs:53:5 | LL | x | (0); | ^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:57:5 + --> tests/ui/identity_op.rs:57:5 | LL | x * 1; | ^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:59:5 + --> tests/ui/identity_op.rs:59:5 | LL | 1 * x; | ^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:66:5 + --> tests/ui/identity_op.rs:66:5 | LL | -1 & x; | ^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:70:5 + --> tests/ui/identity_op.rs:70:5 | LL | u & 255; | ^^^^^^^ help: consider reducing it to: `u` error: this operation has no effect - --> $DIR/identity_op.rs:74:5 + --> tests/ui/identity_op.rs:74:5 | LL | 42 << 0; | ^^^^^^^ help: consider reducing it to: `42` error: this operation has no effect - --> $DIR/identity_op.rs:76:5 + --> tests/ui/identity_op.rs:76:5 | LL | 1 >> 0; | ^^^^^^ help: consider reducing it to: `1` error: this operation has no effect - --> $DIR/identity_op.rs:78:5 + --> tests/ui/identity_op.rs:78:5 | LL | 42 >> 0; | ^^^^^^^ help: consider reducing it to: `42` error: this operation has no effect - --> $DIR/identity_op.rs:80:5 + --> tests/ui/identity_op.rs:80:5 | LL | &x >> 0; | ^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:82:5 + --> tests/ui/identity_op.rs:82:5 | LL | x >> &0; | ^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:90:5 + --> tests/ui/identity_op.rs:90:5 | LL | 2 % 3; | ^^^^^ help: consider reducing it to: `2` error: this operation has no effect - --> $DIR/identity_op.rs:92:5 + --> tests/ui/identity_op.rs:92:5 | LL | -2 % 3; | ^^^^^^ help: consider reducing it to: `-2` error: this operation has no effect - --> $DIR/identity_op.rs:94:5 + --> tests/ui/identity_op.rs:94:5 | LL | 2 % -3 + x; | ^^^^^^ help: consider reducing it to: `2` error: this operation has no effect - --> $DIR/identity_op.rs:96:5 + --> tests/ui/identity_op.rs:96:5 | LL | -2 % -3 + x; | ^^^^^^^ help: consider reducing it to: `-2` error: this operation has no effect - --> $DIR/identity_op.rs:98:9 + --> tests/ui/identity_op.rs:98:9 | LL | x + 1 % 3; | ^^^^^ help: consider reducing it to: `1` error: this operation has no effect - --> $DIR/identity_op.rs:107:5 + --> tests/ui/identity_op.rs:107:5 | LL | 0 + if b { 1 } else { 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:109:5 + --> tests/ui/identity_op.rs:109:5 | LL | 0 + if b { 1 } else { 2 } + if b { 3 } else { 4 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:111:5 + --> tests/ui/identity_op.rs:111:5 | LL | 0 + match a { 0 => 10, _ => 20 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` error: this operation has no effect - --> $DIR/identity_op.rs:113:5 + --> tests/ui/identity_op.rs:113:5 | LL | 0 + match a { 0 => 10, _ => 20 } + match a { 0 => 30, _ => 40 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` error: this operation has no effect - --> $DIR/identity_op.rs:115:5 + --> tests/ui/identity_op.rs:115:5 | LL | 0 + if b { 1 } else { 2 } + match a { 0 => 30, _ => 40 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:117:5 + --> tests/ui/identity_op.rs:117:5 | LL | 0 + match a { 0 => 10, _ => 20 } + if b { 3 } else { 4 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` error: this operation has no effect - --> $DIR/identity_op.rs:119:5 + --> tests/ui/identity_op.rs:119:5 | LL | (if b { 1 } else { 2 }) + 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:122:5 + --> tests/ui/identity_op.rs:122:5 | LL | 0 + { a } + 3; | ^^^^^^^^^ help: consider reducing it to: `({ a })` error: this operation has no effect - --> $DIR/identity_op.rs:124:5 + --> tests/ui/identity_op.rs:124:5 | LL | 0 + { a } * 2; | ^^^^^^^^^^^^^ help: consider reducing it to: `({ a } * 2)` error: this operation has no effect - --> $DIR/identity_op.rs:126:5 + --> tests/ui/identity_op.rs:126:5 | LL | 0 + loop { let mut c = 0; if c == 10 { break c; } c += 1; } + { a * 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(loop { let mut c = 0; if c == 10 { break c; } c += 1; })` error: this operation has no effect - --> $DIR/identity_op.rs:133:7 + --> tests/ui/identity_op.rs:133:7 | LL | f(1 * a + { 8 * 5 }); | ^^^^^ help: consider reducing it to: `a` error: this operation has no effect - --> $DIR/identity_op.rs:135:7 + --> tests/ui/identity_op.rs:135:7 | LL | f(0 + if b { 1 } else { 2 } + 3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `if b { 1 } else { 2 }` error: this operation has no effect - --> $DIR/identity_op.rs:138:20 + --> tests/ui/identity_op.rs:138:20 | LL | const _: i32 = { 2 * 4 } + 0 + 3; | ^^^^^^^^^^^^^ help: consider reducing it to: `{ 2 * 4 }` error: this operation has no effect - --> $DIR/identity_op.rs:140:20 + --> tests/ui/identity_op.rs:140:20 | LL | const _: i32 = 0 + { 1 + 2 * 3 } + 3; | ^^^^^^^^^^^^^^^^^ help: consider reducing it to: `{ 1 + 2 * 3 }` error: this operation has no effect - --> $DIR/identity_op.rs:143:5 + --> tests/ui/identity_op.rs:143:5 | LL | 0 + a as usize; | ^^^^^^^^^^^^^^ help: consider reducing it to: `a as usize` error: this operation has no effect - --> $DIR/identity_op.rs:145:13 + --> tests/ui/identity_op.rs:145:13 | LL | let _ = 0 + a as usize; | ^^^^^^^^^^^^^^ help: consider reducing it to: `a as usize` error: this operation has no effect - --> $DIR/identity_op.rs:147:5 + --> tests/ui/identity_op.rs:147:5 | LL | 0 + { a } as usize; | ^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `({ a } as usize)` error: this operation has no effect - --> $DIR/identity_op.rs:150:9 + --> tests/ui/identity_op.rs:150:9 | LL | 2 * (0 + { a }); | ^^^^^^^^^^^ help: consider reducing it to: `{ a }` error: this operation has no effect - --> $DIR/identity_op.rs:152:5 + --> tests/ui/identity_op.rs:152:5 | LL | 1 * ({ a } + 4); | ^^^^^^^^^^^^^^^ help: consider reducing it to: `(({ a } + 4))` error: this operation has no effect - --> $DIR/identity_op.rs:154:5 + --> tests/ui/identity_op.rs:154:5 | LL | 1 * 1; | ^^^^^ help: consider reducing it to: `1` error: this operation has no effect - --> $DIR/identity_op.rs:159:18 + --> tests/ui/identity_op.rs:159:18 | LL | let _: i32 = &x + 0; | ^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:164:5 + --> tests/ui/identity_op.rs:164:5 | LL | 0 + if a { 1 } else { 2 } + if b { 3 } else { 5 } | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if a { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:175:22 + --> tests/ui/identity_op.rs:175:22 | LL | let _: i32 = *x + 0; | ^^^^^^ help: consider reducing it to: `*x` error: this operation has no effect - --> $DIR/identity_op.rs:177:22 + --> tests/ui/identity_op.rs:177:22 | LL | let _: i32 = x + 0; | ^^^^^ help: consider reducing it to: `*x` error: this operation has no effect - --> $DIR/identity_op.rs:182:22 + --> tests/ui/identity_op.rs:182:22 | LL | let _: i32 = **x + 0; | ^^^^^^^ help: consider reducing it to: `**x` error: this operation has no effect - --> $DIR/identity_op.rs:185:22 + --> tests/ui/identity_op.rs:185:22 | LL | let _: i32 = *x + 0; | ^^^^^^ help: consider reducing it to: `**x` error: this operation has no effect - --> $DIR/identity_op.rs:191:22 + --> tests/ui/identity_op.rs:191:22 | LL | let _: i32 = ***x + 0; | ^^^^^^^^ help: consider reducing it to: `***x` error: this operation has no effect - --> $DIR/identity_op.rs:193:22 + --> tests/ui/identity_op.rs:193:22 | LL | let _: i32 = **x + 0; | ^^^^^^^ help: consider reducing it to: `***x` error: this operation has no effect - --> $DIR/identity_op.rs:196:22 + --> tests/ui/identity_op.rs:196:22 | LL | let _: i32 = *&x + 0; | ^^^^^^^ help: consider reducing it to: `*&x` error: this operation has no effect - --> $DIR/identity_op.rs:198:22 + --> tests/ui/identity_op.rs:198:22 | LL | let _: i32 = **&&x + 0; | ^^^^^^^^^ help: consider reducing it to: `**&&x` error: this operation has no effect - --> $DIR/identity_op.rs:200:22 + --> tests/ui/identity_op.rs:200:22 | LL | let _: i32 = *&*&x + 0; | ^^^^^^^^^ help: consider reducing it to: `*&*&x` error: this operation has no effect - --> $DIR/identity_op.rs:202:22 + --> tests/ui/identity_op.rs:202:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `**&&*&x` error: this operation has no effect - --> $DIR/identity_op.rs:209:22 + --> tests/ui/identity_op.rs:209:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `***&&*&x` error: this operation has no effect - --> $DIR/identity_op.rs:211:22 + --> tests/ui/identity_op.rs:211:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `***&&*&x` diff --git a/tests/ui/if_let_mutex.stderr b/tests/ui/if_let_mutex.stderr index 8934294430b25..6e0115c23af68 100644 --- a/tests/ui/if_let_mutex.stderr +++ b/tests/ui/if_let_mutex.stderr @@ -1,5 +1,5 @@ error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock - --> $DIR/if_let_mutex.rs:10:5 + --> tests/ui/if_let_mutex.rs:10:5 | LL | if let Err(locked) = m.lock() { | ^ - this Mutex will remain locked for the entire `if let`-block... @@ -19,7 +19,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::if_let_mutex)]` error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock - --> $DIR/if_let_mutex.rs:23:5 + --> tests/ui/if_let_mutex.rs:23:5 | LL | if let Some(locked) = m.lock().unwrap().deref() { | ^ - this Mutex will remain locked for the entire `if let`-block... @@ -37,7 +37,7 @@ LL | | }; = help: move the lock call outside of the `if let ...` expression error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock - --> $DIR/if_let_mutex.rs:45:5 + --> tests/ui/if_let_mutex.rs:45:5 | LL | if let Ok(i) = mutex.lock() { | ^ ----- this Mutex will remain locked for the entire `if let`-block... diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index 8b86f82fa8ee0..92fed7b1bf700 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,5 +1,5 @@ error: unnecessary boolean `not` operation - --> $DIR/if_not_else.rs:12:5 + --> tests/ui/if_not_else.rs:12:5 | LL | / if !bla() { LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::if_not_else)]` error: unnecessary `!=` operation - --> $DIR/if_not_else.rs:18:5 + --> tests/ui/if_not_else.rs:18:5 | LL | / if 4 != 5 { LL | | diff --git a/tests/ui/if_same_then_else.stderr b/tests/ui/if_same_then_else.stderr index 281f30f88b46d..b76da3fb1cb58 100644 --- a/tests/ui/if_same_then_else.stderr +++ b/tests/ui/if_same_then_else.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:23:13 + --> tests/ui/if_same_then_else.rs:23:13 | LL | if true { | _____________^ @@ -12,7 +12,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:31:12 + --> tests/ui/if_same_then_else.rs:31:12 | LL | } else { | ____________^ @@ -27,43 +27,43 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]` error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:67:21 + --> tests/ui/if_same_then_else.rs:67:21 | LL | let _ = if true { 0.0 } else { 0.0 }; | ^^^^^^^ | note: same as this - --> $DIR/if_same_then_else.rs:67:34 + --> tests/ui/if_same_then_else.rs:67:34 | LL | let _ = if true { 0.0 } else { 0.0 }; | ^^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:70:21 + --> tests/ui/if_same_then_else.rs:70:21 | LL | let _ = if true { -0.0 } else { -0.0 }; | ^^^^^^^^ | note: same as this - --> $DIR/if_same_then_else.rs:70:35 + --> tests/ui/if_same_then_else.rs:70:35 | LL | let _ = if true { -0.0 } else { -0.0 }; | ^^^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:82:21 + --> tests/ui/if_same_then_else.rs:82:21 | LL | let _ = if true { 42 } else { 42 }; | ^^^^^^ | note: same as this - --> $DIR/if_same_then_else.rs:82:33 + --> tests/ui/if_same_then_else.rs:82:33 | LL | let _ = if true { 42 } else { 42 }; | ^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:85:13 + --> tests/ui/if_same_then_else.rs:85:13 | LL | if true { | _____________^ @@ -76,7 +76,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:92:12 + --> tests/ui/if_same_then_else.rs:92:12 | LL | } else { | ____________^ @@ -89,7 +89,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:238:14 + --> tests/ui/if_same_then_else.rs:238:14 | LL | if x { | ______________^ @@ -98,7 +98,7 @@ LL | | } else { | |_________^ | note: same as this - --> $DIR/if_same_then_else.rs:240:16 + --> tests/ui/if_same_then_else.rs:240:16 | LL | } else { | ________________^ diff --git a/tests/ui/if_same_then_else2.stderr b/tests/ui/if_same_then_else2.stderr index 4e7a7c87dc54b..93507eb2c6fde 100644 --- a/tests/ui/if_same_then_else2.stderr +++ b/tests/ui/if_same_then_else2.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:15:13 + --> tests/ui/if_same_then_else2.rs:15:13 | LL | if true { | _____________^ @@ -12,7 +12,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:24:12 + --> tests/ui/if_same_then_else2.rs:24:12 | LL | } else { | ____________^ @@ -27,7 +27,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]` error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:36:13 + --> tests/ui/if_same_then_else2.rs:36:13 | LL | if true { | _____________^ @@ -36,7 +36,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:38:12 + --> tests/ui/if_same_then_else2.rs:38:12 | LL | } else { | ____________^ @@ -45,7 +45,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:43:13 + --> tests/ui/if_same_then_else2.rs:43:13 | LL | if true { | _____________^ @@ -54,7 +54,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:45:12 + --> tests/ui/if_same_then_else2.rs:45:12 | LL | } else { | ____________^ @@ -63,19 +63,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:93:21 + --> tests/ui/if_same_then_else2.rs:93:21 | LL | let _ = if true { f32::NAN } else { f32::NAN }; | ^^^^^^^^^^^^ | note: same as this - --> $DIR/if_same_then_else2.rs:93:39 + --> tests/ui/if_same_then_else2.rs:93:39 | LL | let _ = if true { f32::NAN } else { f32::NAN }; | ^^^^^^^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:96:13 + --> tests/ui/if_same_then_else2.rs:96:13 | LL | if true { | _____________^ @@ -84,7 +84,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:98:12 + --> tests/ui/if_same_then_else2.rs:98:12 | LL | } else { | ____________^ @@ -93,7 +93,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:120:20 + --> tests/ui/if_same_then_else2.rs:120:20 | LL | } else if true { | ____________________^ @@ -103,7 +103,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:123:12 + --> tests/ui/if_same_then_else2.rs:123:12 | LL | } else { | ____________^ diff --git a/tests/ui/if_then_some_else_none.stderr b/tests/ui/if_then_some_else_none.stderr index 9b3d65cc803ac..e0a95aebdc134 100644 --- a/tests/ui/if_then_some_else_none.stderr +++ b/tests/ui/if_then_some_else_none.stderr @@ -1,5 +1,5 @@ error: this could be simplified with `bool::then` - --> $DIR/if_then_some_else_none.rs:6:13 + --> tests/ui/if_then_some_else_none.rs:6:13 | LL | let _ = if foo() { | _____________^ @@ -16,7 +16,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::if_then_some_else_none)]` error: this could be simplified with `bool::then` - --> $DIR/if_then_some_else_none.rs:15:13 + --> tests/ui/if_then_some_else_none.rs:15:13 | LL | let _ = if matches!(true, true) { | _____________^ @@ -31,7 +31,7 @@ LL | | }; = help: consider using `bool::then` like: `matches!(true, true).then(|| { /* snippet */ matches!(true, false) })` error: this could be simplified with `bool::then_some` - --> $DIR/if_then_some_else_none.rs:25:28 + --> tests/ui/if_then_some_else_none.rs:25:28 | LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); = help: consider using `bool::then_some` like: `(o < 32).then_some(o)` error: this could be simplified with `bool::then_some` - --> $DIR/if_then_some_else_none.rs:30:13 + --> tests/ui/if_then_some_else_none.rs:30:13 | LL | let _ = if !x { Some(0) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | let _ = if !x { Some(0) } else { None }; = help: consider using `bool::then_some` like: `(!x).then_some(0)` error: this could be simplified with `bool::then` - --> $DIR/if_then_some_else_none.rs:86:13 + --> tests/ui/if_then_some_else_none.rs:86:13 | LL | let _ = if foo() { | _____________^ diff --git a/tests/ui/ifs_same_cond.stderr b/tests/ui/ifs_same_cond.stderr index c5cd6b2c42e5a..81fbb921e8463 100644 --- a/tests/ui/ifs_same_cond.stderr +++ b/tests/ui/ifs_same_cond.stderr @@ -1,11 +1,11 @@ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:14:15 + --> tests/ui/ifs_same_cond.rs:14:15 | LL | } else if b { | ^ | note: same as this - --> $DIR/ifs_same_cond.rs:13:8 + --> tests/ui/ifs_same_cond.rs:13:8 | LL | if b { | ^ @@ -13,37 +13,37 @@ LL | if b { = help: to override `-D warnings` add `#[allow(clippy::ifs_same_cond)]` error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:19:15 + --> tests/ui/ifs_same_cond.rs:19:15 | LL | } else if a == 1 { | ^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:18:8 + --> tests/ui/ifs_same_cond.rs:18:8 | LL | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:25:15 + --> tests/ui/ifs_same_cond.rs:25:15 | LL | } else if 2 * a == 1 { | ^^^^^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:23:8 + --> tests/ui/ifs_same_cond.rs:23:8 | LL | if 2 * a == 1 { | ^^^^^^^^^^ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:58:15 + --> tests/ui/ifs_same_cond.rs:58:15 | LL | } else if a.contains("ah") { | ^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:57:8 + --> tests/ui/ifs_same_cond.rs:57:8 | LL | if a.contains("ah") { | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/ignored_unit_patterns.stderr b/tests/ui/ignored_unit_patterns.stderr index 18ca7ebbcf2c4..00a254e39192c 100644 --- a/tests/ui/ignored_unit_patterns.stderr +++ b/tests/ui/ignored_unit_patterns.stderr @@ -1,5 +1,5 @@ error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:16:12 + --> tests/ui/ignored_unit_patterns.rs:16:12 | LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` @@ -8,49 +8,49 @@ LL | Ok(_) => {}, = help: to override `-D warnings` add `#[allow(clippy::ignored_unit_patterns)]` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:17:13 + --> tests/ui/ignored_unit_patterns.rs:17:13 | LL | Err(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:19:15 + --> tests/ui/ignored_unit_patterns.rs:19:15 | LL | if let Ok(_) = foo() {} | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:21:28 + --> tests/ui/ignored_unit_patterns.rs:21:28 | LL | let _ = foo().map_err(|_| todo!()); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:27:16 + --> tests/ui/ignored_unit_patterns.rs:27:16 | LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:29:17 + --> tests/ui/ignored_unit_patterns.rs:29:17 | LL | Err(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:41:9 + --> tests/ui/ignored_unit_patterns.rs:41:9 | LL | let _ = foo().unwrap(); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:50:13 + --> tests/ui/ignored_unit_patterns.rs:50:13 | LL | (1, _) => unimplemented!(), | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:57:13 + --> tests/ui/ignored_unit_patterns.rs:57:13 | LL | for (x, _) in v { | ^ help: use `()` instead of `_`: `()` diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index 833a106062a38..bb906957a0d33 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,5 +1,5 @@ error: multiple implementations of this structure - --> $DIR/impl.rs:10:1 + --> tests/ui/impl.rs:10:1 | LL | / impl MyStruct { LL | | @@ -8,7 +8,7 @@ LL | | } | |_^ | note: first implementation here - --> $DIR/impl.rs:6:1 + --> tests/ui/impl.rs:6:1 | LL | / impl MyStruct { LL | | fn first() {} @@ -18,7 +18,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::multiple_inherent_impl)]` error: multiple implementations of this structure - --> $DIR/impl.rs:25:5 + --> tests/ui/impl.rs:25:5 | LL | / impl super::MyStruct { LL | | @@ -27,7 +27,7 @@ LL | | } | |_____^ | note: first implementation here - --> $DIR/impl.rs:6:1 + --> tests/ui/impl.rs:6:1 | LL | / impl MyStruct { LL | | fn first() {} @@ -35,7 +35,7 @@ LL | | } | |_^ error: multiple implementations of this structure - --> $DIR/impl.rs:46:1 + --> tests/ui/impl.rs:46:1 | LL | / impl WithArgs { LL | | @@ -44,7 +44,7 @@ LL | | } | |_^ | note: first implementation here - --> $DIR/impl.rs:43:1 + --> tests/ui/impl.rs:43:1 | LL | / impl WithArgs { LL | | fn f2() {} @@ -52,13 +52,13 @@ LL | | } | |_^ error: multiple implementations of this structure - --> $DIR/impl.rs:68:1 + --> tests/ui/impl.rs:68:1 | LL | impl OneAllowedImpl {} // Lint, only one of the three blocks is allowed. | ^^^^^^^^^^^^^^^^^^^^^^ | note: first implementation here - --> $DIR/impl.rs:65:1 + --> tests/ui/impl.rs:65:1 | LL | impl OneAllowedImpl {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr b/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr index afc35ef98459b..7328f563ce13d 100644 --- a/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr +++ b/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr @@ -1,5 +1,5 @@ error: the semantics of `Borrow` around `Hash` can't be satisfied when both `Borrow` and `Borrow<[u8]>` are implemented - --> $DIR/impl_hash_with_borrow_str_and_bytes.rs:10:6 + --> tests/ui/impl_hash_with_borrow_str_and_bytes.rs:10:6 | LL | impl Hash for ExampleType { | ^^^^ @@ -13,7 +13,7 @@ LL | impl Hash for ExampleType { = help: to override `-D warnings` add `#[allow(clippy::impl_hash_borrow_with_str_and_bytes)]` error: the semantics of `Borrow` around `Hash` can't be satisfied when both `Borrow` and `Borrow<[u8]>` are implemented - --> $DIR/impl_hash_with_borrow_str_and_bytes.rs:73:10 + --> tests/ui/impl_hash_with_borrow_str_and_bytes.rs:73:10 | LL | #[derive(Hash)] | ^^^^ @@ -26,7 +26,7 @@ LL | #[derive(Hash)] = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) error: the semantics of `Borrow` around `Hash` can't be satisfied when both `Borrow` and `Borrow<[u8]>` are implemented - --> $DIR/impl_hash_with_borrow_str_and_bytes.rs:117:6 + --> tests/ui/impl_hash_with_borrow_str_and_bytes.rs:117:6 | LL | impl Hash for GenericExampleType2 { | ^^^^ diff --git a/tests/ui/impl_trait_in_params.stderr b/tests/ui/impl_trait_in_params.stderr index 0ae7a3672d190..0ec0a34ea8db9 100644 --- a/tests/ui/impl_trait_in_params.stderr +++ b/tests/ui/impl_trait_in_params.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:9:13 + --> tests/ui/impl_trait_in_params.rs:9:13 | LL | pub fn a(_: impl Trait) {} | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | pub fn a<{ /* Generic name */ }: Trait>(_: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:11:29 + --> tests/ui/impl_trait_in_params.rs:11:29 | LL | pub fn c(_: C, _: impl Trait) {} | ^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | pub fn c(_: C, _: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:36:17 + --> tests/ui/impl_trait_in_params.rs:36:17 | LL | pub fn h(_: impl Trait) {} | ^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | pub fn h<{ /* Generic name */ }: Trait>(_: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:39:45 + --> tests/ui/impl_trait_in_params.rs:39:45 | LL | pub fn k>(_: K, _: impl AnotherTrait) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/implicit_clone.stderr b/tests/ui/implicit_clone.stderr index 64c31e65175ab..31c212eba2c8d 100644 --- a/tests/ui/implicit_clone.stderr +++ b/tests/ui/implicit_clone.stderr @@ -1,5 +1,5 @@ error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:65:13 + --> tests/ui/implicit_clone.rs:65:13 | LL | let _ = vec.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `vec.clone()` @@ -8,61 +8,61 @@ LL | let _ = vec.to_owned(); = help: to override `-D warnings` add `#[allow(clippy::implicit_clone)]` error: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type - --> $DIR/implicit_clone.rs:66:13 + --> tests/ui/implicit_clone.rs:66:13 | LL | let _ = vec.to_vec(); | ^^^^^^^^^^^^ help: consider using: `vec.clone()` error: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type - --> $DIR/implicit_clone.rs:71:13 + --> tests/ui/implicit_clone.rs:71:13 | LL | let _ = vec_ref.to_vec(); | ^^^^^^^^^^^^^^^^ help: consider using: `vec_ref.clone()` error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:83:13 + --> tests/ui/implicit_clone.rs:83:13 | LL | let _ = str.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `str.clone()` error: implicitly cloning a `Kitten` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:87:13 + --> tests/ui/implicit_clone.rs:87:13 | LL | let _ = kitten.to_owned(); | ^^^^^^^^^^^^^^^^^ help: consider using: `kitten.clone()` error: implicitly cloning a `PathBuf` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:97:13 + --> tests/ui/implicit_clone.rs:97:13 | LL | let _ = pathbuf.to_owned(); | ^^^^^^^^^^^^^^^^^^ help: consider using: `pathbuf.clone()` error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type - --> $DIR/implicit_clone.rs:98:13 + --> tests/ui/implicit_clone.rs:98:13 | LL | let _ = pathbuf.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `pathbuf.clone()` error: implicitly cloning a `OsString` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:101:13 + --> tests/ui/implicit_clone.rs:101:13 | LL | let _ = os_string.to_owned(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `os_string.clone()` error: implicitly cloning a `OsString` by calling `to_os_string` on its dereferenced type - --> $DIR/implicit_clone.rs:102:13 + --> tests/ui/implicit_clone.rs:102:13 | LL | let _ = os_string.to_os_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `os_string.clone()` error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type - --> $DIR/implicit_clone.rs:113:13 + --> tests/ui/implicit_clone.rs:113:13 | LL | let _ = pathbuf_ref.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(*pathbuf_ref).clone()` error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type - --> $DIR/implicit_clone.rs:116:13 + --> tests/ui/implicit_clone.rs:116:13 | LL | let _ = pathbuf_ref.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(**pathbuf_ref).clone()` diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index a27590288bc48..a3df8edf389be 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -1,29 +1,29 @@ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:14:1 + --> tests/ui/implicit_hasher.rs:14:1 | LL | pub trait Foo: Sized { | ^^^^^^^^^^^^^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:71:1 + --> tests/ui/implicit_hasher.rs:71:1 | LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:74:1 + --> tests/ui/implicit_hasher.rs:74:1 | LL | pub mod gen { | ^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:92:1 + --> tests/ui/implicit_hasher.rs:92:1 | LL | pub mod test_macro; | ^^^^^^^^^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:96:1 + --> tests/ui/implicit_hasher.rs:96:1 | LL | external! { | ^^^^^^^^^ @@ -31,7 +31,7 @@ LL | external! { = note: this error originates in the macro `external` (in Nightly builds, run with -Z macro-backtrace for more info) error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:101:1 + --> tests/ui/implicit_hasher.rs:101:1 | LL | pub async fn election_vote(_data: HashMap) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index 1edc6cc6f7788..3ffed273e0f16 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -1,5 +1,5 @@ error: missing `return` statement - --> $DIR/implicit_return.rs:11:5 + --> tests/ui/implicit_return.rs:11:5 | LL | true | ^^^^ help: add `return` as shown: `return true` @@ -8,85 +8,85 @@ LL | true = help: to override `-D warnings` add `#[allow(clippy::implicit_return)]` error: missing `return` statement - --> $DIR/implicit_return.rs:15:15 + --> tests/ui/implicit_return.rs:15:15 | LL | if true { true } else { false } | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:15:29 + --> tests/ui/implicit_return.rs:15:29 | LL | if true { true } else { false } | ^^^^^ help: add `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:21:17 + --> tests/ui/implicit_return.rs:21:17 | LL | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:22:20 + --> tests/ui/implicit_return.rs:22:20 | LL | false => { true }, | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:35:9 + --> tests/ui/implicit_return.rs:35:9 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:42:13 + --> tests/ui/implicit_return.rs:42:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:50:13 + --> tests/ui/implicit_return.rs:50:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:68:18 + --> tests/ui/implicit_return.rs:68:18 | LL | let _ = || { true }; | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:69:16 + --> tests/ui/implicit_return.rs:69:16 | LL | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:77:5 + --> tests/ui/implicit_return.rs:77:5 | LL | format!("test {}", "test") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")` error: missing `return` statement - --> $DIR/implicit_return.rs:86:5 + --> tests/ui/implicit_return.rs:86:5 | LL | m!(true, false) | ^^^^^^^^^^^^^^^ help: add `return` as shown: `return m!(true, false)` error: missing `return` statement - --> $DIR/implicit_return.rs:92:13 + --> tests/ui/implicit_return.rs:92:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:97:17 + --> tests/ui/implicit_return.rs:97:17 | LL | break 'outer false; | ^^^^^^^^^^^^^^^^^^ help: change `break` to `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:112:5 + --> tests/ui/implicit_return.rs:112:5 | LL | / loop { LL | | m!(true); @@ -101,7 +101,7 @@ LL + } | error: missing `return` statement - --> $DIR/implicit_return.rs:126:5 + --> tests/ui/implicit_return.rs:126:5 | LL | true | ^^^^ help: add `return` as shown: `return true` diff --git a/tests/ui/implicit_saturating_add.stderr b/tests/ui/implicit_saturating_add.stderr index 7119c8bf6fad0..4fb9282bc91db 100644 --- a/tests/ui/implicit_saturating_add.stderr +++ b/tests/ui/implicit_saturating_add.stderr @@ -1,5 +1,5 @@ error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:21:5 + --> tests/ui/implicit_saturating_add.rs:21:5 | LL | / if u_8 != u8::MAX { LL | | u_8 += 1; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_add)]` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:25:5 + --> tests/ui/implicit_saturating_add.rs:25:5 | LL | / if u_8 < u8::MAX { LL | | u_8 += 1; @@ -18,7 +18,7 @@ LL | | } | |_____^ help: use instead: `u_8 = u_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:33:5 + --> tests/ui/implicit_saturating_add.rs:33:5 | LL | / if u_16 != u16::MAX { LL | | u_16 += 1; @@ -26,7 +26,7 @@ LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:37:5 + --> tests/ui/implicit_saturating_add.rs:37:5 | LL | / if u_16 < u16::MAX { LL | | u_16 += 1; @@ -34,7 +34,7 @@ LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:41:5 + --> tests/ui/implicit_saturating_add.rs:41:5 | LL | / if u16::MAX > u_16 { LL | | u_16 += 1; @@ -42,7 +42,7 @@ LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:45:5 + --> tests/ui/implicit_saturating_add.rs:45:5 | LL | / if u_32 != u32::MAX { LL | | u_32 += 1; @@ -50,7 +50,7 @@ LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:49:5 + --> tests/ui/implicit_saturating_add.rs:49:5 | LL | / if u_32 < u32::MAX { LL | | u_32 += 1; @@ -58,7 +58,7 @@ LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:53:5 + --> tests/ui/implicit_saturating_add.rs:53:5 | LL | / if u32::MAX > u_32 { LL | | u_32 += 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:57:5 + --> tests/ui/implicit_saturating_add.rs:57:5 | LL | / if u_64 != u64::MAX { LL | | u_64 += 1; @@ -74,7 +74,7 @@ LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:61:5 + --> tests/ui/implicit_saturating_add.rs:61:5 | LL | / if u_64 < u64::MAX { LL | | u_64 += 1; @@ -82,7 +82,7 @@ LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:65:5 + --> tests/ui/implicit_saturating_add.rs:65:5 | LL | / if u64::MAX > u_64 { LL | | u_64 += 1; @@ -90,7 +90,7 @@ LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:69:5 + --> tests/ui/implicit_saturating_add.rs:69:5 | LL | / if i_8 != i8::MAX { LL | | i_8 += 1; @@ -98,7 +98,7 @@ LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:73:5 + --> tests/ui/implicit_saturating_add.rs:73:5 | LL | / if i_8 < i8::MAX { LL | | i_8 += 1; @@ -106,7 +106,7 @@ LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:77:5 + --> tests/ui/implicit_saturating_add.rs:77:5 | LL | / if i8::MAX > i_8 { LL | | i_8 += 1; @@ -114,7 +114,7 @@ LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:81:5 + --> tests/ui/implicit_saturating_add.rs:81:5 | LL | / if i_16 != i16::MAX { LL | | i_16 += 1; @@ -122,7 +122,7 @@ LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:85:5 + --> tests/ui/implicit_saturating_add.rs:85:5 | LL | / if i_16 < i16::MAX { LL | | i_16 += 1; @@ -130,7 +130,7 @@ LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:89:5 + --> tests/ui/implicit_saturating_add.rs:89:5 | LL | / if i16::MAX > i_16 { LL | | i_16 += 1; @@ -138,7 +138,7 @@ LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:93:5 + --> tests/ui/implicit_saturating_add.rs:93:5 | LL | / if i_32 != i32::MAX { LL | | i_32 += 1; @@ -146,7 +146,7 @@ LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:97:5 + --> tests/ui/implicit_saturating_add.rs:97:5 | LL | / if i_32 < i32::MAX { LL | | i_32 += 1; @@ -154,7 +154,7 @@ LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:101:5 + --> tests/ui/implicit_saturating_add.rs:101:5 | LL | / if i32::MAX > i_32 { LL | | i_32 += 1; @@ -162,7 +162,7 @@ LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:105:5 + --> tests/ui/implicit_saturating_add.rs:105:5 | LL | / if i_64 != i64::MAX { LL | | i_64 += 1; @@ -170,7 +170,7 @@ LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:109:5 + --> tests/ui/implicit_saturating_add.rs:109:5 | LL | / if i_64 < i64::MAX { LL | | i_64 += 1; @@ -178,7 +178,7 @@ LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:113:5 + --> tests/ui/implicit_saturating_add.rs:113:5 | LL | / if i64::MAX > i_64 { LL | | i_64 += 1; @@ -186,7 +186,7 @@ LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:149:12 + --> tests/ui/implicit_saturating_add.rs:149:12 | LL | } else if u_32 < u32::MAX { | ____________^ diff --git a/tests/ui/implicit_saturating_sub.stderr b/tests/ui/implicit_saturating_sub.stderr index 6e026d1a69875..59a9ddbff2d6e 100644 --- a/tests/ui/implicit_saturating_sub.stderr +++ b/tests/ui/implicit_saturating_sub.stderr @@ -1,5 +1,5 @@ error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:27:5 + --> tests/ui/implicit_saturating_sub.rs:27:5 | LL | / if u_8 > 0 { LL | | u_8 = u_8 - 1; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:34:13 + --> tests/ui/implicit_saturating_sub.rs:34:13 | LL | / if u_8 > 0 { LL | | u_8 -= 1; @@ -18,7 +18,7 @@ LL | | } | |_____________^ help: try: `u_8 = u_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:48:5 + --> tests/ui/implicit_saturating_sub.rs:48:5 | LL | / if u_16 > 0 { LL | | u_16 -= 1; @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try: `u_16 = u_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:58:5 + --> tests/ui/implicit_saturating_sub.rs:58:5 | LL | / if u_32 != 0 { LL | | u_32 -= 1; @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try: `u_32 = u_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:79:5 + --> tests/ui/implicit_saturating_sub.rs:79:5 | LL | / if u_64 > 0 { LL | | u_64 -= 1; @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:84:5 + --> tests/ui/implicit_saturating_sub.rs:84:5 | LL | / if 0 < u_64 { LL | | u_64 -= 1; @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:89:5 + --> tests/ui/implicit_saturating_sub.rs:89:5 | LL | / if 0 != u_64 { LL | | u_64 -= 1; @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:110:5 + --> tests/ui/implicit_saturating_sub.rs:110:5 | LL | / if u_usize > 0 { LL | | u_usize -= 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try: `u_usize = u_usize.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:122:5 + --> tests/ui/implicit_saturating_sub.rs:122:5 | LL | / if i_8 > i8::MIN { LL | | i_8 -= 1; @@ -74,7 +74,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:127:5 + --> tests/ui/implicit_saturating_sub.rs:127:5 | LL | / if i_8 > i8::MIN { LL | | i_8 -= 1; @@ -82,7 +82,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:132:5 + --> tests/ui/implicit_saturating_sub.rs:132:5 | LL | / if i_8 != i8::MIN { LL | | i_8 -= 1; @@ -90,7 +90,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:137:5 + --> tests/ui/implicit_saturating_sub.rs:137:5 | LL | / if i_8 != i8::MIN { LL | | i_8 -= 1; @@ -98,7 +98,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:147:5 + --> tests/ui/implicit_saturating_sub.rs:147:5 | LL | / if i_16 > i16::MIN { LL | | i_16 -= 1; @@ -106,7 +106,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:152:5 + --> tests/ui/implicit_saturating_sub.rs:152:5 | LL | / if i_16 > i16::MIN { LL | | i_16 -= 1; @@ -114,7 +114,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:157:5 + --> tests/ui/implicit_saturating_sub.rs:157:5 | LL | / if i_16 != i16::MIN { LL | | i_16 -= 1; @@ -122,7 +122,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:162:5 + --> tests/ui/implicit_saturating_sub.rs:162:5 | LL | / if i_16 != i16::MIN { LL | | i_16 -= 1; @@ -130,7 +130,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:172:5 + --> tests/ui/implicit_saturating_sub.rs:172:5 | LL | / if i_32 > i32::MIN { LL | | i_32 -= 1; @@ -138,7 +138,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:177:5 + --> tests/ui/implicit_saturating_sub.rs:177:5 | LL | / if i_32 > i32::MIN { LL | | i_32 -= 1; @@ -146,7 +146,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:182:5 + --> tests/ui/implicit_saturating_sub.rs:182:5 | LL | / if i_32 != i32::MIN { LL | | i_32 -= 1; @@ -154,7 +154,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:187:5 + --> tests/ui/implicit_saturating_sub.rs:187:5 | LL | / if i_32 != i32::MIN { LL | | i_32 -= 1; @@ -162,7 +162,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:197:5 + --> tests/ui/implicit_saturating_sub.rs:197:5 | LL | / if i64::MIN < i_64 { LL | | i_64 -= 1; @@ -170,7 +170,7 @@ LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:202:5 + --> tests/ui/implicit_saturating_sub.rs:202:5 | LL | / if i64::MIN != i_64 { LL | | i_64 -= 1; @@ -178,7 +178,7 @@ LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:207:5 + --> tests/ui/implicit_saturating_sub.rs:207:5 | LL | / if i64::MIN < i_64 { LL | | i_64 -= 1; diff --git a/tests/ui/implied_bounds_in_impls.stderr b/tests/ui/implied_bounds_in_impls.stderr index 3b09e4582e30d..fa1938f77d9df 100644 --- a/tests/ui/implied_bounds_in_impls.stderr +++ b/tests/ui/implied_bounds_in_impls.stderr @@ -1,5 +1,5 @@ error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:12:36 + --> tests/ui/implied_bounds_in_impls.rs:12:36 | LL | fn deref_derefmut(x: T) -> impl Deref + DerefMut { | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + fn deref_derefmut(x: T) -> impl DerefMut { | error: this bound is already specified as the supertrait of `GenericSubtrait` - --> $DIR/implied_bounds_in_impls.rs:29:37 + --> tests/ui/implied_bounds_in_impls.rs:29:37 | LL | fn generics_implied() -> impl GenericTrait + GenericSubtrait | ^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + fn generics_implied() -> impl GenericSubtrait | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, V>` - --> $DIR/implied_bounds_in_impls.rs:35:40 + --> tests/ui/implied_bounds_in_impls.rs:35:40 | LL | fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + fn generics_implied_multi() -> impl GenericTrait2 + GenericSubtrait<( | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, V>` - --> $DIR/implied_bounds_in_impls.rs:35:60 + --> tests/ui/implied_bounds_in_impls.rs:35:60 | LL | fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + fn generics_implied_multi() -> impl GenericTrait + GenericSubtrait< | error: this bound is already specified as the supertrait of `GenericSubtrait<(), T, V>` - --> $DIR/implied_bounds_in_impls.rs:37:44 + --> tests/ui/implied_bounds_in_impls.rs:37:44 | LL | fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> | ^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + fn generics_implied_multi2() -> impl GenericTrait2 + GenericSubtra | error: this bound is already specified as the supertrait of `GenericSubtrait<(), T, V>` - --> $DIR/implied_bounds_in_impls.rs:37:62 + --> tests/ui/implied_bounds_in_impls.rs:37:62 | LL | fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + fn generics_implied_multi2() -> impl GenericTrait + GenericSubtrai | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, ()>` - --> $DIR/implied_bounds_in_impls.rs:47:28 + --> tests/ui/implied_bounds_in_impls.rs:47:28 | LL | fn generics_same() -> impl GenericTrait + GenericSubtrait<(), i32, ()> {} | ^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + fn generics_same() -> impl GenericSubtrait<(), i32, ()> {} | error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:51:20 + --> tests/ui/implied_bounds_in_impls.rs:51:20 | LL | fn f() -> impl Deref + DerefMut; | ^^^^^ @@ -97,7 +97,7 @@ LL + fn f() -> impl DerefMut; | error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:56:20 + --> tests/ui/implied_bounds_in_impls.rs:56:20 | LL | fn f() -> impl Deref + DerefMut { | ^^^^^ @@ -109,7 +109,7 @@ LL + fn f() -> impl DerefMut { | error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:62:20 + --> tests/ui/implied_bounds_in_impls.rs:62:20 | LL | fn f() -> impl Deref + DerefMut { | ^^^^^ @@ -121,7 +121,7 @@ LL + fn f() -> impl DerefMut { | error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/implied_bounds_in_impls.rs:73:41 + --> tests/ui/implied_bounds_in_impls.rs:73:41 | LL | fn default_generic_param1() -> impl PartialEq + PartialOrd + Debug {} | ^^^^^^^^^ @@ -133,7 +133,7 @@ LL + fn default_generic_param1() -> impl PartialOrd + Debug {} | error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/implied_bounds_in_impls.rs:74:54 + --> tests/ui/implied_bounds_in_impls.rs:74:54 | LL | fn default_generic_param2() -> impl PartialOrd + PartialEq + Debug {} | ^^^^^^^^^ @@ -145,7 +145,7 @@ LL + fn default_generic_param2() -> impl PartialOrd + Debug {} | error: this bound is already specified as the supertrait of `DoubleEndedIterator` - --> $DIR/implied_bounds_in_impls.rs:87:26 + --> tests/ui/implied_bounds_in_impls.rs:87:26 | LL | fn my_iter() -> impl Iterator + DoubleEndedIterator { | ^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + fn my_iter() -> impl DoubleEndedIterator { | error: this bound is already specified as the supertrait of `Copy` - --> $DIR/implied_bounds_in_impls.rs:92:27 + --> tests/ui/implied_bounds_in_impls.rs:92:27 | LL | fn f() -> impl Copy + Clone { | ^^^^^ @@ -169,7 +169,7 @@ LL + fn f() -> impl Copy { | error: this bound is already specified as the supertrait of `Trait2` - --> $DIR/implied_bounds_in_impls.rs:106:21 + --> tests/ui/implied_bounds_in_impls.rs:106:21 | LL | fn f2() -> impl Trait1 + Trait2 {} | ^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + fn f2() -> impl Trait2 {} | error: this bound is already specified as the supertrait of `Trait4` - --> $DIR/implied_bounds_in_impls.rs:121:21 + --> tests/ui/implied_bounds_in_impls.rs:121:21 | LL | fn f3() -> impl Trait3 + Trait4 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL + fn f3() -> impl Trait4 {} | error: this bound is already specified as the supertrait of `Y` - --> $DIR/implied_bounds_in_impls.rs:148:21 + --> tests/ui/implied_bounds_in_impls.rs:148:21 | LL | fn f3() -> impl X + Y {} | ^ @@ -205,7 +205,7 @@ LL + fn f3() -> impl Y {} | error: this bound is already specified as the supertrait of `Y` - --> $DIR/implied_bounds_in_impls.rs:149:21 + --> tests/ui/implied_bounds_in_impls.rs:149:21 | LL | fn f4() -> impl X + Y {} | ^ @@ -217,7 +217,7 @@ LL + fn f4() -> impl Y {} | error: this bound is already specified as the supertrait of `Y` - --> $DIR/implied_bounds_in_impls.rs:150:21 + --> tests/ui/implied_bounds_in_impls.rs:150:21 | LL | fn f5() -> impl X + Y {} | ^^^^^^^^^^^^^ diff --git a/tests/ui/incompatible_msrv.stderr b/tests/ui/incompatible_msrv.stderr index 9e1c81b82bcd0..34f01c3e14a17 100644 --- a/tests/ui/incompatible_msrv.stderr +++ b/tests/ui/incompatible_msrv.stderr @@ -1,5 +1,5 @@ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.10.0` - --> $DIR/incompatible_msrv.rs:13:39 + --> tests/ui/incompatible_msrv.rs:13:39 | LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); | ^^^^^ @@ -8,13 +8,13 @@ LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); = help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]` error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.12.0` - --> $DIR/incompatible_msrv.rs:16:11 + --> tests/ui/incompatible_msrv.rs:16:11 | LL | v.into_key(); | ^^^^^^^^^^ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.4.0` - --> $DIR/incompatible_msrv.rs:20:5 + --> tests/ui/incompatible_msrv.rs:20:5 | LL | sleep(Duration::new(1, 0)); | ^^^^^ diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index 6aeb33edafd3c..173b824935c8f 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -1,5 +1,5 @@ error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:16 + --> tests/ui/inconsistent_digit_grouping.rs:25:16 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` @@ -8,61 +8,61 @@ LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:26 + --> tests/ui/inconsistent_digit_grouping.rs:25:26 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^ help: consider: `12_345_678` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:38 + --> tests/ui/inconsistent_digit_grouping.rs:25:38 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `1_234_567` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:48 + --> tests/ui/inconsistent_digit_grouping.rs:25:48 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:64 + --> tests/ui/inconsistent_digit_grouping.rs:25:64 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32` error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:28:13 + --> tests/ui/inconsistent_digit_grouping.rs:28:13 | LL | let _ = 0x100000; | ^^^^^^^^ help: consider: `0x0010_0000` | note: the lint level is defined here - --> $DIR/inconsistent_digit_grouping.rs:2:8 + --> tests/ui/inconsistent_digit_grouping.rs:2:8 | LL | #[deny(clippy::unreadable_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:29:13 + --> tests/ui/inconsistent_digit_grouping.rs:29:13 | LL | let _ = 0x1000000; | ^^^^^^^^^ help: consider: `0x0100_0000` error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:30:13 + --> tests/ui/inconsistent_digit_grouping.rs:30:13 | LL | let _ = 0x10000000; | ^^^^^^^^^^ help: consider: `0x1000_0000` error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:31:13 + --> tests/ui/inconsistent_digit_grouping.rs:31:13 | LL | let _ = 0x100000000_u64; | ^^^^^^^^^^^^^^^ help: consider: `0x0001_0000_0000_u64` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:34:18 + --> tests/ui/inconsistent_digit_grouping.rs:34:18 | LL | let _: f32 = 1_23_456.; | ^^^^^^^^^ help: consider: `123_456.` diff --git a/tests/ui/inconsistent_struct_constructor.stderr b/tests/ui/inconsistent_struct_constructor.stderr index fc080d7ec057d..1192271f911fd 100644 --- a/tests/ui/inconsistent_struct_constructor.stderr +++ b/tests/ui/inconsistent_struct_constructor.stderr @@ -1,5 +1,5 @@ error: struct constructor field order is inconsistent with struct definition field order - --> $DIR/inconsistent_struct_constructor.rs:28:9 + --> tests/ui/inconsistent_struct_constructor.rs:28:9 | LL | Foo { y, x, z }; | ^^^^^^^^^^^^^^^ help: try: `Foo { x, y, z }` @@ -8,7 +8,7 @@ LL | Foo { y, x, z }; = help: to override `-D warnings` add `#[allow(clippy::inconsistent_struct_constructor)]` error: struct constructor field order is inconsistent with struct definition field order - --> $DIR/inconsistent_struct_constructor.rs:55:9 + --> tests/ui/inconsistent_struct_constructor.rs:55:9 | LL | / Foo { LL | | z, diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr index d08ba64d9bae2..14e0f931f2401 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:14:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:14:17 | LL | if let Some(slice) = slice { | ^^^^^ | note: the lint level is defined here - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:1:9 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:21:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:21:17 | LL | if let Some(slice) = slice { | ^^^^^ @@ -34,7 +34,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:28:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:28:17 | LL | if let Some(slice) = slice { | ^^^^^ @@ -50,7 +50,7 @@ LL ~ println!("{}", slice_0); | error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:36:26 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:36:26 | LL | if let SomeEnum::One(slice) | SomeEnum::Three(slice) = slice_wrapped { | ^^^^^ @@ -65,7 +65,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:44:29 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:44:29 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { | ^ @@ -80,7 +80,7 @@ LL | println!("{} -> {}", a_2, b[1]); | ~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:44:38 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:44:38 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { | ^ @@ -95,7 +95,7 @@ LL | println!("{} -> {}", a[2], b_1); | ~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:53:21 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:53:21 | LL | if let Some(ref slice) = slice { | ^^^^^ @@ -110,7 +110,7 @@ LL | println!("{:?}", slice_1); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:62:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:62:17 | LL | if let Some(slice) = &slice { | ^^^^^ @@ -125,7 +125,7 @@ LL | println!("{:?}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:132:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:132:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ @@ -140,7 +140,7 @@ LL | println!("This is awesome! {}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/if_let_slice_binding.rs:140:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:140:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ diff --git a/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr b/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr index 40da4b53b8e0d..caccd0f9295e1 100644 --- a/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr +++ b/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice/slice_indexing_in_macro.rs:23:21 + --> tests/ui/index_refutable_slice/slice_indexing_in_macro.rs:23:21 | LL | if let Some(slice) = slice; | ^^^^^ | note: the lint level is defined here - --> $DIR/index_refutable_slice/slice_indexing_in_macro.rs:1:9 + --> tests/ui/index_refutable_slice/slice_indexing_in_macro.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/indexing_slicing_index.stderr b/tests/ui/indexing_slicing_index.stderr index 6d64fa1e6cf89..4a1d34128e0cc 100644 --- a/tests/ui/indexing_slicing_index.stderr +++ b/tests/ui/indexing_slicing_index.stderr @@ -1,5 +1,5 @@ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:14:20 + --> tests/ui/indexing_slicing_index.rs:14:20 | LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false. | ^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic - --> $DIR/indexing_slicing_index.rs:16:24 + --> tests/ui/indexing_slicing_index.rs:16:24 | LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ @@ -19,19 +19,19 @@ LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. = note: the suggestion might not be applicable in constant blocks error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/indexing_slicing_index.rs:48:14 + --> tests/ui/indexing_slicing_index.rs:48:14 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant encountered - --> $DIR/indexing_slicing_index.rs:48:5 + --> tests/ui/indexing_slicing_index.rs:48:5 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^^^^^^^^^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:29:5 + --> tests/ui/indexing_slicing_index.rs:29:5 | LL | x[index]; | ^^^^^^^^ @@ -39,7 +39,7 @@ LL | x[index]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:32:5 + --> tests/ui/indexing_slicing_index.rs:32:5 | LL | x[4]; | ^^^^ @@ -48,13 +48,13 @@ LL | x[4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:34:5 + --> tests/ui/indexing_slicing_index.rs:34:5 | LL | x[1 << 3]; | ^^^^^^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:45:14 + --> tests/ui/indexing_slicing_index.rs:45:14 | LL | const { &ARR[idx()] }; | ^^^^^^^^^^ @@ -63,7 +63,7 @@ LL | const { &ARR[idx()] }; = note: the suggestion might not be applicable in constant blocks error: indexing may panic - --> $DIR/indexing_slicing_index.rs:48:14 + --> tests/ui/indexing_slicing_index.rs:48:14 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^ @@ -72,13 +72,13 @@ LL | const { &ARR[idx4()] }; = note: the suggestion might not be applicable in constant blocks error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:55:5 + --> tests/ui/indexing_slicing_index.rs:55:5 | LL | y[4]; | ^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:58:5 + --> tests/ui/indexing_slicing_index.rs:58:5 | LL | v[0]; | ^^^^ @@ -86,7 +86,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:60:5 + --> tests/ui/indexing_slicing_index.rs:60:5 | LL | v[10]; | ^^^^^ @@ -94,7 +94,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:62:5 + --> tests/ui/indexing_slicing_index.rs:62:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -102,13 +102,13 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:70:5 + --> tests/ui/indexing_slicing_index.rs:70:5 | LL | x[N]; | ^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:73:5 + --> tests/ui/indexing_slicing_index.rs:73:5 | LL | v[N]; | ^^^^ @@ -116,7 +116,7 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:75:5 + --> tests/ui/indexing_slicing_index.rs:75:5 | LL | v[M]; | ^^^^ @@ -124,13 +124,13 @@ LL | v[M]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:79:13 + --> tests/ui/indexing_slicing_index.rs:79:13 | LL | let _ = x[4]; | ^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/indexing_slicing_index.rs:16:24 + --> tests/ui/indexing_slicing_index.rs:16:24 | LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 diff --git a/tests/ui/indexing_slicing_slice.stderr b/tests/ui/indexing_slicing_slice.stderr index eebe67810a024..790d4a41f5b1e 100644 --- a/tests/ui/indexing_slicing_slice.stderr +++ b/tests/ui/indexing_slicing_slice.stderr @@ -1,5 +1,5 @@ error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:12:6 + --> tests/ui/indexing_slicing_slice.rs:12:6 | LL | &x[index..]; | ^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | &x[index..]; = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:14:6 + --> tests/ui/indexing_slicing_slice.rs:14:6 | LL | &x[..index]; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | &x[..index]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:16:6 + --> tests/ui/indexing_slicing_slice.rs:16:6 | LL | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | &x[index_from..index_to]; = help: consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:18:6 + --> tests/ui/indexing_slicing_slice.rs:18:6 | LL | &x[index_from..][..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | &x[index_from..][..index_to]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:18:6 + --> tests/ui/indexing_slicing_slice.rs:18:6 | LL | &x[index_from..][..index_to]; | ^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | &x[index_from..][..index_to]; = help: consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:21:6 + --> tests/ui/indexing_slicing_slice.rs:21:6 | LL | &x[5..][..10]; | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | &x[5..][..10]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:21:8 + --> tests/ui/indexing_slicing_slice.rs:21:8 | LL | &x[5..][..10]; | ^ @@ -58,7 +58,7 @@ LL | &x[5..][..10]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:25:6 + --> tests/ui/indexing_slicing_slice.rs:25:6 | LL | &x[0..][..3]; | ^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | &x[0..][..3]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:27:6 + --> tests/ui/indexing_slicing_slice.rs:27:6 | LL | &x[1..][..5]; | ^^^^^^^^^^^ @@ -74,19 +74,19 @@ LL | &x[1..][..5]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:35:12 + --> tests/ui/indexing_slicing_slice.rs:35:12 | LL | &y[0..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:37:11 + --> tests/ui/indexing_slicing_slice.rs:37:11 | LL | &y[..=4]; | ^ error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:43:6 + --> tests/ui/indexing_slicing_slice.rs:43:6 | LL | &v[10..100]; | ^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | &v[10..100]; = help: consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:45:6 + --> tests/ui/indexing_slicing_slice.rs:45:6 | LL | &x[10..][..100]; | ^^^^^^^^^^^^^^ @@ -102,13 +102,13 @@ LL | &x[10..][..100]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:45:8 + --> tests/ui/indexing_slicing_slice.rs:45:8 | LL | &x[10..][..100]; | ^^ error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:48:6 + --> tests/ui/indexing_slicing_slice.rs:48:6 | LL | &v[10..]; | ^^^^^^^ @@ -116,7 +116,7 @@ LL | &v[10..]; = help: consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:50:6 + --> tests/ui/indexing_slicing_slice.rs:50:6 | LL | &v[..100]; | ^^^^^^^^ diff --git a/tests/ui/ineffective_open_options.stderr b/tests/ui/ineffective_open_options.stderr index 7dc5322232c00..0d6933bb449e8 100644 --- a/tests/ui/ineffective_open_options.stderr +++ b/tests/ui/ineffective_open_options.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `.write(true)` because there is `.append(true)` - --> $DIR/ineffective_open_options.rs:8:9 + --> tests/ui/ineffective_open_options.rs:8:9 | LL | .write(true) | ^^^^^^^^^^^^ help: remove `.write(true)` @@ -8,7 +8,7 @@ LL | .write(true) = help: to override `-D warnings` add `#[allow(clippy::ineffective_open_options)]` error: unnecessary use of `.write(true)` because there is `.append(true)` - --> $DIR/ineffective_open_options.rs:16:9 + --> tests/ui/ineffective_open_options.rs:16:9 | LL | .write(true) | ^^^^^^^^^^^^ help: remove `.write(true)` diff --git a/tests/ui/inefficient_to_string.stderr b/tests/ui/inefficient_to_string.stderr index 4b93465c4f9dd..e71e667cf0cfe 100644 --- a/tests/ui/inefficient_to_string.stderr +++ b/tests/ui/inefficient_to_string.stderr @@ -1,18 +1,18 @@ error: calling `to_string` on `&&str` - --> $DIR/inefficient_to_string.rs:10:21 + --> tests/ui/inefficient_to_string.rs:10:21 | LL | let _: String = rrstr.to_string(); | ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstr).to_string()` | = help: `&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString` note: the lint level is defined here - --> $DIR/inefficient_to_string.rs:1:9 + --> tests/ui/inefficient_to_string.rs:1:9 | LL | #![deny(clippy::inefficient_to_string)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `to_string` on `&&&str` - --> $DIR/inefficient_to_string.rs:11:21 + --> tests/ui/inefficient_to_string.rs:11:21 | LL | let _: String = rrrstr.to_string(); | ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstr).to_string()` @@ -20,7 +20,7 @@ LL | let _: String = rrrstr.to_string(); = help: `&&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString` error: calling `to_string` on `&&std::string::String` - --> $DIR/inefficient_to_string.rs:19:21 + --> tests/ui/inefficient_to_string.rs:19:21 | LL | let _: String = rrstring.to_string(); | ^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstring).to_string()` @@ -28,7 +28,7 @@ LL | let _: String = rrstring.to_string(); = help: `&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` error: calling `to_string` on `&&&std::string::String` - --> $DIR/inefficient_to_string.rs:20:21 + --> tests/ui/inefficient_to_string.rs:20:21 | LL | let _: String = rrrstring.to_string(); | ^^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstring).to_string()` @@ -36,7 +36,7 @@ LL | let _: String = rrrstring.to_string(); = help: `&&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` error: calling `to_string` on `&&std::borrow::Cow<'_, str>` - --> $DIR/inefficient_to_string.rs:28:21 + --> tests/ui/inefficient_to_string.rs:28:21 | LL | let _: String = rrcow.to_string(); | ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrcow).to_string()` @@ -44,7 +44,7 @@ LL | let _: String = rrcow.to_string(); = help: `&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString` error: calling `to_string` on `&&&std::borrow::Cow<'_, str>` - --> $DIR/inefficient_to_string.rs:29:21 + --> tests/ui/inefficient_to_string.rs:29:21 | LL | let _: String = rrrcow.to_string(); | ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrcow).to_string()` diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index 93851aae82bd7..b709fd8630e99 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:28:5 + --> tests/ui/infallible_destructuring_match.rs:28:5 | LL | / let data = match wrapper { LL | | SingleVariantEnum::Variant(i) => i, @@ -10,7 +10,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::infallible_destructuring_match)]` error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:60:5 + --> tests/ui/infallible_destructuring_match.rs:60:5 | LL | / let data = match wrapper { LL | | TupleStruct(i) => i, @@ -18,7 +18,7 @@ LL | | }; | |______^ help: try: `let TupleStruct(data) = wrapper;` error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:84:5 + --> tests/ui/infallible_destructuring_match.rs:84:5 | LL | / let data = match wrapper { LL | | TupleStructWithNonCopy(ref n) => n, @@ -26,7 +26,7 @@ LL | | }; | |______^ help: try: `let TupleStructWithNonCopy(ref data) = wrapper;` error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:103:5 + --> tests/ui/infallible_destructuring_match.rs:103:5 | LL | / let data = match wrapper { LL | | Ok(i) => i, diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index d0d0f0db443bb..e33d83b75edb0 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -1,29 +1,29 @@ error: infinite iteration detected - --> $DIR/infinite_iter.rs:11:5 + --> tests/ui/infinite_iter.rs:11:5 | LL | repeat(0_u8).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/infinite_iter.rs:9:8 + --> tests/ui/infinite_iter.rs:9:8 | LL | #[deny(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:14:5 + --> tests/ui/infinite_iter.rs:14:5 | LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:17:5 + --> tests/ui/infinite_iter.rs:17:5 | LL | (0..8_u64).chain(0..).max(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:25:5 + --> tests/ui/infinite_iter.rs:25:5 | LL | / (0..8_u32) LL | | @@ -34,37 +34,37 @@ LL | | .for_each(|x| println!("{}", x)); | |________________________________________^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:34:5 + --> tests/ui/infinite_iter.rs:34:5 | LL | (0_usize..).flat_map(|x| 0..x).product::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:37:5 + --> tests/ui/infinite_iter.rs:37:5 | LL | (0_u64..).filter(|x| x % 2 == 0).last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:48:5 + --> tests/ui/infinite_iter.rs:48:5 | LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/infinite_iter.rs:45:8 + --> tests/ui/infinite_iter.rs:45:8 | LL | #[deny(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:51:5 + --> tests/ui/infinite_iter.rs:51:5 | LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:54:5 + --> tests/ui/infinite_iter.rs:54:5 | LL | / (1..) LL | | @@ -76,31 +76,31 @@ LL | | .min(); | |______________^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:62:5 + --> tests/ui/infinite_iter.rs:62:5 | LL | (0..).find(|x| *x == 24); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:65:5 + --> tests/ui/infinite_iter.rs:65:5 | LL | (0..).position(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:68:5 + --> tests/ui/infinite_iter.rs:68:5 | LL | (0..).any(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:71:5 + --> tests/ui/infinite_iter.rs:71:5 | LL | (0..).all(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:97:31 + --> tests/ui/infinite_iter.rs:97:31 | LL | let _: HashSet = (0..).collect(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index a78e47d02290c..7ba1374d64f46 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,5 +1,5 @@ error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:22:11 + --> tests/ui/infinite_loop.rs:22:11 | LL | while y < 10 { | ^^^^^^ @@ -8,7 +8,7 @@ LL | while y < 10 { = note: `#[deny(clippy::while_immutable_condition)]` on by default error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:29:11 + --> tests/ui/infinite_loop.rs:29:11 | LL | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | while y < 10 && x < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:38:11 + --> tests/ui/infinite_loop.rs:38:11 | LL | while !cond { | ^^^^^ @@ -24,7 +24,7 @@ LL | while !cond { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:84:11 + --> tests/ui/infinite_loop.rs:84:11 | LL | while i < 3 { | ^^^^^ @@ -32,7 +32,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:91:11 + --> tests/ui/infinite_loop.rs:91:11 | LL | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:97:11 + --> tests/ui/infinite_loop.rs:97:11 | LL | while i < 3 { | ^^^^^ @@ -48,7 +48,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:114:11 + --> tests/ui/infinite_loop.rs:114:11 | LL | while i < 3 { | ^^^^^ @@ -56,7 +56,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:121:11 + --> tests/ui/infinite_loop.rs:121:11 | LL | while i < 3 { | ^^^^^ @@ -64,7 +64,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:189:15 + --> tests/ui/infinite_loop.rs:189:15 | LL | while self.count < n { | ^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | while self.count < n { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:199:11 + --> tests/ui/infinite_loop.rs:199:11 | LL | while y < 10 { | ^^^^^^ @@ -82,7 +82,7 @@ LL | while y < 10 { = help: rewrite it as `if cond { loop { } }` error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:208:11 + --> tests/ui/infinite_loop.rs:208:11 | LL | while y < 10 { | ^^^^^^ diff --git a/tests/ui/infinite_loops.stderr b/tests/ui/infinite_loops.stderr index 771fbfa44ee9f..012696f3828f4 100644 --- a/tests/ui/infinite_loops.stderr +++ b/tests/ui/infinite_loops.stderr @@ -1,5 +1,5 @@ error: infinite loop detected - --> $DIR/infinite_loops.rs:8:5 + --> tests/ui/infinite_loops.rs:8:5 | LL | / loop { LL | | @@ -15,7 +15,7 @@ LL | fn no_break() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:15:5 + --> tests/ui/infinite_loops.rs:15:5 | LL | / loop { LL | | @@ -32,7 +32,7 @@ LL | fn all_inf() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:17:9 + --> tests/ui/infinite_loops.rs:17:9 | LL | / loop { LL | | @@ -49,7 +49,7 @@ LL | fn all_inf() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:19:13 + --> tests/ui/infinite_loops.rs:19:13 | LL | / loop { LL | | @@ -63,7 +63,7 @@ LL | fn all_inf() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:33:5 + --> tests/ui/infinite_loops.rs:33:5 | LL | / loop { LL | | @@ -74,7 +74,7 @@ LL | | } = help: if this is not intended, try adding a `break` or `return` condition in the loop error: infinite loop detected - --> $DIR/infinite_loops.rs:46:5 + --> tests/ui/infinite_loops.rs:46:5 | LL | / loop { LL | | fn inner_fn() -> ! { @@ -90,7 +90,7 @@ LL | fn no_break_never_ret_noise() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:89:5 + --> tests/ui/infinite_loops.rs:89:5 | LL | / loop { LL | | @@ -107,7 +107,7 @@ LL | fn break_inner_but_not_outer_1(cond: bool) -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:100:5 + --> tests/ui/infinite_loops.rs:100:5 | LL | / loop { LL | | @@ -124,7 +124,7 @@ LL | fn break_inner_but_not_outer_2(cond: bool) -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:114:9 + --> tests/ui/infinite_loops.rs:114:9 | LL | / loop { LL | | @@ -138,7 +138,7 @@ LL | fn break_outer_but_not_inner() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:137:9 + --> tests/ui/infinite_loops.rs:137:9 | LL | / loop { LL | | @@ -155,7 +155,7 @@ LL | fn break_wrong_loop(cond: bool) -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:177:5 + --> tests/ui/infinite_loops.rs:177:5 | LL | / loop { LL | | @@ -172,7 +172,7 @@ LL | fn match_like() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:218:5 + --> tests/ui/infinite_loops.rs:218:5 | LL | / loop { LL | | @@ -186,7 +186,7 @@ LL | fn match_like() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:223:5 + --> tests/ui/infinite_loops.rs:223:5 | LL | / loop { LL | | @@ -203,7 +203,7 @@ LL | fn match_like() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:328:9 + --> tests/ui/infinite_loops.rs:328:9 | LL | / loop { LL | | @@ -217,7 +217,7 @@ LL | fn problematic_trait_method() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:338:9 + --> tests/ui/infinite_loops.rs:338:9 | LL | / loop { LL | | @@ -231,7 +231,7 @@ LL | fn could_be_problematic() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:347:9 + --> tests/ui/infinite_loops.rs:347:9 | LL | / loop { LL | | @@ -245,7 +245,7 @@ LL | let _loop_forever = || -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:361:8 + --> tests/ui/infinite_loops.rs:361:8 | LL | Ok(loop { | ________^ diff --git a/tests/ui/inherent_to_string.stderr b/tests/ui/inherent_to_string.stderr index cf8d09180191b..eb22525a24919 100644 --- a/tests/ui/inherent_to_string.stderr +++ b/tests/ui/inherent_to_string.stderr @@ -1,5 +1,5 @@ error: implementation of inherent method `to_string(&self) -> String` for type `A` - --> $DIR/inherent_to_string.rs:22:5 + --> tests/ui/inherent_to_string.rs:22:5 | LL | / fn to_string(&self) -> String { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::inherent_to_string)]` error: type `C` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display` - --> $DIR/inherent_to_string.rs:47:5 + --> tests/ui/inherent_to_string.rs:47:5 | LL | / fn to_string(&self) -> String { LL | | diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 60f6eb8dff082..89db710fabe77 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -1,5 +1,5 @@ error: use of `#[inline]` on trait method `default_inline` which has no body - --> $DIR/inline_fn_without_body.rs:5:5 + --> tests/ui/inline_fn_without_body.rs:5:5 | LL | #[inline] | _____-^^^^^^^^ @@ -10,7 +10,7 @@ LL | | fn default_inline(); = help: to override `-D warnings` add `#[allow(clippy::inline_fn_without_body)]` error: use of `#[inline]` on trait method `always_inline` which has no body - --> $DIR/inline_fn_without_body.rs:8:5 + --> tests/ui/inline_fn_without_body.rs:8:5 | LL | #[inline(always)] | _____-^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | | fn always_inline(); | |____- help: remove error: use of `#[inline]` on trait method `never_inline` which has no body - --> $DIR/inline_fn_without_body.rs:11:5 + --> tests/ui/inline_fn_without_body.rs:11:5 | LL | #[inline(never)] | _____-^^^^^^^^^^^^^^^ diff --git a/tests/ui/inspect_for_each.stderr b/tests/ui/inspect_for_each.stderr index 8bd4fe3987c5d..3c2dee15ebd5b 100644 --- a/tests/ui/inspect_for_each.stderr +++ b/tests/ui/inspect_for_each.stderr @@ -1,5 +1,5 @@ error: called `inspect(..).for_each(..)` on an `Iterator` - --> $DIR/inspect_for_each.rs:7:19 + --> tests/ui/inspect_for_each.rs:7:19 | LL | a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| { | ___________________^ diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 6a62eac7cc476..cedac14f350d4 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,5 +1,5 @@ error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:7:13 + --> tests/ui/int_plus_one.rs:7:13 | LL | let _ = x >= y + 1; | ^^^^^^^^^^ help: change it to: `x > y` @@ -8,19 +8,19 @@ LL | let _ = x >= y + 1; = help: to override `-D warnings` add `#[allow(clippy::int_plus_one)]` error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:8:13 + --> tests/ui/int_plus_one.rs:8:13 | LL | let _ = y + 1 <= x; | ^^^^^^^^^^ help: change it to: `y < x` error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:10:13 + --> tests/ui/int_plus_one.rs:10:13 | LL | let _ = x - 1 >= y; | ^^^^^^^^^^ help: change it to: `x > y` error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:11:13 + --> tests/ui/int_plus_one.rs:11:13 | LL | let _ = y <= x - 1; | ^^^^^^^^^^ help: change it to: `y < x` diff --git a/tests/ui/integer_division.stderr b/tests/ui/integer_division.stderr index 420f0f30e77cf..5f0d905a48b63 100644 --- a/tests/ui/integer_division.stderr +++ b/tests/ui/integer_division.stderr @@ -1,5 +1,5 @@ error: integer division - --> $DIR/integer_division.rs:5:13 + --> tests/ui/integer_division.rs:5:13 | LL | let n = 1 / 2; | ^^^^^ @@ -9,7 +9,7 @@ LL | let n = 1 / 2; = help: to override `-D warnings` add `#[allow(clippy::integer_division)]` error: integer division - --> $DIR/integer_division.rs:7:13 + --> tests/ui/integer_division.rs:7:13 | LL | let o = 1 / two; | ^^^^^^^ @@ -17,7 +17,7 @@ LL | let o = 1 / two; = help: division of integers may cause loss of precision. consider using floats error: integer division - --> $DIR/integer_division.rs:9:13 + --> tests/ui/integer_division.rs:9:13 | LL | let p = two / 4; | ^^^^^^^ diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index 481957d50e205..0e9d485f1a9d9 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,5 +1,5 @@ error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` - --> $DIR/into_iter_on_ref.rs:13:30 + --> tests/ui/into_iter_on_ref.rs:13:30 | LL | let _ = (&vec![1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` @@ -8,157 +8,157 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); = help: to override `-D warnings` add `#[allow(clippy::into_iter_on_ref)]` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> $DIR/into_iter_on_ref.rs:14:46 + --> tests/ui/into_iter_on_ref.rs:14:46 | LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> $DIR/into_iter_on_ref.rs:15:41 + --> tests/ui/into_iter_on_ref.rs:15:41 | LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> $DIR/into_iter_on_ref.rs:16:44 + --> tests/ui/into_iter_on_ref.rs:16:44 | LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:18:32 + --> tests/ui/into_iter_on_ref.rs:18:32 | LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:19:36 + --> tests/ui/into_iter_on_ref.rs:19:36 | LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:20:40 + --> tests/ui/into_iter_on_ref.rs:20:40 | LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Option` - --> $DIR/into_iter_on_ref.rs:22:24 + --> tests/ui/into_iter_on_ref.rs:22:24 | LL | let _ = (&Some(4)).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Option` - --> $DIR/into_iter_on_ref.rs:23:28 + --> tests/ui/into_iter_on_ref.rs:23:28 | LL | let _ = (&mut Some(5)).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Result` - --> $DIR/into_iter_on_ref.rs:24:32 + --> tests/ui/into_iter_on_ref.rs:24:32 | LL | let _ = (&Ok::<_, i32>(6)).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Result` - --> $DIR/into_iter_on_ref.rs:25:37 + --> tests/ui/into_iter_on_ref.rs:25:37 | LL | let _ = (&mut Err::(7)).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` - --> $DIR/into_iter_on_ref.rs:26:34 + --> tests/ui/into_iter_on_ref.rs:26:34 | LL | let _ = (&Vec::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Vec` - --> $DIR/into_iter_on_ref.rs:27:38 + --> tests/ui/into_iter_on_ref.rs:27:38 | LL | let _ = (&mut Vec::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeMap` - --> $DIR/into_iter_on_ref.rs:28:44 + --> tests/ui/into_iter_on_ref.rs:28:44 | LL | let _ = (&BTreeMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `BTreeMap` - --> $DIR/into_iter_on_ref.rs:29:48 + --> tests/ui/into_iter_on_ref.rs:29:48 | LL | let _ = (&mut BTreeMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `VecDeque` - --> $DIR/into_iter_on_ref.rs:30:39 + --> tests/ui/into_iter_on_ref.rs:30:39 | LL | let _ = (&VecDeque::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `VecDeque` - --> $DIR/into_iter_on_ref.rs:31:43 + --> tests/ui/into_iter_on_ref.rs:31:43 | LL | let _ = (&mut VecDeque::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `LinkedList` - --> $DIR/into_iter_on_ref.rs:32:41 + --> tests/ui/into_iter_on_ref.rs:32:41 | LL | let _ = (&LinkedList::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `LinkedList` - --> $DIR/into_iter_on_ref.rs:33:45 + --> tests/ui/into_iter_on_ref.rs:33:45 | LL | let _ = (&mut LinkedList::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashMap` - --> $DIR/into_iter_on_ref.rs:34:43 + --> tests/ui/into_iter_on_ref.rs:34:43 | LL | let _ = (&HashMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `HashMap` - --> $DIR/into_iter_on_ref.rs:35:47 + --> tests/ui/into_iter_on_ref.rs:35:47 | LL | let _ = (&mut HashMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeSet` - --> $DIR/into_iter_on_ref.rs:37:39 + --> tests/ui/into_iter_on_ref.rs:37:39 | LL | let _ = (&BTreeSet::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BinaryHeap` - --> $DIR/into_iter_on_ref.rs:38:41 + --> tests/ui/into_iter_on_ref.rs:38:41 | LL | let _ = (&BinaryHeap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashSet` - --> $DIR/into_iter_on_ref.rs:39:38 + --> tests/ui/into_iter_on_ref.rs:39:38 | LL | let _ = (&HashSet::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Path` - --> $DIR/into_iter_on_ref.rs:40:43 + --> tests/ui/into_iter_on_ref.rs:40:43 | LL | let _ = std::path::Path::new("12/34").into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `PathBuf` - --> $DIR/into_iter_on_ref.rs:41:47 + --> tests/ui/into_iter_on_ref.rs:41:47 | LL | let _ = std::path::PathBuf::from("12/34").into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:43:26 + --> tests/ui/into_iter_on_ref.rs:43:26 | LL | let _ = (&[1, 2, 3]).into_iter().next(); | ^^^^^^^^^ help: call directly: `iter` diff --git a/tests/ui/into_iter_without_iter.stderr b/tests/ui/into_iter_without_iter.stderr index a232c7cecc577..533a7f6859354 100644 --- a/tests/ui/into_iter_without_iter.stderr +++ b/tests/ui/into_iter_without_iter.stderr @@ -1,5 +1,5 @@ error: `IntoIterator` implemented for a reference type without an `iter` method - --> $DIR/into_iter_without_iter.rs:9:1 + --> tests/ui/into_iter_without_iter.rs:9:1 | LL | / impl<'a> IntoIterator for &'a S1 { LL | | @@ -23,7 +23,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter_mut` method - --> $DIR/into_iter_without_iter.rs:17:1 + --> tests/ui/into_iter_without_iter.rs:17:1 | LL | / impl<'a> IntoIterator for &'a mut S1 { LL | | @@ -45,7 +45,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter` method - --> $DIR/into_iter_without_iter.rs:27:1 + --> tests/ui/into_iter_without_iter.rs:27:1 | LL | / impl<'a, T> IntoIterator for &'a S2 { LL | | @@ -67,7 +67,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter_mut` method - --> $DIR/into_iter_without_iter.rs:35:1 + --> tests/ui/into_iter_without_iter.rs:35:1 | LL | / impl<'a, T> IntoIterator for &'a mut S2 { LL | | @@ -89,7 +89,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter_mut` method - --> $DIR/into_iter_without_iter.rs:86:1 + --> tests/ui/into_iter_without_iter.rs:86:1 | LL | / impl<'a, T> IntoIterator for &mut S4<'a, T> { LL | | @@ -111,7 +111,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter` method - --> $DIR/into_iter_without_iter.rs:120:9 + --> tests/ui/into_iter_without_iter.rs:120:9 | LL | / impl<'a> IntoIterator for &'a Issue12037 { LL | | type IntoIter = std::slice::Iter<'a, u8>; diff --git a/tests/ui/invalid_null_ptr_usage.stderr b/tests/ui/invalid_null_ptr_usage.stderr index 22efa0d84ad42..54d79ba1aeb4f 100644 --- a/tests/ui/invalid_null_ptr_usage.stderr +++ b/tests/ui/invalid_null_ptr_usage.stderr @@ -1,5 +1,5 @@ error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:3:59 + --> tests/ui/invalid_null_ptr_usage.rs:3:59 | LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` @@ -7,145 +7,145 @@ LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), = note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:4:59 + --> tests/ui/invalid_null_ptr_usage.rs:4:59 | LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:6:63 + --> tests/ui/invalid_null_ptr_usage.rs:6:63 | LL | let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:8:33 + --> tests/ui/invalid_null_ptr_usage.rs:8:33 | LL | std::ptr::copy::(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:9:73 + --> tests/ui/invalid_null_ptr_usage.rs:9:73 | LL | std::ptr::copy::(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:11:48 + --> tests/ui/invalid_null_ptr_usage.rs:11:48 | LL | std::ptr::copy_nonoverlapping::(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:12:88 + --> tests/ui/invalid_null_ptr_usage.rs:12:88 | LL | std::ptr::copy_nonoverlapping::(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:17:36 + --> tests/ui/invalid_null_ptr_usage.rs:17:36 | LL | let _a: A = std::ptr::read(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:18:36 + --> tests/ui/invalid_null_ptr_usage.rs:18:36 | LL | let _a: A = std::ptr::read(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:20:46 + --> tests/ui/invalid_null_ptr_usage.rs:20:46 | LL | let _a: A = std::ptr::read_unaligned(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:21:46 + --> tests/ui/invalid_null_ptr_usage.rs:21:46 | LL | let _a: A = std::ptr::read_unaligned(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:23:45 + --> tests/ui/invalid_null_ptr_usage.rs:23:45 | LL | let _a: A = std::ptr::read_volatile(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:24:45 + --> tests/ui/invalid_null_ptr_usage.rs:24:45 | LL | let _a: A = std::ptr::read_volatile(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:26:39 + --> tests/ui/invalid_null_ptr_usage.rs:26:39 | LL | let _a: A = std::ptr::replace(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:28:69 + --> tests/ui/invalid_null_ptr_usage.rs:28:69 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:29:69 + --> tests/ui/invalid_null_ptr_usage.rs:29:69 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:31:73 + --> tests/ui/invalid_null_ptr_usage.rs:31:73 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:33:29 + --> tests/ui/invalid_null_ptr_usage.rs:33:29 | LL | std::ptr::swap::(std::ptr::null_mut(), &mut A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:34:37 + --> tests/ui/invalid_null_ptr_usage.rs:34:37 | LL | std::ptr::swap::(&mut A, std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:36:44 + --> tests/ui/invalid_null_ptr_usage.rs:36:44 | LL | std::ptr::swap_nonoverlapping::(std::ptr::null_mut(), &mut A, 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:37:52 + --> tests/ui/invalid_null_ptr_usage.rs:37:52 | LL | std::ptr::swap_nonoverlapping::(&mut A, std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:39:25 + --> tests/ui/invalid_null_ptr_usage.rs:39:25 | LL | std::ptr::write(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:41:35 + --> tests/ui/invalid_null_ptr_usage.rs:41:35 | LL | std::ptr::write_unaligned(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:43:34 + --> tests/ui/invalid_null_ptr_usage.rs:43:34 | LL | std::ptr::write_volatile(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:45:40 + --> tests/ui/invalid_null_ptr_usage.rs:45:40 | LL | std::ptr::write_bytes::(std::ptr::null_mut(), 42, 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index a57b4b02dce3a..b1fbe29515775 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,5 +1,5 @@ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:21:5 + --> tests/ui/invalid_upcast_comparisons.rs:21:5 | LL | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ @@ -8,157 +8,157 @@ LL | (u8 as u32) > 300; = help: to override `-D warnings` add `#[allow(clippy::invalid_upcast_comparisons)]` error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:24:5 + --> tests/ui/invalid_upcast_comparisons.rs:24:5 | LL | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:26:5 + --> tests/ui/invalid_upcast_comparisons.rs:26:5 | LL | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:28:5 + --> tests/ui/invalid_upcast_comparisons.rs:28:5 | LL | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:30:5 + --> tests/ui/invalid_upcast_comparisons.rs:30:5 | LL | 300 < (u8 as u32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:32:5 + --> tests/ui/invalid_upcast_comparisons.rs:32:5 | LL | 300 < (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:34:5 + --> tests/ui/invalid_upcast_comparisons.rs:34:5 | LL | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:36:5 + --> tests/ui/invalid_upcast_comparisons.rs:36:5 | LL | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:39:5 + --> tests/ui/invalid_upcast_comparisons.rs:39:5 | LL | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:41:5 + --> tests/ui/invalid_upcast_comparisons.rs:41:5 | LL | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:43:5 + --> tests/ui/invalid_upcast_comparisons.rs:43:5 | LL | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:45:5 + --> tests/ui/invalid_upcast_comparisons.rs:45:5 | LL | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:47:5 + --> tests/ui/invalid_upcast_comparisons.rs:47:5 | LL | 300 >= (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:49:5 + --> tests/ui/invalid_upcast_comparisons.rs:49:5 | LL | 300 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:51:5 + --> tests/ui/invalid_upcast_comparisons.rs:51:5 | LL | 300 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:53:5 + --> tests/ui/invalid_upcast_comparisons.rs:53:5 | LL | 300 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:57:5 + --> tests/ui/invalid_upcast_comparisons.rs:57:5 | LL | (u8 as i32) < 0; | ^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:59:5 + --> tests/ui/invalid_upcast_comparisons.rs:59:5 | LL | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:62:5 + --> tests/ui/invalid_upcast_comparisons.rs:62:5 | LL | (u8 as i32) >= 0; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:64:5 + --> tests/ui/invalid_upcast_comparisons.rs:64:5 | LL | -5 == (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:68:5 + --> tests/ui/invalid_upcast_comparisons.rs:68:5 | LL | 1337 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:70:5 + --> tests/ui/invalid_upcast_comparisons.rs:70:5 | LL | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:73:5 + --> tests/ui/invalid_upcast_comparisons.rs:73:5 | LL | 1337 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:75:5 + --> tests/ui/invalid_upcast_comparisons.rs:75:5 | LL | 1337 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:90:5 + --> tests/ui/invalid_upcast_comparisons.rs:90:5 | LL | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:92:5 + --> tests/ui/invalid_upcast_comparisons.rs:92:5 | LL | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:109:5 + --> tests/ui/invalid_upcast_comparisons.rs:109:5 | LL | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/is_digit_ascii_radix.stderr b/tests/ui/is_digit_ascii_radix.stderr index 28040c3a9c26d..f26183ddab84d 100644 --- a/tests/ui/is_digit_ascii_radix.stderr +++ b/tests/ui/is_digit_ascii_radix.stderr @@ -1,5 +1,5 @@ error: use of `char::is_digit` with literal radix of 10 - --> $DIR/is_digit_ascii_radix.rs:9:13 + --> tests/ui/is_digit_ascii_radix.rs:9:13 | LL | let _ = c.is_digit(10); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_digit()` @@ -8,13 +8,13 @@ LL | let _ = c.is_digit(10); = help: to override `-D warnings` add `#[allow(clippy::is_digit_ascii_radix)]` error: use of `char::is_digit` with literal radix of 16 - --> $DIR/is_digit_ascii_radix.rs:10:13 + --> tests/ui/is_digit_ascii_radix.rs:10:13 | LL | let _ = c.is_digit(16); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_hexdigit()` error: use of `char::is_digit` with literal radix of 16 - --> $DIR/is_digit_ascii_radix.rs:11:13 + --> tests/ui/is_digit_ascii_radix.rs:11:13 | LL | let _ = c.is_digit(0x10); | ^^^^^^^^^^^^^^^^ help: try: `c.is_ascii_hexdigit()` diff --git a/tests/ui/issue-3145.stderr b/tests/ui/issue-3145.stderr index 51debc9b72f82..b7dacd484e9af 100644 --- a/tests/ui/issue-3145.stderr +++ b/tests/ui/issue-3145.stderr @@ -1,5 +1,5 @@ error: expected `,`, found `a` - --> $DIR/issue-3145.rs:2:19 + --> tests/ui/issue-3145.rs:2:19 | LL | println!("{}" a); | ^ expected `,` diff --git a/tests/ui/issue-7447.stderr b/tests/ui/issue-7447.stderr index 51ecac4559c95..5e28c1423840f 100644 --- a/tests/ui/issue-7447.stderr +++ b/tests/ui/issue-7447.stderr @@ -1,5 +1,5 @@ error: sub-expression diverges - --> $DIR/issue-7447.rs:26:15 + --> tests/ui/issue-7447.rs:26:15 | LL | byte_view(panic!()); | ^^^^^^^^ @@ -9,7 +9,7 @@ LL | byte_view(panic!()); = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: sub-expression diverges - --> $DIR/issue-7447.rs:29:19 + --> tests/ui/issue-7447.rs:29:19 | LL | group_entries(panic!()); | ^^^^^^^^ diff --git a/tests/ui/issue_2356.stderr b/tests/ui/issue_2356.stderr index 860c545c7b827..eae2ce97fc6b1 100644 --- a/tests/ui/issue_2356.stderr +++ b/tests/ui/issue_2356.stderr @@ -1,11 +1,11 @@ error: this loop could be written as a `for` loop - --> $DIR/issue_2356.rs:17:9 + --> tests/ui/issue_2356.rs:17:9 | LL | while let Some(e) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for e in it` | note: the lint level is defined here - --> $DIR/issue_2356.rs:1:9 + --> tests/ui/issue_2356.rs:1:9 | LL | #![deny(clippy::while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issue_4266.stderr b/tests/ui/issue_4266.stderr index 692de2ae58c09..c0e8179158969 100644 --- a/tests/ui/issue_4266.stderr +++ b/tests/ui/issue_4266.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/issue_4266.rs:4:16 + --> tests/ui/issue_4266.rs:4:16 | LL | async fn sink1<'a>(_: &'a str) {} // lint | ^^ ^^ @@ -8,13 +8,13 @@ LL | async fn sink1<'a>(_: &'a str) {} // lint = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` error: the following explicit lifetimes could be elided: 'a - --> $DIR/issue_4266.rs:10:21 + --> tests/ui/issue_4266.rs:10:21 | LL | async fn one_to_one<'a>(s: &'a str) -> &'a str { | ^^ ^^ error: methods called `new` usually take no `self` - --> $DIR/issue_4266.rs:31:22 + --> tests/ui/issue_4266.rs:31:22 | LL | pub async fn new(&mut self) -> Self { | ^^^^^^^^^ diff --git a/tests/ui/items_after_statement.stderr b/tests/ui/items_after_statement.stderr index fa494f2174895..0f1989d4c9fc5 100644 --- a/tests/ui/items_after_statement.stderr +++ b/tests/ui/items_after_statement.stderr @@ -1,5 +1,5 @@ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/items_after_statement.rs:13:5 + --> tests/ui/items_after_statement.rs:13:5 | LL | / fn foo() { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::items_after_statements)]` error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/items_after_statement.rs:22:5 + --> tests/ui/items_after_statement.rs:22:5 | LL | / fn foo() { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/items_after_statement.rs:36:13 + --> tests/ui/items_after_statement.rs:36:13 | LL | / fn say_something() { LL | | println!("something"); diff --git a/tests/ui/items_after_test_module/in_submodule.stderr b/tests/ui/items_after_test_module/in_submodule.stderr index 7d4675af0f046..8aa6b809cd1e7 100644 --- a/tests/ui/items_after_test_module/in_submodule.stderr +++ b/tests/ui/items_after_test_module/in_submodule.stderr @@ -1,5 +1,5 @@ error: items after a test module - --> $DIR/items_after_test_module/auxiliary/submodule.rs:2:1 + --> tests/ui/items_after_test_module/auxiliary/submodule.rs:2:1 | LL | mod tests {} | ^^^^^^^^^ diff --git a/tests/ui/items_after_test_module/root_module.stderr b/tests/ui/items_after_test_module/root_module.stderr index b736b166295d9..bed8d4bd5a00c 100644 --- a/tests/ui/items_after_test_module/root_module.stderr +++ b/tests/ui/items_after_test_module/root_module.stderr @@ -1,5 +1,5 @@ error: items after a test module - --> $DIR/items_after_test_module/root_module.rs:12:1 + --> tests/ui/items_after_test_module/root_module.rs:12:1 | LL | mod tests { | ^^^^^^^^^ diff --git a/tests/ui/iter_cloned_collect.stderr b/tests/ui/iter_cloned_collect.stderr index aa7fb98a7c8ad..e8d82ec2c1b39 100644 --- a/tests/ui/iter_cloned_collect.stderr +++ b/tests/ui/iter_cloned_collect.stderr @@ -1,5 +1,5 @@ error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/iter_cloned_collect.rs:8:27 + --> tests/ui/iter_cloned_collect.rs:8:27 | LL | let v2: Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` @@ -8,13 +8,13 @@ LL | let v2: Vec = v.iter().cloned().collect(); = help: to override `-D warnings` add `#[allow(clippy::iter_cloned_collect)]` error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/iter_cloned_collect.rs:13:38 + --> tests/ui/iter_cloned_collect.rs:13:38 | LL | let _: Vec = vec![1, 2, 3].iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/iter_cloned_collect.rs:18:24 + --> tests/ui/iter_cloned_collect.rs:18:24 | LL | .to_bytes() | ________________________^ @@ -24,13 +24,13 @@ LL | | .collect(); | |______________________^ help: try: `.to_vec()` error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/iter_cloned_collect.rs:26:24 + --> tests/ui/iter_cloned_collect.rs:26:24 | LL | let _: Vec<_> = arr.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` error: called `iter().copied().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/iter_cloned_collect.rs:29:26 + --> tests/ui/iter_cloned_collect.rs:29:26 | LL | let _: Vec = v.iter().copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` diff --git a/tests/ui/iter_count.stderr b/tests/ui/iter_count.stderr index 2882b7d28505f..b703310731f34 100644 --- a/tests/ui/iter_count.stderr +++ b/tests/ui/iter_count.stderr @@ -1,5 +1,5 @@ error: called `.iter().count()` on a `slice` - --> $DIR/iter_count.rs:54:6 + --> tests/ui/iter_count.rs:54:6 | LL | &vec[..].iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` @@ -8,145 +8,145 @@ LL | &vec[..].iter().count(); = help: to override `-D warnings` add `#[allow(clippy::iter_count)]` error: called `.iter().count()` on a `Vec` - --> $DIR/iter_count.rs:55:5 + --> tests/ui/iter_count.rs:55:5 | LL | vec.iter().count(); | ^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.iter().count()` on a `slice` - --> $DIR/iter_count.rs:56:5 + --> tests/ui/iter_count.rs:56:5 | LL | boxed_slice.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice.len()` error: called `.iter().count()` on a `VecDeque` - --> $DIR/iter_count.rs:57:5 + --> tests/ui/iter_count.rs:57:5 | LL | vec_deque.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` error: called `.iter().count()` on a `HashSet` - --> $DIR/iter_count.rs:58:5 + --> tests/ui/iter_count.rs:58:5 | LL | hash_set.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_set.len()` error: called `.iter().count()` on a `HashMap` - --> $DIR/iter_count.rs:59:5 + --> tests/ui/iter_count.rs:59:5 | LL | hash_map.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` error: called `.iter().count()` on a `BTreeMap` - --> $DIR/iter_count.rs:60:5 + --> tests/ui/iter_count.rs:60:5 | LL | b_tree_map.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` error: called `.iter().count()` on a `BTreeSet` - --> $DIR/iter_count.rs:61:5 + --> tests/ui/iter_count.rs:61:5 | LL | b_tree_set.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_set.len()` error: called `.iter().count()` on a `LinkedList` - --> $DIR/iter_count.rs:62:5 + --> tests/ui/iter_count.rs:62:5 | LL | linked_list.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.iter().count()` on a `BinaryHeap` - --> $DIR/iter_count.rs:63:5 + --> tests/ui/iter_count.rs:63:5 | LL | binary_heap.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `binary_heap.len()` error: called `.iter_mut().count()` on a `Vec` - --> $DIR/iter_count.rs:65:5 + --> tests/ui/iter_count.rs:65:5 | LL | vec.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.iter_mut().count()` on a `slice` - --> $DIR/iter_count.rs:66:6 + --> tests/ui/iter_count.rs:66:6 | LL | &vec[..].iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` error: called `.iter_mut().count()` on a `VecDeque` - --> $DIR/iter_count.rs:67:5 + --> tests/ui/iter_count.rs:67:5 | LL | vec_deque.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` error: called `.iter_mut().count()` on a `HashMap` - --> $DIR/iter_count.rs:68:5 + --> tests/ui/iter_count.rs:68:5 | LL | hash_map.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` error: called `.iter_mut().count()` on a `BTreeMap` - --> $DIR/iter_count.rs:69:5 + --> tests/ui/iter_count.rs:69:5 | LL | b_tree_map.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` error: called `.iter_mut().count()` on a `LinkedList` - --> $DIR/iter_count.rs:70:5 + --> tests/ui/iter_count.rs:70:5 | LL | linked_list.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.into_iter().count()` on a `slice` - --> $DIR/iter_count.rs:72:6 + --> tests/ui/iter_count.rs:72:6 | LL | &vec[..].into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` error: called `.into_iter().count()` on a `Vec` - --> $DIR/iter_count.rs:73:5 + --> tests/ui/iter_count.rs:73:5 | LL | vec.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.into_iter().count()` on a `VecDeque` - --> $DIR/iter_count.rs:74:5 + --> tests/ui/iter_count.rs:74:5 | LL | vec_deque.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` error: called `.into_iter().count()` on a `HashSet` - --> $DIR/iter_count.rs:75:5 + --> tests/ui/iter_count.rs:75:5 | LL | hash_set.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_set.len()` error: called `.into_iter().count()` on a `HashMap` - --> $DIR/iter_count.rs:76:5 + --> tests/ui/iter_count.rs:76:5 | LL | hash_map.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` error: called `.into_iter().count()` on a `BTreeMap` - --> $DIR/iter_count.rs:77:5 + --> tests/ui/iter_count.rs:77:5 | LL | b_tree_map.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` error: called `.into_iter().count()` on a `BTreeSet` - --> $DIR/iter_count.rs:78:5 + --> tests/ui/iter_count.rs:78:5 | LL | b_tree_set.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_set.len()` error: called `.into_iter().count()` on a `LinkedList` - --> $DIR/iter_count.rs:79:5 + --> tests/ui/iter_count.rs:79:5 | LL | linked_list.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.into_iter().count()` on a `BinaryHeap` - --> $DIR/iter_count.rs:80:5 + --> tests/ui/iter_count.rs:80:5 | LL | binary_heap.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `binary_heap.len()` diff --git a/tests/ui/iter_filter_is_ok.stderr b/tests/ui/iter_filter_is_ok.stderr index d99e2e0446da8..0aff60224e0e0 100644 --- a/tests/ui/iter_filter_is_ok.stderr +++ b/tests/ui/iter_filter_is_ok.stderr @@ -1,5 +1,5 @@ error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:11:56 + --> tests/ui/iter_filter_is_ok.rs:11:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(Result::is_ok); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,67 +8,67 @@ LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(Result::is_ok = help: to override `-D warnings` add `#[allow(clippy::iter_filter_is_ok)]` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:13:56 + --> tests/ui/iter_filter_is_ok.rs:13:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:16:49 + --> tests/ui/iter_filter_is_ok.rs:16:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:21:56 + --> tests/ui/iter_filter_is_ok.rs:21:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:24:56 + --> tests/ui/iter_filter_is_ok.rs:24:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:28:49 + --> tests/ui/iter_filter_is_ok.rs:28:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|&o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:35:14 + --> tests/ui/iter_filter_is_ok.rs:35:14 | LL | .filter(std::result::Result::is_ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:40:14 + --> tests/ui/iter_filter_is_ok.rs:40:14 | LL | .filter(|a| std::result::Result::is_ok(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:43:56 + --> tests/ui/iter_filter_is_ok.rs:43:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| { std::result::Result::is_ok(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:48:56 + --> tests/ui/iter_filter_is_ok.rs:48:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:51:56 + --> tests/ui/iter_filter_is_ok.rs:51:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:55:49 + --> tests/ui/iter_filter_is_ok.rs:55:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|ref o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` diff --git a/tests/ui/iter_filter_is_some.stderr b/tests/ui/iter_filter_is_some.stderr index 2eb00633e88fc..165ccfedf14dc 100644 --- a/tests/ui/iter_filter_is_some.stderr +++ b/tests/ui/iter_filter_is_some.stderr @@ -1,5 +1,5 @@ error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:14:58 + --> tests/ui/iter_filter_is_some.rs:14:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,55 +8,55 @@ LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(Option::is_ = help: to override `-D warnings` add `#[allow(clippy::iter_filter_is_some)]` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:16:58 + --> tests/ui/iter_filter_is_some.rs:16:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:19:58 + --> tests/ui/iter_filter_is_some.rs:19:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:26:14 + --> tests/ui/iter_filter_is_some.rs:26:14 | LL | .filter(std::option::Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:31:14 + --> tests/ui/iter_filter_is_some.rs:31:14 | LL | .filter(|a| std::option::Option::is_some(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:34:58 + --> tests/ui/iter_filter_is_some.rs:34:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| { std::option::Option::is_some(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:39:58 + --> tests/ui/iter_filter_is_some.rs:39:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:43:58 + --> tests/ui/iter_filter_is_some.rs:43:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:48:58 + --> tests/ui/iter_filter_is_some.rs:48:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:52:58 + --> tests/ui/iter_filter_is_some.rs:52:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` diff --git a/tests/ui/iter_kv_map.stderr b/tests/ui/iter_kv_map.stderr index 471615978e1e5..ad23dba55cb6a 100644 --- a/tests/ui/iter_kv_map.stderr +++ b/tests/ui/iter_kv_map.stderr @@ -1,5 +1,5 @@ error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:14:13 + --> tests/ui/iter_kv_map.rs:14:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` @@ -8,73 +8,73 @@ LL | let _ = map.iter().map(|(key, _)| key).collect::>(); = help: to override `-D warnings` add `#[allow(clippy::iter_kv_map)]` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:15:13 + --> tests/ui/iter_kv_map.rs:15:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:16:13 + --> tests/ui/iter_kv_map.rs:16:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:18:13 + --> tests/ui/iter_kv_map.rs:18:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:19:13 + --> tests/ui/iter_kv_map.rs:19:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:21:13 + --> tests/ui/iter_kv_map.rs:21:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:22:13 + --> tests/ui/iter_kv_map.rs:22:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:24:13 + --> tests/ui/iter_kv_map.rs:24:13 | LL | let _ = map.clone().iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:25:13 + --> tests/ui/iter_kv_map.rs:25:13 | LL | let _ = map.iter().map(|(key, _)| key).filter(|x| *x % 2 == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:35:13 + --> tests/ui/iter_kv_map.rs:35:13 | LL | let _ = map.iter().map(|(key, _value)| key * 9).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys().map(|key| key * 9)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:36:13 + --> tests/ui/iter_kv_map.rs:36:13 | LL | let _ = map.iter().map(|(_key, value)| value * 17).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|value| value * 17)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:39:13 + --> tests/ui/iter_kv_map.rs:39:13 | LL | let _ = map.clone().into_iter().map(|(_, ref val)| ref_acceptor(val)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|ref val| ref_acceptor(val))` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:42:13 + --> tests/ui/iter_kv_map.rs:42:13 | LL | let _ = map | _____________^ @@ -96,85 +96,85 @@ LL + }) | error: iterating on a map's values - --> $DIR/iter_kv_map.rs:52:13 + --> tests/ui/iter_kv_map.rs:52:13 | LL | let _ = map.clone().into_iter().map(|(_, mut val)| val).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:56:13 + --> tests/ui/iter_kv_map.rs:56:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:57:13 + --> tests/ui/iter_kv_map.rs:57:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:58:13 + --> tests/ui/iter_kv_map.rs:58:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:60:13 + --> tests/ui/iter_kv_map.rs:60:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:61:13 + --> tests/ui/iter_kv_map.rs:61:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:63:13 + --> tests/ui/iter_kv_map.rs:63:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:64:13 + --> tests/ui/iter_kv_map.rs:64:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:66:13 + --> tests/ui/iter_kv_map.rs:66:13 | LL | let _ = map.clone().iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:67:13 + --> tests/ui/iter_kv_map.rs:67:13 | LL | let _ = map.iter().map(|(key, _)| key).filter(|x| *x % 2 == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:77:13 + --> tests/ui/iter_kv_map.rs:77:13 | LL | let _ = map.iter().map(|(key, _value)| key * 9).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys().map(|key| key * 9)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:78:13 + --> tests/ui/iter_kv_map.rs:78:13 | LL | let _ = map.iter().map(|(_key, value)| value * 17).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|value| value * 17)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:81:13 + --> tests/ui/iter_kv_map.rs:81:13 | LL | let _ = map.clone().into_iter().map(|(_, ref val)| ref_acceptor(val)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|ref val| ref_acceptor(val))` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:84:13 + --> tests/ui/iter_kv_map.rs:84:13 | LL | let _ = map | _____________^ @@ -196,67 +196,67 @@ LL + }) | error: iterating on a map's values - --> $DIR/iter_kv_map.rs:94:13 + --> tests/ui/iter_kv_map.rs:94:13 | LL | let _ = map.clone().into_iter().map(|(_, mut val)| val).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:109:13 + --> tests/ui/iter_kv_map.rs:109:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:111:13 + --> tests/ui/iter_kv_map.rs:111:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:113:13 + --> tests/ui/iter_kv_map.rs:113:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:122:13 + --> tests/ui/iter_kv_map.rs:122:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:124:13 + --> tests/ui/iter_kv_map.rs:124:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:127:13 + --> tests/ui/iter_kv_map.rs:127:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:129:13 + --> tests/ui/iter_kv_map.rs:129:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:132:13 + --> tests/ui/iter_kv_map.rs:132:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:134:13 + --> tests/ui/iter_kv_map.rs:134:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:136:13 + --> tests/ui/iter_kv_map.rs:136:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` diff --git a/tests/ui/iter_next_loop.stderr b/tests/ui/iter_next_loop.stderr index 5871d21e49157..85c23f4e70944 100644 --- a/tests/ui/iter_next_loop.stderr +++ b/tests/ui/iter_next_loop.stderr @@ -1,5 +1,5 @@ error[E0423]: expected value, found macro `vec` - --> $DIR/iter_next_loop.rs:6:14 + --> tests/ui/iter_next_loop.rs:6:14 | LL | for _ in vec.iter().next() {} | ^^^ not a value diff --git a/tests/ui/iter_next_slice.stderr b/tests/ui/iter_next_slice.stderr index e6b4bd6c0b480..55cce2b9103da 100644 --- a/tests/ui/iter_next_slice.stderr +++ b/tests/ui/iter_next_slice.stderr @@ -1,5 +1,5 @@ error: using `.iter().next()` on an array - --> $DIR/iter_next_slice.rs:9:13 + --> tests/ui/iter_next_slice.rs:9:13 | LL | let _ = s.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `s.first()` @@ -8,19 +8,19 @@ LL | let _ = s.iter().next(); = help: to override `-D warnings` add `#[allow(clippy::iter_next_slice)]` error: using `.iter().next()` on a Slice without end index - --> $DIR/iter_next_slice.rs:12:13 + --> tests/ui/iter_next_slice.rs:12:13 | LL | let _ = s[2..].iter().next(); | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)` error: using `.iter().next()` on a Slice without end index - --> $DIR/iter_next_slice.rs:15:13 + --> tests/ui/iter_next_slice.rs:15:13 | LL | let _ = v[5..].iter().next(); | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)` error: using `.iter().next()` on an array - --> $DIR/iter_next_slice.rs:18:13 + --> tests/ui/iter_next_slice.rs:18:13 | LL | let _ = v.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `v.first()` diff --git a/tests/ui/iter_not_returning_iterator.stderr b/tests/ui/iter_not_returning_iterator.stderr index c695b1932d356..c3ee8bae772d5 100644 --- a/tests/ui/iter_not_returning_iterator.stderr +++ b/tests/ui/iter_not_returning_iterator.stderr @@ -1,5 +1,5 @@ error: this method is named `iter` but its return type does not implement `Iterator` - --> $DIR/iter_not_returning_iterator.rs:30:5 + --> tests/ui/iter_not_returning_iterator.rs:30:5 | LL | fn iter(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | fn iter(&self) -> Counter2 { = help: to override `-D warnings` add `#[allow(clippy::iter_not_returning_iterator)]` error: this method is named `iter_mut` but its return type does not implement `Iterator` - --> $DIR/iter_not_returning_iterator.rs:36:5 + --> tests/ui/iter_not_returning_iterator.rs:36:5 | LL | fn iter_mut(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this method is named `iter` but its return type does not implement `Iterator` - --> $DIR/iter_not_returning_iterator.rs:53:5 + --> tests/ui/iter_not_returning_iterator.rs:53:5 | LL | fn iter(&self) -> Self::I; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/iter_nth.stderr b/tests/ui/iter_nth.stderr index 162e6c3384941..c5dd0c99727be 100644 --- a/tests/ui/iter_nth.stderr +++ b/tests/ui/iter_nth.stderr @@ -1,5 +1,5 @@ error: called `.iter().nth()` on a `Vec` - --> $DIR/iter_nth.rs:34:23 + --> tests/ui/iter_nth.rs:34:23 | LL | let bad_vec = some_vec.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let bad_vec = some_vec.iter().nth(3); = help: to override `-D warnings` add `#[allow(clippy::iter_nth)]` error: called `.iter().nth()` on a slice - --> $DIR/iter_nth.rs:35:26 + --> tests/ui/iter_nth.rs:35:26 | LL | let bad_slice = &some_vec[..].iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let bad_slice = &some_vec[..].iter().nth(3); = help: calling `.get()` is both faster and more readable error: called `.iter().nth()` on a slice - --> $DIR/iter_nth.rs:36:31 + --> tests/ui/iter_nth.rs:36:31 | LL | let bad_boxed_slice = boxed_slice.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let bad_boxed_slice = boxed_slice.iter().nth(3); = help: calling `.get()` is both faster and more readable error: called `.iter().nth()` on a `VecDeque` - --> $DIR/iter_nth.rs:37:29 + --> tests/ui/iter_nth.rs:37:29 | LL | let bad_vec_deque = some_vec_deque.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let bad_vec_deque = some_vec_deque.iter().nth(3); = help: calling `.get()` is both faster and more readable error: called `.iter_mut().nth()` on a `Vec` - --> $DIR/iter_nth.rs:42:23 + --> tests/ui/iter_nth.rs:42:23 | LL | let bad_vec = some_vec.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let bad_vec = some_vec.iter_mut().nth(3); = help: calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a slice - --> $DIR/iter_nth.rs:45:26 + --> tests/ui/iter_nth.rs:45:26 | LL | let bad_slice = &some_vec[..].iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let bad_slice = &some_vec[..].iter_mut().nth(3); = help: calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a `VecDeque` - --> $DIR/iter_nth.rs:48:29 + --> tests/ui/iter_nth.rs:48:29 | LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/iter_nth_zero.stderr b/tests/ui/iter_nth_zero.stderr index 939fd0063c0b1..b5e5cf45c26bf 100644 --- a/tests/ui/iter_nth_zero.stderr +++ b/tests/ui/iter_nth_zero.stderr @@ -1,5 +1,5 @@ error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent - --> $DIR/iter_nth_zero.rs:18:14 + --> tests/ui/iter_nth_zero.rs:18:14 | LL | let _x = s.iter().nth(0); | ^^^^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `s.iter().next()` @@ -8,13 +8,13 @@ LL | let _x = s.iter().nth(0); = help: to override `-D warnings` add `#[allow(clippy::iter_nth_zero)]` error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent - --> $DIR/iter_nth_zero.rs:23:14 + --> tests/ui/iter_nth_zero.rs:23:14 | LL | let _y = iter.nth(0); | ^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter.next()` error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent - --> $DIR/iter_nth_zero.rs:28:22 + --> tests/ui/iter_nth_zero.rs:28:22 | LL | let _unwrapped = iter2.nth(0).unwrap(); | ^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter2.next()` diff --git a/tests/ui/iter_on_empty_collections.stderr b/tests/ui/iter_on_empty_collections.stderr index 57a5320199665..ade20ff26a019 100644 --- a/tests/ui/iter_on_empty_collections.stderr +++ b/tests/ui/iter_on_empty_collections.stderr @@ -1,5 +1,5 @@ error: `into_iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:5:16 + --> tests/ui/iter_on_empty_collections.rs:5:16 | LL | assert_eq!([].into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^ help: try: `std::iter::empty()` @@ -8,31 +8,31 @@ LL | assert_eq!([].into_iter().next(), Option::::None); = help: to override `-D warnings` add `#[allow(clippy::iter_on_empty_collections)]` error: `iter_mut` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:6:16 + --> tests/ui/iter_on_empty_collections.rs:6:16 | LL | assert_eq!([].iter_mut().next(), Option::<&mut i32>::None); | ^^^^^^^^^^^^^ help: try: `std::iter::empty()` error: `iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:7:16 + --> tests/ui/iter_on_empty_collections.rs:7:16 | LL | assert_eq!([].iter().next(), Option::<&i32>::None); | ^^^^^^^^^ help: try: `std::iter::empty()` error: `into_iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:8:16 + --> tests/ui/iter_on_empty_collections.rs:8:16 | LL | assert_eq!(None.into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` error: `iter_mut` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:9:16 + --> tests/ui/iter_on_empty_collections.rs:9:16 | LL | assert_eq!(None.iter_mut().next(), Option::<&mut i32>::None); | ^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` error: `iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:10:16 + --> tests/ui/iter_on_empty_collections.rs:10:16 | LL | assert_eq!(None.iter().next(), Option::<&i32>::None); | ^^^^^^^^^^^ help: try: `std::iter::empty()` diff --git a/tests/ui/iter_on_single_items.stderr b/tests/ui/iter_on_single_items.stderr index 00398f541e9a1..0252c859581b6 100644 --- a/tests/ui/iter_on_single_items.stderr +++ b/tests/ui/iter_on_single_items.stderr @@ -1,5 +1,5 @@ error: `into_iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:5:16 + --> tests/ui/iter_on_single_items.rs:5:16 | LL | assert_eq!([123].into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` @@ -8,31 +8,31 @@ LL | assert_eq!([123].into_iter().next(), Some(123)); = help: to override `-D warnings` add `#[allow(clippy::iter_on_single_items)]` error: `iter_mut` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:6:16 + --> tests/ui/iter_on_single_items.rs:6:16 | LL | assert_eq!([123].iter_mut().next(), Some(&mut 123)); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&mut 123)` error: `iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:7:16 + --> tests/ui/iter_on_single_items.rs:7:16 | LL | assert_eq!([123].iter().next(), Some(&123)); | ^^^^^^^^^^^^ help: try: `std::iter::once(&123)` error: `into_iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:8:16 + --> tests/ui/iter_on_single_items.rs:8:16 | LL | assert_eq!(Some(123).into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` error: `iter_mut` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:9:16 + --> tests/ui/iter_on_single_items.rs:9:16 | LL | assert_eq!(Some(123).iter_mut().next(), Some(&mut 123)); | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&mut 123)` error: `iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:10:16 + --> tests/ui/iter_on_single_items.rs:10:16 | LL | assert_eq!(Some(123).iter().next(), Some(&123)); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&123)` diff --git a/tests/ui/iter_out_of_bounds.stderr b/tests/ui/iter_out_of_bounds.stderr index f235faec8e59c..96df04251fc9e 100644 --- a/tests/ui/iter_out_of_bounds.stderr +++ b/tests/ui/iter_out_of_bounds.stderr @@ -1,18 +1,18 @@ error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:12:14 + --> tests/ui/iter_out_of_bounds.rs:12:14 | LL | for _ in [1, 2, 3].iter().skip(4) { | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this operation is useless and will create an empty iterator note: the lint level is defined here - --> $DIR/iter_out_of_bounds.rs:3:9 + --> tests/ui/iter_out_of_bounds.rs:3:9 | LL | #![deny(clippy::iter_out_of_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:16:19 + --> tests/ui/iter_out_of_bounds.rs:16:19 | LL | for (i, _) in [1, 2, 3].iter().take(4).enumerate() { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | for (i, _) in [1, 2, 3].iter().take(4).enumerate() { = note: this operation is useless and the returned iterator will simply yield the same items error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:22:14 + --> tests/ui/iter_out_of_bounds.rs:22:14 | LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:25:14 + --> tests/ui/iter_out_of_bounds.rs:25:14 | LL | for _ in [1, 2, 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | for _ in [1, 2, 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:28:14 + --> tests/ui/iter_out_of_bounds.rs:28:14 | LL | for _ in [1; 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | for _ in [1; 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:34:14 + --> tests/ui/iter_out_of_bounds.rs:34:14 | LL | for _ in vec![1, 2, 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | for _ in vec![1, 2, 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:37:14 + --> tests/ui/iter_out_of_bounds.rs:37:14 | LL | for _ in vec![1; 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | for _ in vec![1; 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:41:14 + --> tests/ui/iter_out_of_bounds.rs:41:14 | LL | for _ in x.iter().skip(4) {} | ^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | for _ in x.iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:45:14 + --> tests/ui/iter_out_of_bounds.rs:45:14 | LL | for _ in x.iter().skip(n) {} | ^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | for _ in x.iter().skip(n) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:50:14 + --> tests/ui/iter_out_of_bounds.rs:50:14 | LL | for _ in empty().skip(1) {} | ^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | for _ in empty().skip(1) {} = note: this operation is useless and will create an empty iterator error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:53:14 + --> tests/ui/iter_out_of_bounds.rs:53:14 | LL | for _ in empty().take(1) {} | ^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | for _ in empty().take(1) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:56:14 + --> tests/ui/iter_out_of_bounds.rs:56:14 | LL | for _ in std::iter::once(1).skip(2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | for _ in std::iter::once(1).skip(2) {} = note: this operation is useless and will create an empty iterator error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:59:14 + --> tests/ui/iter_out_of_bounds.rs:59:14 | LL | for _ in std::iter::once(1).take(2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | for _ in std::iter::once(1).take(2) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:62:14 + --> tests/ui/iter_out_of_bounds.rs:62:14 | LL | for x in [].iter().take(1) { | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/iter_over_hash_type.stderr b/tests/ui/iter_over_hash_type.stderr index cf420fb8e996e..6afe69ee20e1d 100644 --- a/tests/ui/iter_over_hash_type.stderr +++ b/tests/ui/iter_over_hash_type.stderr @@ -1,5 +1,5 @@ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:18:5 + --> tests/ui/iter_over_hash_type.rs:18:5 | LL | / for x in &hash_set { LL | | let _ = x; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::iter_over_hash_type)]` error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:21:5 + --> tests/ui/iter_over_hash_type.rs:21:5 | LL | / for x in hash_set.iter() { LL | | let _ = x; @@ -18,7 +18,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:24:5 + --> tests/ui/iter_over_hash_type.rs:24:5 | LL | / for x in hash_set.clone() { LL | | let _ = x; @@ -26,7 +26,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:27:5 + --> tests/ui/iter_over_hash_type.rs:27:5 | LL | / for x in hash_set.drain() { LL | | let _ = x; @@ -34,7 +34,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:32:5 + --> tests/ui/iter_over_hash_type.rs:32:5 | LL | / for (x, y) in &hash_map { LL | | let _ = (x, y); @@ -42,7 +42,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:35:5 + --> tests/ui/iter_over_hash_type.rs:35:5 | LL | / for x in hash_map.keys() { LL | | let _ = x; @@ -50,7 +50,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:38:5 + --> tests/ui/iter_over_hash_type.rs:38:5 | LL | / for x in hash_map.values() { LL | | let _ = x; @@ -58,7 +58,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:41:5 + --> tests/ui/iter_over_hash_type.rs:41:5 | LL | / for x in hash_map.values_mut() { LL | | *x += 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:44:5 + --> tests/ui/iter_over_hash_type.rs:44:5 | LL | / for x in hash_map.iter() { LL | | let _ = x; @@ -74,7 +74,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:47:5 + --> tests/ui/iter_over_hash_type.rs:47:5 | LL | / for x in hash_map.clone() { LL | | let _ = x; @@ -82,7 +82,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:50:5 + --> tests/ui/iter_over_hash_type.rs:50:5 | LL | / for x in hash_map.drain() { LL | | let _ = x; @@ -90,7 +90,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:55:5 + --> tests/ui/iter_over_hash_type.rs:55:5 | LL | / for x in fx_hash_set { LL | | let _ = x; @@ -98,7 +98,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:58:5 + --> tests/ui/iter_over_hash_type.rs:58:5 | LL | / for x in fx_hash_map { LL | | let _ = x; diff --git a/tests/ui/iter_overeager_cloned.stderr b/tests/ui/iter_overeager_cloned.stderr index a9a739688ebf2..7a822a79494b7 100644 --- a/tests/ui/iter_overeager_cloned.stderr +++ b/tests/ui/iter_overeager_cloned.stderr @@ -1,5 +1,5 @@ error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:7:29 + --> tests/ui/iter_overeager_cloned.rs:7:29 | LL | let _: Option = vec.iter().cloned().last(); | ^^^^^^^^^^---------------- @@ -10,7 +10,7 @@ LL | let _: Option = vec.iter().cloned().last(); = help: to override `-D warnings` add `#[allow(clippy::iter_overeager_cloned)]` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:9:29 + --> tests/ui/iter_overeager_cloned.rs:9:29 | LL | let _: Option = vec.iter().chain(vec.iter()).cloned().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------- @@ -18,7 +18,7 @@ LL | let _: Option = vec.iter().chain(vec.iter()).cloned().next(); | help: try: `.next().cloned()` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:11:20 + --> tests/ui/iter_overeager_cloned.rs:11:20 | LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------- @@ -29,7 +29,7 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:13:21 + --> tests/ui/iter_overeager_cloned.rs:13:21 | LL | let _: Vec<_> = vec.iter().cloned().take(2).collect(); | ^^^^^^^^^^----------------- @@ -37,7 +37,7 @@ LL | let _: Vec<_> = vec.iter().cloned().take(2).collect(); | help: try: `.take(2).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:15:21 + --> tests/ui/iter_overeager_cloned.rs:15:21 | LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect(); | ^^^^^^^^^^----------------- @@ -45,7 +45,7 @@ LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect(); | help: try: `.skip(2).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:17:13 + --> tests/ui/iter_overeager_cloned.rs:17:13 | LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------- @@ -53,7 +53,7 @@ LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | help: try: `.nth(2).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:19:13 + --> tests/ui/iter_overeager_cloned.rs:19:13 | LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))] | _____________^ @@ -69,7 +69,7 @@ LL ~ .flatten().cloned(); | error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:24:13 + --> tests/ui/iter_overeager_cloned.rs:24:13 | LL | let _ = vec.iter().cloned().filter(|x| x.starts_with('2')); | ^^^^^^^^^^---------------------------------------- @@ -77,7 +77,7 @@ LL | let _ = vec.iter().cloned().filter(|x| x.starts_with('2')); | help: try: `.filter(|&x| x.starts_with('2')).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:26:13 + --> tests/ui/iter_overeager_cloned.rs:26:13 | LL | let _ = vec.iter().cloned().find(|x| x == "2"); | ^^^^^^^^^^---------------------------- @@ -85,7 +85,7 @@ LL | let _ = vec.iter().cloned().find(|x| x == "2"); | help: try: `.find(|&x| x == "2").cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:30:17 + --> tests/ui/iter_overeager_cloned.rs:30:17 | LL | let _ = vec.iter().cloned().filter(f); | ^^^^^^^^^^------------------- @@ -93,7 +93,7 @@ LL | let _ = vec.iter().cloned().filter(f); | help: try: `.filter(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:31:17 + --> tests/ui/iter_overeager_cloned.rs:31:17 | LL | let _ = vec.iter().cloned().find(f); | ^^^^^^^^^^----------------- @@ -101,7 +101,7 @@ LL | let _ = vec.iter().cloned().find(f); | help: try: `.find(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:37:17 + --> tests/ui/iter_overeager_cloned.rs:37:17 | LL | let _ = vec.iter().cloned().filter(f); | ^^^^^^^^^^------------------- @@ -109,7 +109,7 @@ LL | let _ = vec.iter().cloned().filter(f); | help: try: `.filter(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:38:17 + --> tests/ui/iter_overeager_cloned.rs:38:17 | LL | let _ = vec.iter().cloned().find(f); | ^^^^^^^^^^----------------- @@ -117,7 +117,7 @@ LL | let _ = vec.iter().cloned().find(f); | help: try: `.find(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:45:9 + --> tests/ui/iter_overeager_cloned.rs:45:9 | LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == &target) | ^^^^------------------------------------------------------- @@ -125,7 +125,7 @@ LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == &target) | help: try: `.filter(move |&(&a, b)| a == 1 && b == &target).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:56:13 + --> tests/ui/iter_overeager_cloned.rs:56:13 | LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == &target) | ^^^^------------------------------------------------------------ @@ -133,7 +133,7 @@ LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == &target | help: try: `.filter(move |&S { a, b }| **a == 1 && b == &target).cloned()` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:60:13 + --> tests/ui/iter_overeager_cloned.rs:60:13 | LL | let _ = vec.iter().cloned().map(|x| x.len()); | ^^^^^^^^^^-------------------------- @@ -141,7 +141,7 @@ LL | let _ = vec.iter().cloned().map(|x| x.len()); | help: try: `.map(|x| x.len())` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:65:13 + --> tests/ui/iter_overeager_cloned.rs:65:13 | LL | let _ = vec.iter().cloned().for_each(|x| assert!(!x.is_empty())); | ^^^^^^^^^^---------------------------------------------- @@ -149,7 +149,7 @@ LL | let _ = vec.iter().cloned().for_each(|x| assert!(!x.is_empty())); | help: try: `.for_each(|x| assert!(!x.is_empty()))` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:67:13 + --> tests/ui/iter_overeager_cloned.rs:67:13 | LL | let _ = vec.iter().cloned().all(|x| x.len() == 1); | ^^^^^^^^^^------------------------------- @@ -157,7 +157,7 @@ LL | let _ = vec.iter().cloned().all(|x| x.len() == 1); | help: try: `.all(|x| x.len() == 1)` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:69:13 + --> tests/ui/iter_overeager_cloned.rs:69:13 | LL | let _ = vec.iter().cloned().any(|x| x.len() == 1); | ^^^^^^^^^^------------------------------- diff --git a/tests/ui/iter_skip_next.stderr b/tests/ui/iter_skip_next.stderr index 39b173e758693..0fa04465ff156 100644 --- a/tests/ui/iter_skip_next.stderr +++ b/tests/ui/iter_skip_next.stderr @@ -1,5 +1,5 @@ error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:17:28 + --> tests/ui/iter_skip_next.rs:17:28 | LL | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` @@ -8,37 +8,37 @@ LL | let _ = some_vec.iter().skip(42).next(); = help: to override `-D warnings` add `#[allow(clippy::iter_skip_next)]` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:18:36 + --> tests/ui/iter_skip_next.rs:18:36 | LL | let _ = some_vec.iter().cycle().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:19:20 + --> tests/ui/iter_skip_next.rs:19:20 | LL | let _ = (1..10).skip(10).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(10)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:20:33 + --> tests/ui/iter_skip_next.rs:20:33 | LL | let _ = &some_vec[..].iter().skip(3).next(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(3)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:28:26 + --> tests/ui/iter_skip_next.rs:28:26 | LL | let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:30:29 + --> tests/ui/iter_skip_next.rs:30:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:36:29 + --> tests/ui/iter_skip_next.rs:36:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` diff --git a/tests/ui/iter_skip_next_unfixable.stderr b/tests/ui/iter_skip_next_unfixable.stderr index 09a467793bd12..9bfffb07ca62d 100644 --- a/tests/ui/iter_skip_next_unfixable.stderr +++ b/tests/ui/iter_skip_next_unfixable.stderr @@ -1,11 +1,11 @@ error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next_unfixable.rs:9:26 + --> tests/ui/iter_skip_next_unfixable.rs:9:26 | LL | let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `sp` has to be mutable - --> $DIR/iter_skip_next_unfixable.rs:8:9 + --> tests/ui/iter_skip_next_unfixable.rs:8:9 | LL | let sp = test_string.split('|').map(|s| s.trim()); | ^^ @@ -13,25 +13,25 @@ LL | let sp = test_string.split('|').map(|s| s.trim()); = help: to override `-D warnings` add `#[allow(clippy::iter_skip_next)]` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next_unfixable.rs:12:29 + --> tests/ui/iter_skip_next_unfixable.rs:12:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `s` has to be mutable - --> $DIR/iter_skip_next_unfixable.rs:11:17 + --> tests/ui/iter_skip_next_unfixable.rs:11:17 | LL | if let Some(s) = Some(test_string.split('|').map(|s| s.trim())) { | ^ error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next_unfixable.rs:19:29 + --> tests/ui/iter_skip_next_unfixable.rs:19:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `s` has to be mutable - --> $DIR/iter_skip_next_unfixable.rs:15:17 + --> tests/ui/iter_skip_next_unfixable.rs:15:17 | LL | fn check(s: T) | ^ diff --git a/tests/ui/iter_skip_zero.stderr b/tests/ui/iter_skip_zero.stderr index 6b8b3b1056acf..ef46db8433778 100644 --- a/tests/ui/iter_skip_zero.stderr +++ b/tests/ui/iter_skip_zero.stderr @@ -1,5 +1,5 @@ error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:11:35 + --> tests/ui/iter_skip_zero.rs:11:35 | LL | let _ = [1, 2, 3].iter().skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -9,7 +9,7 @@ LL | let _ = [1, 2, 3].iter().skip(0); = help: to override `-D warnings` add `#[allow(clippy::iter_skip_zero)]` error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:12:39 + --> tests/ui/iter_skip_zero.rs:12:39 | LL | let _ = vec![1, 2, 3].iter().skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -17,7 +17,7 @@ LL | let _ = vec![1, 2, 3].iter().skip(0); = note: this call to `skip` does nothing and is useless; remove it error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:13:34 + --> tests/ui/iter_skip_zero.rs:13:34 | LL | let _ = once([1, 2, 3]).skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -25,7 +25,7 @@ LL | let _ = once([1, 2, 3]).skip(0); = note: this call to `skip` does nothing and is useless; remove it error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:14:71 + --> tests/ui/iter_skip_zero.rs:14:71 | LL | let _ = vec![1, 2, 3].iter().chain([1, 2, 3].iter().skip(0)).skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -33,7 +33,7 @@ LL | let _ = vec![1, 2, 3].iter().chain([1, 2, 3].iter().skip(0)).skip(0); = note: this call to `skip` does nothing and is useless; remove it error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:14:62 + --> tests/ui/iter_skip_zero.rs:14:62 | LL | let _ = vec![1, 2, 3].iter().chain([1, 2, 3].iter().skip(0)).skip(0); | ^ help: if you meant to skip the first element, use: `1` diff --git a/tests/ui/iter_with_drain.stderr b/tests/ui/iter_with_drain.stderr index ac04f9396f5d2..265e18c263be8 100644 --- a/tests/ui/iter_with_drain.stderr +++ b/tests/ui/iter_with_drain.stderr @@ -1,5 +1,5 @@ error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:10:34 + --> tests/ui/iter_with_drain.rs:10:34 | LL | let mut a: BinaryHeap<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try: `into_iter()` @@ -8,31 +8,31 @@ LL | let mut a: BinaryHeap<_> = a.drain(..).collect(); = help: to override `-D warnings` add `#[allow(clippy::iter_with_drain)]` error: `drain(..)` used on a `VecDeque` - --> $DIR/iter_with_drain.rs:13:27 + --> tests/ui/iter_with_drain.rs:13:27 | LL | let mut a: Vec<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:14:34 + --> tests/ui/iter_with_drain.rs:14:34 | LL | let mut a: HashMap<_, _> = a.drain(..).map(|x| (x.clone(), x)).collect(); | ^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:20:34 + --> tests/ui/iter_with_drain.rs:20:34 | LL | let mut a: BinaryHeap<_> = a.drain(0..).collect(); | ^^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `VecDeque` - --> $DIR/iter_with_drain.rs:23:27 + --> tests/ui/iter_with_drain.rs:23:27 | LL | let mut a: Vec<_> = a.drain(..a.len()).collect(); | ^^^^^^^^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:24:34 + --> tests/ui/iter_with_drain.rs:24:34 | LL | let mut a: HashMap<_, _> = a.drain(0..a.len()).map(|x| (x.clone(), x)).collect(); | ^^^^^^^^^^^^^^^^^ help: try: `into_iter()` diff --git a/tests/ui/iter_without_into_iter.stderr b/tests/ui/iter_without_into_iter.stderr index 4cf20e2aa56c9..382a7606f48c6 100644 --- a/tests/ui/iter_without_into_iter.stderr +++ b/tests/ui/iter_without_into_iter.stderr @@ -1,5 +1,5 @@ error: `iter` method without an `IntoIterator` impl for `&S1` - --> $DIR/iter_without_into_iter.rs:8:5 + --> tests/ui/iter_without_into_iter.rs:8:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'_, u8> { LL | | @@ -22,7 +22,7 @@ LL + } | error: `iter_mut` method without an `IntoIterator` impl for `&mut S1` - --> $DIR/iter_without_into_iter.rs:12:5 + --> tests/ui/iter_without_into_iter.rs:12:5 | LL | / pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, u8> { LL | | @@ -43,7 +43,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&S3<'a>` - --> $DIR/iter_without_into_iter.rs:28:5 + --> tests/ui/iter_without_into_iter.rs:28:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'_, u8> { LL | | @@ -64,7 +64,7 @@ LL + } | error: `iter_mut` method without an `IntoIterator` impl for `&mut S3<'a>` - --> $DIR/iter_without_into_iter.rs:32:5 + --> tests/ui/iter_without_into_iter.rs:32:5 | LL | / pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, u8> { LL | | @@ -85,7 +85,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&S8` - --> $DIR/iter_without_into_iter.rs:69:5 + --> tests/ui/iter_without_into_iter.rs:69:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'static, T> { LL | | todo!() @@ -105,7 +105,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&S9` - --> $DIR/iter_without_into_iter.rs:77:5 + --> tests/ui/iter_without_into_iter.rs:77:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'_, T> { LL | | @@ -126,7 +126,7 @@ LL + } | error: `iter_mut` method without an `IntoIterator` impl for `&mut S9` - --> $DIR/iter_without_into_iter.rs:81:5 + --> tests/ui/iter_without_into_iter.rs:81:5 | LL | / pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, T> { LL | | @@ -147,7 +147,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&Issue12037` - --> $DIR/iter_without_into_iter.rs:130:13 + --> tests/ui/iter_without_into_iter.rs:130:13 | LL | / fn iter(&self) -> std::slice::Iter<'_, u8> { LL | | todo!() diff --git a/tests/ui/iterator_step_by_zero.stderr b/tests/ui/iterator_step_by_zero.stderr index 20ea29322e858..4156642d6dbb8 100644 --- a/tests/ui/iterator_step_by_zero.stderr +++ b/tests/ui/iterator_step_by_zero.stderr @@ -1,5 +1,5 @@ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:4:13 + --> tests/ui/iterator_step_by_zero.rs:4:13 | LL | let _ = vec!["A", "B", "B"].iter().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,37 +8,37 @@ LL | let _ = vec!["A", "B", "B"].iter().step_by(0); = help: to override `-D warnings` add `#[allow(clippy::iterator_step_by_zero)]` error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:7:13 + --> tests/ui/iterator_step_by_zero.rs:7:13 | LL | let _ = "XXX".chars().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:9:13 + --> tests/ui/iterator_step_by_zero.rs:9:13 | LL | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:19:13 + --> tests/ui/iterator_step_by_zero.rs:19:13 | LL | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:21:13 + --> tests/ui/iterator_step_by_zero.rs:21:13 | LL | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:25:13 + --> tests/ui/iterator_step_by_zero.rs:25:13 | LL | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:30:13 + --> tests/ui/iterator_step_by_zero.rs:30:13 | LL | let _ = v1.iter().step_by(2 / 3); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/join_absolute_paths.stderr b/tests/ui/join_absolute_paths.stderr index ab4d189ca3a22..e7fd5508823ae 100644 --- a/tests/ui/join_absolute_paths.stderr +++ b/tests/ui/join_absolute_paths.stderr @@ -1,5 +1,5 @@ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:10:15 + --> tests/ui/join_absolute_paths.rs:10:15 | LL | path.join("/sh"); | ^^^^^ @@ -17,7 +17,7 @@ LL | PathBuf::from("/sh"); | ~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:14:15 + --> tests/ui/join_absolute_paths.rs:14:15 | LL | path.join("\\user"); | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | PathBuf::from("\\user"); | ~~~~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:18:15 + --> tests/ui/join_absolute_paths.rs:18:15 | LL | path.join("/sh"); | ^^^^^ @@ -49,7 +49,7 @@ LL | PathBuf::from("/sh"); | ~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:22:15 + --> tests/ui/join_absolute_paths.rs:22:15 | LL | path.join(r#"/sh"#); | ^^^^^^^^ diff --git a/tests/ui/large_const_arrays.stderr b/tests/ui/large_const_arrays.stderr index e522550ffcbdc..88f921b81f721 100644 --- a/tests/ui/large_const_arrays.stderr +++ b/tests/ui/large_const_arrays.stderr @@ -1,5 +1,5 @@ error: large array defined as const - --> $DIR/large_const_arrays.rs:10:1 + --> tests/ui/large_const_arrays.rs:10:1 | LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]` error: large array defined as const - --> $DIR/large_const_arrays.rs:11:1 + --> tests/ui/large_const_arrays.rs:11:1 | LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:12:1 + --> tests/ui/large_const_arrays.rs:12:1 | LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:21:5 + --> tests/ui/large_const_arrays.rs:21:5 | LL | pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:22:5 + --> tests/ui/large_const_arrays.rs:22:5 | LL | const BAR: [u32; 1_000_000] = [0u32; 1_000_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | const BAR: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:23:5 + --> tests/ui/large_const_arrays.rs:23:5 | LL | pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:24:5 + --> tests/ui/large_const_arrays.rs:24:5 | LL | const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL | const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:25:5 + --> tests/ui/large_const_arrays.rs:25:5 | LL | pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:26:5 + --> tests/ui/large_const_arrays.rs:26:5 | LL | const BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index e5f37a6cce96b..da34a91bc3bcf 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -1,5 +1,5 @@ error: digits of hex, binary or octal literal not in groups of equal size - --> $DIR/large_digit_groups.rs:22:9 + --> tests/ui/large_digit_groups.rs:22:9 | LL | 0xd_e_adbee_f_usize, | ^^^^^^^^^^^^^^^^^^^ help: consider: `0xdead_beef_usize` @@ -8,7 +8,7 @@ LL | 0xd_e_adbee_f_usize, = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:23:9 + --> tests/ui/large_digit_groups.rs:23:9 | LL | 1_23456_f32, | ^^^^^^^^^^^ help: consider: `123_456_f32` @@ -17,19 +17,19 @@ LL | 1_23456_f32, = help: to override `-D warnings` add `#[allow(clippy::large_digit_groups)]` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:24:9 + --> tests/ui/large_digit_groups.rs:24:9 | LL | 1_23456.12_f32, | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:25:9 + --> tests/ui/large_digit_groups.rs:25:9 | LL | 1_23456.12345_f64, | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f64` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:26:9 + --> tests/ui/large_digit_groups.rs:26:9 | LL | 1_23456.12345_6_f64, | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f64` diff --git a/tests/ui/large_enum_variant.32bit.stderr b/tests/ui/large_enum_variant.32bit.stderr index 0e0eee21cf30a..ff4f1a7f312cb 100644 --- a/tests/ui/large_enum_variant.32bit.stderr +++ b/tests/ui/large_enum_variant.32bit.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:11:1 + --> tests/ui/large_enum_variant.rs:11:1 | LL | / enum LargeEnum { LL | | A(i32), @@ -17,7 +17,7 @@ LL | B(Box<[i32; 8000]>), | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:35:1 + --> tests/ui/large_enum_variant.rs:35:1 | LL | / enum LargeEnum2 { LL | | VariantOk(i32, u32), @@ -33,7 +33,7 @@ LL | ContainingLargeEnum(Box), | ~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:40:1 + --> tests/ui/large_enum_variant.rs:40:1 | LL | / enum LargeEnum3 { LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), @@ -50,7 +50,7 @@ LL | ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>), | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:46:1 + --> tests/ui/large_enum_variant.rs:46:1 | LL | / enum LargeEnum4 { LL | | VariantOk(i32, u32), @@ -66,7 +66,7 @@ LL | StructLikeLarge { x: Box<[i32; 8000]>, y: i32 }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:51:1 + --> tests/ui/large_enum_variant.rs:51:1 | LL | / enum LargeEnum5 { LL | | VariantOk(i32, u32), @@ -82,7 +82,7 @@ LL | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:67:1 + --> tests/ui/large_enum_variant.rs:67:1 | LL | / enum LargeEnum7 { LL | | A, @@ -99,7 +99,7 @@ LL | B(Box<[u8; 1255]>), | ~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:73:1 + --> tests/ui/large_enum_variant.rs:73:1 | LL | / enum LargeEnum8 { LL | | VariantOk(i32, u32), @@ -115,7 +115,7 @@ LL | ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]> | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:78:1 + --> tests/ui/large_enum_variant.rs:78:1 | LL | / enum LargeEnum9 { LL | | A(Struct<()>), @@ -131,7 +131,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:83:1 + --> tests/ui/large_enum_variant.rs:83:1 | LL | / enum LargeEnumOk2 { LL | | A(T), @@ -147,7 +147,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:88:1 + --> tests/ui/large_enum_variant.rs:88:1 | LL | / enum LargeEnumOk3 { LL | | A(Struct), @@ -163,7 +163,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:103:1 + --> tests/ui/large_enum_variant.rs:103:1 | LL | / enum CopyableLargeEnum { LL | | A(bool), @@ -174,18 +174,18 @@ LL | | } | |_^ the entire enum is at least 64004 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:103:6 + --> tests/ui/large_enum_variant.rs:103:6 | LL | enum CopyableLargeEnum { | ^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:105:5 + --> tests/ui/large_enum_variant.rs:105:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:108:1 + --> tests/ui/large_enum_variant.rs:108:1 | LL | / enum ManuallyCopyLargeEnum { LL | | A(bool), @@ -196,18 +196,18 @@ LL | | } | |_^ the entire enum is at least 64004 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:108:6 + --> tests/ui/large_enum_variant.rs:108:6 | LL | enum ManuallyCopyLargeEnum { | ^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:110:5 + --> tests/ui/large_enum_variant.rs:110:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:121:1 + --> tests/ui/large_enum_variant.rs:121:1 | LL | / enum SomeGenericPossiblyCopyEnum { LL | | A(bool, std::marker::PhantomData), @@ -218,18 +218,18 @@ LL | | } | |_^ the entire enum is at least 32004 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:121:6 + --> tests/ui/large_enum_variant.rs:121:6 | LL | enum SomeGenericPossiblyCopyEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:123:5 + --> tests/ui/large_enum_variant.rs:123:5 | LL | B([u64; 4000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:134:1 + --> tests/ui/large_enum_variant.rs:134:1 | LL | / enum LargeEnumWithGenerics { LL | | Small, @@ -245,7 +245,7 @@ LL | Large(Box<(T, [u8; 512])>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:143:1 + --> tests/ui/large_enum_variant.rs:143:1 | LL | / enum WithGenerics { LL | | Large([Foo; 64]), @@ -261,7 +261,7 @@ LL | Large(Box<[Foo; 64]>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:153:1 + --> tests/ui/large_enum_variant.rs:153:1 | LL | / enum LargeEnumOfConst { LL | | Ok, diff --git a/tests/ui/large_enum_variant.64bit.stderr b/tests/ui/large_enum_variant.64bit.stderr index 3eba43e05ece5..805cb406f8344 100644 --- a/tests/ui/large_enum_variant.64bit.stderr +++ b/tests/ui/large_enum_variant.64bit.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:11:1 + --> tests/ui/large_enum_variant.rs:11:1 | LL | / enum LargeEnum { LL | | A(i32), @@ -17,7 +17,7 @@ LL | B(Box<[i32; 8000]>), | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:35:1 + --> tests/ui/large_enum_variant.rs:35:1 | LL | / enum LargeEnum2 { LL | | VariantOk(i32, u32), @@ -33,7 +33,7 @@ LL | ContainingLargeEnum(Box), | ~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:40:1 + --> tests/ui/large_enum_variant.rs:40:1 | LL | / enum LargeEnum3 { LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), @@ -50,7 +50,7 @@ LL | ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>), | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:46:1 + --> tests/ui/large_enum_variant.rs:46:1 | LL | / enum LargeEnum4 { LL | | VariantOk(i32, u32), @@ -66,7 +66,7 @@ LL | StructLikeLarge { x: Box<[i32; 8000]>, y: i32 }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:51:1 + --> tests/ui/large_enum_variant.rs:51:1 | LL | / enum LargeEnum5 { LL | | VariantOk(i32, u32), @@ -82,7 +82,7 @@ LL | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:67:1 + --> tests/ui/large_enum_variant.rs:67:1 | LL | / enum LargeEnum7 { LL | | A, @@ -99,7 +99,7 @@ LL | B(Box<[u8; 1255]>), | ~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:73:1 + --> tests/ui/large_enum_variant.rs:73:1 | LL | / enum LargeEnum8 { LL | | VariantOk(i32, u32), @@ -115,7 +115,7 @@ LL | ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]> | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:78:1 + --> tests/ui/large_enum_variant.rs:78:1 | LL | / enum LargeEnum9 { LL | | A(Struct<()>), @@ -131,7 +131,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:83:1 + --> tests/ui/large_enum_variant.rs:83:1 | LL | / enum LargeEnumOk2 { LL | | A(T), @@ -147,7 +147,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:88:1 + --> tests/ui/large_enum_variant.rs:88:1 | LL | / enum LargeEnumOk3 { LL | | A(Struct), @@ -163,7 +163,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:103:1 + --> tests/ui/large_enum_variant.rs:103:1 | LL | / enum CopyableLargeEnum { LL | | A(bool), @@ -174,18 +174,18 @@ LL | | } | |_^ the entire enum is at least 64008 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:103:6 + --> tests/ui/large_enum_variant.rs:103:6 | LL | enum CopyableLargeEnum { | ^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:105:5 + --> tests/ui/large_enum_variant.rs:105:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:108:1 + --> tests/ui/large_enum_variant.rs:108:1 | LL | / enum ManuallyCopyLargeEnum { LL | | A(bool), @@ -196,18 +196,18 @@ LL | | } | |_^ the entire enum is at least 64008 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:108:6 + --> tests/ui/large_enum_variant.rs:108:6 | LL | enum ManuallyCopyLargeEnum { | ^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:110:5 + --> tests/ui/large_enum_variant.rs:110:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:121:1 + --> tests/ui/large_enum_variant.rs:121:1 | LL | / enum SomeGenericPossiblyCopyEnum { LL | | A(bool, std::marker::PhantomData), @@ -218,18 +218,18 @@ LL | | } | |_^ the entire enum is at least 32008 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:121:6 + --> tests/ui/large_enum_variant.rs:121:6 | LL | enum SomeGenericPossiblyCopyEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:123:5 + --> tests/ui/large_enum_variant.rs:123:5 | LL | B([u64; 4000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:134:1 + --> tests/ui/large_enum_variant.rs:134:1 | LL | / enum LargeEnumWithGenerics { LL | | Small, @@ -245,7 +245,7 @@ LL | Large(Box<(T, [u8; 512])>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:143:1 + --> tests/ui/large_enum_variant.rs:143:1 | LL | / enum WithGenerics { LL | | Large([Foo; 64]), @@ -261,7 +261,7 @@ LL | Large(Box<[Foo; 64]>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:153:1 + --> tests/ui/large_enum_variant.rs:153:1 | LL | / enum LargeEnumOfConst { LL | | Ok, diff --git a/tests/ui/large_futures.stderr b/tests/ui/large_futures.stderr index 861366dafac6d..5709c7b77a0a5 100644 --- a/tests/ui/large_futures.stderr +++ b/tests/ui/large_futures.stderr @@ -1,5 +1,5 @@ error: large future with a size of 16385 bytes - --> $DIR/large_futures.rs:11:9 + --> tests/ui/large_futures.rs:11:9 | LL | big_fut([0u8; 1024 * 16]).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(big_fut([0u8; 1024 * 16]))` @@ -8,37 +8,37 @@ LL | big_fut([0u8; 1024 * 16]).await; = help: to override `-D warnings` add `#[allow(clippy::large_futures)]` error: large future with a size of 16386 bytes - --> $DIR/large_futures.rs:15:5 + --> tests/ui/large_futures.rs:15:5 | LL | f.await | ^ help: consider `Box::pin` on it: `Box::pin(f)` error: large future with a size of 16387 bytes - --> $DIR/large_futures.rs:20:9 + --> tests/ui/large_futures.rs:20:9 | LL | wait().await; | ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())` error: large future with a size of 16387 bytes - --> $DIR/large_futures.rs:25:13 + --> tests/ui/large_futures.rs:25:13 | LL | wait().await; | ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())` error: large future with a size of 65540 bytes - --> $DIR/large_futures.rs:33:5 + --> tests/ui/large_futures.rs:33:5 | LL | foo().await; | ^^^^^ help: consider `Box::pin` on it: `Box::pin(foo())` error: large future with a size of 49159 bytes - --> $DIR/large_futures.rs:35:5 + --> tests/ui/large_futures.rs:35:5 | LL | calls_fut(fut).await; | ^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(calls_fut(fut))` error: large future with a size of 65540 bytes - --> $DIR/large_futures.rs:48:5 + --> tests/ui/large_futures.rs:48:5 | LL | / async { LL | | @@ -59,7 +59,7 @@ LL + }) | error: large future with a size of 65540 bytes - --> $DIR/large_futures.rs:60:13 + --> tests/ui/large_futures.rs:60:13 | LL | / async { LL | | let x = [0i32; 1024 * 16]; diff --git a/tests/ui/large_stack_arrays.stderr b/tests/ui/large_stack_arrays.stderr index 0dfb6732b02a5..007ca61c2de13 100644 --- a/tests/ui/large_stack_arrays.stderr +++ b/tests/ui/large_stack_arrays.stderr @@ -1,5 +1,5 @@ error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:29:14 + --> tests/ui/large_stack_arrays.rs:29:14 | LL | let _x = [build(); 3]; | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _x = [build(); 3]; = help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:32:14 + --> tests/ui/large_stack_arrays.rs:32:14 | LL | let _y = [build(), build(), build()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _y = [build(), build(), build()]; = help: consider allocating on the heap with `vec![build(), build(), build()].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:38:9 + --> tests/ui/large_stack_arrays.rs:38:9 | LL | [0u32; 20_000_000], | ^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | [0u32; 20_000_000], = help: consider allocating on the heap with `vec![0u32; 20_000_000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:40:9 + --> tests/ui/large_stack_arrays.rs:40:9 | LL | [S { data: [0; 32] }; 5000], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | [S { data: [0; 32] }; 5000], = help: consider allocating on the heap with `vec![S { data: [0; 32] }; 5000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:42:9 + --> tests/ui/large_stack_arrays.rs:42:9 | LL | [Some(""); 20_000_000], | ^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | [Some(""); 20_000_000], = help: consider allocating on the heap with `vec![Some(""); 20_000_000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:44:9 + --> tests/ui/large_stack_arrays.rs:44:9 | LL | [E::T(0); 5000], | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | [E::T(0); 5000], = help: consider allocating on the heap with `vec![E::T(0); 5000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:46:9 + --> tests/ui/large_stack_arrays.rs:46:9 | LL | [0u8; usize::MAX], | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/large_stack_frames.stderr b/tests/ui/large_stack_frames.stderr index 12a458db807e1..b99500fd9c34d 100644 --- a/tests/ui/large_stack_frames.stderr +++ b/tests/ui/large_stack_frames.stderr @@ -1,5 +1,5 @@ error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames.rs:25:1 + --> tests/ui/large_stack_frames.rs:25:1 | LL | / fn many_small_arrays() { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]` error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames.rs:36:1 + --> tests/ui/large_stack_frames.rs:36:1 | LL | / fn large_return_value() -> ArrayDefault<1_000_000> { LL | | @@ -27,7 +27,7 @@ LL | | } = note: allocating large amounts of stack space can overflow the stack error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames.rs:42:1 + --> tests/ui/large_stack_frames.rs:42:1 | LL | / fn large_fn_arg(x: ArrayDefault<1_000_000>) { LL | | diff --git a/tests/ui/large_types_passed_by_value.stderr b/tests/ui/large_types_passed_by_value.stderr index b3f102cc498d8..5b42ab9e02ac4 100644 --- a/tests/ui/large_types_passed_by_value.stderr +++ b/tests/ui/large_types_passed_by_value.stderr @@ -1,5 +1,5 @@ error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:20:11 + --> tests/ui/large_types_passed_by_value.rs:20:11 | LL | fn bad(a: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` @@ -8,43 +8,43 @@ LL | fn bad(a: LargeAndCopy) {} = help: to override `-D warnings` add `#[allow(clippy::large_types_passed_by_value)]` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:25:37 + --> tests/ui/large_types_passed_by_value.rs:25:37 | LL | fn other_is_not_ok(self, other: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:31:36 + --> tests/ui/large_types_passed_by_value.rs:31:36 | LL | fn devoure_array(&self, array: [u8; 6666]); | ^^^^^^^^^^ help: consider passing by reference instead: `&[u8; 6666]` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:32:34 + --> tests/ui/large_types_passed_by_value.rs:32:34 | LL | fn devoure_tuple(&self, tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider passing by reference instead: `&(LargeAndCopy, LargeAndCopy)` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:33:50 + --> tests/ui/large_types_passed_by_value.rs:33:50 | LL | fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^ help: consider passing by reference instead: `&[u8; 6666]` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:33:67 + --> tests/ui/large_types_passed_by_value.rs:33:67 | LL | fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider passing by reference instead: `&(LargeAndCopy, LargeAndCopy)` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:58:17 + --> tests/ui/large_types_passed_by_value.rs:58:17 | LL | fn foo_never(x: LargeAndCopy) { | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) - --> $DIR/large_types_passed_by_value.rs:62:11 + --> tests/ui/large_types_passed_by_value.rs:62:11 | LL | fn foo(x: LargeAndCopy) { | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` diff --git a/tests/ui/len_without_is_empty.stderr b/tests/ui/len_without_is_empty.stderr index 8e51c28b33003..11d0d855fc0b8 100644 --- a/tests/ui/len_without_is_empty.stderr +++ b/tests/ui/len_without_is_empty.stderr @@ -1,5 +1,5 @@ error: struct `PubOne` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:7:5 + --> tests/ui/len_without_is_empty.rs:7:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | pub fn len(&self) -> isize { = help: to override `-D warnings` add `#[allow(clippy::len_without_is_empty)]` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_without_is_empty.rs:57:1 + --> tests/ui/len_without_is_empty.rs:57:1 | LL | / pub trait PubTraitsToo { LL | | @@ -17,45 +17,45 @@ LL | | } | |_^ error: struct `HasIsEmpty` has a public `len` method, but a private `is_empty` method - --> $DIR/len_without_is_empty.rs:71:5 + --> tests/ui/len_without_is_empty.rs:71:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:76:5 + --> tests/ui/len_without_is_empty.rs:76:5 | LL | fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `HasWrongIsEmpty` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:84:5 + --> tests/ui/len_without_is_empty.rs:84:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:89:5 + --> tests/ui/len_without_is_empty.rs:89:5 | LL | pub fn is_empty(&self, x: u32) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` error: struct `MismatchedSelf` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:97:5 + --> tests/ui/len_without_is_empty.rs:97:5 | LL | pub fn len(self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:102:5 + --> tests/ui/len_without_is_empty.rs:102:5 | LL | pub fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(self) -> bool` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_without_is_empty.rs:177:1 + --> tests/ui/len_without_is_empty.rs:177:1 | LL | / pub trait DependsOnFoo: Foo { LL | | @@ -64,33 +64,33 @@ LL | | } | |_^ error: struct `OptionalLen3` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:223:5 + --> tests/ui/len_without_is_empty.rs:223:5 | LL | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:229:5 + --> tests/ui/len_without_is_empty.rs:229:5 | LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` error: struct `ResultLen` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:236:5 + --> tests/ui/len_without_is_empty.rs:236:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:243:5 + --> tests/ui/len_without_is_empty.rs:243:5 | LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` or `(&self) -> Result error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:236:5 + --> tests/ui/len_without_is_empty.rs:236:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | pub fn len(&self) -> Result { = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:250:5 + --> tests/ui/len_without_is_empty.rs:250:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | pub fn len(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:255:5 + --> tests/ui/len_without_is_empty.rs:255:5 | LL | pub fn is_empty(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | pub fn is_empty(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:263:5 + --> tests/ui/len_without_is_empty.rs:263:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,25 +124,25 @@ LL | pub fn len(&self) -> Result { = help: use a custom `Error` type instead error: struct `AsyncLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:305:5 + --> tests/ui/len_without_is_empty.rs:305:5 | LL | pub async fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `AsyncOptionLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:318:5 + --> tests/ui/len_without_is_empty.rs:318:5 | LL | pub async fn len(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `AsyncResultLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:340:5 + --> tests/ui/len_without_is_empty.rs:340:5 | LL | pub async fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `Alias2` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:456:5 + --> tests/ui/len_without_is_empty.rs:456:5 | LL | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index e1f2434415d0f..b1f04c94de665 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,5 +1,5 @@ error: length comparison to zero - --> $DIR/len_zero.rs:82:8 + --> tests/ui/len_zero.rs:82:8 | LL | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` @@ -8,13 +8,13 @@ LL | if x.len() == 0 { = help: to override `-D warnings` add `#[allow(clippy::len_zero)]` error: length comparison to zero - --> $DIR/len_zero.rs:86:8 + --> tests/ui/len_zero.rs:86:8 | LL | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:95:20 + --> tests/ui/len_zero.rs:95:20 | LL | println!("{}", *s1 == ""); | ^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s1.is_empty()` @@ -23,121 +23,121 @@ LL | println!("{}", *s1 == ""); = help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]` error: comparison to empty slice - --> $DIR/len_zero.rs:96:20 + --> tests/ui/len_zero.rs:96:20 | LL | println!("{}", **s2 == ""); | ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s2.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:97:20 + --> tests/ui/len_zero.rs:97:20 | LL | println!("{}", ***s3 == ""); | ^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s3.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:98:20 + --> tests/ui/len_zero.rs:98:20 | LL | println!("{}", ****s4 == ""); | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s4.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:99:20 + --> tests/ui/len_zero.rs:99:20 | LL | println!("{}", *****s5 == ""); | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s5.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:100:20 + --> tests/ui/len_zero.rs:100:20 | LL | println!("{}", ******(s6) == ""); | ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(s6).is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:103:20 + --> tests/ui/len_zero.rs:103:20 | LL | println!("{}", &**d2s == ""); | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(**d2s).is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:118:8 + --> tests/ui/len_zero.rs:118:8 | LL | if has_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:121:8 + --> tests/ui/len_zero.rs:121:8 | LL | if has_is_empty.len() != 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:124:8 + --> tests/ui/len_zero.rs:124:8 | LL | if has_is_empty.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:127:8 + --> tests/ui/len_zero.rs:127:8 | LL | if has_is_empty.len() < 1 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:130:8 + --> tests/ui/len_zero.rs:130:8 | LL | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:141:8 + --> tests/ui/len_zero.rs:141:8 | LL | if 0 == has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:144:8 + --> tests/ui/len_zero.rs:144:8 | LL | if 0 != has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:147:8 + --> tests/ui/len_zero.rs:147:8 | LL | if 0 < has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:150:8 + --> tests/ui/len_zero.rs:150:8 | LL | if 1 <= has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:153:8 + --> tests/ui/len_zero.rs:153:8 | LL | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:167:8 + --> tests/ui/len_zero.rs:167:8 | LL | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:179:6 + --> tests/ui/len_zero.rs:179:6 | LL | (has_is_empty.len() > 0).then(|| println!("This can happen.")); | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:180:6 + --> tests/ui/len_zero.rs:180:6 | LL | (has_is_empty.len() == 0).then(|| println!("Or this!")); | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:184:8 + --> tests/ui/len_zero.rs:184:8 | LL | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!b.is_empty()` diff --git a/tests/ui/len_zero_ranges.stderr b/tests/ui/len_zero_ranges.stderr index 1922e9b304443..0b2991e15ea32 100644 --- a/tests/ui/len_zero_ranges.stderr +++ b/tests/ui/len_zero_ranges.stderr @@ -1,5 +1,5 @@ error: length comparison to zero - --> $DIR/len_zero_ranges.rs:7:17 + --> tests/ui/len_zero_ranges.rs:7:17 | LL | let _ = (0..42).len() == 0; | ^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0..42).is_empty()` @@ -8,7 +8,7 @@ LL | let _ = (0..42).len() == 0; = help: to override `-D warnings` add `#[allow(clippy::len_zero)]` error: length comparison to zero - --> $DIR/len_zero_ranges.rs:11:17 + --> tests/ui/len_zero_ranges.rs:11:17 | LL | let _ = (0_u8..=42).len() == 0; | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0_u8..=42).is_empty()` diff --git a/tests/ui/let_and_return.stderr b/tests/ui/let_and_return.stderr index fe60072d13f84..f614a5739a860 100644 --- a/tests/ui/let_and_return.stderr +++ b/tests/ui/let_and_return.stderr @@ -1,5 +1,5 @@ error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:9:5 + --> tests/ui/let_and_return.rs:9:5 | LL | let x = 5; | ---------- unnecessary `let` binding @@ -15,7 +15,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:17:9 + --> tests/ui/let_and_return.rs:17:9 | LL | let x = 5; | ---------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:80:5 + --> tests/ui/let_and_return.rs:80:5 | LL | let line = stdin.lock().lines().next().unwrap().unwrap(); | --------------------------------------------------------- unnecessary `let` binding @@ -43,7 +43,7 @@ LL ~ stdin.lock().lines().next().unwrap().unwrap() | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:171:13 + --> tests/ui/let_and_return.rs:171:13 | LL | let clone = Arc::clone(&self.foo); | ---------------------------------- unnecessary `let` binding @@ -57,7 +57,7 @@ LL ~ (Arc::clone(&self.foo)) as _ | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:190:13 + --> tests/ui/let_and_return.rs:190:13 | LL | / let result = match self { LL | | E::A(x) => x, diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index bfb4bb9d0d2fd..87ad20dc27ee3 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,5 +1,5 @@ error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:66:5 + --> tests/ui/let_if_seq.rs:66:5 | LL | / let mut foo = 0; LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::useless_let_if_seq)]` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:73:5 + --> tests/ui/let_if_seq.rs:73:5 | LL | / let mut bar = 0; LL | | @@ -28,7 +28,7 @@ LL | | } = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:83:5 + --> tests/ui/let_if_seq.rs:83:5 | LL | / let quz; LL | | @@ -40,7 +40,7 @@ LL | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:113:5 + --> tests/ui/let_if_seq.rs:113:5 | LL | / let mut baz = 0; LL | | diff --git a/tests/ui/let_underscore_future.stderr b/tests/ui/let_underscore_future.stderr index ef927a8083bcc..66aeb5035394d 100644 --- a/tests/ui/let_underscore_future.stderr +++ b/tests/ui/let_underscore_future.stderr @@ -1,5 +1,5 @@ error: non-binding `let` on a future - --> $DIR/let_underscore_future.rs:14:5 + --> tests/ui/let_underscore_future.rs:14:5 | LL | let _ = some_async_fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = some_async_fn(); = help: to override `-D warnings` add `#[allow(clippy::let_underscore_future)]` error: non-binding `let` on a future - --> $DIR/let_underscore_future.rs:16:5 + --> tests/ui/let_underscore_future.rs:16:5 | LL | let _ = custom(); | ^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = custom(); = help: consider awaiting the future or dropping explicitly with `std::mem::drop` error: non-binding `let` on a future - --> $DIR/let_underscore_future.rs:21:5 + --> tests/ui/let_underscore_future.rs:21:5 | LL | let _ = future; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/let_underscore_lock.stderr b/tests/ui/let_underscore_lock.stderr index ac6e0978e637b..a38309dd4fab0 100644 --- a/tests/ui/let_underscore_lock.stderr +++ b/tests/ui/let_underscore_lock.stderr @@ -1,5 +1,5 @@ error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:10:5 + --> tests/ui/let_underscore_lock.rs:10:5 | LL | let _ = p_m.lock(); | ^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = p_m.lock(); = help: to override `-D warnings` add `#[allow(clippy::let_underscore_lock)]` error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:14:5 + --> tests/ui/let_underscore_lock.rs:14:5 | LL | let _ = p_m1.lock(); | ^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = p_m1.lock(); = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:18:5 + --> tests/ui/let_underscore_lock.rs:18:5 | LL | let _ = p_rw.read(); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = p_rw.read(); = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:20:5 + --> tests/ui/let_underscore_lock.rs:20:5 | LL | let _ = p_rw.write(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/let_underscore_must_use.stderr b/tests/ui/let_underscore_must_use.stderr index 83d0372e668cc..e8785b92b8158 100644 --- a/tests/ui/let_underscore_must_use.stderr +++ b/tests/ui/let_underscore_must_use.stderr @@ -1,5 +1,5 @@ error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:67:5 + --> tests/ui/let_underscore_must_use.rs:67:5 | LL | let _ = f(); | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = f(); = help: to override `-D warnings` add `#[allow(clippy::let_underscore_must_use)]` error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:69:5 + --> tests/ui/let_underscore_must_use.rs:69:5 | LL | let _ = g(); | ^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = g(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:72:5 + --> tests/ui/let_underscore_must_use.rs:72:5 | LL | let _ = l(0_u32); | ^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = l(0_u32); = help: consider explicitly using function result error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:77:5 + --> tests/ui/let_underscore_must_use.rs:77:5 | LL | let _ = s.f(); | ^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = s.f(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:79:5 + --> tests/ui/let_underscore_must_use.rs:79:5 | LL | let _ = s.g(); | ^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = s.g(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:83:5 + --> tests/ui/let_underscore_must_use.rs:83:5 | LL | let _ = S::h(); | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = S::h(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:85:5 + --> tests/ui/let_underscore_must_use.rs:85:5 | LL | let _ = S::p(); | ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = S::p(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:88:5 + --> tests/ui/let_underscore_must_use.rs:88:5 | LL | let _ = S::a(); | ^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = S::a(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:91:5 + --> tests/ui/let_underscore_must_use.rs:91:5 | LL | let _ = if true { Ok(()) } else { Err(()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = if true { Ok(()) } else { Err(()) }; = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:96:5 + --> tests/ui/let_underscore_must_use.rs:96:5 | LL | let _ = a.is_ok(); | ^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = a.is_ok(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:99:5 + --> tests/ui/let_underscore_must_use.rs:99:5 | LL | let _ = a.map(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = a.map(|_| ()); = help: consider explicitly using expression value error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:102:5 + --> tests/ui/let_underscore_must_use.rs:102:5 | LL | let _ = a; | ^^^^^^^^^^ diff --git a/tests/ui/let_underscore_untyped.stderr b/tests/ui/let_underscore_untyped.stderr index 0e5647fa1e92c..1dd51e1e59b10 100644 --- a/tests/ui/let_underscore_untyped.stderr +++ b/tests/ui/let_underscore_untyped.stderr @@ -1,11 +1,11 @@ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:51:5 + --> tests/ui/let_underscore_untyped.rs:51:5 | LL | let _ = a(); | ^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:51:10 + --> tests/ui/let_underscore_untyped.rs:51:10 | LL | let _ = a(); | ^ @@ -13,49 +13,49 @@ LL | let _ = a(); = help: to override `-D warnings` add `#[allow(clippy::let_underscore_untyped)]` error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:52:5 + --> tests/ui/let_underscore_untyped.rs:52:5 | LL | let _ = b(1); | ^^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:52:10 + --> tests/ui/let_underscore_untyped.rs:52:10 | LL | let _ = b(1); | ^ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:54:5 + --> tests/ui/let_underscore_untyped.rs:54:5 | LL | let _ = d(&1); | ^^^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:54:10 + --> tests/ui/let_underscore_untyped.rs:54:10 | LL | let _ = d(&1); | ^ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:55:5 + --> tests/ui/let_underscore_untyped.rs:55:5 | LL | let _ = e(); | ^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:55:10 + --> tests/ui/let_underscore_untyped.rs:55:10 | LL | let _ = e(); | ^ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:56:5 + --> tests/ui/let_underscore_untyped.rs:56:5 | LL | let _ = f(); | ^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:56:10 + --> tests/ui/let_underscore_untyped.rs:56:10 | LL | let _ = f(); | ^ diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index 00a3c439ba06f..0f1f3d7822348 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,5 +1,5 @@ error: this let-binding has unit value - --> $DIR/let_unit.rs:12:5 + --> tests/ui/let_unit.rs:12:5 | LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `println!("x");` @@ -8,7 +8,7 @@ LL | let _x = println!("x"); = help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]` error: this let-binding has unit value - --> $DIR/let_unit.rs:60:5 + --> tests/ui/let_unit.rs:60:5 | LL | / let _ = v LL | | .into_iter() @@ -31,7 +31,7 @@ LL + .unwrap(); | error: this let-binding has unit value - --> $DIR/let_unit.rs:109:5 + --> tests/ui/let_unit.rs:109:5 | LL | / let x = match Some(0) { LL | | None => f2(1), diff --git a/tests/ui/let_with_type_underscore.stderr b/tests/ui/let_with_type_underscore.stderr index d4c9ba19c39f5..29ec25a5b2acc 100644 --- a/tests/ui/let_with_type_underscore.stderr +++ b/tests/ui/let_with_type_underscore.stderr @@ -1,11 +1,11 @@ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:15:5 + --> tests/ui/let_with_type_underscore.rs:15:5 | LL | let x: _ = 1; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:15:10 + --> tests/ui/let_with_type_underscore.rs:15:10 | LL | let x: _ = 1; | ^^^ @@ -13,49 +13,49 @@ LL | let x: _ = 1; = help: to override `-D warnings` add `#[allow(clippy::let_with_type_underscore)]` error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:16:5 + --> tests/ui/let_with_type_underscore.rs:16:5 | LL | let _: _ = 2; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:16:10 + --> tests/ui/let_with_type_underscore.rs:16:10 | LL | let _: _ = 2; | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:17:5 + --> tests/ui/let_with_type_underscore.rs:17:5 | LL | let x: _ = func(); | ^^^^^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:17:10 + --> tests/ui/let_with_type_underscore.rs:17:10 | LL | let x: _ = func(); | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:18:5 + --> tests/ui/let_with_type_underscore.rs:18:5 | LL | let x: _; | ^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:18:10 + --> tests/ui/let_with_type_underscore.rs:18:10 | LL | let x: _; | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:25:5 + --> tests/ui/let_with_type_underscore.rs:25:5 | LL | let x : _ = 1; | ^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:25:10 + --> tests/ui/let_with_type_underscore.rs:25:10 | LL | let x : _ = 1; | ^^^^ diff --git a/tests/ui/lines_filter_map_ok.stderr b/tests/ui/lines_filter_map_ok.stderr index 9833ab16473c8..558c0532be95a 100644 --- a/tests/ui/lines_filter_map_ok.stderr +++ b/tests/ui/lines_filter_map_ok.stderr @@ -1,11 +1,11 @@ error: `filter_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:9:31 + --> tests/ui/lines_filter_map_ok.rs:9:31 | LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:9:5 + --> tests/ui/lines_filter_map_ok.rs:9:5 | LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,61 +13,61 @@ LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); = help: to override `-D warnings` add `#[allow(clippy::lines_filter_map_ok)]` error: `flat_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:12:31 + --> tests/ui/lines_filter_map_ok.rs:12:31 | LL | BufReader::new(f).lines().flat_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:12:5 + --> tests/ui/lines_filter_map_ok.rs:12:5 | LL | BufReader::new(f).lines().flat_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `flatten()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:15:31 + --> tests/ui/lines_filter_map_ok.rs:15:31 | LL | BufReader::new(f).lines().flatten().for_each(|_| ()); | ^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:15:5 + --> tests/ui/lines_filter_map_ok.rs:15:5 | LL | BufReader::new(f).lines().flatten().for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `filter_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:19:25 + --> tests/ui/lines_filter_map_ok.rs:19:25 | LL | io::stdin().lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:19:5 + --> tests/ui/lines_filter_map_ok.rs:19:5 | LL | io::stdin().lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^ error: `filter_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:21:25 + --> tests/ui/lines_filter_map_ok.rs:21:25 | LL | io::stdin().lines().filter_map(|x| x.ok()).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:21:5 + --> tests/ui/lines_filter_map_ok.rs:21:5 | LL | io::stdin().lines().filter_map(|x| x.ok()).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^ error: `flatten()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:23:25 + --> tests/ui/lines_filter_map_ok.rs:23:25 | LL | io::stdin().lines().flatten().for_each(|_| ()); | ^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:23:5 + --> tests/ui/lines_filter_map_ok.rs:23:5 | LL | io::stdin().lines().flatten().for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/linkedlist.stderr b/tests/ui/linkedlist.stderr index 792af4dd06e8d..d19176c7b0d21 100644 --- a/tests/ui/linkedlist.stderr +++ b/tests/ui/linkedlist.stderr @@ -1,5 +1,5 @@ error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:8:10 + --> tests/ui/linkedlist.rs:8:10 | LL | const C: LinkedList = LinkedList::new(); | ^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const C: LinkedList = LinkedList::new(); = help: to override `-D warnings` add `#[allow(clippy::linkedlist)]` error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:10:11 + --> tests/ui/linkedlist.rs:10:11 | LL | static S: LinkedList = LinkedList::new(); | ^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static S: LinkedList = LinkedList::new(); = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:14:16 + --> tests/ui/linkedlist.rs:14:16 | LL | type Baz = LinkedList; | ^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type Baz = LinkedList; = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:16:15 + --> tests/ui/linkedlist.rs:16:15 | LL | fn foo(_: LinkedList); | ^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn foo(_: LinkedList); = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:18:23 + --> tests/ui/linkedlist.rs:18:23 | LL | const BAR: Option>; | ^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | const BAR: Option>; = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:29:29 + --> tests/ui/linkedlist.rs:29:29 | LL | priv_linked_list_field: LinkedList, | ^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | priv_linked_list_field: LinkedList, = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:34:15 + --> tests/ui/linkedlist.rs:34:15 | LL | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn foo(_: LinkedList) {} = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:40:34 + --> tests/ui/linkedlist.rs:40:34 | LL | fn test(my_favorite_linked_list: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn test(my_favorite_linked_list: LinkedList) {} = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:42:25 + --> tests/ui/linkedlist.rs:42:25 | LL | fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index bc755b1123db3..564e0bc4f7472 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -1,5 +1,5 @@ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:13:15 + --> tests/ui/literals.rs:13:15 | LL | let ok4 = 0xab_cd_i32; | ^^^^^^^^^^^ help: remove the underscore: `0xab_cdi32` @@ -8,19 +8,19 @@ LL | let ok4 = 0xab_cd_i32; = help: to override `-D warnings` add `#[allow(clippy::separated_literal_suffix)]` error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:16:15 + --> tests/ui/literals.rs:16:15 | LL | let ok5 = 0xAB_CD_u32; | ^^^^^^^^^^^ help: remove the underscore: `0xAB_CDu32` error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:18:15 + --> tests/ui/literals.rs:18:15 | LL | let ok5 = 0xAB_CD_isize; | ^^^^^^^^^^^^^ help: remove the underscore: `0xAB_CDisize` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:20:17 + --> tests/ui/literals.rs:20:17 | LL | let fail1 = 0xabCD; | ^^^^^^ @@ -29,31 +29,31 @@ LL | let fail1 = 0xabCD; = help: to override `-D warnings` add `#[allow(clippy::mixed_case_hex_literals)]` error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:23:17 + --> tests/ui/literals.rs:23:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ help: remove the underscore: `0xabCDu32` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:23:17 + --> tests/ui/literals.rs:23:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:26:17 + --> tests/ui/literals.rs:26:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ help: remove the underscore: `0xabCDisize` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:26:17 + --> tests/ui/literals.rs:26:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:29:27 + --> tests/ui/literals.rs:29:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ help: add an underscore: `000_123_usize` @@ -62,7 +62,7 @@ LL | let fail_multi_zero = 000_123usize; = help: to override `-D warnings` add `#[allow(clippy::unseparated_literal_suffix)]` error: this is a decimal constant - --> $DIR/literals.rs:29:27 + --> tests/ui/literals.rs:29:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ @@ -79,13 +79,13 @@ LL | let fail_multi_zero = 0o123usize; | ~~~~~~~~~~ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:36:16 + --> tests/ui/literals.rs:36:16 | LL | let ok10 = 0_i64; | ^^^^^ help: remove the underscore: `0i64` error: this is a decimal constant - --> $DIR/literals.rs:38:17 + --> tests/ui/literals.rs:38:17 | LL | let fail8 = 0123; | ^^^^ @@ -100,13 +100,13 @@ LL | let fail8 = 0o123; | ~~~~~ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:48:16 + --> tests/ui/literals.rs:48:16 | LL | let ok17 = 0x123_4567_8901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: remove the underscore: `0x123_4567_8901usize` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:52:18 + --> tests/ui/literals.rs:52:18 | LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` @@ -115,19 +115,19 @@ LL | let fail19 = 12_3456_21; = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:55:18 + --> tests/ui/literals.rs:55:18 | LL | let fail22 = 3__4___23; | ^^^^^^^^^ help: consider: `3_423` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:57:18 + --> tests/ui/literals.rs:57:18 | LL | let fail23 = 3__16___23; | ^^^^^^^^^^ help: consider: `31_623` error: digits of hex, binary or octal literal not in groups of equal size - --> $DIR/literals.rs:60:18 + --> tests/ui/literals.rs:60:18 | LL | let fail24 = 0xAB_ABC_AB; | ^^^^^^^^^^^ help: consider: `0x0ABA_BCAB` @@ -136,7 +136,7 @@ LL | let fail24 = 0xAB_ABC_AB; = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: this is a decimal constant - --> $DIR/literals.rs:70:13 + --> tests/ui/literals.rs:70:13 | LL | let _ = 08; | ^^ @@ -147,7 +147,7 @@ LL | let _ = 8; | ~ error: this is a decimal constant - --> $DIR/literals.rs:72:13 + --> tests/ui/literals.rs:72:13 | LL | let _ = 09; | ^^ @@ -158,7 +158,7 @@ LL | let _ = 9; | ~ error: this is a decimal constant - --> $DIR/literals.rs:74:13 + --> tests/ui/literals.rs:74:13 | LL | let _ = 089; | ^^^ diff --git a/tests/ui/lossy_float_literal.stderr b/tests/ui/lossy_float_literal.stderr index ea787f5726aaf..7904719141c18 100644 --- a/tests/ui/lossy_float_literal.stderr +++ b/tests/ui/lossy_float_literal.stderr @@ -1,5 +1,5 @@ error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:6:18 + --> tests/ui/lossy_float_literal.rs:6:18 | LL | let _: f32 = 16_777_217.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_216.0` @@ -8,61 +8,61 @@ LL | let _: f32 = 16_777_217.0; = help: to override `-D warnings` add `#[allow(clippy::lossy_float_literal)]` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:7:18 + --> tests/ui/lossy_float_literal.rs:7:18 | LL | let _: f32 = 16_777_219.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:8:18 + --> tests/ui/lossy_float_literal.rs:8:18 | LL | let _: f32 = 16_777_219.; | ^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:9:18 + --> tests/ui/lossy_float_literal.rs:9:18 | LL | let _: f32 = 16_777_219.000; | ^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:10:13 + --> tests/ui/lossy_float_literal.rs:10:13 | LL | let _ = 16_777_219f32; | ^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220_f32` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:11:19 + --> tests/ui/lossy_float_literal.rs:11:19 | LL | let _: f32 = -16_777_219.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:12:18 + --> tests/ui/lossy_float_literal.rs:12:18 | LL | let _: f64 = 9_007_199_254_740_993.0; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:13:18 + --> tests/ui/lossy_float_literal.rs:13:18 | LL | let _: f64 = 9_007_199_254_740_993.; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:14:18 + --> tests/ui/lossy_float_literal.rs:14:18 | LL | let _: f64 = 9_007_199_254_740_993.00; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:15:13 + --> tests/ui/lossy_float_literal.rs:15:13 | LL | let _ = 9_007_199_254_740_993f64; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992_f64` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:16:19 + --> tests/ui/lossy_float_literal.rs:16:19 | LL | let _: f64 = -9_007_199_254_740_993.0; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` diff --git a/tests/ui/macro_use_imports.stderr b/tests/ui/macro_use_imports.stderr index 5524e7e5642df..a3733b1c0c96c 100644 --- a/tests/ui/macro_use_imports.stderr +++ b/tests/ui/macro_use_imports.stderr @@ -1,5 +1,5 @@ error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:19:5 + --> tests/ui/macro_use_imports.rs:19:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};` @@ -8,19 +8,19 @@ LL | #[macro_use] = help: to override `-D warnings` add `#[allow(clippy::macro_use_imports)]` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:23:5 + --> tests/ui/macro_use_imports.rs:23:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::mut_mut, inner::try_err};` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:25:5 + --> tests/ui/macro_use_imports.rs:25:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:21:5 + --> tests/ui/macro_use_imports.rs:21:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;` diff --git a/tests/ui/manual_assert.edition2018.stderr b/tests/ui/manual_assert.edition2018.stderr index b19cca4d5f91d..57015933d40a9 100644 --- a/tests/ui/manual_assert.edition2018.stderr +++ b/tests/ui/manual_assert.edition2018.stderr @@ -1,5 +1,5 @@ error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:30:5 + --> tests/ui/manual_assert.rs:30:5 | LL | / if !a.is_empty() { LL | | panic!("qaqaq{:?}", a); @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_assert)]` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:33:5 + --> tests/ui/manual_assert.rs:33:5 | LL | / if !a.is_empty() { LL | | panic!("qwqwq"); @@ -18,7 +18,7 @@ LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:50:5 + --> tests/ui/manual_assert.rs:50:5 | LL | / if b.is_empty() { LL | | panic!("panic1"); @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:53:5 + --> tests/ui/manual_assert.rs:53:5 | LL | / if b.is_empty() && a.is_empty() { LL | | panic!("panic2"); @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:56:5 + --> tests/ui/manual_assert.rs:56:5 | LL | / if a.is_empty() && !b.is_empty() { LL | | panic!("panic3"); @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:59:5 + --> tests/ui/manual_assert.rs:59:5 | LL | / if b.is_empty() || a.is_empty() { LL | | panic!("panic4"); @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:62:5 + --> tests/ui/manual_assert.rs:62:5 | LL | / if a.is_empty() || !b.is_empty() { LL | | panic!("panic5"); @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:65:5 + --> tests/ui/manual_assert.rs:65:5 | LL | / if a.is_empty() { LL | | panic!("with expansion {}", one!()) @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:77:5 + --> tests/ui/manual_assert.rs:77:5 | LL | / if a > 2 { LL | | // comment diff --git a/tests/ui/manual_assert.edition2021.stderr b/tests/ui/manual_assert.edition2021.stderr index b19cca4d5f91d..57015933d40a9 100644 --- a/tests/ui/manual_assert.edition2021.stderr +++ b/tests/ui/manual_assert.edition2021.stderr @@ -1,5 +1,5 @@ error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:30:5 + --> tests/ui/manual_assert.rs:30:5 | LL | / if !a.is_empty() { LL | | panic!("qaqaq{:?}", a); @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_assert)]` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:33:5 + --> tests/ui/manual_assert.rs:33:5 | LL | / if !a.is_empty() { LL | | panic!("qwqwq"); @@ -18,7 +18,7 @@ LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:50:5 + --> tests/ui/manual_assert.rs:50:5 | LL | / if b.is_empty() { LL | | panic!("panic1"); @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:53:5 + --> tests/ui/manual_assert.rs:53:5 | LL | / if b.is_empty() && a.is_empty() { LL | | panic!("panic2"); @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:56:5 + --> tests/ui/manual_assert.rs:56:5 | LL | / if a.is_empty() && !b.is_empty() { LL | | panic!("panic3"); @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:59:5 + --> tests/ui/manual_assert.rs:59:5 | LL | / if b.is_empty() || a.is_empty() { LL | | panic!("panic4"); @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:62:5 + --> tests/ui/manual_assert.rs:62:5 | LL | / if a.is_empty() || !b.is_empty() { LL | | panic!("panic5"); @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:65:5 + --> tests/ui/manual_assert.rs:65:5 | LL | / if a.is_empty() { LL | | panic!("with expansion {}", one!()) @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:77:5 + --> tests/ui/manual_assert.rs:77:5 | LL | / if a > 2 { LL | | // comment diff --git a/tests/ui/manual_async_fn.stderr b/tests/ui/manual_async_fn.stderr index c0c471912e494..c50af5a49883a 100644 --- a/tests/ui/manual_async_fn.stderr +++ b/tests/ui/manual_async_fn.stderr @@ -1,5 +1,5 @@ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:6:1 + --> tests/ui/manual_async_fn.rs:6:1 | LL | fn fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | fn fut() -> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:11:1 + --> tests/ui/manual_async_fn.rs:11:1 | LL | fn fut2() ->impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | fn fut2() ->impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:16:1 + --> tests/ui/manual_async_fn.rs:16:1 | LL | fn fut3()-> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | fn fut3()-> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:20:1 + --> tests/ui/manual_async_fn.rs:20:1 | LL | fn empty_fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | fn empty_fut() -> impl Future {} | ~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:25:1 + --> tests/ui/manual_async_fn.rs:25:1 | LL | fn empty_fut2() ->impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | fn empty_fut2() ->impl Future {} | ~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:30:1 + --> tests/ui/manual_async_fn.rs:30:1 | LL | fn empty_fut3()-> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | fn empty_fut3()-> impl Future {} | ~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:34:1 + --> tests/ui/manual_async_fn.rs:34:1 | LL | fn core_fut() -> impl core::future::Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | fn core_fut() -> impl core::future::Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:56:5 + --> tests/ui/manual_async_fn.rs:56:5 | LL | fn inh_fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + } | error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:91:1 + --> tests/ui/manual_async_fn.rs:91:1 | LL | fn elided(_: &i32) -> impl Future + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | fn elided(_: &i32) -> impl Future + '_ { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:100:1 + --> tests/ui/manual_async_fn.rs:100:1 | LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + 'a + 'b { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:129:1 + --> tests/ui/manual_async_fn.rs:129:1 | LL | pub fn issue_10450() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +178,7 @@ LL | pub fn issue_10450() -> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:133:1 + --> tests/ui/manual_async_fn.rs:133:1 | LL | pub(crate) fn issue_10450_2() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | pub(crate) fn issue_10450_2() -> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:137:1 + --> tests/ui/manual_async_fn.rs:137:1 | LL | pub(self) fn issue_10450_3() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/manual_bits.stderr b/tests/ui/manual_bits.stderr index 2f2ed5909c1a5..4383aa49df9b4 100644 --- a/tests/ui/manual_bits.stderr +++ b/tests/ui/manual_bits.stderr @@ -1,5 +1,5 @@ error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:14:5 + --> tests/ui/manual_bits.rs:14:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` @@ -8,169 +8,169 @@ LL | size_of::() * 8; = help: to override `-D warnings` add `#[allow(clippy::manual_bits)]` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:15:5 + --> tests/ui/manual_bits.rs:15:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:16:5 + --> tests/ui/manual_bits.rs:16:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:17:5 + --> tests/ui/manual_bits.rs:17:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:18:5 + --> tests/ui/manual_bits.rs:18:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `i128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:19:5 + --> tests/ui/manual_bits.rs:19:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `isize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:21:5 + --> tests/ui/manual_bits.rs:21:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `u8::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:22:5 + --> tests/ui/manual_bits.rs:22:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:23:5 + --> tests/ui/manual_bits.rs:23:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:24:5 + --> tests/ui/manual_bits.rs:24:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:25:5 + --> tests/ui/manual_bits.rs:25:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:26:5 + --> tests/ui/manual_bits.rs:26:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `usize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:28:5 + --> tests/ui/manual_bits.rs:28:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:29:5 + --> tests/ui/manual_bits.rs:29:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:30:5 + --> tests/ui/manual_bits.rs:30:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:31:5 + --> tests/ui/manual_bits.rs:31:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:32:5 + --> tests/ui/manual_bits.rs:32:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `i128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:33:5 + --> tests/ui/manual_bits.rs:33:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `isize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:35:5 + --> tests/ui/manual_bits.rs:35:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `u8::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:36:5 + --> tests/ui/manual_bits.rs:36:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:37:5 + --> tests/ui/manual_bits.rs:37:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:38:5 + --> tests/ui/manual_bits.rs:38:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:39:5 + --> tests/ui/manual_bits.rs:39:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:40:5 + --> tests/ui/manual_bits.rs:40:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `usize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:50:5 + --> tests/ui/manual_bits.rs:50:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `Word::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:54:18 + --> tests/ui/manual_bits.rs:54:18 | LL | let _: u32 = (size_of::() * 8) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:55:18 + --> tests/ui/manual_bits.rs:55:18 | LL | let _: u32 = (size_of::() * 8).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:56:13 + --> tests/ui/manual_bits.rs:56:13 | LL | let _ = (size_of::() * 8).pow(5); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(u128::BITS as usize)` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:57:14 + --> tests/ui/manual_bits.rs:57:14 | LL | let _ = &(size_of::() * 8); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(u128::BITS as usize)` diff --git a/tests/ui/manual_c_str_literals.stderr b/tests/ui/manual_c_str_literals.stderr index 8de4e16f010d6..9c70bddb81c18 100644 --- a/tests/ui/manual_c_str_literals.stderr +++ b/tests/ui/manual_c_str_literals.stderr @@ -1,5 +1,5 @@ error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:31:5 + --> tests/ui/manual_c_str_literals.rs:31:5 | LL | CStr::from_bytes_with_nul(b"foo\0"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` @@ -8,73 +8,73 @@ LL | CStr::from_bytes_with_nul(b"foo\0"); = help: to override `-D warnings` add `#[allow(clippy::manual_c_str_literals)]` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:35:5 + --> tests/ui/manual_c_str_literals.rs:35:5 | LL | CStr::from_bytes_with_nul(b"foo\0"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:36:5 + --> tests/ui/manual_c_str_literals.rs:36:5 | LL | CStr::from_bytes_with_nul(b"foo\x00"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:37:5 + --> tests/ui/manual_c_str_literals.rs:37:5 | LL | CStr::from_bytes_with_nul(b"foo\0").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:38:5 + --> tests/ui/manual_c_str_literals.rs:38:5 | LL | CStr::from_bytes_with_nul(b"foo\\0sdsd\0").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo\\0sdsd"` error: calling `CStr::from_ptr` with a byte string literal - --> $DIR/manual_c_str_literals.rs:43:14 + --> tests/ui/manual_c_str_literals.rs:43:14 | LL | unsafe { CStr::from_ptr(b"foo\0".as_ptr().cast()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::from_ptr` with a byte string literal - --> $DIR/manual_c_str_literals.rs:44:14 + --> tests/ui/manual_c_str_literals.rs:44:14 | LL | unsafe { CStr::from_ptr(b"foo\0".as_ptr() as *const _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:45:23 + --> tests/ui/manual_c_str_literals.rs:45:23 | LL | let _: *const _ = b"foo\0".as_ptr(); | ^^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:46:23 + --> tests/ui/manual_c_str_literals.rs:46:23 | LL | let _: *const _ = "foo\0".as_ptr(); | ^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:49:23 + --> tests/ui/manual_c_str_literals.rs:49:23 | LL | let _: *const _ = b"foo\0".as_ptr().cast::(); | ^^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:52:13 + --> tests/ui/manual_c_str_literals.rs:52:13 | LL | let _ = "电脑\\\0".as_ptr(); | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑\\"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:53:13 + --> tests/ui/manual_c_str_literals.rs:53:13 | LL | let _ = "电脑\0".as_ptr(); | ^^^^^^^^ help: use a `c""` literal: `c"电脑"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:54:13 + --> tests/ui/manual_c_str_literals.rs:54:13 | LL | let _ = "电脑\x00".as_ptr(); | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑"` diff --git a/tests/ui/manual_clamp.stderr b/tests/ui/manual_clamp.stderr index 2fa68ede12614..52c816f2b347b 100644 --- a/tests/ui/manual_clamp.stderr +++ b/tests/ui/manual_clamp.stderr @@ -1,5 +1,5 @@ error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:94:5 + --> tests/ui/manual_clamp.rs:94:5 | LL | / if x9 < min { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_clamp)]` error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:113:5 + --> tests/ui/manual_clamp.rs:113:5 | LL | / if x11 > max { LL | | @@ -29,7 +29,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:123:5 + --> tests/ui/manual_clamp.rs:123:5 | LL | / if min > x12 { LL | | @@ -43,7 +43,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:133:5 + --> tests/ui/manual_clamp.rs:133:5 | LL | / if max < x13 { LL | | @@ -57,7 +57,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:227:5 + --> tests/ui/manual_clamp.rs:227:5 | LL | / if max < x33 { LL | | @@ -71,7 +71,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:21:14 + --> tests/ui/manual_clamp.rs:21:14 | LL | let x0 = if max < input { | ______________^ @@ -86,7 +86,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:31:14 + --> tests/ui/manual_clamp.rs:31:14 | LL | let x1 = if input > max { | ______________^ @@ -101,7 +101,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:41:14 + --> tests/ui/manual_clamp.rs:41:14 | LL | let x2 = if input < min { | ______________^ @@ -116,7 +116,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:51:14 + --> tests/ui/manual_clamp.rs:51:14 | LL | let x3 = if min > input { | ______________^ @@ -131,7 +131,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:61:14 + --> tests/ui/manual_clamp.rs:61:14 | LL | let x4 = input.max(min).min(max); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)` @@ -139,7 +139,7 @@ LL | let x4 = input.max(min).min(max); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:65:14 + --> tests/ui/manual_clamp.rs:65:14 | LL | let x5 = input.min(max).max(min); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)` @@ -147,7 +147,7 @@ LL | let x5 = input.min(max).max(min); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:69:14 + --> tests/ui/manual_clamp.rs:69:14 | LL | let x6 = match input { | ______________^ @@ -162,7 +162,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:77:14 + --> tests/ui/manual_clamp.rs:77:14 | LL | let x7 = match input { | ______________^ @@ -177,7 +177,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:85:14 + --> tests/ui/manual_clamp.rs:85:14 | LL | let x8 = match input { | ______________^ @@ -192,7 +192,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:103:15 + --> tests/ui/manual_clamp.rs:103:15 | LL | let x10 = match input { | _______________^ @@ -207,7 +207,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:142:15 + --> tests/ui/manual_clamp.rs:142:15 | LL | let x14 = if input > CONST_MAX { | _______________^ @@ -222,7 +222,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:153:19 + --> tests/ui/manual_clamp.rs:153:19 | LL | let x15 = if input > max { | ___________________^ @@ -238,7 +238,7 @@ LL | | }; = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:166:19 + --> tests/ui/manual_clamp.rs:166:19 | LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -246,7 +246,7 @@ LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:169:19 + --> tests/ui/manual_clamp.rs:169:19 | LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -254,7 +254,7 @@ LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:172:19 + --> tests/ui/manual_clamp.rs:172:19 | LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -262,7 +262,7 @@ LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:175:19 + --> tests/ui/manual_clamp.rs:175:19 | LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -270,7 +270,7 @@ LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:178:19 + --> tests/ui/manual_clamp.rs:178:19 | LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -278,7 +278,7 @@ LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:181:19 + --> tests/ui/manual_clamp.rs:181:19 | LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -286,7 +286,7 @@ LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:184:19 + --> tests/ui/manual_clamp.rs:184:19 | LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -294,7 +294,7 @@ LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:187:19 + --> tests/ui/manual_clamp.rs:187:19 | LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -302,7 +302,7 @@ LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:191:19 + --> tests/ui/manual_clamp.rs:191:19 | LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -311,7 +311,7 @@ LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:194:19 + --> tests/ui/manual_clamp.rs:194:19 | LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -320,7 +320,7 @@ LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:197:19 + --> tests/ui/manual_clamp.rs:197:19 | LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -329,7 +329,7 @@ LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:200:19 + --> tests/ui/manual_clamp.rs:200:19 | LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -338,7 +338,7 @@ LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:203:19 + --> tests/ui/manual_clamp.rs:203:19 | LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -347,7 +347,7 @@ LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:206:19 + --> tests/ui/manual_clamp.rs:206:19 | LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -356,7 +356,7 @@ LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:209:19 + --> tests/ui/manual_clamp.rs:209:19 | LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -365,7 +365,7 @@ LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:212:19 + --> tests/ui/manual_clamp.rs:212:19 | LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -374,7 +374,7 @@ LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:217:5 + --> tests/ui/manual_clamp.rs:217:5 | LL | / if x32 < min { LL | | @@ -388,7 +388,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:389:13 + --> tests/ui/manual_clamp.rs:389:13 | LL | let _ = if input < min { | _____________^ diff --git a/tests/ui/manual_filter.stderr b/tests/ui/manual_filter.stderr index b23ad887eb2c5..3add706d7f73c 100644 --- a/tests/ui/manual_filter.stderr +++ b/tests/ui/manual_filter.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:5:5 + --> tests/ui/manual_filter.rs:5:5 | LL | / match Some(0) { LL | | None => None, @@ -14,7 +14,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_filter)]` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:16:5 + --> tests/ui/manual_filter.rs:16:5 | LL | / match Some(1) { LL | | Some(x) => { @@ -26,7 +26,7 @@ LL | | }; | |_____^ help: try: `Some(1).filter(|&x| x <= 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:27:5 + --> tests/ui/manual_filter.rs:27:5 | LL | / match Some(2) { LL | | Some(x) => { @@ -38,7 +38,7 @@ LL | | }; | |_____^ help: try: `Some(2).filter(|&x| x <= 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:38:5 + --> tests/ui/manual_filter.rs:38:5 | LL | / match Some(3) { LL | | Some(x) => { @@ -50,7 +50,7 @@ LL | | }; | |_____^ help: try: `Some(3).filter(|&x| x > 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:50:5 + --> tests/ui/manual_filter.rs:50:5 | LL | / match y { LL | | // Some(4) @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: try: `y.filter(|&x| x <= 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:62:5 + --> tests/ui/manual_filter.rs:62:5 | LL | / match Some(5) { LL | | Some(x) => { @@ -74,7 +74,7 @@ LL | | }; | |_____^ help: try: `Some(5).filter(|&x| x > 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:73:5 + --> tests/ui/manual_filter.rs:73:5 | LL | / match Some(6) { LL | | Some(ref x) => { @@ -86,7 +86,7 @@ LL | | }; | |_____^ help: try: `Some(6).as_ref().filter(|&x| x > &0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:85:5 + --> tests/ui/manual_filter.rs:85:5 | LL | / match Some(String::new()) { LL | | Some(x) => { @@ -98,7 +98,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).filter(|x| external_cond)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:96:5 + --> tests/ui/manual_filter.rs:96:5 | LL | / if let Some(x) = Some(7) { LL | | if external_cond { Some(x) } else { None } @@ -108,7 +108,7 @@ LL | | }; | |_____^ help: try: `Some(7).filter(|&x| external_cond)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:102:5 + --> tests/ui/manual_filter.rs:102:5 | LL | / match &Some(8) { LL | | &Some(x) => { @@ -120,7 +120,7 @@ LL | | }; | |_____^ help: try: `Some(8).filter(|&x| x != 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:113:5 + --> tests/ui/manual_filter.rs:113:5 | LL | / match Some(9) { LL | | Some(x) => { @@ -132,7 +132,7 @@ LL | | }; | |_____^ help: try: `Some(9).filter(|&x| x > 10 && x < 100)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:139:5 + --> tests/ui/manual_filter.rs:139:5 | LL | / match Some(11) { LL | | // Lint, statement is preserved by `.filter` @@ -152,7 +152,7 @@ LL ~ }); | error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:183:13 + --> tests/ui/manual_filter.rs:183:13 | LL | let _ = match Some(14) { | _____________^ @@ -165,7 +165,7 @@ LL | | }; | |_____^ help: try: `Some(14).filter(|&x| unsafe { f(x) })` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:193:13 + --> tests/ui/manual_filter.rs:193:13 | LL | let _ = match Some(15) { | _____________^ @@ -175,7 +175,7 @@ LL | | }; | |_____^ help: try: `Some(15).filter(|&x| unsafe { f(x) })` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:201:12 + --> tests/ui/manual_filter.rs:201:12 | LL | } else if let Some(x) = Some(16) { | ____________^ diff --git a/tests/ui/manual_filter_map.stderr b/tests/ui/manual_filter_map.stderr index cf64bb25951a3..2e50567278319 100644 --- a/tests/ui/manual_filter_map.stderr +++ b/tests/ui/manual_filter_map.stderr @@ -1,11 +1,11 @@ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:9:19 + --> tests/ui/manual_filter_map.rs:9:19 | LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:9:30 + --> tests/ui/manual_filter_map.rs:9:30 | LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap = help: to override `-D warnings` add `#[allow(clippy::manual_filter_map)]` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:12:19 + --> tests/ui/manual_filter_map.rs:12:19 | LL | let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:12:31 + --> tests/ui/manual_filter_map.rs:12:31 | LL | let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:15:19 + --> tests/ui/manual_filter_map.rs:15:19 | LL | let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_res(a).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:15:31 + --> tests/ui/manual_filter_map.rs:15:31 | LL | let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:18:10 + --> tests/ui/manual_filter_map.rs:18:10 | LL | .filter(|&x| to_ref(to_opt(x)).is_some()) | __________^ @@ -45,13 +45,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:18:22 + --> tests/ui/manual_filter_map.rs:18:22 | LL | .filter(|&x| to_ref(to_opt(x)).is_some()) | ^^^^^^^^^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:21:10 + --> tests/ui/manual_filter_map.rs:21:10 | LL | .filter(|x| to_ref(to_opt(*x)).is_some()) | __________^ @@ -59,13 +59,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:21:21 + --> tests/ui/manual_filter_map.rs:21:21 | LL | .filter(|x| to_ref(to_opt(*x)).is_some()) | ^^^^^^^^^^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:25:10 + --> tests/ui/manual_filter_map.rs:25:10 | LL | .filter(|&x| to_ref(to_res(x)).is_ok()) | __________^ @@ -73,13 +73,13 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:25:22 + --> tests/ui/manual_filter_map.rs:25:22 | LL | .filter(|&x| to_ref(to_res(x)).is_ok()) | ^^^^^^^^^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:28:10 + --> tests/ui/manual_filter_map.rs:28:10 | LL | .filter(|x| to_ref(to_res(*x)).is_ok()) | __________^ @@ -87,13 +87,13 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:28:21 + --> tests/ui/manual_filter_map.rs:28:21 | LL | .filter(|x| to_ref(to_res(*x)).is_ok()) | ^^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:34:27 + --> tests/ui/manual_filter_map.rs:34:27 | LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` @@ -102,79 +102,79 @@ LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap() = help: to override `-D warnings` add `#[allow(clippy::manual_find_map)]` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:35:28 + --> tests/ui/manual_filter_map.rs:35:28 | LL | iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:36:31 + --> tests/ui/manual_filter_map.rs:36:31 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:37:31 + --> tests/ui/manual_filter_map.rs:37:31 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:37:41 + --> tests/ui/manual_filter_map.rs:37:41 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:39:30 + --> tests/ui/manual_filter_map.rs:39:30 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:40:31 + --> tests/ui/manual_filter_map.rs:40:31 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:41:32 + --> tests/ui/manual_filter_map.rs:41:32 | LL | iter::<&&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:42:31 + --> tests/ui/manual_filter_map.rs:42:31 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:43:32 + --> tests/ui/manual_filter_map.rs:43:32 | LL | iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:44:35 + --> tests/ui/manual_filter_map.rs:44:35 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:45:35 + --> tests/ui/manual_filter_map.rs:45:35 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:45:45 + --> tests/ui/manual_filter_map.rs:45:45 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:93:10 + --> tests/ui/manual_filter_map.rs:93:10 | LL | .filter(|f| f.option_field.is_some()) | __________^ @@ -182,7 +182,7 @@ LL | | .map(|f| f.option_field.clone().unwrap()); | |_________________________________________________^ help: try: `filter_map(|f| f.option_field.clone())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:98:10 + --> tests/ui/manual_filter_map.rs:98:10 | LL | .filter(|f| f.ref_field.is_some()) | __________^ @@ -190,7 +190,7 @@ LL | | .map(|f| f.ref_field.cloned().unwrap()); | |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.cloned())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:103:10 + --> tests/ui/manual_filter_map.rs:103:10 | LL | .filter(|f| f.ref_field.is_some()) | __________^ @@ -198,7 +198,7 @@ LL | | .map(|f| f.ref_field.copied().unwrap()); | |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.copied())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:108:10 + --> tests/ui/manual_filter_map.rs:108:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -206,7 +206,7 @@ LL | | .map(|f| f.result_field.clone().unwrap()); | |_________________________________________________^ help: try: `filter_map(|f| f.result_field.clone().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:113:10 + --> tests/ui/manual_filter_map.rs:113:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -214,7 +214,7 @@ LL | | .map(|f| f.result_field.as_ref().unwrap()); | |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_ref().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:118:10 + --> tests/ui/manual_filter_map.rs:118:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -222,7 +222,7 @@ LL | | .map(|f| f.result_field.as_deref().unwrap()); | |____________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:123:10 + --> tests/ui/manual_filter_map.rs:123:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -230,7 +230,7 @@ LL | | .map(|f| f.result_field.as_mut().unwrap()); | |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_mut().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:128:10 + --> tests/ui/manual_filter_map.rs:128:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -238,7 +238,7 @@ LL | | .map(|f| f.result_field.as_deref_mut().unwrap()); | |________________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref_mut().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:133:10 + --> tests/ui/manual_filter_map.rs:133:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -246,7 +246,7 @@ LL | | .map(|f| f.result_field.to_owned().unwrap()); | |____________________________________________________^ help: try: `filter_map(|f| f.result_field.to_owned().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:146:27 + --> tests/ui/manual_filter_map.rs:146:27 | LL | let _x = iter.clone().filter(|x| matches!(x, Enum::A(_))).map(|x| match x { | ___________________________^ @@ -256,7 +256,7 @@ LL | | }); | |______^ help: try: `filter_map(|x| match x { Enum::A(s) => Some(s), _ => None })` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:156:10 + --> tests/ui/manual_filter_map.rs:156:10 | LL | .filter(|x| matches!(x, Enum::A(_))) | __________^ diff --git a/tests/ui/manual_find.stderr b/tests/ui/manual_find.stderr index 286ad54625d7d..eb55a0c11f244 100644 --- a/tests/ui/manual_find.stderr +++ b/tests/ui/manual_find.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Iterator::find` - --> $DIR/manual_find.rs:5:5 + --> tests/ui/manual_find.rs:5:5 | LL | / for s in strings { LL | | @@ -15,7 +15,7 @@ LL | | None = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` - --> $DIR/manual_find.rs:16:5 + --> tests/ui/manual_find.rs:16:5 | LL | / for (s, _) in arr { LL | | diff --git a/tests/ui/manual_find_fixable.stderr b/tests/ui/manual_find_fixable.stderr index 387d1509c136c..c3f48fb9f98a3 100644 --- a/tests/ui/manual_find_fixable.stderr +++ b/tests/ui/manual_find_fixable.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:10:5 + --> tests/ui/manual_find_fixable.rs:10:5 | LL | / for &v in ARRAY { LL | | if v == n { @@ -13,7 +13,7 @@ LL | | None = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:19:5 + --> tests/ui/manual_find_fixable.rs:19:5 | LL | / for (a, _) in arr { LL | | if a % 2 == 0 { @@ -24,7 +24,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|(a, _)| a).find(|&a| a % 2 == 0)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:32:5 + --> tests/ui/manual_find_fixable.rs:32:5 | LL | / for el in arr { LL | | if el.name.len() == 10 { @@ -37,7 +37,7 @@ LL | | None = note: you may need to dereference some variables error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:42:5 + --> tests/ui/manual_find_fixable.rs:42:5 | LL | / for Tuple(a, _) in arr { LL | | if a >= 3 { @@ -48,7 +48,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|Tuple(a, _)| a).find(|&a| a >= 3)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:57:5 + --> tests/ui/manual_find_fixable.rs:57:5 | LL | / for el in arr { LL | | if el.should_keep() { @@ -61,7 +61,7 @@ LL | | None = note: you may need to dereference some variables error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:67:5 + --> tests/ui/manual_find_fixable.rs:67:5 | LL | / for el in arr { LL | | if f(el) == 20 { @@ -72,7 +72,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|&el| f(el) == 20)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:77:5 + --> tests/ui/manual_find_fixable.rs:77:5 | LL | / for &el in arr.values() { LL | | if f(el) { @@ -83,7 +83,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.values().find(|&&el| f(el)).copied()` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:86:5 + --> tests/ui/manual_find_fixable.rs:86:5 | LL | / for el in arr { LL | | if el.is_true { @@ -96,7 +96,7 @@ LL | | None = note: you may need to dereference some variables error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:116:5 + --> tests/ui/manual_find_fixable.rs:116:5 | LL | / for (_, &x) in v { LL | | if x > 10 { @@ -107,7 +107,7 @@ LL | | None | |________^ help: replace with an iterator: `v.into_iter().map(|(_, &x)| x).find(|&x| x > 10)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:125:5 + --> tests/ui/manual_find_fixable.rs:125:5 | LL | / for &(_, &x) in v { LL | | if x > 10 { @@ -118,7 +118,7 @@ LL | | None | |________^ help: replace with an iterator: `v.iter().map(|&(_, &x)| x).find(|&x| x > 10)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:134:5 + --> tests/ui/manual_find_fixable.rs:134:5 | LL | / for x in arr { LL | | if x >= 5 { @@ -129,7 +129,7 @@ LL | | return None; | |________________^ help: replace with an iterator: `arr.into_iter().find(|&x| x >= 5)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:189:9 + --> tests/ui/manual_find_fixable.rs:189:9 | LL | / for x in arr { LL | | if x < 1 { diff --git a/tests/ui/manual_find_map.stderr b/tests/ui/manual_find_map.stderr index 0526382323d36..2722d59f52a90 100644 --- a/tests/ui/manual_find_map.stderr +++ b/tests/ui/manual_find_map.stderr @@ -1,11 +1,11 @@ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:9:19 + --> tests/ui/manual_find_map.rs:9:19 | LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:9:28 + --> tests/ui/manual_find_map.rs:9:28 | LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap() = help: to override `-D warnings` add `#[allow(clippy::manual_find_map)]` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:12:19 + --> tests/ui/manual_find_map.rs:12:19 | LL | let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:12:29 + --> tests/ui/manual_find_map.rs:12:29 | LL | let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:15:19 + --> tests/ui/manual_find_map.rs:15:19 | LL | let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_res(a).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:15:29 + --> tests/ui/manual_find_map.rs:15:29 | LL | let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:18:10 + --> tests/ui/manual_find_map.rs:18:10 | LL | .find(|&x| to_ref(to_opt(x)).is_some()) | __________^ @@ -45,13 +45,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:18:20 + --> tests/ui/manual_find_map.rs:18:20 | LL | .find(|&x| to_ref(to_opt(x)).is_some()) | ^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:21:10 + --> tests/ui/manual_find_map.rs:21:10 | LL | .find(|x| to_ref(to_opt(*x)).is_some()) | __________^ @@ -59,13 +59,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:21:19 + --> tests/ui/manual_find_map.rs:21:19 | LL | .find(|x| to_ref(to_opt(*x)).is_some()) | ^^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:25:10 + --> tests/ui/manual_find_map.rs:25:10 | LL | .find(|&x| to_ref(to_res(x)).is_ok()) | __________^ @@ -73,13 +73,13 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:25:20 + --> tests/ui/manual_find_map.rs:25:20 | LL | .find(|&x| to_ref(to_res(x)).is_ok()) | ^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:28:10 + --> tests/ui/manual_find_map.rs:28:10 | LL | .find(|x| to_ref(to_res(*x)).is_ok()) | __________^ @@ -87,109 +87,109 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:28:19 + --> tests/ui/manual_find_map.rs:28:19 | LL | .find(|x| to_ref(to_res(*x)).is_ok()) | ^^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:34:26 + --> tests/ui/manual_find_map.rs:34:26 | LL | iter::>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x)` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:35:27 + --> tests/ui/manual_find_map.rs:35:27 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| *x)` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:36:28 + --> tests/ui/manual_find_map.rs:36:28 | LL | iter::<&&Option>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| **x)` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:37:27 + --> tests/ui/manual_find_map.rs:37:27 | LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:38:28 + --> tests/ui/manual_find_map.rs:38:28 | LL | iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:39:31 + --> tests/ui/manual_find_map.rs:39:31 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:40:31 + --> tests/ui/manual_find_map.rs:40:31 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:40:41 + --> tests/ui/manual_find_map.rs:40:41 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:42:30 + --> tests/ui/manual_find_map.rs:42:30 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:43:31 + --> tests/ui/manual_find_map.rs:43:31 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:44:32 + --> tests/ui/manual_find_map.rs:44:32 | LL | iter::<&&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:45:31 + --> tests/ui/manual_find_map.rs:45:31 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:46:32 + --> tests/ui/manual_find_map.rs:46:32 | LL | iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:47:35 + --> tests/ui/manual_find_map.rs:47:35 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:48:35 + --> tests/ui/manual_find_map.rs:48:35 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:48:45 + --> tests/ui/manual_find_map.rs:48:45 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:96:10 + --> tests/ui/manual_find_map.rs:96:10 | LL | .find(|f| f.option_field.is_some()) | __________^ @@ -197,7 +197,7 @@ LL | | .map(|f| f.option_field.clone().unwrap()); | |_________________________________________________^ help: try: `find_map(|f| f.option_field.clone())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:101:10 + --> tests/ui/manual_find_map.rs:101:10 | LL | .find(|f| f.ref_field.is_some()) | __________^ @@ -205,7 +205,7 @@ LL | | .map(|f| f.ref_field.cloned().unwrap()); | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:106:10 + --> tests/ui/manual_find_map.rs:106:10 | LL | .find(|f| f.ref_field.is_some()) | __________^ @@ -213,7 +213,7 @@ LL | | .map(|f| f.ref_field.copied().unwrap()); | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.copied())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:111:10 + --> tests/ui/manual_find_map.rs:111:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -221,7 +221,7 @@ LL | | .map(|f| f.result_field.clone().unwrap()); | |_________________________________________________^ help: try: `find_map(|f| f.result_field.clone().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:116:10 + --> tests/ui/manual_find_map.rs:116:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -229,7 +229,7 @@ LL | | .map(|f| f.result_field.as_ref().unwrap()); | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_ref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:121:10 + --> tests/ui/manual_find_map.rs:121:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -237,7 +237,7 @@ LL | | .map(|f| f.result_field.as_deref().unwrap()); | |____________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:126:10 + --> tests/ui/manual_find_map.rs:126:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -245,7 +245,7 @@ LL | | .map(|f| f.result_field.as_mut().unwrap()); | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_mut().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:131:10 + --> tests/ui/manual_find_map.rs:131:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -253,7 +253,7 @@ LL | | .map(|f| f.result_field.as_deref_mut().unwrap()); | |________________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref_mut().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:136:10 + --> tests/ui/manual_find_map.rs:136:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ diff --git a/tests/ui/manual_flatten.stderr b/tests/ui/manual_flatten.stderr index aa5c2104f6548..3b64d9ef859d6 100644 --- a/tests/ui/manual_flatten.stderr +++ b/tests/ui/manual_flatten.stderr @@ -1,5 +1,5 @@ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:7:5 + --> tests/ui/manual_flatten.rs:7:5 | LL | for n in x { | ^ - help: try: `x.into_iter().flatten()` @@ -13,7 +13,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:9:9 + --> tests/ui/manual_flatten.rs:9:9 | LL | / if let Some(y) = n { LL | | println!("{}", y); @@ -23,7 +23,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_flatten)]` error: unnecessary `if let` since only the `Ok` variant of the iterator element is used - --> $DIR/manual_flatten.rs:16:5 + --> tests/ui/manual_flatten.rs:16:5 | LL | for n in y.clone() { | ^ --------- help: try: `y.clone().into_iter().flatten()` @@ -37,7 +37,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:18:9 + --> tests/ui/manual_flatten.rs:18:9 | LL | / if let Ok(n) = n { LL | | println!("{}", n); @@ -45,7 +45,7 @@ LL | | }; | |_________^ error: unnecessary `if let` since only the `Ok` variant of the iterator element is used - --> $DIR/manual_flatten.rs:24:5 + --> tests/ui/manual_flatten.rs:24:5 | LL | for n in &y { | ^ -- help: try: `y.iter().flatten()` @@ -59,7 +59,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:26:9 + --> tests/ui/manual_flatten.rs:26:9 | LL | / if let Ok(n) = n { LL | | println!("{}", n); @@ -67,7 +67,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Ok` variant of the iterator element is used - --> $DIR/manual_flatten.rs:33:5 + --> tests/ui/manual_flatten.rs:33:5 | LL | for n in z { | ^ - help: try: `z.iter().flatten()` @@ -81,7 +81,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:35:9 + --> tests/ui/manual_flatten.rs:35:9 | LL | / if let Ok(n) = n { LL | | println!("{}", n); @@ -89,7 +89,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:43:5 + --> tests/ui/manual_flatten.rs:43:5 | LL | for n in z { | ^ - help: try: `z.flatten()` @@ -103,7 +103,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:45:9 + --> tests/ui/manual_flatten.rs:45:9 | LL | / if let Some(m) = n { LL | | println!("{}", m); @@ -111,7 +111,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:77:5 + --> tests/ui/manual_flatten.rs:77:5 | LL | for n in &vec_of_ref { | ^ ----------- help: try: `vec_of_ref.iter().copied().flatten()` @@ -125,7 +125,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:79:9 + --> tests/ui/manual_flatten.rs:79:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); @@ -133,7 +133,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:85:5 + --> tests/ui/manual_flatten.rs:85:5 | LL | for n in vec_of_ref { | ^ ---------- help: try: `vec_of_ref.iter().copied().flatten()` @@ -147,7 +147,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:87:9 + --> tests/ui/manual_flatten.rs:87:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); @@ -155,7 +155,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:93:5 + --> tests/ui/manual_flatten.rs:93:5 | LL | for n in slice_of_ref { | ^ ------------ help: try: `slice_of_ref.iter().copied().flatten()` @@ -169,7 +169,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:95:9 + --> tests/ui/manual_flatten.rs:95:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); @@ -177,7 +177,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:124:5 + --> tests/ui/manual_flatten.rs:124:5 | LL | / for n in vec![ LL | | @@ -189,7 +189,7 @@ LL | | } | |_____^ | help: remove the `if let` statement in the for loop and then... - --> $DIR/manual_flatten.rs:130:9 + --> tests/ui/manual_flatten.rs:130:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); diff --git a/tests/ui/manual_float_methods.stderr b/tests/ui/manual_float_methods.stderr index 680ab2efa094f..dae96839262d1 100644 --- a/tests/ui/manual_float_methods.stderr +++ b/tests/ui/manual_float_methods.stderr @@ -1,5 +1,5 @@ error: manually checking if a float is infinite - --> $DIR/manual_float_methods.rs:23:8 + --> tests/ui/manual_float_methods.rs:23:8 | LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` @@ -8,7 +8,7 @@ LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {} = help: to override `-D warnings` add `#[allow(clippy::manual_is_infinite)]` error: manually checking if a float is finite - --> $DIR/manual_float_methods.rs:24:8 + --> tests/ui/manual_float_methods.rs:24:8 | LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,13 +29,13 @@ LL | if !x.is_infinite() {} | ~~~~~~~~~~~~~~~~ error: manually checking if a float is infinite - --> $DIR/manual_float_methods.rs:25:8 + --> tests/ui/manual_float_methods.rs:25:8 | LL | if x == INFINITE || x == NEG_INFINITE {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` error: manually checking if a float is finite - --> $DIR/manual_float_methods.rs:26:8 + --> tests/ui/manual_float_methods.rs:26:8 | LL | if x != INFINITE && x != NEG_INFINITE {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | if !x.is_infinite() {} | ~~~~~~~~~~~~~~~~ error: manually checking if a float is infinite - --> $DIR/manual_float_methods.rs:28:8 + --> tests/ui/manual_float_methods.rs:28:8 | LL | if x == f64::INFINITY || x == f64::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` error: manually checking if a float is finite - --> $DIR/manual_float_methods.rs:29:8 + --> tests/ui/manual_float_methods.rs:29:8 | LL | if x != f64::INFINITY && x != f64::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/manual_hash_one.stderr b/tests/ui/manual_hash_one.stderr index 3ce6f41e1f910..bcff36d9bafc1 100644 --- a/tests/ui/manual_hash_one.stderr +++ b/tests/ui/manual_hash_one.stderr @@ -1,5 +1,5 @@ error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:9:5 + --> tests/ui/manual_hash_one.rs:9:5 | LL | hasher.finish() | ^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL ~ b.hash_one(&true) | error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:15:13 + --> tests/ui/manual_hash_one.rs:15:13 | LL | let _ = hasher.finish(); | ^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL ~ let _ = b.hash_one(&s[4..10]); | error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:21:13 + --> tests/ui/manual_hash_one.rs:21:13 | LL | let _ = hasher.finish(); | ^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL ~ let _ = b.hash_one(&v); | error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:88:13 + --> tests/ui/manual_hash_one.rs:88:13 | LL | let _ = hasher.finish(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/manual_instant_elapsed.stderr b/tests/ui/manual_instant_elapsed.stderr index 56d0b9cd77b26..e8ffeb5f8ca3e 100644 --- a/tests/ui/manual_instant_elapsed.stderr +++ b/tests/ui/manual_instant_elapsed.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Instant::elapsed` - --> $DIR/manual_instant_elapsed.rs:17:20 + --> tests/ui/manual_instant_elapsed.rs:17:20 | LL | let duration = Instant::now() - prev_instant; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `prev_instant.elapsed()` @@ -8,7 +8,7 @@ LL | let duration = Instant::now() - prev_instant; = help: to override `-D warnings` add `#[allow(clippy::manual_instant_elapsed)]` error: manual implementation of `Instant::elapsed` - --> $DIR/manual_instant_elapsed.rs:26:5 + --> tests/ui/manual_instant_elapsed.rs:26:5 | LL | Instant::now() - *ref_to_instant; // to ensure parens are added correctly | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*ref_to_instant).elapsed()` diff --git a/tests/ui/manual_is_ascii_check.stderr b/tests/ui/manual_is_ascii_check.stderr index f69522c5ff84c..3632077ec8086 100644 --- a/tests/ui/manual_is_ascii_check.stderr +++ b/tests/ui/manual_is_ascii_check.stderr @@ -1,5 +1,5 @@ error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:5:13 + --> tests/ui/manual_is_ascii_check.rs:5:13 | LL | assert!(matches!('x', 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_lowercase()` @@ -8,127 +8,127 @@ LL | assert!(matches!('x', 'a'..='z')); = help: to override `-D warnings` add `#[allow(clippy::manual_is_ascii_check)]` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:6:13 + --> tests/ui/manual_is_ascii_check.rs:6:13 | LL | assert!(matches!('X', 'A'..='Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:7:13 + --> tests/ui/manual_is_ascii_check.rs:7:13 | LL | assert!(matches!(b'x', b'a'..=b'z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'x'.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:8:13 + --> tests/ui/manual_is_ascii_check.rs:8:13 | LL | assert!(matches!(b'X', b'A'..=b'Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'X'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:11:13 + --> tests/ui/manual_is_ascii_check.rs:11:13 | LL | assert!(matches!(num, '0'..='9')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:12:13 + --> tests/ui/manual_is_ascii_check.rs:12:13 | LL | assert!(matches!(b'1', b'0'..=b'9')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:13:13 + --> tests/ui/manual_is_ascii_check.rs:13:13 | LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:17:5 + --> tests/ui/manual_is_ascii_check.rs:17:5 | LL | (b'0'..=b'9').contains(&b'0'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'0'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:18:5 + --> tests/ui/manual_is_ascii_check.rs:18:5 | LL | (b'a'..=b'z').contains(&b'a'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'a'.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:19:5 + --> tests/ui/manual_is_ascii_check.rs:19:5 | LL | (b'A'..=b'Z').contains(&b'A'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'A'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:21:5 + --> tests/ui/manual_is_ascii_check.rs:21:5 | LL | ('0'..='9').contains(&'0'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'0'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:22:5 + --> tests/ui/manual_is_ascii_check.rs:22:5 | LL | ('a'..='z').contains(&'a'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'a'.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:23:5 + --> tests/ui/manual_is_ascii_check.rs:23:5 | LL | ('A'..='Z').contains(&'A'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'A'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:26:5 + --> tests/ui/manual_is_ascii_check.rs:26:5 | LL | ('0'..='9').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:27:5 + --> tests/ui/manual_is_ascii_check.rs:27:5 | LL | ('a'..='z').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:28:5 + --> tests/ui/manual_is_ascii_check.rs:28:5 | LL | ('A'..='Z').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:41:13 + --> tests/ui/manual_is_ascii_check.rs:41:13 | LL | assert!(matches!(b'1', b'0'..=b'9')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:42:13 + --> tests/ui/manual_is_ascii_check.rs:42:13 | LL | assert!(matches!('X', 'A'..='Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:43:13 + --> tests/ui/manual_is_ascii_check.rs:43:13 | LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:44:13 + --> tests/ui/manual_is_ascii_check.rs:44:13 | LL | assert!(matches!('x', '0'..='9' | 'a'..='f' | 'A'..='F')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_hexdigit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:55:23 + --> tests/ui/manual_is_ascii_check.rs:55:23 | LL | const FOO: bool = matches!('x', '0'..='9'); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:56:23 + --> tests/ui/manual_is_ascii_check.rs:56:23 | LL | const BAR: bool = matches!('x', '0'..='9' | 'a'..='f' | 'A'..='F'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_hexdigit()` diff --git a/tests/ui/manual_is_variant_and.stderr b/tests/ui/manual_is_variant_and.stderr index c243de098dc67..d3ff7cf8b316a 100644 --- a/tests/ui/manual_is_variant_and.stderr +++ b/tests/ui/manual_is_variant_and.stderr @@ -1,5 +1,5 @@ error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:13:17 + --> tests/ui/manual_is_variant_and.rs:13:17 | LL | let _ = opt.map(|x| x > 1) | _________________^ @@ -11,7 +11,7 @@ LL | | .unwrap_or_default(); = help: to override `-D warnings` add `#[allow(clippy::manual_is_variant_and)]` error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:17:17 + --> tests/ui/manual_is_variant_and.rs:17:17 | LL | let _ = opt.map(|x| { | _________________^ @@ -28,13 +28,13 @@ LL ~ }); | error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:21:17 + --> tests/ui/manual_is_variant_and.rs:21:17 | LL | let _ = opt.map(|x| x > 1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_some_and(|x| x > 1)` error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:23:10 + --> tests/ui/manual_is_variant_and.rs:23:10 | LL | .map(|x| x > 1) | __________^ @@ -42,13 +42,13 @@ LL | | .unwrap_or_default(); | |____________________________^ help: use: `is_some_and(|x| x > 1)` error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:30:18 + --> tests/ui/manual_is_variant_and.rs:30:18 | LL | let _ = opt2.map(char::is_alphanumeric).unwrap_or_default(); // should lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_some_and(char::is_alphanumeric)` error: called `map().unwrap_or_default()` on a `Result` value - --> $DIR/manual_is_variant_and.rs:39:17 + --> tests/ui/manual_is_variant_and.rs:39:17 | LL | let _ = res.map(|x| { | _________________^ @@ -65,7 +65,7 @@ LL ~ }); | error: called `map().unwrap_or_default()` on a `Result` value - --> $DIR/manual_is_variant_and.rs:43:17 + --> tests/ui/manual_is_variant_and.rs:43:17 | LL | let _ = res.map(|x| x > 1) | _________________^ @@ -73,7 +73,7 @@ LL | | .unwrap_or_default(); | |____________________________^ help: use: `is_ok_and(|x| x > 1)` error: called `map().unwrap_or_default()` on a `Result` value - --> $DIR/manual_is_variant_and.rs:50:18 + --> tests/ui/manual_is_variant_and.rs:50:18 | LL | let _ = res2.map(char::is_alphanumeric).unwrap_or_default(); // should lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_ok_and(char::is_alphanumeric)` diff --git a/tests/ui/manual_let_else.stderr b/tests/ui/manual_let_else.stderr index 3beaf766efb13..b6433fc460c92 100644 --- a/tests/ui/manual_let_else.stderr +++ b/tests/ui/manual_let_else.stderr @@ -1,5 +1,5 @@ error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:27:5 + --> tests/ui/manual_let_else.rs:27:5 | LL | let v = if let Some(v_some) = g() { v_some } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };` @@ -8,7 +8,7 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return }; = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:30:5 + --> tests/ui/manual_let_else.rs:30:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -26,7 +26,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:37:5 + --> tests/ui/manual_let_else.rs:37:5 | LL | / let v = if let Some(v) = g() { LL | | @@ -47,25 +47,25 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:49:9 + --> tests/ui/manual_let_else.rs:49:9 | LL | let v = if let Some(v_some) = g() { v_some } else { continue }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { continue };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:51:9 + --> tests/ui/manual_let_else.rs:51:9 | LL | let v = if let Some(v_some) = g() { v_some } else { break }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { break };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:56:5 + --> tests/ui/manual_let_else.rs:56:5 | LL | let v = if let Some(v_some) = g() { v_some } else { panic!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { panic!() };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:60:5 + --> tests/ui/manual_let_else.rs:60:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -83,7 +83,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:68:5 + --> tests/ui/manual_let_else.rs:68:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -101,7 +101,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:76:5 + --> tests/ui/manual_let_else.rs:76:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -121,7 +121,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:85:5 + --> tests/ui/manual_let_else.rs:85:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -141,7 +141,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:94:5 + --> tests/ui/manual_let_else.rs:94:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -168,7 +168,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:110:5 + --> tests/ui/manual_let_else.rs:110:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -190,7 +190,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:121:5 + --> tests/ui/manual_let_else.rs:121:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -217,7 +217,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:137:5 + --> tests/ui/manual_let_else.rs:137:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -239,7 +239,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:148:5 + --> tests/ui/manual_let_else.rs:148:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -257,7 +257,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:156:5 + --> tests/ui/manual_let_else.rs:156:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -278,7 +278,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:166:5 + --> tests/ui/manual_let_else.rs:166:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -299,7 +299,7 @@ LL + } }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:176:5 + --> tests/ui/manual_let_else.rs:176:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -328,7 +328,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:194:5 + --> tests/ui/manual_let_else.rs:194:5 | LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) { LL | | @@ -346,7 +346,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:202:5 + --> tests/ui/manual_let_else.rs:202:5 | LL | / let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) { LL | | @@ -364,7 +364,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:212:13 + --> tests/ui/manual_let_else.rs:212:13 | LL | let $n = if let Some(v) = $e { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };` @@ -375,19 +375,19 @@ LL | create_binding_if_some!(w, g()); = note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info) error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:221:5 + --> tests/ui/manual_let_else.rs:221:5 | LL | let v = if let Variant::A(a, 0) = e() { a } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:225:5 + --> tests/ui/manual_let_else.rs:225:5 | LL | let mut v = if let Variant::B(b) = e() { b } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:230:5 + --> tests/ui/manual_let_else.rs:230:5 | LL | / let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested { LL | | @@ -405,19 +405,19 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:237:5 + --> tests/ui/manual_let_else.rs:237:5 | LL | let v = if let Variant::A(.., a) = e() { a } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(.., v) = e() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:241:5 + --> tests/ui/manual_let_else.rs:241:5 | LL | let w = if let (Some(v), ()) = (g(), ()) { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let (Some(w), ()) = (g(), ()) else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:245:5 + --> tests/ui/manual_let_else.rs:245:5 | LL | / let w = if let Some(S { v: x }) = Some(S { v: 0 }) { LL | | @@ -435,7 +435,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:253:5 + --> tests/ui/manual_let_else.rs:253:5 | LL | / let v = if let Some(S { v: x }) = Some(S { v: 0 }) { LL | | @@ -453,7 +453,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:261:5 + --> tests/ui/manual_let_else.rs:261:5 | LL | / let (x, S { v }, w) = if let Some(U { v, w, x }) = None::>> { LL | | @@ -471,7 +471,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:378:5 + --> tests/ui/manual_let_else.rs:378:5 | LL | / let _ = match ff { LL | | diff --git a/tests/ui/manual_let_else_match.stderr b/tests/ui/manual_let_else_match.stderr index 18bfe324ba76a..3c0065f64033f 100644 --- a/tests/ui/manual_let_else_match.stderr +++ b/tests/ui/manual_let_else_match.stderr @@ -1,5 +1,5 @@ error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:36:5 + --> tests/ui/manual_let_else_match.rs:36:5 | LL | / let v = match g() { LL | | @@ -13,7 +13,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:43:5 + --> tests/ui/manual_let_else_match.rs:43:5 | LL | / let v = match g() { LL | | @@ -23,7 +23,7 @@ LL | | }; | |______^ help: consider writing: `let Some(v) = g() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:51:9 + --> tests/ui/manual_let_else_match.rs:51:9 | LL | / let v = match h() { LL | | @@ -33,7 +33,7 @@ LL | | }; | |__________^ help: consider writing: `let ((Some(v), None) | (None, Some(v))) = h() else { continue };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:57:9 + --> tests/ui/manual_let_else_match.rs:57:9 | LL | / let v = match build_enum() { LL | | @@ -43,7 +43,7 @@ LL | | }; | |__________^ help: consider writing: `let (Variant::Bar(v) | Variant::Baz(v)) = build_enum() else { continue };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:66:5 + --> tests/ui/manual_let_else_match.rs:66:5 | LL | / let v = match f() { LL | | @@ -53,7 +53,7 @@ LL | | }; | |______^ help: consider writing: `let Ok(v) = f() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:73:5 + --> tests/ui/manual_let_else_match.rs:73:5 | LL | / let v = match f().map_err(|_| ()) { LL | | @@ -63,7 +63,7 @@ LL | | }; | |______^ help: consider writing: `let Ok(v) = f().map_err(|_| ()) else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:81:5 + --> tests/ui/manual_let_else_match.rs:81:5 | LL | / let _value = match f { LL | | @@ -73,7 +73,7 @@ LL | | }; | |______^ help: consider writing: `let (Variant::Bar(_value) | Variant::Baz(_value)) = f else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:87:5 + --> tests/ui/manual_let_else_match.rs:87:5 | LL | / let _value = match Some(build_enum()) { LL | | @@ -83,7 +83,7 @@ LL | | }; | |______^ help: consider writing: `let Some(Variant::Bar(_value) | Variant::Baz(_value)) = Some(build_enum()) else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:94:5 + --> tests/ui/manual_let_else_match.rs:94:5 | LL | / let data = match data.as_slice() { LL | | @@ -93,7 +93,7 @@ LL | | }; | |______^ help: consider writing: `let ([data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0]) = data.as_slice() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:175:5 + --> tests/ui/manual_let_else_match.rs:175:5 | LL | / let msg = match Some("hi") { LL | | diff --git a/tests/ui/manual_let_else_question_mark.stderr b/tests/ui/manual_let_else_question_mark.stderr index dec6947697a7e..434872ca26777 100644 --- a/tests/ui/manual_let_else_question_mark.stderr +++ b/tests/ui/manual_let_else_question_mark.stderr @@ -1,5 +1,5 @@ error: this `let...else` may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:29:5 + --> tests/ui/manual_let_else_question_mark.rs:29:5 | LL | let Some(v) = g() else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let v = g()?;` @@ -8,19 +8,19 @@ LL | let Some(v) = g() else { return None }; = help: to override `-D warnings` add `#[allow(clippy::question_mark)]` error: this `let...else` may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:35:5 + --> tests/ui/manual_let_else_question_mark.rs:35:5 | LL | let Some((v, w)) = g() else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let (v, w) = g()?;` error: this block may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:38:13 + --> tests/ui/manual_let_else_question_mark.rs:38:13 | LL | let v = if let Some(v_some) = g() { v_some } else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `g()?` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_question_mark.rs:42:5 + --> tests/ui/manual_let_else_question_mark.rs:42:5 | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -39,7 +39,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_question_mark.rs:53:9 + --> tests/ui/manual_let_else_question_mark.rs:53:9 | LL | / let v = match g() { LL | | Some(v_some) => v_some, @@ -48,13 +48,13 @@ LL | | }; | |__________^ help: consider writing: `let Some(v) = g() else { return None };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_question_mark.rs:63:9 + --> tests/ui/manual_let_else_question_mark.rs:63:9 | LL | let v = if let Some(v_some) = g() { v_some } else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return None };` error: this `let...else` may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:71:5 + --> tests/ui/manual_let_else_question_mark.rs:71:5 | LL | / let Some(x) = y else { LL | | return None; diff --git a/tests/ui/manual_main_separator_str.stderr b/tests/ui/manual_main_separator_str.stderr index 3e92bd0238c3a..78395eb7d6648 100644 --- a/tests/ui/manual_main_separator_str.stderr +++ b/tests/ui/manual_main_separator_str.stderr @@ -1,5 +1,5 @@ error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:21:19 + --> tests/ui/manual_main_separator_str.rs:21:19 | LL | let _: &str = &MAIN_SEPARATOR.to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` @@ -8,19 +8,19 @@ LL | let _: &str = &MAIN_SEPARATOR.to_string(); = help: to override `-D warnings` add `#[allow(clippy::manual_main_separator_str)]` error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:22:17 + --> tests/ui/manual_main_separator_str.rs:22:17 | LL | let _ = len(&MAIN_SEPARATOR.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:23:23 + --> tests/ui/manual_main_separator_str.rs:23:23 | LL | let _: Vec = MAIN_SEPARATOR.to_string().encode_utf16().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:27:12 + --> tests/ui/manual_main_separator_str.rs:27:12 | LL | f: &MAIN_SEPARATOR.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` diff --git a/tests/ui/manual_map_option.stderr b/tests/ui/manual_map_option.stderr index 3754a982cb9bc..47cc18303ba57 100644 --- a/tests/ui/manual_map_option.stderr +++ b/tests/ui/manual_map_option.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:14:5 + --> tests/ui/manual_map_option.rs:14:5 | LL | / match Some(0) { LL | | Some(_) => Some(2), @@ -11,7 +11,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_map)]` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:19:5 + --> tests/ui/manual_map_option.rs:19:5 | LL | / match Some(0) { LL | | Some(x) => Some(x + 1), @@ -20,7 +20,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| x + 1)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:24:5 + --> tests/ui/manual_map_option.rs:24:5 | LL | / match Some("") { LL | | Some(x) => Some(x.is_empty()), @@ -29,7 +29,7 @@ LL | | }; | |_____^ help: try: `Some("").map(|x| x.is_empty())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:29:5 + --> tests/ui/manual_map_option.rs:29:5 | LL | / if let Some(x) = Some(0) { LL | | Some(!x) @@ -39,7 +39,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| !x)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:36:5 + --> tests/ui/manual_map_option.rs:36:5 | LL | / match Some(0) { LL | | Some(x) => { Some(std::convert::identity(x)) } @@ -48,7 +48,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(std::convert::identity)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:41:5 + --> tests/ui/manual_map_option.rs:41:5 | LL | / match Some(&String::new()) { LL | | Some(x) => Some(str::len(x)), @@ -57,7 +57,7 @@ LL | | }; | |_____^ help: try: `Some(&String::new()).map(|x| str::len(x))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:51:5 + --> tests/ui/manual_map_option.rs:51:5 | LL | / match &Some([0, 1]) { LL | | Some(x) => Some(x[0]), @@ -66,7 +66,7 @@ LL | | }; | |_____^ help: try: `Some([0, 1]).as_ref().map(|x| x[0])` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:56:5 + --> tests/ui/manual_map_option.rs:56:5 | LL | / match &Some(0) { LL | | &Some(x) => Some(x * 2), @@ -75,7 +75,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| x * 2)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:61:5 + --> tests/ui/manual_map_option.rs:61:5 | LL | / match Some(String::new()) { LL | | Some(ref x) => Some(x.is_empty()), @@ -84,7 +84,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.is_empty())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:66:5 + --> tests/ui/manual_map_option.rs:66:5 | LL | / match &&Some(String::new()) { LL | | Some(x) => Some(x.len()), @@ -93,7 +93,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.len())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:71:5 + --> tests/ui/manual_map_option.rs:71:5 | LL | / match &&Some(0) { LL | | &&Some(x) => Some(x + x), @@ -102,7 +102,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| x + x)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:84:9 + --> tests/ui/manual_map_option.rs:84:9 | LL | / match &mut Some(String::new()) { LL | | Some(x) => Some(x.push_str("")), @@ -111,7 +111,7 @@ LL | | }; | |_________^ help: try: `Some(String::new()).as_mut().map(|x| x.push_str(""))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:90:5 + --> tests/ui/manual_map_option.rs:90:5 | LL | / match &mut Some(String::new()) { LL | | Some(ref x) => Some(x.len()), @@ -120,7 +120,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.len())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:95:5 + --> tests/ui/manual_map_option.rs:95:5 | LL | / match &mut &Some(String::new()) { LL | | Some(x) => Some(x.is_empty()), @@ -129,7 +129,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.is_empty())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:100:5 + --> tests/ui/manual_map_option.rs:100:5 | LL | / match Some((0, 1, 2)) { LL | | Some((x, y, z)) => Some(x + y + z), @@ -138,7 +138,7 @@ LL | | }; | |_____^ help: try: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:105:5 + --> tests/ui/manual_map_option.rs:105:5 | LL | / match Some([1, 2, 3]) { LL | | Some([first, ..]) => Some(first), @@ -147,7 +147,7 @@ LL | | }; | |_____^ help: try: `Some([1, 2, 3]).map(|[first, ..]| first)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:110:5 + --> tests/ui/manual_map_option.rs:110:5 | LL | / match &Some((String::new(), "test")) { LL | | Some((x, y)) => Some((y, x)), @@ -156,7 +156,7 @@ LL | | }; | |_____^ help: try: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:168:5 + --> tests/ui/manual_map_option.rs:168:5 | LL | / match Some(0) { LL | | Some(x) => Some(vec![x]), @@ -165,7 +165,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| vec![x])` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:173:5 + --> tests/ui/manual_map_option.rs:173:5 | LL | / match option_env!("") { LL | | Some(x) => Some(String::from(x)), @@ -174,7 +174,7 @@ LL | | }; | |_____^ help: try: `option_env!("").map(String::from)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:193:12 + --> tests/ui/manual_map_option.rs:193:12 | LL | } else if let Some(x) = Some(0) { | ____________^ @@ -185,7 +185,7 @@ LL | | }; | |_____^ help: try: `{ Some(0).map(|x| x + 1) }` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:201:12 + --> tests/ui/manual_map_option.rs:201:12 | LL | } else if let Some(x) = Some(0) { | ____________^ diff --git a/tests/ui/manual_map_option_2.stderr b/tests/ui/manual_map_option_2.stderr index d3754f22d8996..78e4677544bc8 100644 --- a/tests/ui/manual_map_option_2.stderr +++ b/tests/ui/manual_map_option_2.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:6:13 + --> tests/ui/manual_map_option_2.rs:6:13 | LL | let _ = match Some(0) { | _____________^ @@ -22,7 +22,7 @@ LL ~ }); | error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:48:13 + --> tests/ui/manual_map_option_2.rs:48:13 | LL | let _ = match &s { | _____________^ @@ -32,7 +32,7 @@ LL | | }; | |_____^ help: try: `s.as_ref().map(|x| { if let Some(ref s) = s { (x.clone(), s) } else { panic!() } })` error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:58:17 + --> tests/ui/manual_map_option_2.rs:58:17 | LL | let _ = match Some(0) { | _________________^ @@ -42,7 +42,7 @@ LL | | }; | |_________^ help: try: `Some(0).map(|x| f(x))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:63:13 + --> tests/ui/manual_map_option_2.rs:63:13 | LL | let _ = match Some(0) { | _____________^ @@ -52,7 +52,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| unsafe { f(x) })` error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:67:13 + --> tests/ui/manual_map_option_2.rs:67:13 | LL | let _ = match Some(0) { | _____________^ diff --git a/tests/ui/manual_memcpy/with_loop_counters.stderr b/tests/ui/manual_memcpy/with_loop_counters.stderr index ffa396ec01aa7..41a991e9688f5 100644 --- a/tests/ui/manual_memcpy/with_loop_counters.stderr +++ b/tests/ui/manual_memcpy/with_loop_counters.stderr @@ -1,5 +1,5 @@ error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:5:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:5:5 | LL | / for i in 3..src.len() { LL | | @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:13:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:13:5 | LL | / for i in 3..src.len() { LL | | @@ -23,7 +23,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..(src.len() - 3)].copy_from_slice(&src[3..]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:20:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:20:5 | LL | / for i in 0..src.len() { LL | | @@ -33,7 +33,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(src.len() + 3)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:27:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:27:5 | LL | / for i in 0..src.len() { LL | | @@ -43,7 +43,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[3..(src.len() + 3)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:34:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:34:5 | LL | / for i in 3..(3 + src.len()) { LL | | @@ -53,7 +53,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(3 + src.len())].copy_from_slice(&src[..(3 + src.len() - 3)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:41:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:41:5 | LL | / for i in 5..src.len() { LL | | @@ -63,7 +63,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[5..src.len()].copy_from_slice(&src[(3 - 2)..((src.len() - 2) + 3 - 5)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:48:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:48:5 | LL | / for i in 0..dst.len() { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[2..(dst.len() + 2)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:55:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:55:5 | LL | / for i in 3..10 { LL | | @@ -83,7 +83,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..10].copy_from_slice(&src[5..(10 + 5 - 3)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:63:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:63:5 | LL | / for i in 0..src.len() { LL | | @@ -101,7 +101,7 @@ LL + dst2[30..(src.len() + 30)].copy_from_slice(&src[..]); | error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:74:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:74:5 | LL | / for i in 0..1 << 1 { LL | | @@ -111,7 +111,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(0 << 1)..((1 << 1) + (0 << 1))].copy_from_slice(&src[2..((1 << 1) + 2)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/with_loop_counters.rs:82:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:82:5 | LL | / for i in 3..src.len() { LL | | diff --git a/tests/ui/manual_memcpy/without_loop_counters.stderr b/tests/ui/manual_memcpy/without_loop_counters.stderr index 0d9b50d162d7c..55cca1fb584a0 100644 --- a/tests/ui/manual_memcpy/without_loop_counters.stderr +++ b/tests/ui/manual_memcpy/without_loop_counters.stderr @@ -1,5 +1,5 @@ error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:8:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:8:5 | LL | / for i in 0..src.len() { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:15:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:15:5 | LL | / for i in 0..src.len() { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[10..(src.len() + 10)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:21:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:21:5 | LL | / for i in 0..src.len() { LL | | @@ -30,7 +30,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[10..(src.len() + 10)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:27:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:27:5 | LL | / for i in 11..src.len() { LL | | @@ -39,7 +39,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[11..src.len()].copy_from_slice(&src[(11 - 10)..(src.len() - 10)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:33:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:33:5 | LL | / for i in 0..dst.len() { LL | | @@ -48,7 +48,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..dst.len()]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:47:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:47:5 | LL | / for i in 10..256 { LL | | @@ -64,7 +64,7 @@ LL + dst2[(10 + 500)..(256 + 500)].copy_from_slice(&src[10..256]); | error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:60:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:60:5 | LL | / for i in 10..LOOP_OFFSET { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].copy_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:74:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:74:5 | LL | / for i in 0..src_vec.len() { LL | | @@ -82,7 +82,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst_vec[..src_vec.len()].copy_from_slice(&src_vec[..]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:104:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:104:5 | LL | / for i in from..from + src.len() { LL | | @@ -91,7 +91,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + src.len())].copy_from_slice(&src[..(from + src.len() - from)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:109:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:109:5 | LL | / for i in from..from + 3 { LL | | @@ -100,7 +100,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + 3)].copy_from_slice(&src[..(from + 3 - from)]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:115:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:115:5 | LL | / for i in 0..5 { LL | | @@ -109,7 +109,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:121:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:121:5 | LL | / for i in 0..0 { LL | | @@ -118,7 +118,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:145:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:145:5 | LL | / for i in 0..4 { LL | | @@ -127,7 +127,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..4]);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:151:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:151:5 | LL | / for i in 0..5 { LL | | @@ -136,7 +136,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:157:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:157:5 | LL | / for i in 0..5 { LL | | @@ -145,7 +145,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/manual_memcpy/without_loop_counters.rs:165:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:165:5 | LL | / for i in 0..src.len() { LL | | diff --git a/tests/ui/manual_next_back.stderr b/tests/ui/manual_next_back.stderr index a63d266dd623f..c7e1ceca437cc 100644 --- a/tests/ui/manual_next_back.stderr +++ b/tests/ui/manual_next_back.stderr @@ -1,5 +1,5 @@ error: manual backwards iteration - --> $DIR/manual_next_back.rs:32:20 + --> tests/ui/manual_next_back.rs:32:20 | LL | let _ = (0..10).rev().next().unwrap(); | ^^^^^^^^^^^^^ help: use: `.next_back()` @@ -8,7 +8,7 @@ LL | let _ = (0..10).rev().next().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::manual_next_back)]` error: manual backwards iteration - --> $DIR/manual_next_back.rs:33:32 + --> tests/ui/manual_next_back.rs:33:32 | LL | let _ = "something".bytes().rev().next(); | ^^^^^^^^^^^^^ help: use: `.next_back()` diff --git a/tests/ui/manual_non_exhaustive_enum.stderr b/tests/ui/manual_non_exhaustive_enum.stderr index c4b13a577a96b..ee43b8ddc0246 100644 --- a/tests/ui/manual_non_exhaustive_enum.stderr +++ b/tests/ui/manual_non_exhaustive_enum.stderr @@ -1,5 +1,5 @@ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_enum.rs:5:1 + --> tests/ui/manual_non_exhaustive_enum.rs:5:1 | LL | enum E { | ^----- @@ -15,7 +15,7 @@ LL | | } | |_^ | help: remove this variant - --> $DIR/manual_non_exhaustive_enum.rs:10:5 + --> tests/ui/manual_non_exhaustive_enum.rs:10:5 | LL | _C, | ^^ @@ -23,7 +23,7 @@ LL | _C, = help: to override `-D warnings` add `#[allow(clippy::manual_non_exhaustive)]` error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_enum.rs:30:1 + --> tests/ui/manual_non_exhaustive_enum.rs:30:1 | LL | enum NoUnderscore { | ^---------------- @@ -38,7 +38,7 @@ LL | | } | |_^ | help: remove this variant - --> $DIR/manual_non_exhaustive_enum.rs:34:5 + --> tests/ui/manual_non_exhaustive_enum.rs:34:5 | LL | C, | ^ diff --git a/tests/ui/manual_non_exhaustive_struct.stderr b/tests/ui/manual_non_exhaustive_struct.stderr index 0b88b19691e13..1cab812988a34 100644 --- a/tests/ui/manual_non_exhaustive_struct.stderr +++ b/tests/ui/manual_non_exhaustive_struct.stderr @@ -1,5 +1,5 @@ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:5:5 + --> tests/ui/manual_non_exhaustive_struct.rs:5:5 | LL | struct S { | ^------- @@ -14,7 +14,7 @@ LL | | } | |_____^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:9:9 + --> tests/ui/manual_non_exhaustive_struct.rs:9:9 | LL | _c: (), | ^^^^^^ @@ -22,7 +22,7 @@ LL | _c: (), = help: to override `-D warnings` add `#[allow(clippy::manual_non_exhaustive)]` error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:14:5 + --> tests/ui/manual_non_exhaustive_struct.rs:14:5 | LL | / struct Sp { LL | | @@ -33,13 +33,13 @@ LL | | } | |_____^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:18:9 + --> tests/ui/manual_non_exhaustive_struct.rs:18:9 | LL | _c: (), | ^^^^^^ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:29:5 + --> tests/ui/manual_non_exhaustive_struct.rs:29:5 | LL | struct NoUnderscore { | ^------------------ @@ -53,13 +53,13 @@ LL | | } | |_____^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:32:9 + --> tests/ui/manual_non_exhaustive_struct.rs:32:9 | LL | c: (), | ^^^^^ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:56:5 + --> tests/ui/manual_non_exhaustive_struct.rs:56:5 | LL | struct T(pub i32, pub i32, ()); | --------^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,19 +67,19 @@ LL | struct T(pub i32, pub i32, ()); | help: add the attribute: `#[non_exhaustive] struct T` | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:56:32 + --> tests/ui/manual_non_exhaustive_struct.rs:56:32 | LL | struct T(pub i32, pub i32, ()); | ^^ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:61:5 + --> tests/ui/manual_non_exhaustive_struct.rs:61:5 | LL | struct Tp(pub i32, pub i32, ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:61:33 + --> tests/ui/manual_non_exhaustive_struct.rs:61:33 | LL | struct Tp(pub i32, pub i32, ()); | ^^ diff --git a/tests/ui/manual_ok_or.stderr b/tests/ui/manual_ok_or.stderr index 89df6cdbedbcc..2441a75b5c46e 100644 --- a/tests/ui/manual_ok_or.stderr +++ b/tests/ui/manual_ok_or.stderr @@ -1,5 +1,5 @@ error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:11:5 + --> tests/ui/manual_ok_or.rs:11:5 | LL | foo.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` @@ -8,13 +8,13 @@ LL | foo.map_or(Err("error"), |v| Ok(v)); = help: to override `-D warnings` add `#[allow(clippy::manual_ok_or)]` error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:14:5 + --> tests/ui/manual_ok_or.rs:14:5 | LL | foo.map_or(Err("error"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` error: called `map_or(Err(_), Ok)` on an `Option` value - --> $DIR/manual_ok_or.rs:14:5 + --> tests/ui/manual_ok_or.rs:14:5 | LL | foo.map_or(Err("error"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `foo.ok_or("error")` @@ -23,13 +23,13 @@ LL | foo.map_or(Err("error"), Ok); = help: to override `-D warnings` add `#[allow(clippy::option_map_or_err_ok)]` error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:17:5 + --> tests/ui/manual_ok_or.rs:17:5 | LL | None::.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `None::.ok_or("error")` error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:21:5 + --> tests/ui/manual_ok_or.rs:21:5 | LL | / foo.map_or(Err::( LL | | &format!( diff --git a/tests/ui/manual_range_patterns.stderr b/tests/ui/manual_range_patterns.stderr index fbeb9455769df..7c19fdd475f19 100644 --- a/tests/ui/manual_range_patterns.stderr +++ b/tests/ui/manual_range_patterns.stderr @@ -1,5 +1,5 @@ error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:8:25 + --> tests/ui/manual_range_patterns.rs:8:25 | LL | let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` @@ -8,109 +8,109 @@ LL | let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10); = help: to override `-D warnings` add `#[allow(clippy::manual_range_patterns)]` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:9:25 + --> tests/ui/manual_range_patterns.rs:9:25 | LL | let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 7 | 8 | 10); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:16:25 + --> tests/ui/manual_range_patterns.rs:16:25 | LL | let _ = matches!(f, 1 | (2..=4)); | ^^^^^^^^^^^ help: try: `1..=4` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:17:25 + --> tests/ui/manual_range_patterns.rs:17:25 | LL | let _ = matches!(f, 1 | (2..4)); | ^^^^^^^^^^ help: try: `1..4` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:18:25 + --> tests/ui/manual_range_patterns.rs:18:25 | LL | let _ = matches!(f, (1..=10) | (2..=13) | (14..=48324728) | 48324729); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=48324729` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:19:25 + --> tests/ui/manual_range_patterns.rs:19:25 | LL | let _ = matches!(f, 0 | (1..=10) | 48324730 | (2..=13) | (14..=48324728) | 48324729); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0..=48324730` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:20:25 + --> tests/ui/manual_range_patterns.rs:20:25 | LL | let _ = matches!(f, 0..=1 | 0..=2 | 0..=3); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `0..=3` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:23:9 + --> tests/ui/manual_range_patterns.rs:23:9 | LL | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => true, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:26:25 + --> tests/ui/manual_range_patterns.rs:26:25 | LL | let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1 | 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-5..=3` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:28:25 + --> tests/ui/manual_range_patterns.rs:28:25 | LL | let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_001); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-1_000_001..=1_000_001` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:31:17 + --> tests/ui/manual_range_patterns.rs:31:17 | LL | matches!(f, 0x00 | 0x01 | 0x02 | 0x03); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0x00..=0x03` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:32:17 + --> tests/ui/manual_range_patterns.rs:32:17 | LL | matches!(f, 0x00..=0x05 | 0x06 | 0x07); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0x00..=0x07` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:33:17 + --> tests/ui/manual_range_patterns.rs:33:17 | LL | matches!(f, -0x09 | -0x08 | -0x07..=0x00); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-0x09..=0x00` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:35:17 + --> tests/ui/manual_range_patterns.rs:35:17 | LL | matches!(f, 0..5 | 5); | ^^^^^^^^ help: try: `0..=5` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:36:17 + --> tests/ui/manual_range_patterns.rs:36:17 | LL | matches!(f, 0 | 1..5); | ^^^^^^^^ help: try: `0..5` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:38:17 + --> tests/ui/manual_range_patterns.rs:38:17 | LL | matches!(f, 0..=5 | 6..10); | ^^^^^^^^^^^^^ help: try: `0..10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:39:17 + --> tests/ui/manual_range_patterns.rs:39:17 | LL | matches!(f, 0..5 | 5..=10); | ^^^^^^^^^^^^^ help: try: `0..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:40:17 + --> tests/ui/manual_range_patterns.rs:40:17 | LL | matches!(f, 5..=10 | 0..5); | ^^^^^^^^^^^^^ help: try: `0..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:44:26 + --> tests/ui/manual_range_patterns.rs:44:26 | LL | matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` diff --git a/tests/ui/manual_rem_euclid.stderr b/tests/ui/manual_rem_euclid.stderr index f296f264665ca..a19fdadb1c9bd 100644 --- a/tests/ui/manual_rem_euclid.stderr +++ b/tests/ui/manual_rem_euclid.stderr @@ -1,5 +1,5 @@ error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:13:18 + --> tests/ui/manual_rem_euclid.rs:13:18 | LL | let _: i32 = ((value % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` @@ -8,31 +8,31 @@ LL | let _: i32 = ((value % 4) + 4) % 4; = help: to override `-D warnings` add `#[allow(clippy::manual_rem_euclid)]` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:14:18 + --> tests/ui/manual_rem_euclid.rs:14:18 | LL | let _: i32 = (4 + (value % 4)) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:15:18 + --> tests/ui/manual_rem_euclid.rs:15:18 | LL | let _: i32 = (value % 4 + 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:16:18 + --> tests/ui/manual_rem_euclid.rs:16:18 | LL | let _: i32 = (4 + value % 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:17:22 + --> tests/ui/manual_rem_euclid.rs:17:22 | LL | let _: i32 = 1 + (4 + value % 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:37:22 + --> tests/ui/manual_rem_euclid.rs:37:22 | LL | let _: i32 = ((value % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` @@ -40,25 +40,25 @@ LL | let _: i32 = ((value % 4) + 4) % 4; = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:49:5 + --> tests/ui/manual_rem_euclid.rs:49:5 | LL | ((num % 4) + 4) % 4 | ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:54:5 + --> tests/ui/manual_rem_euclid.rs:54:5 | LL | ((num % 4) + 4) % 4 | ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:66:18 + --> tests/ui/manual_rem_euclid.rs:66:18 | LL | let _: i32 = ((x % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:79:18 + --> tests/ui/manual_rem_euclid.rs:79:18 | LL | let _: i32 = ((x % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)` diff --git a/tests/ui/manual_retain.stderr b/tests/ui/manual_retain.stderr index 2c872f3b430e8..c25c804df7581 100644 --- a/tests/ui/manual_retain.stderr +++ b/tests/ui/manual_retain.stderr @@ -1,5 +1,5 @@ error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:25:5 + --> tests/ui/manual_retain.rs:25:5 | LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` @@ -8,43 +8,43 @@ LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect(); = help: to override `-D warnings` add `#[allow(clippy::manual_retain)]` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:26:5 + --> tests/ui/manual_retain.rs:26:5 | LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:27:5 + --> tests/ui/manual_retain.rs:27:5 | LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:31:5 + --> tests/ui/manual_retain.rs:31:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:32:5 + --> tests/ui/manual_retain.rs:32:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:62:5 + --> tests/ui/manual_retain.rs:62:5 | LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:63:5 + --> tests/ui/manual_retain.rs:63:5 | LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:64:5 + --> tests/ui/manual_retain.rs:64:5 | LL | / btree_map = btree_map LL | | .into_iter() @@ -53,49 +53,49 @@ LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:89:5 + --> tests/ui/manual_retain.rs:89:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:90:5 + --> tests/ui/manual_retain.rs:90:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:91:5 + --> tests/ui/manual_retain.rs:91:5 | LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:95:5 + --> tests/ui/manual_retain.rs:95:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:96:5 + --> tests/ui/manual_retain.rs:96:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:126:5 + --> tests/ui/manual_retain.rs:126:5 | LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:127:5 + --> tests/ui/manual_retain.rs:127:5 | LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:128:5 + --> tests/ui/manual_retain.rs:128:5 | LL | / hash_map = hash_map LL | | .into_iter() @@ -104,133 +104,133 @@ LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:152:5 + --> tests/ui/manual_retain.rs:152:5 | LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:153:5 + --> tests/ui/manual_retain.rs:153:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:154:5 + --> tests/ui/manual_retain.rs:154:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:158:5 + --> tests/ui/manual_retain.rs:158:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:159:5 + --> tests/ui/manual_retain.rs:159:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:188:5 + --> tests/ui/manual_retain.rs:188:5 | LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:200:5 + --> tests/ui/manual_retain.rs:200:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:201:5 + --> tests/ui/manual_retain.rs:201:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:202:5 + --> tests/ui/manual_retain.rs:202:5 | LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:206:5 + --> tests/ui/manual_retain.rs:206:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:207:5 + --> tests/ui/manual_retain.rs:207:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:229:5 + --> tests/ui/manual_retain.rs:229:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:230:5 + --> tests/ui/manual_retain.rs:230:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:231:5 + --> tests/ui/manual_retain.rs:231:5 | LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:288:5 + --> tests/ui/manual_retain.rs:288:5 | LL | vec = vec.into_iter().filter(|(x, y)| *x == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:292:5 + --> tests/ui/manual_retain.rs:292:5 | LL | tuples = tuples.into_iter().filter(|(_, n)| *n > 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(_, n)| *n > 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:309:5 + --> tests/ui/manual_retain.rs:309:5 | LL | vec = vec.iter().filter(|&&x| x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:310:5 + --> tests/ui/manual_retain.rs:310:5 | LL | vec = vec.iter().filter(|&&x| x == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:311:5 + --> tests/ui/manual_retain.rs:311:5 | LL | vec = vec.into_iter().filter(|&x| x == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:314:5 + --> tests/ui/manual_retain.rs:314:5 | LL | vec = vec.iter().filter(|&x| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:315:5 + --> tests/ui/manual_retain.rs:315:5 | LL | vec = vec.iter().filter(|&x| *x == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:316:5 + --> tests/ui/manual_retain.rs:316:5 | LL | vec = vec.into_iter().filter(|x| *x == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` diff --git a/tests/ui/manual_saturating_arithmetic.stderr b/tests/ui/manual_saturating_arithmetic.stderr index 3ce108b1ca81e..b6a8df0f84e13 100644 --- a/tests/ui/manual_saturating_arithmetic.stderr +++ b/tests/ui/manual_saturating_arithmetic.stderr @@ -1,5 +1,5 @@ error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:6:13 + --> tests/ui/manual_saturating_arithmetic.rs:6:13 | LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)` @@ -8,19 +8,19 @@ LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); = help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:7:13 + --> tests/ui/manual_saturating_arithmetic.rs:7:13 | LL | let _ = 1u32.checked_add(1).unwrap_or(u32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:8:13 + --> tests/ui/manual_saturating_arithmetic.rs:8:13 | LL | let _ = 1u8.checked_add(1).unwrap_or(255); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u8.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:9:13 + --> tests/ui/manual_saturating_arithmetic.rs:9:13 | LL | let _ = 1u128 | _____________^ @@ -29,49 +29,49 @@ LL | | .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455); | |_______________________________________________________________________^ help: consider using `saturating_add`: `1u128.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:14:13 + --> tests/ui/manual_saturating_arithmetic.rs:14:13 | LL | let _ = 1u32.checked_mul(1).unwrap_or(u32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `1u32.saturating_mul(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:16:13 + --> tests/ui/manual_saturating_arithmetic.rs:16:13 | LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:17:13 + --> tests/ui/manual_saturating_arithmetic.rs:17:13 | LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:18:13 + --> tests/ui/manual_saturating_arithmetic.rs:18:13 | LL | let _ = 1u8.checked_sub(1).unwrap_or(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u8.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:22:13 + --> tests/ui/manual_saturating_arithmetic.rs:22:13 | LL | let _ = 1i32.checked_add(1).unwrap_or(i32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:23:13 + --> tests/ui/manual_saturating_arithmetic.rs:23:13 | LL | let _ = 1i32.checked_add(1).unwrap_or(i32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:24:13 + --> tests/ui/manual_saturating_arithmetic.rs:24:13 | LL | let _ = 1i8.checked_add(1).unwrap_or(127); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:25:13 + --> tests/ui/manual_saturating_arithmetic.rs:25:13 | LL | let _ = 1i128 | _____________^ @@ -80,25 +80,25 @@ LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); | |_______________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:28:13 + --> tests/ui/manual_saturating_arithmetic.rs:28:13 | LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:29:13 + --> tests/ui/manual_saturating_arithmetic.rs:29:13 | LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:30:13 + --> tests/ui/manual_saturating_arithmetic.rs:30:13 | LL | let _ = 1i8.checked_add(-1).unwrap_or(-128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:31:13 + --> tests/ui/manual_saturating_arithmetic.rs:31:13 | LL | let _ = 1i128 | _____________^ @@ -107,25 +107,25 @@ LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); | |________________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:38:13 + --> tests/ui/manual_saturating_arithmetic.rs:38:13 | LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:39:13 + --> tests/ui/manual_saturating_arithmetic.rs:39:13 | LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:40:13 + --> tests/ui/manual_saturating_arithmetic.rs:40:13 | LL | let _ = 1i8.checked_sub(1).unwrap_or(-128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:41:13 + --> tests/ui/manual_saturating_arithmetic.rs:41:13 | LL | let _ = 1i128 | _____________^ @@ -134,25 +134,25 @@ LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); | |________________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:44:13 + --> tests/ui/manual_saturating_arithmetic.rs:44:13 | LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:45:13 + --> tests/ui/manual_saturating_arithmetic.rs:45:13 | LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:46:13 + --> tests/ui/manual_saturating_arithmetic.rs:46:13 | LL | let _ = 1i8.checked_sub(-1).unwrap_or(127); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:47:13 + --> tests/ui/manual_saturating_arithmetic.rs:47:13 | LL | let _ = 1i128 | _____________^ diff --git a/tests/ui/manual_slice_size_calculation.stderr b/tests/ui/manual_slice_size_calculation.stderr index ebdb748137a90..4bd8a4fdf17b7 100644 --- a/tests/ui/manual_slice_size_calculation.stderr +++ b/tests/ui/manual_slice_size_calculation.stderr @@ -1,5 +1,5 @@ error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:15:13 + --> tests/ui/manual_slice_size_calculation.rs:15:13 | LL | let _ = s_i32.len() * size_of::(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` @@ -8,37 +8,37 @@ LL | let _ = s_i32.len() * size_of::(); // WARNING = help: to override `-D warnings` add `#[allow(clippy::manual_slice_size_calculation)]` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:16:13 + --> tests/ui/manual_slice_size_calculation.rs:16:13 | LL | let _ = size_of::() * s_i32.len(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:17:13 + --> tests/ui/manual_slice_size_calculation.rs:17:13 | LL | let _ = size_of::() * s_i32.len() * 5; // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:21:13 + --> tests/ui/manual_slice_size_calculation.rs:21:13 | LL | let _ = len * size_of::(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:22:13 + --> tests/ui/manual_slice_size_calculation.rs:22:13 | LL | let _ = s_i32.len() * size; // WARNING | ^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:23:13 + --> tests/ui/manual_slice_size_calculation.rs:23:13 | LL | let _ = len * size; // WARNING | ^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:25:13 + --> tests/ui/manual_slice_size_calculation.rs:25:13 | LL | let _ = external!(&[1u64][..]).len() * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(external!(&[1u64][..]))` diff --git a/tests/ui/manual_split_once.stderr b/tests/ui/manual_split_once.stderr index 494a035edc3ab..b4e51f473cf4d 100644 --- a/tests/ui/manual_split_once.stderr +++ b/tests/ui/manual_split_once.stderr @@ -1,5 +1,5 @@ error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:11:13 + --> tests/ui/manual_split_once.rs:11:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` @@ -8,79 +8,79 @@ LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::manual_split_once)]` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:12:13 + --> tests/ui/manual_split_once.rs:12:13 | LL | let _ = "key=value".splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:13:18 + --> tests/ui/manual_split_once.rs:13:18 | LL | let (_, _) = "key=value".splitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=')` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:16:13 + --> tests/ui/manual_split_once.rs:16:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:19:13 + --> tests/ui/manual_split_once.rs:19:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:22:13 + --> tests/ui/manual_split_once.rs:22:13 | LL | let _ = s.splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:25:17 + --> tests/ui/manual_split_once.rs:25:17 | LL | let _ = s.splitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:26:17 + --> tests/ui/manual_split_once.rs:26:17 | LL | let _ = s.splitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:27:17 + --> tests/ui/manual_split_once.rs:27:17 | LL | let _ = s.rsplitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:28:17 + --> tests/ui/manual_split_once.rs:28:17 | LL | let _ = s.rsplitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:36:13 + --> tests/ui/manual_split_once.rs:36:13 | LL | let _ = "key=value".rsplitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').unwrap().0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:37:18 + --> tests/ui/manual_split_once.rs:37:18 | LL | let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:38:13 + --> tests/ui/manual_split_once.rs:38:13 | LL | let _ = s.rsplitn(2, '=').nth(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=').map(|x| x.0)` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:42:5 + --> tests/ui/manual_split_once.rs:42:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL + | error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:46:5 + --> tests/ui/manual_split_once.rs:46:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL + | error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:50:5 + --> tests/ui/manual_split_once.rs:50:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + | error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:54:5 + --> tests/ui/manual_split_once.rs:54:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -180,13 +180,13 @@ LL + | error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:139:13 + --> tests/ui/manual_split_once.rs:139:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:141:5 + --> tests/ui/manual_split_once.rs:141:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/manual_str_repeat.stderr b/tests/ui/manual_str_repeat.stderr index 9a13aa9722737..9cc71e6e8b811 100644 --- a/tests/ui/manual_str_repeat.stderr +++ b/tests/ui/manual_str_repeat.stderr @@ -1,5 +1,5 @@ error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:7:21 + --> tests/ui/manual_str_repeat.rs:7:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` @@ -8,55 +8,55 @@ LL | let _: String = std::iter::repeat("test").take(10).collect(); = help: to override `-D warnings` add `#[allow(clippy::manual_str_repeat)]` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:8:21 + --> tests/ui/manual_str_repeat.rs:8:21 | LL | let _: String = std::iter::repeat('x').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"x".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:9:21 + --> tests/ui/manual_str_repeat.rs:9:21 | LL | let _: String = std::iter::repeat('\'').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"'".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:10:21 + --> tests/ui/manual_str_repeat.rs:10:21 | LL | let _: String = std::iter::repeat('"').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"\"".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:14:13 + --> tests/ui/manual_str_repeat.rs:14:13 | LL | let _ = repeat(x).take(count + 2).collect::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count + 2)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:23:21 + --> tests/ui/manual_str_repeat.rs:23:21 | LL | let _: String = repeat(*x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*x).repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:32:21 + --> tests/ui/manual_str_repeat.rs:32:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:44:21 + --> tests/ui/manual_str_repeat.rs:44:21 | LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Cow::Borrowed("test").repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:47:21 + --> tests/ui/manual_str_repeat.rs:47:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:62:21 + --> tests/ui/manual_str_repeat.rs:62:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` diff --git a/tests/ui/manual_string_new.stderr b/tests/ui/manual_string_new.stderr index cb2d78c39ed15..6b434f405d31c 100644 --- a/tests/ui/manual_string_new.stderr +++ b/tests/ui/manual_string_new.stderr @@ -1,5 +1,5 @@ error: empty String is being created manually - --> $DIR/manual_string_new.rs:14:13 + --> tests/ui/manual_string_new.rs:14:13 | LL | let _ = "".to_string(); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` @@ -8,49 +8,49 @@ LL | let _ = "".to_string(); = help: to override `-D warnings` add `#[allow(clippy::manual_string_new)]` error: empty String is being created manually - --> $DIR/manual_string_new.rs:17:13 + --> tests/ui/manual_string_new.rs:17:13 | LL | let _ = "".to_owned(); | ^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:20:21 + --> tests/ui/manual_string_new.rs:20:21 | LL | let _: String = "".into(); | ^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:27:13 + --> tests/ui/manual_string_new.rs:27:13 | LL | let _ = String::from(""); | ^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:28:13 + --> tests/ui/manual_string_new.rs:28:13 | LL | let _ = ::from(""); | ^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:33:13 + --> tests/ui/manual_string_new.rs:33:13 | LL | let _ = String::try_from("").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:39:21 + --> tests/ui/manual_string_new.rs:39:21 | LL | let _: String = From::from(""); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:44:21 + --> tests/ui/manual_string_new.rs:44:21 | LL | let _: String = TryFrom::try_from("").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:47:21 + --> tests/ui/manual_string_new.rs:47:21 | LL | let _: String = TryFrom::try_from("").expect("this should warn"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` diff --git a/tests/ui/manual_strip.stderr b/tests/ui/manual_strip.stderr index 0bf6975b1e363..d2d4f765310b9 100644 --- a/tests/ui/manual_strip.stderr +++ b/tests/ui/manual_strip.stderr @@ -1,11 +1,11 @@ error: stripping a prefix manually - --> $DIR/manual_strip.rs:7:24 + --> tests/ui/manual_strip.rs:7:24 | LL | str::to_string(&s["ab".len()..]); | ^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:6:5 + --> tests/ui/manual_strip.rs:6:5 | LL | if s.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,13 +23,13 @@ LL ~ .to_string(); | error: stripping a suffix manually - --> $DIR/manual_strip.rs:16:24 + --> tests/ui/manual_strip.rs:16:24 | LL | str::to_string(&s[..s.len() - "bc".len()]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the suffix was tested here - --> $DIR/manual_strip.rs:15:5 + --> tests/ui/manual_strip.rs:15:5 | LL | if s.ends_with("bc") { | ^^^^^^^^^^^^^^^^^^^^^ @@ -45,13 +45,13 @@ LL ~ .to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:26:24 + --> tests/ui/manual_strip.rs:26:24 | LL | str::to_string(&s[1..]); | ^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:25:5 + --> tests/ui/manual_strip.rs:25:5 | LL | if s.starts_with('a') { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -64,13 +64,13 @@ LL ~ .to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:34:24 + --> tests/ui/manual_strip.rs:34:24 | LL | str::to_string(&s[prefix.len()..]); | ^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:33:5 + --> tests/ui/manual_strip.rs:33:5 | LL | if s.starts_with(prefix) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,13 +81,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:41:24 + --> tests/ui/manual_strip.rs:41:24 | LL | str::to_string(&s[PREFIX.len()..]); | ^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:40:5 + --> tests/ui/manual_strip.rs:40:5 | LL | if s.starts_with(PREFIX) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,13 +100,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:49:24 + --> tests/ui/manual_strip.rs:49:24 | LL | str::to_string(&TARGET[prefix.len()..]); | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:48:5 + --> tests/ui/manual_strip.rs:48:5 | LL | if TARGET.starts_with(prefix) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,13 +117,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:56:9 + --> tests/ui/manual_strip.rs:56:9 | LL | s1[2..].to_uppercase(); | ^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:55:5 + --> tests/ui/manual_strip.rs:55:5 | LL | if s1.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -134,13 +134,13 @@ LL ~ .to_uppercase(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:87:9 + --> tests/ui/manual_strip.rs:87:9 | LL | s[1..].to_string(); | ^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:86:5 + --> tests/ui/manual_strip.rs:86:5 | LL | if s.starts_with('a') { | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/manual_try_fold.stderr b/tests/ui/manual_try_fold.stderr index 4eb3e302b2143..bc075e87d71f5 100644 --- a/tests/ui/manual_try_fold.stderr +++ b/tests/ui/manual_try_fold.stderr @@ -1,5 +1,5 @@ error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:59:10 + --> tests/ui/manual_try_fold.rs:59:10 | LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` @@ -8,19 +8,19 @@ LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) = help: to override `-D warnings` add `#[allow(clippy::manual_try_fold)]` error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:63:10 + --> tests/ui/manual_try_fold.rs:63:10 | LL | .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(..., |sum, i| ...)` error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:66:10 + --> tests/ui/manual_try_fold.rs:66:10 | LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:96:10 + --> tests/ui/manual_try_fold.rs:96:10 | LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` diff --git a/tests/ui/manual_unwrap_or.stderr b/tests/ui/manual_unwrap_or.stderr index 3a0759dccaf20..511b79881ac3f 100644 --- a/tests/ui/manual_unwrap_or.stderr +++ b/tests/ui/manual_unwrap_or.stderr @@ -1,5 +1,5 @@ error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:6:5 + --> tests/ui/manual_unwrap_or.rs:6:5 | LL | / match Some(1) { LL | | Some(i) => i, @@ -11,7 +11,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or)]` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:12:5 + --> tests/ui/manual_unwrap_or.rs:12:5 | LL | / match Some(1) { LL | | None => 42, @@ -20,7 +20,7 @@ LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(42)` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:18:5 + --> tests/ui/manual_unwrap_or.rs:18:5 | LL | / match Some(1) { LL | | Some(i) => i, @@ -29,7 +29,7 @@ LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(1 + 42)` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:25:5 + --> tests/ui/manual_unwrap_or.rs:25:5 | LL | / match Some(1) { LL | | Some(i) => i, @@ -50,7 +50,7 @@ LL ~ }); | error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:35:5 + --> tests/ui/manual_unwrap_or.rs:35:5 | LL | / match Some("Bob") { LL | | Some(i) => i, @@ -59,7 +59,7 @@ LL | | }; | |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:85:5 + --> tests/ui/manual_unwrap_or.rs:85:5 | LL | / match Ok::(1) { LL | | Ok(i) => i, @@ -68,7 +68,7 @@ LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:92:5 + --> tests/ui/manual_unwrap_or.rs:92:5 | LL | / match a { LL | | Ok(i) => i, @@ -77,7 +77,7 @@ LL | | }; | |_____^ help: replace with: `a.unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:98:5 + --> tests/ui/manual_unwrap_or.rs:98:5 | LL | / match Ok(1) as Result { LL | | Ok(i) => i, @@ -86,7 +86,7 @@ LL | | }; | |_____^ help: replace with: `(Ok(1) as Result).unwrap_or(42)` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:111:5 + --> tests/ui/manual_unwrap_or.rs:111:5 | LL | / match s.method() { LL | | Some(i) => i, @@ -95,7 +95,7 @@ LL | | }; | |_____^ help: replace with: `s.method().unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:117:5 + --> tests/ui/manual_unwrap_or.rs:117:5 | LL | / match Ok::(1) { LL | | Err(_) => 42, @@ -104,7 +104,7 @@ LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:123:5 + --> tests/ui/manual_unwrap_or.rs:123:5 | LL | / match Ok::(1) { LL | | Ok(i) => i, @@ -113,7 +113,7 @@ LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(1 + 42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:130:5 + --> tests/ui/manual_unwrap_or.rs:130:5 | LL | / match Ok::(1) { LL | | Ok(i) => i, @@ -134,7 +134,7 @@ LL ~ }); | error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:140:5 + --> tests/ui/manual_unwrap_or.rs:140:5 | LL | / match Ok::<&str, &str>("Bob") { LL | | Ok(i) => i, @@ -143,7 +143,7 @@ LL | | }; | |_____^ help: replace with: `Ok::<&str, &str>("Bob").unwrap_or("Alice")` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:200:17 + --> tests/ui/manual_unwrap_or.rs:200:17 | LL | let _ = match some_macro!() { | _________________^ diff --git a/tests/ui/manual_while_let_some.stderr b/tests/ui/manual_while_let_some.stderr index 37387c8c320f2..8d444b80aaffa 100644 --- a/tests/ui/manual_while_let_some.stderr +++ b/tests/ui/manual_while_let_some.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:21:9 + --> tests/ui/manual_while_let_some.rs:21:9 | LL | let number = numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL ~ | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:29:9 + --> tests/ui/manual_while_let_some.rs:29:9 | LL | let number = val.numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL ~ | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:33:20 + --> tests/ui/manual_while_let_some.rs:33:20 | LL | accept_i32(numbers.pop().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL ~ accept_i32(element); | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:37:20 + --> tests/ui/manual_while_let_some.rs:37:20 | LL | accept_i32(numbers.pop().expect("")); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL ~ accept_i32(element); | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:80:9 + --> tests/ui/manual_while_let_some.rs:80:9 | LL | let (a, b) = numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL ~ | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:84:26 + --> tests/ui/manual_while_let_some.rs:84:26 | LL | accept_i32_tuple(numbers.pop().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL ~ accept_i32_tuple(element); | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:89:9 + --> tests/ui/manual_while_let_some.rs:89:9 | LL | let Foo { a, b } = results.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/many_single_char_names.stderr b/tests/ui/many_single_char_names.stderr index 688158cff6b03..131836ef7c882 100644 --- a/tests/ui/many_single_char_names.stderr +++ b/tests/ui/many_single_char_names.stderr @@ -1,5 +1,5 @@ error: 5 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:5:9 + --> tests/ui/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -14,7 +14,7 @@ LL | let e: i32; = help: to override `-D warnings` add `#[allow(clippy::many_single_char_names)]` error: 6 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:5:9 + --> tests/ui/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -28,7 +28,7 @@ LL | let f: i32; | ^ error: 5 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:5:9 + --> tests/ui/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -40,13 +40,13 @@ LL | e => panic!(), | ^ error: 8 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:34:13 + --> tests/ui/many_single_char_names.rs:34:13 | LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} | ^ ^ ^ ^ ^ ^ ^ ^ error: 8 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:38:10 + --> tests/ui/many_single_char_names.rs:38:10 | LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!(); | ^ ^ ^ ^ ^ ^ ^ ^ diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 2c86a67fab8d6..1a26a26a4cacb 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,5 +1,5 @@ error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:13:22 + --> tests/ui/map_clone.rs:13:22 | LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()` @@ -8,85 +8,85 @@ LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); = help: to override `-D warnings` add `#[allow(clippy::map_clone)]` error: you are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:14:26 + --> tests/ui/map_clone.rs:14:26 | LL | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()` error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:15:23 + --> tests/ui/map_clone.rs:15:23 | LL | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()` error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:17:26 + --> tests/ui/map_clone.rs:17:26 | LL | let _: Option = Some(&16).map(|b| *b); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()` error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:18:25 + --> tests/ui/map_clone.rs:18:25 | LL | let _: Option = Some(&1).map(|x| x.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&1).copied()` error: you are needlessly cloning iterator elements - --> $DIR/map_clone.rs:29:29 + --> tests/ui/map_clone.rs:29:29 | LL | let _ = std::env::args().map(|v| v.clone()); | ^^^^^^^^^^^^^^^^^^^ help: remove the `map` call error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:68:13 + --> tests/ui/map_clone.rs:68:13 | LL | let y = x.map(|x| String::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:70:13 + --> tests/ui/map_clone.rs:70:13 | LL | let y = x.map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:73:13 + --> tests/ui/map_clone.rs:73:13 | LL | let y = x.map(String::clone); | ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:79:13 + --> tests/ui/map_clone.rs:79:13 | LL | let y = x.map(|x| u32::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:82:13 + --> tests/ui/map_clone.rs:82:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:94:13 + --> tests/ui/map_clone.rs:94:13 | LL | let y = x.map(|x| String::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:97:13 + --> tests/ui/map_clone.rs:97:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:103:13 + --> tests/ui/map_clone.rs:103:13 | LL | let y = x.map(|x| u32::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:106:13 + --> tests/ui/map_clone.rs:106:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` diff --git a/tests/ui/map_collect_result_unit.stderr b/tests/ui/map_collect_result_unit.stderr index 1a505d4cecc32..8d147340e16aa 100644 --- a/tests/ui/map_collect_result_unit.stderr +++ b/tests/ui/map_collect_result_unit.stderr @@ -1,5 +1,5 @@ error: `.map().collect()` can be replaced with `.try_for_each()` - --> $DIR/map_collect_result_unit.rs:5:17 + --> tests/ui/map_collect_result_unit.rs:5:17 | LL | let _ = (0..3).map(|t| Err(t + 1)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))` @@ -8,7 +8,7 @@ LL | let _ = (0..3).map(|t| Err(t + 1)).collect::>(); = help: to override `-D warnings` add `#[allow(clippy::map_collect_result_unit)]` error: `.map().collect()` can be replaced with `.try_for_each()` - --> $DIR/map_collect_result_unit.rs:6:32 + --> tests/ui/map_collect_result_unit.rs:6:32 | LL | let _: Result<(), _> = (0..3).map(|t| Err(t + 1)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))` diff --git a/tests/ui/map_err.stderr b/tests/ui/map_err.stderr index eb6742ff23382..702c5e9783a4d 100644 --- a/tests/ui/map_err.stderr +++ b/tests/ui/map_err.stderr @@ -1,5 +1,5 @@ error: `map_err(|_|...` wildcard pattern discards the original error - --> $DIR/map_err.rs:22:32 + --> tests/ui/map_err.rs:22:32 | LL | println!("{:?}", x.map_err(|_| Errors::Ignored)); | ^^^ diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index a65d8f75ddd2a..a5837b97617db 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -1,5 +1,5 @@ error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten.rs:8:10 + --> tests/ui/map_flatten.rs:8:10 | LL | .map(|x| { | __________^ @@ -27,7 +27,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten.rs:20:10 + --> tests/ui/map_flatten.rs:20:10 | LL | .map(|x| { | __________^ @@ -52,7 +52,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten.rs:33:10 + --> tests/ui/map_flatten.rs:33:10 | LL | .map(|res| { | __________^ @@ -78,7 +78,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten.rs:46:10 + --> tests/ui/map_flatten.rs:46:10 | LL | .map(|some_value| { | __________^ diff --git a/tests/ui/map_flatten_fixable.stderr b/tests/ui/map_flatten_fixable.stderr index e5387eead2e0c..128c95146aa2c 100644 --- a/tests/ui/map_flatten_fixable.stderr +++ b/tests/ui/map_flatten_fixable.stderr @@ -1,5 +1,5 @@ error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:16:47 + --> tests/ui/map_flatten_fixable.rs:16:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)` @@ -8,43 +8,43 @@ LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().coll = help: to override `-D warnings` add `#[allow(clippy::map_flatten)]` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:17:47 + --> tests/ui/map_flatten_fixable.rs:17:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:18:47 + --> tests/ui/map_flatten_fixable.rs:18:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:19:47 + --> tests/ui/map_flatten_fixable.rs:19:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:22:47 + --> tests/ui/map_flatten_fixable.rs:22:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)` error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten_fixable.rs:25:40 + --> tests/ui/map_flatten_fixable.rs:25:40 | LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten_fixable.rs:28:42 + --> tests/ui/map_flatten_fixable.rs:28:42 | LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:37:10 + --> tests/ui/map_flatten_fixable.rs:37:10 | LL | .map(|n| match n { | __________^ @@ -73,7 +73,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten_fixable.rs:57:10 + --> tests/ui/map_flatten_fixable.rs:57:10 | LL | .map(|_| { | __________^ diff --git a/tests/ui/map_identity.stderr b/tests/ui/map_identity.stderr index ea077d66d6401..0a0dc9c8f075b 100644 --- a/tests/ui/map_identity.stderr +++ b/tests/ui/map_identity.stderr @@ -1,5 +1,5 @@ error: unnecessary map of the identity function - --> $DIR/map_identity.rs:7:47 + --> tests/ui/map_identity.rs:7:47 | LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect(); | ^^^^^^^^^^^^^^^^^^ help: remove the call to `map` @@ -8,25 +8,25 @@ LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect(); = help: to override `-D warnings` add `#[allow(clippy::map_identity)]` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:8:57 + --> tests/ui/map_identity.rs:8:57 | LL | let _: Vec<_> = x.iter().map(std::convert::identity).map(|y| y).collect(); | ^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:8:29 + --> tests/ui/map_identity.rs:8:29 | LL | let _: Vec<_> = x.iter().map(std::convert::identity).map(|y| y).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:9:32 + --> tests/ui/map_identity.rs:9:32 | LL | let _: Option = Some(3).map(|x| x); | ^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:10:36 + --> tests/ui/map_identity.rs:10:36 | LL | let _: Result = Ok(-3).map(|x| { | ____________________________________^ @@ -35,19 +35,19 @@ LL | | }); | |______^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:20:36 + --> tests/ui/map_identity.rs:20:36 | LL | let _: Result = Ok(1).map_err(|a| a); | ^^^^^^^^^^^^^^^ help: remove the call to `map_err` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:30:22 + --> tests/ui/map_identity.rs:30:22 | LL | let _ = x.clone().map(|(x, y)| (x, y)); | ^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:31:22 + --> tests/ui/map_identity.rs:31:22 | LL | let _ = x.clone().map(|(x, y)| { | ______________________^ @@ -56,19 +56,19 @@ LL | | }); | |______^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:34:22 + --> tests/ui/map_identity.rs:34:22 | LL | let _ = x.clone().map(|(x, y)| return (x, y)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:37:22 + --> tests/ui/map_identity.rs:37:22 | LL | let _ = y.clone().map(|(x, y, (z, (w,)))| (x, y, (z, (w,)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:66:30 + --> tests/ui/map_identity.rs:66:30 | LL | let _ = x.iter().copied().map(|(x, y)| (x, y)); | ^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` diff --git a/tests/ui/map_unwrap_or.stderr b/tests/ui/map_unwrap_or.stderr index 54ddd1402e3df..d6ddd09c188c6 100644 --- a/tests/ui/map_unwrap_or.stderr +++ b/tests/ui/map_unwrap_or.stderr @@ -1,5 +1,5 @@ error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:17:13 + --> tests/ui/map_unwrap_or.rs:17:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -16,7 +16,7 @@ LL + let _ = opt.map_or(0, |x| x + 1); | error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:21:13 + --> tests/ui/map_unwrap_or.rs:21:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -34,7 +34,7 @@ LL ~ ); | error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:25:13 + --> tests/ui/map_unwrap_or.rs:25:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -51,7 +51,7 @@ LL ~ }, |x| x + 1); | error: called `map().unwrap_or(None)` on an `Option` value - --> $DIR/map_unwrap_or.rs:30:13 + --> tests/ui/map_unwrap_or.rs:30:13 | LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL + let _ = opt.and_then(|x| Some(x + 1)); | error: called `map().unwrap_or(None)` on an `Option` value - --> $DIR/map_unwrap_or.rs:32:13 + --> tests/ui/map_unwrap_or.rs:32:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -81,7 +81,7 @@ LL ~ ); | error: called `map().unwrap_or(None)` on an `Option` value - --> $DIR/map_unwrap_or.rs:36:13 + --> tests/ui/map_unwrap_or.rs:36:13 | LL | let _ = opt | _____________^ @@ -96,7 +96,7 @@ LL + .and_then(|x| Some(x + 1)); | error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:47:13 + --> tests/ui/map_unwrap_or.rs:47:13 | LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p)); | error: called `map().unwrap_or_else()` on an `Option` value - --> $DIR/map_unwrap_or.rs:51:13 + --> tests/ui/map_unwrap_or.rs:51:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -118,7 +118,7 @@ LL | | ).unwrap_or_else(|| 0); | |__________________________^ error: called `map().unwrap_or_else()` on an `Option` value - --> $DIR/map_unwrap_or.rs:55:13 + --> tests/ui/map_unwrap_or.rs:55:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -128,7 +128,7 @@ LL | | ); | |_________^ error: called `map().unwrap_or(false)` on an `Option` value - --> $DIR/map_unwrap_or.rs:61:13 + --> tests/ui/map_unwrap_or.rs:61:13 | LL | let _ = opt.map(|x| x > 5).unwrap_or(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -140,7 +140,7 @@ LL + let _ = opt.is_some_and(|x| x > 5); | error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or.rs:71:13 + --> tests/ui/map_unwrap_or.rs:71:13 | LL | let _ = res.map(|x| { | _____________^ @@ -150,7 +150,7 @@ LL | | ).unwrap_or_else(|_e| 0); | |____________________________^ error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or.rs:75:13 + --> tests/ui/map_unwrap_or.rs:75:13 | LL | let _ = res.map(|x| x + 1) | _____________^ @@ -160,13 +160,13 @@ LL | | }); | |__________^ error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or.rs:99:13 + --> tests/ui/map_unwrap_or.rs:99:13 | LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or_else(|_e| 0, |x| x + 1)` error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:106:13 + --> tests/ui/map_unwrap_or.rs:106:13 | LL | let _ = opt.map(|x| x > 5).unwrap_or(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +178,7 @@ LL + let _ = opt.map_or(false, |x| x > 5); | error: called `map().unwrap_or(false)` on an `Option` value - --> $DIR/map_unwrap_or.rs:113:13 + --> tests/ui/map_unwrap_or.rs:113:13 | LL | let _ = opt.map(|x| x > 5).unwrap_or(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/map_unwrap_or_fixable.stderr b/tests/ui/map_unwrap_or_fixable.stderr index d1a9fdd6ecffd..89a7c979f6e92 100644 --- a/tests/ui/map_unwrap_or_fixable.stderr +++ b/tests/ui/map_unwrap_or_fixable.stderr @@ -1,5 +1,5 @@ error: called `map().unwrap_or_else()` on an `Option` value - --> $DIR/map_unwrap_or_fixable.rs:16:13 + --> tests/ui/map_unwrap_or_fixable.rs:16:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -11,7 +11,7 @@ LL | | .unwrap_or_else(|| 0); = help: to override `-D warnings` add `#[allow(clippy::map_unwrap_or)]` error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or_fixable.rs:46:13 + --> tests/ui/map_unwrap_or_fixable.rs:46:13 | LL | let _ = res.map(|x| x + 1) | _____________^ diff --git a/tests/ui/match_as_ref.stderr b/tests/ui/match_as_ref.stderr index cb0191370eaa0..97b121424d932 100644 --- a/tests/ui/match_as_ref.stderr +++ b/tests/ui/match_as_ref.stderr @@ -1,5 +1,5 @@ error: use `as_ref()` instead - --> $DIR/match_as_ref.rs:6:33 + --> tests/ui/match_as_ref.rs:6:33 | LL | let borrowed: Option<&()> = match owned { | _________________________________^ @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::match_as_ref)]` error: use `as_mut()` instead - --> $DIR/match_as_ref.rs:12:39 + --> tests/ui/match_as_ref.rs:12:39 | LL | let borrow_mut: Option<&mut ()> = match mut_owned { | _______________________________________^ @@ -22,7 +22,7 @@ LL | | }; | |_____^ help: try: `mut_owned.as_mut()` error: use `as_ref()` instead - --> $DIR/match_as_ref.rs:30:13 + --> tests/ui/match_as_ref.rs:30:13 | LL | / match self.source { LL | | Some(ref s) => Some(s), diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index 369f4e1c6fab3..1303e082daf2f 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/match_bool.rs:36:11 + --> tests/ui/match_bool.rs:36:11 | LL | match test && test { | ^^^^^^^^^^^^ help: try: `test` @@ -8,7 +8,7 @@ LL | match test && test { = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:7:5 + --> tests/ui/match_bool.rs:7:5 | LL | / match test { LL | | @@ -18,13 +18,13 @@ LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if test { 0 } else { 42 }` | note: the lint level is defined here - --> $DIR/match_bool.rs:2:9 + --> tests/ui/match_bool.rs:2:9 | LL | #![deny(clippy::match_bool)] | ^^^^^^^^^^^^^^^^^^ error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:14:5 + --> tests/ui/match_bool.rs:14:5 | LL | / match option == 1 { LL | | @@ -34,7 +34,7 @@ LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if option == 1 { 1 } else { 0 }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:20:5 + --> tests/ui/match_bool.rs:20:5 | LL | / match test { LL | | @@ -53,7 +53,7 @@ LL ~ }; | error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:28:5 + --> tests/ui/match_bool.rs:28:5 | LL | / match test { LL | | @@ -72,7 +72,7 @@ LL ~ }; | error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:36:5 + --> tests/ui/match_bool.rs:36:5 | LL | / match test && test { LL | | @@ -91,7 +91,7 @@ LL ~ }; | error: equal expressions as operands to `&&` - --> $DIR/match_bool.rs:36:11 + --> tests/ui/match_bool.rs:36:11 | LL | match test && test { | ^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | match test && test { = note: `#[deny(clippy::eq_op)]` on by default error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:48:5 + --> tests/ui/match_bool.rs:48:5 | LL | / match test { LL | | diff --git a/tests/ui/match_expr_like_matches_macro.stderr b/tests/ui/match_expr_like_matches_macro.stderr index c702523783e73..201b977e558eb 100644 --- a/tests/ui/match_expr_like_matches_macro.stderr +++ b/tests/ui/match_expr_like_matches_macro.stderr @@ -1,5 +1,5 @@ error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:14:14 + --> tests/ui/match_expr_like_matches_macro.rs:14:14 | LL | let _y = match x { | ______________^ @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` error: redundant pattern matching, consider using `is_some()` - --> $DIR/match_expr_like_matches_macro.rs:20:14 + --> tests/ui/match_expr_like_matches_macro.rs:20:14 | LL | let _w = match x { | ______________^ @@ -25,7 +25,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` - --> $DIR/match_expr_like_matches_macro.rs:26:14 + --> tests/ui/match_expr_like_matches_macro.rs:26:14 | LL | let _z = match x { | ______________^ @@ -35,7 +35,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:32:15 + --> tests/ui/match_expr_like_matches_macro.rs:32:15 | LL | let _zz = match x { | _______________^ @@ -45,13 +45,13 @@ LL | | }; | |_____^ help: try: `!matches!(x, Some(r) if r == 0)` error: if let .. else expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:38:16 + --> tests/ui/match_expr_like_matches_macro.rs:38:16 | LL | let _zzz = if let Some(5) = x { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(x, Some(5))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:62:20 + --> tests/ui/match_expr_like_matches_macro.rs:62:20 | LL | let _ans = match x { | ____________________^ @@ -62,7 +62,7 @@ LL | | }; | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:72:20 + --> tests/ui/match_expr_like_matches_macro.rs:72:20 | LL | let _ans = match x { | ____________________^ @@ -75,7 +75,7 @@ LL | | }; | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:82:20 + --> tests/ui/match_expr_like_matches_macro.rs:82:20 | LL | let _ans = match x { | ____________________^ @@ -86,7 +86,7 @@ LL | | }; | |_________^ help: try: `!matches!(x, E::B(_) | E::C)` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:142:18 + --> tests/ui/match_expr_like_matches_macro.rs:142:18 | LL | let _z = match &z { | __________________^ @@ -96,7 +96,7 @@ LL | | }; | |_________^ help: try: `matches!(z, Some(3))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:151:18 + --> tests/ui/match_expr_like_matches_macro.rs:151:18 | LL | let _z = match &z { | __________________^ @@ -106,7 +106,7 @@ LL | | }; | |_________^ help: try: `matches!(&z, Some(3))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:168:21 + --> tests/ui/match_expr_like_matches_macro.rs:168:21 | LL | let _ = match &z { | _____________________^ @@ -116,7 +116,7 @@ LL | | }; | |_____________^ help: try: `matches!(&z, AnEnum::X)` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:182:20 + --> tests/ui/match_expr_like_matches_macro.rs:182:20 | LL | let _res = match &val { | ____________________^ @@ -126,7 +126,7 @@ LL | | }; | |_________^ help: try: `matches!(&val, &Some(ref _a))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:194:20 + --> tests/ui/match_expr_like_matches_macro.rs:194:20 | LL | let _res = match &val { | ____________________^ @@ -136,7 +136,7 @@ LL | | }; | |_________^ help: try: `matches!(&val, &Some(ref _a))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:252:14 + --> tests/ui/match_expr_like_matches_macro.rs:252:14 | LL | let _y = match Some(5) { | ______________^ diff --git a/tests/ui/match_on_vec_items.stderr b/tests/ui/match_on_vec_items.stderr index 140a458cb9a4c..e31db37841379 100644 --- a/tests/ui/match_on_vec_items.stderr +++ b/tests/ui/match_on_vec_items.stderr @@ -1,5 +1,5 @@ error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:10:11 + --> tests/ui/match_on_vec_items.rs:10:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` @@ -8,43 +8,43 @@ LL | match arr[idx] { = help: to override `-D warnings` add `#[allow(clippy::match_on_vec_items)]` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:19:11 + --> tests/ui/match_on_vec_items.rs:19:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:33:11 + --> tests/ui/match_on_vec_items.rs:33:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:41:11 + --> tests/ui/match_on_vec_items.rs:41:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:55:11 + --> tests/ui/match_on_vec_items.rs:55:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:63:11 + --> tests/ui/match_on_vec_items.rs:63:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:77:11 + --> tests/ui/match_on_vec_items.rs:77:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:85:11 + --> tests/ui/match_on_vec_items.rs:85:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index 322c704f2aa28..1a6c5746c3dd2 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -1,11 +1,11 @@ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:12:9 + --> tests/ui/match_overlapping_arm.rs:12:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:14:9 + --> tests/ui/match_overlapping_arm.rs:14:9 | LL | 0..=11 => println!("0..=11"), | ^^^^^^ @@ -13,85 +13,85 @@ LL | 0..=11 => println!("0..=11"), = help: to override `-D warnings` add `#[allow(clippy::match_overlapping_arm)]` error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:19:9 + --> tests/ui/match_overlapping_arm.rs:19:9 | LL | 0..=5 => println!("0..=5"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:22:9 + --> tests/ui/match_overlapping_arm.rs:22:9 | LL | FOO..=11 => println!("FOO..=11"), | ^^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:57:9 + --> tests/ui/match_overlapping_arm.rs:57:9 | LL | 0..11 => println!("0..11"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:59:9 + --> tests/ui/match_overlapping_arm.rs:59:9 | LL | 0..=11 => println!("0..=11"), | ^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:83:9 + --> tests/ui/match_overlapping_arm.rs:83:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:82:9 + --> tests/ui/match_overlapping_arm.rs:82:9 | LL | 5..14 => println!("5..14"), | ^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:89:9 + --> tests/ui/match_overlapping_arm.rs:89:9 | LL | 0..7 => println!("0..7"), | ^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:91:9 + --> tests/ui/match_overlapping_arm.rs:91:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:102:9 + --> tests/ui/match_overlapping_arm.rs:102:9 | LL | ..=23 => println!("..=23"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:104:9 + --> tests/ui/match_overlapping_arm.rs:104:9 | LL | ..26 => println!("..26"), | ^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:112:9 + --> tests/ui/match_overlapping_arm.rs:112:9 | LL | 21..=30 => (), | ^^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:114:9 + --> tests/ui/match_overlapping_arm.rs:114:9 | LL | 21..=40 => (), | ^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:127:9 + --> tests/ui/match_overlapping_arm.rs:127:9 | LL | 0..=0x0000_0000_0000_00ff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:129:9 + --> tests/ui/match_overlapping_arm.rs:129:9 | LL | 0..=0x0000_0000_0000_ffff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_ref_pats.stderr b/tests/ui/match_ref_pats.stderr index e3bb2824aa070..fc01ab0a919a1 100644 --- a/tests/ui/match_ref_pats.stderr +++ b/tests/ui/match_ref_pats.stderr @@ -1,5 +1,5 @@ error: you don't need to add `&` to all patterns - --> $DIR/match_ref_pats.rs:8:9 + --> tests/ui/match_ref_pats.rs:8:9 | LL | / match v { LL | | &Some(v) => println!("{:?}", v), @@ -17,7 +17,7 @@ LL ~ None => println!("none"), | error: you don't need to add `&` to both the expression and the patterns - --> $DIR/match_ref_pats.rs:25:5 + --> tests/ui/match_ref_pats.rs:25:5 | LL | / match &w { LL | | &Some(v) => println!("{:?}", v), @@ -33,7 +33,7 @@ LL ~ None => println!("none"), | error: redundant pattern matching, consider using `is_none()` - --> $DIR/match_ref_pats.rs:37:12 + --> tests/ui/match_ref_pats.rs:37:12 | LL | if let &None = a { | -------^^^^^---- help: try: `if a.is_none()` @@ -42,13 +42,13 @@ LL | if let &None = a { = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` - --> $DIR/match_ref_pats.rs:42:12 + --> tests/ui/match_ref_pats.rs:42:12 | LL | if let &None = &b { | -------^^^^^----- help: try: `if b.is_none()` error: you don't need to add `&` to all patterns - --> $DIR/match_ref_pats.rs:102:9 + --> tests/ui/match_ref_pats.rs:102:9 | LL | / match foobar_variant!(0) { LL | | &FooBar::Foo => println!("Foo"), diff --git a/tests/ui/match_result_ok.stderr b/tests/ui/match_result_ok.stderr index de0361bd6b41e..0d42d59dc0136 100644 --- a/tests/ui/match_result_ok.stderr +++ b/tests/ui/match_result_ok.stderr @@ -1,5 +1,5 @@ error: matching on `Some` with `ok()` is redundant - --> $DIR/match_result_ok.rs:8:5 + --> tests/ui/match_result_ok.rs:8:5 | LL | if let Some(y) = x.parse().ok() { y } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let Ok(y) = x.parse() { y } else { 0 } | ~~~~~~~~~~~~~~~~~~~~~~~~ error: matching on `Some` with `ok()` is redundant - --> $DIR/match_result_ok.rs:18:9 + --> tests/ui/match_result_ok.rs:18:9 | LL | if let Some(y) = x . parse() . ok () { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if let Ok(y) = x . parse() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: matching on `Some` with `ok()` is redundant - --> $DIR/match_result_ok.rs:44:5 + --> tests/ui/match_result_ok.rs:44:5 | LL | while let Some(a) = wat.next().ok() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms.stderr b/tests/ui/match_same_arms.stderr index 824dcfdce8374..a926570b60ada 100644 --- a/tests/ui/match_same_arms.stderr +++ b/tests/ui/match_same_arms.stderr @@ -1,12 +1,12 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms.rs:12:9 + --> tests/ui/match_same_arms.rs:12:9 | LL | Abc::A => 0, | ^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms.rs:14:9 + --> tests/ui/match_same_arms.rs:14:9 | LL | _ => 0, | ^^^^^^ @@ -14,7 +14,7 @@ LL | _ => 0, = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:18:9 + --> tests/ui/match_same_arms.rs:18:9 | LL | (1, .., 3) => 42, | ----------^^^^^^ @@ -23,13 +23,13 @@ LL | (1, .., 3) => 42, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:19:9 + --> tests/ui/match_same_arms.rs:19:9 | LL | (.., 3) => 42, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:25:9 + --> tests/ui/match_same_arms.rs:25:9 | LL | 51 => 1, | --^^^^^ @@ -38,13 +38,13 @@ LL | 51 => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:24:9 + --> tests/ui/match_same_arms.rs:24:9 | LL | 42 => 1, | ^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:26:9 + --> tests/ui/match_same_arms.rs:26:9 | LL | 41 => 2, | --^^^^^ @@ -53,13 +53,13 @@ LL | 41 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:27:9 + --> tests/ui/match_same_arms.rs:27:9 | LL | 52 => 2, | ^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> tests/ui/match_same_arms.rs:33:9 | LL | 2 => 2, | -^^^^^ @@ -68,13 +68,13 @@ LL | 2 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:32:9 + --> tests/ui/match_same_arms.rs:32:9 | LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:35:9 + --> tests/ui/match_same_arms.rs:35:9 | LL | 3 => 2, | -^^^^^ @@ -83,13 +83,13 @@ LL | 3 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:32:9 + --> tests/ui/match_same_arms.rs:32:9 | LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> tests/ui/match_same_arms.rs:33:9 | LL | 2 => 2, | -^^^^^ @@ -98,13 +98,13 @@ LL | 2 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:35:9 + --> tests/ui/match_same_arms.rs:35:9 | LL | 3 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:52:17 + --> tests/ui/match_same_arms.rs:52:17 | LL | CommandInfo::External { name, .. } => name.to_string(), | ----------------------------------^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | CommandInfo::External { name, .. } => name.to_string(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:51:17 + --> tests/ui/match_same_arms.rs:51:17 | LL | CommandInfo::BuiltIn { name, .. } => name.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms2.stderr b/tests/ui/match_same_arms2.stderr index 512ca7413a795..6abbb582763d4 100644 --- a/tests/ui/match_same_arms2.stderr +++ b/tests/ui/match_same_arms2.stderr @@ -1,5 +1,5 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms2.rs:15:9 + --> tests/ui/match_same_arms2.rs:15:9 | LL | / 42 => { LL | | foo(); @@ -12,7 +12,7 @@ LL | | }, | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms2.rs:24:9 + --> tests/ui/match_same_arms2.rs:24:9 | LL | / _ => { LL | | foo(); @@ -26,7 +26,7 @@ LL | | }, = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:38:9 + --> tests/ui/match_same_arms2.rs:38:9 | LL | 51 => foo(), | --^^^^^^^^^ @@ -35,13 +35,13 @@ LL | 51 => foo(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:37:9 + --> tests/ui/match_same_arms2.rs:37:9 | LL | 42 => foo(), | ^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:44:9 + --> tests/ui/match_same_arms2.rs:44:9 | LL | None => 24, | ----^^^^^^ @@ -50,13 +50,13 @@ LL | None => 24, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:43:9 + --> tests/ui/match_same_arms2.rs:43:9 | LL | Some(_) => 24, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:66:9 + --> tests/ui/match_same_arms2.rs:66:9 | LL | (None, Some(a)) => bar(a), | ---------------^^^^^^^^^^ @@ -65,13 +65,13 @@ LL | (None, Some(a)) => bar(a), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:65:9 + --> tests/ui/match_same_arms2.rs:65:9 | LL | (Some(a), None) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:71:9 + --> tests/ui/match_same_arms2.rs:71:9 | LL | (Some(a), ..) => bar(a), | -------------^^^^^^^^^^ @@ -80,13 +80,13 @@ LL | (Some(a), ..) => bar(a), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:72:9 + --> tests/ui/match_same_arms2.rs:72:9 | LL | (.., Some(a)) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:105:9 + --> tests/ui/match_same_arms2.rs:105:9 | LL | (Ok(x), Some(_)) => println!("ok {}", x), | ----------------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,13 +95,13 @@ LL | (Ok(x), Some(_)) => println!("ok {}", x), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:106:9 + --> tests/ui/match_same_arms2.rs:106:9 | LL | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:121:9 + --> tests/ui/match_same_arms2.rs:121:9 | LL | Ok(_) => println!("ok"), | -----^^^^^^^^^^^^^^^^^^ @@ -110,13 +110,13 @@ LL | Ok(_) => println!("ok"), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:120:9 + --> tests/ui/match_same_arms2.rs:120:9 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:148:9 + --> tests/ui/match_same_arms2.rs:148:9 | LL | 1 => { | ^ help: try merging the arm patterns: `1 | 0` @@ -128,7 +128,7 @@ LL | | }, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:145:9 + --> tests/ui/match_same_arms2.rs:145:9 | LL | / 0 => { LL | | empty!(0); @@ -136,7 +136,7 @@ LL | | }, | |_________^ error: match expression looks like `matches!` macro - --> $DIR/match_same_arms2.rs:167:16 + --> tests/ui/match_same_arms2.rs:167:16 | LL | let _ans = match x { | ________________^ @@ -150,7 +150,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:199:9 + --> tests/ui/match_same_arms2.rs:199:9 | LL | Foo::X(0) => 1, | ---------^^^^^ @@ -159,13 +159,13 @@ LL | Foo::X(0) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:201:9 + --> tests/ui/match_same_arms2.rs:201:9 | LL | Foo::Z(_) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:209:9 + --> tests/ui/match_same_arms2.rs:209:9 | LL | Foo::Z(_) => 1, | ---------^^^^^ @@ -174,13 +174,13 @@ LL | Foo::Z(_) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:207:9 + --> tests/ui/match_same_arms2.rs:207:9 | LL | Foo::X(0) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:232:9 + --> tests/ui/match_same_arms2.rs:232:9 | LL | Some(Bar { y: 0, x: 5, .. }) => 1, | ----------------------------^^^^^ @@ -189,13 +189,13 @@ LL | Some(Bar { y: 0, x: 5, .. }) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:229:9 + --> tests/ui/match_same_arms2.rs:229:9 | LL | Some(Bar { x: 0, y: 5, .. }) => 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:246:9 + --> tests/ui/match_same_arms2.rs:246:9 | LL | 1 => cfg!(not_enable), | -^^^^^^^^^^^^^^^^^^^^ @@ -204,7 +204,7 @@ LL | 1 => cfg!(not_enable), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:245:9 + --> tests/ui/match_same_arms2.rs:245:9 | LL | 0 => cfg!(not_enable), | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms_non_exhaustive.stderr b/tests/ui/match_same_arms_non_exhaustive.stderr index ae6b02ab1b507..cf2a75354e15c 100644 --- a/tests/ui/match_same_arms_non_exhaustive.stderr +++ b/tests/ui/match_same_arms_non_exhaustive.stderr @@ -1,12 +1,12 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms_non_exhaustive.rs:45:9 + --> tests/ui/match_same_arms_non_exhaustive.rs:45:9 | LL | Ordering::AcqRel | Ordering::SeqCst => repeat(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms_non_exhaustive.rs:47:9 + --> tests/ui/match_same_arms_non_exhaustive.rs:47:9 | LL | _ => repeat(), | ^^^^^^^^^^^^^ @@ -14,14 +14,14 @@ LL | _ => repeat(), = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms_non_exhaustive.rs:59:13 + --> tests/ui/match_same_arms_non_exhaustive.rs:59:13 | LL | Ordering::AcqRel | Ordering::SeqCst => repeat(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms_non_exhaustive.rs:61:13 + --> tests/ui/match_same_arms_non_exhaustive.rs:61:13 | LL | _ => repeat(), | ^^^^^^^^^^^^^ diff --git a/tests/ui/match_single_binding.stderr b/tests/ui/match_single_binding.stderr index 81ec200dfc7a0..19ab85180ad28 100644 --- a/tests/ui/match_single_binding.stderr +++ b/tests/ui/match_single_binding.stderr @@ -1,5 +1,5 @@ error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:33:5 + --> tests/ui/match_single_binding.rs:33:5 | LL | / match (a, b, c) { LL | | (x, y, z) => { @@ -19,7 +19,7 @@ LL + } | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:39:5 + --> tests/ui/match_single_binding.rs:39:5 | LL | / match (a, b, c) { LL | | (x, y, z) => println!("{} {} {}", x, y, z), @@ -33,7 +33,7 @@ LL + println!("{} {} {}", x, y, z); | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:56:5 + --> tests/ui/match_single_binding.rs:56:5 | LL | / match a { LL | | _ => println!("whatever"), @@ -41,7 +41,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("whatever");` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:60:5 + --> tests/ui/match_single_binding.rs:60:5 | LL | / match a { LL | | _ => { @@ -60,7 +60,7 @@ LL + } | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:67:5 + --> tests/ui/match_single_binding.rs:67:5 | LL | / match a { LL | | _ => { @@ -82,7 +82,7 @@ LL + } | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:77:5 + --> tests/ui/match_single_binding.rs:77:5 | LL | / match p { LL | | Point { x, y } => println!("Coords: ({}, {})", x, y), @@ -96,7 +96,7 @@ LL + println!("Coords: ({}, {})", x, y); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:81:5 + --> tests/ui/match_single_binding.rs:81:5 | LL | / match p { LL | | Point { x: x1, y: y1 } => println!("Coords: ({}, {})", x1, y1), @@ -110,7 +110,7 @@ LL + println!("Coords: ({}, {})", x1, y1); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:86:5 + --> tests/ui/match_single_binding.rs:86:5 | LL | / match x { LL | | ref r => println!("Got a reference to {}", r), @@ -124,7 +124,7 @@ LL + println!("Got a reference to {}", r); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:91:5 + --> tests/ui/match_single_binding.rs:91:5 | LL | / match x { LL | | ref mut mr => println!("Got a mutable reference to {}", mr), @@ -138,7 +138,7 @@ LL + println!("Got a mutable reference to {}", mr); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:95:5 + --> tests/ui/match_single_binding.rs:95:5 | LL | / let product = match coords() { LL | | Point { x, y } => x * y, @@ -152,7 +152,7 @@ LL + let product = x * y; | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:103:18 + --> tests/ui/match_single_binding.rs:103:18 | LL | .map(|i| match i.unwrap() { | __________________^ @@ -169,7 +169,7 @@ LL ~ }) | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:129:5 + --> tests/ui/match_single_binding.rs:129:5 | LL | / match x { LL | | // => @@ -178,7 +178,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("Not an array index start")` error: this assignment could be simplified - --> $DIR/match_single_binding.rs:138:5 + --> tests/ui/match_single_binding.rs:138:5 | LL | / val = match val.split_at(idx) { LL | | (pre, suf) => { @@ -198,7 +198,7 @@ LL ~ }; | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding.rs:151:16 + --> tests/ui/match_single_binding.rs:151:16 | LL | let _ = || match side_effects() { | ________________^ @@ -215,7 +215,7 @@ LL ~ }; | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:157:5 + --> tests/ui/match_single_binding.rs:157:5 | LL | / match r { LL | | x => match x { @@ -240,7 +240,7 @@ LL ~ }; | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:170:5 + --> tests/ui/match_single_binding.rs:170:5 | LL | / match 1 { LL | | _ => (), @@ -248,7 +248,7 @@ LL | | } | |_____^ help: consider using the match body instead: `();` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:174:13 + --> tests/ui/match_single_binding.rs:174:13 | LL | let a = match 1 { | _____________^ @@ -257,7 +257,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:178:5 + --> tests/ui/match_single_binding.rs:178:5 | LL | / match 1 { LL | | _ => side_effects(), @@ -265,7 +265,7 @@ LL | | } | |_____^ help: consider using the match body instead: `side_effects();` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:182:13 + --> tests/ui/match_single_binding.rs:182:13 | LL | let b = match 1 { | _____________^ @@ -274,7 +274,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `side_effects()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:186:5 + --> tests/ui/match_single_binding.rs:186:5 | LL | / match 1 { LL | | _ => println!("1"), @@ -282,7 +282,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("1");` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:190:13 + --> tests/ui/match_single_binding.rs:190:13 | LL | let c = match 1 { | _____________^ @@ -291,7 +291,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `println!("1")` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:195:9 + --> tests/ui/match_single_binding.rs:195:9 | LL | / match 1 { LL | | _ => (), @@ -299,7 +299,7 @@ LL | | }, | |_________^ help: consider using the match body instead: `()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:198:9 + --> tests/ui/match_single_binding.rs:198:9 | LL | / match 1 { LL | | _ => side_effects(), @@ -307,7 +307,7 @@ LL | | }, | |_________^ help: consider using the match body instead: `side_effects()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:201:9 + --> tests/ui/match_single_binding.rs:201:9 | LL | / match 1 { LL | | _ => println!("1"), diff --git a/tests/ui/match_single_binding2.stderr b/tests/ui/match_single_binding2.stderr index e7b9ef8a1cda9..38659596af1ff 100644 --- a/tests/ui/match_single_binding2.stderr +++ b/tests/ui/match_single_binding2.stderr @@ -1,5 +1,5 @@ error: this match could be written as a `let` statement - --> $DIR/match_single_binding2.rs:17:36 + --> tests/ui/match_single_binding2.rs:17:36 | LL | Some((iter, _item)) => match iter.size_hint() { | ____________________________________^ @@ -18,7 +18,7 @@ LL ~ }, | error: this match could be written as a `let` statement - --> $DIR/match_single_binding2.rs:30:13 + --> tests/ui/match_single_binding2.rs:30:13 | LL | / match get_tup() { LL | | (a, b) => println!("a {:?} and b {:?}", a, b), @@ -32,7 +32,7 @@ LL + println!("a {:?} and b {:?}", a, b) | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding2.rs:41:5 + --> tests/ui/match_single_binding2.rs:41:5 | LL | / match side_effects() { LL | | _ => println!("Side effects"), @@ -46,7 +46,7 @@ LL + println!("Side effects"); | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding2.rs:48:5 + --> tests/ui/match_single_binding2.rs:48:5 | LL | / match match x { LL | | 0 => 1, diff --git a/tests/ui/match_str_case_mismatch.stderr b/tests/ui/match_str_case_mismatch.stderr index f799a4698b943..d0c81ccde7652 100644 --- a/tests/ui/match_str_case_mismatch.stderr +++ b/tests/ui/match_str_case_mismatch.stderr @@ -1,5 +1,5 @@ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:112:9 + --> tests/ui/match_str_case_mismatch.rs:112:9 | LL | "Bar" => {}, | ^^^^^ @@ -12,7 +12,7 @@ LL | "bar" => {}, | ~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:122:9 + --> tests/ui/match_str_case_mismatch.rs:122:9 | LL | "~!@#$%^&*()-_=+Foo" => {}, | ^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | "~!@#$%^&*()-_=+foo" => {}, | ~~~~~~~~~~~~~~~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:134:9 + --> tests/ui/match_str_case_mismatch.rs:134:9 | LL | "Воды" => {}, | ^^^^^^ @@ -34,7 +34,7 @@ LL | "воды" => {}, | ~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:145:9 + --> tests/ui/match_str_case_mismatch.rs:145:9 | LL | "barDz" => {}, | ^^^^^^ @@ -45,7 +45,7 @@ LL | "bardz" => {}, | ~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:155:9 + --> tests/ui/match_str_case_mismatch.rs:155:9 | LL | "bARʁ" => {}, | ^^^^^^ @@ -56,7 +56,7 @@ LL | "BARʁ" => {}, | ~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:165:9 + --> tests/ui/match_str_case_mismatch.rs:165:9 | LL | "Bar" => {}, | ^^^^^ @@ -67,7 +67,7 @@ LL | "bar" => {}, | ~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:180:9 + --> tests/ui/match_str_case_mismatch.rs:180:9 | LL | "bAR" => {}, | ^^^^^ diff --git a/tests/ui/match_wild_err_arm.stderr b/tests/ui/match_wild_err_arm.stderr index c120aec5b23b3..3145665a341e8 100644 --- a/tests/ui/match_wild_err_arm.stderr +++ b/tests/ui/match_wild_err_arm.stderr @@ -1,5 +1,5 @@ error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:24:9 + --> tests/ui/match_wild_err_arm.rs:24:9 | LL | Err(_) => panic!("err"), | ^^^^^^ @@ -9,7 +9,7 @@ LL | Err(_) => panic!("err"), = help: to override `-D warnings` add `#[allow(clippy::match_wild_err_arm)]` error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:32:9 + --> tests/ui/match_wild_err_arm.rs:32:9 | LL | Err(_) => panic!(), | ^^^^^^ @@ -17,7 +17,7 @@ LL | Err(_) => panic!(), = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:40:9 + --> tests/ui/match_wild_err_arm.rs:40:9 | LL | Err(_) => { | ^^^^^^ @@ -25,7 +25,7 @@ LL | Err(_) => { = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable error: `Err(_e)` matches all errors - --> $DIR/match_wild_err_arm.rs:50:9 + --> tests/ui/match_wild_err_arm.rs:50:9 | LL | Err(_e) => panic!(), | ^^^^^^^ diff --git a/tests/ui/match_wildcard_for_single_variants.stderr b/tests/ui/match_wildcard_for_single_variants.stderr index e07d3bdd32e6b..5cc50c823b2ca 100644 --- a/tests/ui/match_wildcard_for_single_variants.stderr +++ b/tests/ui/match_wildcard_for_single_variants.stderr @@ -1,5 +1,5 @@ error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:22:13 + --> tests/ui/match_wildcard_for_single_variants.rs:22:13 | LL | _ => (), | ^ help: try: `Self::Rgb(..)` @@ -8,55 +8,55 @@ LL | _ => (), = help: to override `-D warnings` add `#[allow(clippy::match_wildcard_for_single_variants)]` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:32:9 + --> tests/ui/match_wildcard_for_single_variants.rs:32:9 | LL | _ => {}, | ^ help: try: `Foo::C` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:42:9 + --> tests/ui/match_wildcard_for_single_variants.rs:42:9 | LL | _ => {}, | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:50:9 + --> tests/ui/match_wildcard_for_single_variants.rs:50:9 | LL | _ => {}, | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:56:9 + --> tests/ui/match_wildcard_for_single_variants.rs:56:9 | LL | _ => {}, | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:73:9 + --> tests/ui/match_wildcard_for_single_variants.rs:73:9 | LL | &_ => (), | ^^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:82:9 + --> tests/ui/match_wildcard_for_single_variants.rs:82:9 | LL | _ => (), | ^ help: try: `C::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:89:9 + --> tests/ui/match_wildcard_for_single_variants.rs:89:9 | LL | _ => (), | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:124:13 + --> tests/ui/match_wildcard_for_single_variants.rs:124:13 | LL | _ => (), | ^ help: try: `Enum::__Private` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:151:13 + --> tests/ui/match_wildcard_for_single_variants.rs:151:13 | LL | _ => 2, | ^ help: try: `Foo::B` diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index a5ab150317a1b..3b0e839e0871a 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -1,5 +1,5 @@ error: usage of `mem::forget` on `Drop` type - --> $DIR/mem_forget.rs:14:5 + --> tests/ui/mem_forget.rs:14:5 | LL | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | memstuff::forget(six); = help: to override `-D warnings` add `#[allow(clippy::mem_forget)]` error: usage of `mem::forget` on `Drop` type - --> $DIR/mem_forget.rs:19:5 + --> tests/ui/mem_forget.rs:19:5 | LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | std::mem::forget(seven); = note: argument has type `std::rc::Rc` error: usage of `mem::forget` on `Drop` type - --> $DIR/mem_forget.rs:24:5 + --> tests/ui/mem_forget.rs:24:5 | LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | forgetSomething(eight); = note: argument has type `std::vec::Vec` error: usage of `mem::forget` on type with `Drop` fields - --> $DIR/mem_forget.rs:29:5 + --> tests/ui/mem_forget.rs:29:5 | LL | std::mem::forget(string); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index c8ddf585fd2a5..44be2c9b63d75 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -1,5 +1,5 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:14:13 + --> tests/ui/mem_replace.rs:14:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` @@ -8,13 +8,13 @@ LL | let _ = mem::replace(&mut an_option, None); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_option_with_none)]` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:16:13 + --> tests/ui/mem_replace.rs:16:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:21:13 + --> tests/ui/mem_replace.rs:21:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` @@ -23,127 +23,127 @@ LL | let _ = std::mem::replace(&mut s, String::default()); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_default)]` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:24:13 + --> tests/ui/mem_replace.rs:24:13 | LL | let _ = std::mem::replace(s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:25:13 + --> tests/ui/mem_replace.rs:25:13 | LL | let _ = std::mem::replace(s, Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:28:13 + --> tests/ui/mem_replace.rs:28:13 | LL | let _ = std::mem::replace(&mut v, Vec::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:29:13 + --> tests/ui/mem_replace.rs:29:13 | LL | let _ = std::mem::replace(&mut v, Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:30:13 + --> tests/ui/mem_replace.rs:30:13 | LL | let _ = std::mem::replace(&mut v, Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:31:13 + --> tests/ui/mem_replace.rs:31:13 | LL | let _ = std::mem::replace(&mut v, vec![]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:34:13 + --> tests/ui/mem_replace.rs:34:13 | LL | let _ = std::mem::replace(&mut hash_map, HashMap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_map)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:37:13 + --> tests/ui/mem_replace.rs:37:13 | LL | let _ = std::mem::replace(&mut btree_map, BTreeMap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_map)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:40:13 + --> tests/ui/mem_replace.rs:40:13 | LL | let _ = std::mem::replace(&mut vd, VecDeque::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut vd)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:43:13 + --> tests/ui/mem_replace.rs:43:13 | LL | let _ = std::mem::replace(&mut hash_set, HashSet::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_set)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:46:13 + --> tests/ui/mem_replace.rs:46:13 | LL | let _ = std::mem::replace(&mut btree_set, BTreeSet::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_set)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:49:13 + --> tests/ui/mem_replace.rs:49:13 | LL | let _ = std::mem::replace(&mut list, LinkedList::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut list)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:52:13 + --> tests/ui/mem_replace.rs:52:13 | LL | let _ = std::mem::replace(&mut binary_heap, BinaryHeap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut binary_heap)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:55:13 + --> tests/ui/mem_replace.rs:55:13 | LL | let _ = std::mem::replace(&mut tuple, (vec![], BinaryHeap::new())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut tuple)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:58:13 + --> tests/ui/mem_replace.rs:58:13 | LL | let _ = std::mem::replace(&mut refstr, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut refstr)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:61:13 + --> tests/ui/mem_replace.rs:61:13 | LL | let _ = std::mem::replace(&mut slice, &[]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut slice)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:97:13 + --> tests/ui/mem_replace.rs:97:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:127:13 + --> tests/ui/mem_replace.rs:127:13 | LL | let _ = std::mem::replace(&mut f.0, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `f.0.take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:128:13 + --> tests/ui/mem_replace.rs:128:13 | LL | let _ = std::mem::replace(&mut *f, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `(*f).take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:129:13 + --> tests/ui/mem_replace.rs:129:13 | LL | let _ = std::mem::replace(&mut b.opt, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `b.opt.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:131:13 + --> tests/ui/mem_replace.rs:131:13 | LL | let _ = std::mem::replace(&mut b.val, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut b.val)` diff --git a/tests/ui/mem_replace_macro.stderr b/tests/ui/mem_replace_macro.stderr index 63043e6bf261c..0c98200bf04e5 100644 --- a/tests/ui/mem_replace_macro.stderr +++ b/tests/ui/mem_replace_macro.stderr @@ -1,5 +1,5 @@ error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace_macro.rs:10:21 + --> tests/ui/mem_replace_macro.rs:10:21 | LL | let _ = inline!(std::mem::replace($s, Default::default())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mem_replace_no_std.stderr b/tests/ui/mem_replace_no_std.stderr index 744fb5a15876e..eea538da4277a 100644 --- a/tests/ui/mem_replace_no_std.stderr +++ b/tests/ui/mem_replace_no_std.stderr @@ -1,5 +1,5 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:24:13 + --> tests/ui/mem_replace_no_std.rs:24:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` @@ -8,13 +8,13 @@ LL | let _ = mem::replace(&mut an_option, None); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_option_with_none)]` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:26:13 + --> tests/ui/mem_replace_no_std.rs:26:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `core::mem::take` - --> $DIR/mem_replace_no_std.rs:31:13 + --> tests/ui/mem_replace_no_std.rs:31:13 | LL | let _ = mem::replace(&mut refstr, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::mem::take(&mut refstr)` @@ -23,25 +23,25 @@ LL | let _ = mem::replace(&mut refstr, ""); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_default)]` error: replacing a value of type `T` with `T::default()` is better expressed using `core::mem::take` - --> $DIR/mem_replace_no_std.rs:34:13 + --> tests/ui/mem_replace_no_std.rs:34:13 | LL | let _ = mem::replace(&mut slice, &[]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::mem::take(&mut slice)` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:77:13 + --> tests/ui/mem_replace_no_std.rs:77:13 | LL | let _ = mem::replace(&mut f.0, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `f.0.take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:78:13 + --> tests/ui/mem_replace_no_std.rs:78:13 | LL | let _ = mem::replace(&mut *f, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `(*f).take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:79:13 + --> tests/ui/mem_replace_no_std.rs:79:13 | LL | let _ = mem::replace(&mut b.opt, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `b.opt.take()` diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index e32b3b336af65..2e2bd3d874f51 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -1,5 +1,5 @@ error: methods called `new` usually return `Self` - --> $DIR/methods.rs:103:5 + --> tests/ui/methods.rs:103:5 | LL | / fn new() -> i32 { LL | | 0 @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::new_ret_no_self)]` error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead - --> $DIR/methods.rs:124:13 + --> tests/ui/methods.rs:124:13 | LL | let _ = v.iter().filter(|&x| { | _____________^ diff --git a/tests/ui/methods_fixable.stderr b/tests/ui/methods_fixable.stderr index f290c20e5e989..852e7a224a6e3 100644 --- a/tests/ui/methods_fixable.stderr +++ b/tests/ui/methods_fixable.stderr @@ -1,5 +1,5 @@ error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead - --> $DIR/methods_fixable.rs:9:13 + --> tests/ui/methods_fixable.rs:9:13 | LL | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `v.iter().find(|&x| *x < 0)` diff --git a/tests/ui/methods_unfixable.stderr b/tests/ui/methods_unfixable.stderr index 771e10cbe105c..76691860f819d 100644 --- a/tests/ui/methods_unfixable.stderr +++ b/tests/ui/methods_unfixable.stderr @@ -1,11 +1,11 @@ error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead - --> $DIR/methods_unfixable.rs:9:13 + --> tests/ui/methods_unfixable.rs:9:13 | LL | let _ = iter.filter(|_| true).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `iter.find(|_| true)` | help: you will also need to make `iter` mutable, because `find` takes `&mut self` - --> $DIR/methods_unfixable.rs:8:9 + --> tests/ui/methods_unfixable.rs:8:9 | LL | let iter = (0..10); | ^^^^ diff --git a/tests/ui/min_ident_chars.stderr b/tests/ui/min_ident_chars.stderr index 7490878d57262..3dd5c9561fd02 100644 --- a/tests/ui/min_ident_chars.stderr +++ b/tests/ui/min_ident_chars.stderr @@ -1,5 +1,5 @@ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:9:8 + --> tests/ui/min_ident_chars.rs:9:8 | LL | struct A { | ^ @@ -8,187 +8,187 @@ LL | struct A { = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:10:5 + --> tests/ui/min_ident_chars.rs:10:5 | LL | a: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:12:5 + --> tests/ui/min_ident_chars.rs:12:5 | LL | A: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:13:5 + --> tests/ui/min_ident_chars.rs:13:5 | LL | I: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:16:8 + --> tests/ui/min_ident_chars.rs:16:8 | LL | struct B(u32); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:18:8 + --> tests/ui/min_ident_chars.rs:18:8 | LL | struct O { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:19:5 + --> tests/ui/min_ident_chars.rs:19:5 | LL | o: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:24:6 + --> tests/ui/min_ident_chars.rs:24:6 | LL | enum C { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:25:5 + --> tests/ui/min_ident_chars.rs:25:5 | LL | D, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:26:5 + --> tests/ui/min_ident_chars.rs:26:5 | LL | E, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:27:5 + --> tests/ui/min_ident_chars.rs:27:5 | LL | F, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:41:11 + --> tests/ui/min_ident_chars.rs:41:11 | LL | const A: u32 = 0; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:42:10 + --> tests/ui/min_ident_chars.rs:42:10 | LL | type A; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:43:8 + --> tests/ui/min_ident_chars.rs:43:8 | LL | fn a() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:57:9 + --> tests/ui/min_ident_chars.rs:57:9 | LL | let h = 1; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:58:9 + --> tests/ui/min_ident_chars.rs:58:9 | LL | let e = 2; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:59:9 + --> tests/ui/min_ident_chars.rs:59:9 | LL | let l = 3; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:9 + --> tests/ui/min_ident_chars.rs:60:9 | LL | let l = 4; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:61:9 + --> tests/ui/min_ident_chars.rs:61:9 | LL | let o = 6; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:65:10 + --> tests/ui/min_ident_chars.rs:65:10 | LL | let (h, o, w) = (1, 2, 3); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:65:13 + --> tests/ui/min_ident_chars.rs:65:13 | LL | let (h, o, w) = (1, 2, 3); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:66:10 + --> tests/ui/min_ident_chars.rs:66:10 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:66:14 + --> tests/ui/min_ident_chars.rs:66:14 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:66:17 + --> tests/ui/min_ident_chars.rs:66:17 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:68:16 + --> tests/ui/min_ident_chars.rs:68:16 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:68:19 + --> tests/ui/min_ident_chars.rs:68:19 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:68:29 + --> tests/ui/min_ident_chars.rs:68:29 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:72:9 + --> tests/ui/min_ident_chars.rs:72:9 | LL | let o = 1; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:73:9 + --> tests/ui/min_ident_chars.rs:73:9 | LL | let o = O { o }; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:87:4 + --> tests/ui/min_ident_chars.rs:87:4 | LL | fn b() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:88:21 + --> tests/ui/min_ident_chars.rs:88:21 | LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:88:29 + --> tests/ui/min_ident_chars.rs:88:29 | LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index e9c64e56b619e..bb1a82e320d97 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,5 +1,5 @@ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:22:5 + --> tests/ui/min_max.rs:22:5 | LL | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ @@ -8,73 +8,73 @@ LL | min(1, max(3, x)); = help: to override `-D warnings` add `#[allow(clippy::min_max)]` error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:25:5 + --> tests/ui/min_max.rs:25:5 | LL | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:27:5 + --> tests/ui/min_max.rs:27:5 | LL | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:29:5 + --> tests/ui/min_max.rs:29:5 | LL | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:32:5 + --> tests/ui/min_max.rs:32:5 | LL | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:43:5 + --> tests/ui/min_max.rs:43:5 | LL | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:45:5 + --> tests/ui/min_max.rs:45:5 | LL | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:51:5 + --> tests/ui/min_max.rs:51:5 | LL | x.min(1).max(3); | ^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:53:5 + --> tests/ui/min_max.rs:53:5 | LL | x.max(3).min(1); | ^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:55:5 + --> tests/ui/min_max.rs:55:5 | LL | f.max(3f32).min(1f32); | ^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:62:5 + --> tests/ui/min_max.rs:62:5 | LL | max(x.min(1), 3); | ^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:66:5 + --> tests/ui/min_max.rs:66:5 | LL | s.max("Zoo").min("Apple"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:68:5 + --> tests/ui/min_max.rs:68:5 | LL | s.min("Apple").max("Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/min_rust_version_attr.stderr b/tests/ui/min_rust_version_attr.stderr index 3c8555c62446c..809b1cfe73bf0 100644 --- a/tests/ui/min_rust_version_attr.stderr +++ b/tests/ui/min_rust_version_attr.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:13:19 + --> tests/ui/min_rust_version_attr.rs:13:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let log2_10 = 3.321928094887362; = note: `#[deny(clippy::approx_constant)]` on by default error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:19:19 + --> tests/ui/min_rust_version_attr.rs:19:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:30:19 + --> tests/ui/min_rust_version_attr.rs:30:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:41:19 + --> tests/ui/min_rust_version_attr.rs:41:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:52:19 + --> tests/ui/min_rust_version_attr.rs:52:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:60:27 + --> tests/ui/min_rust_version_attr.rs:60:27 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/min_rust_version_invalid_attr.stderr b/tests/ui/min_rust_version_invalid_attr.stderr index cf8392f03165d..cf0d08a5d21ad 100644 --- a/tests/ui/min_rust_version_invalid_attr.stderr +++ b/tests/ui/min_rust_version_invalid_attr.stderr @@ -1,35 +1,35 @@ error: `invalid.version` is not a valid Rust version - --> $DIR/min_rust_version_invalid_attr.rs:2:1 + --> tests/ui/min_rust_version_invalid_attr.rs:2:1 | LL | #![clippy::msrv = "invalid.version"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `invalid.version` is not a valid Rust version - --> $DIR/min_rust_version_invalid_attr.rs:7:1 + --> tests/ui/min_rust_version_invalid_attr.rs:7:1 | LL | #[clippy::msrv = "invalid.version"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `clippy::msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:14:5 + --> tests/ui/min_rust_version_invalid_attr.rs:14:5 | LL | #![clippy::msrv = "1.10.1"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:12:5 + --> tests/ui/min_rust_version_invalid_attr.rs:12:5 | LL | #![clippy::msrv = "1.40"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `clippy::msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:19:9 + --> tests/ui/min_rust_version_invalid_attr.rs:19:9 | LL | #![clippy::msrv = "1.0.0"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:18:9 + --> tests/ui/min_rust_version_invalid_attr.rs:18:9 | LL | #![clippy::msrv = "1"] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mismatched_target_os_non_unix.stderr b/tests/ui/mismatched_target_os_non_unix.stderr index 795d043e2ac76..7f7a4e9d6f623 100644 --- a/tests/ui/mismatched_target_os_non_unix.stderr +++ b/tests/ui/mismatched_target_os_non_unix.stderr @@ -1,5 +1,5 @@ error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:4:1 + --> tests/ui/mismatched_target_os_non_unix.rs:4:1 | LL | #[cfg(hermit)] | ^^^^^^------^^ @@ -10,7 +10,7 @@ LL | #[cfg(hermit)] = help: to override `-D warnings` add `#[allow(clippy::mismatched_target_os)]` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:7:1 + --> tests/ui/mismatched_target_os_non_unix.rs:7:1 | LL | #[cfg(wasi)] | ^^^^^^----^^ @@ -18,7 +18,7 @@ LL | #[cfg(wasi)] | help: try: `target_os = "wasi"` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:10:1 + --> tests/ui/mismatched_target_os_non_unix.rs:10:1 | LL | #[cfg(none)] | ^^^^^^----^^ @@ -26,7 +26,7 @@ LL | #[cfg(none)] | help: try: `target_os = "none"` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:14:1 + --> tests/ui/mismatched_target_os_non_unix.rs:14:1 | LL | #[cfg(all(not(windows), wasi))] | ^^^^^^^^^^^^^^^^^^^^^^^^----^^^ diff --git a/tests/ui/mismatched_target_os_unix.stderr b/tests/ui/mismatched_target_os_unix.stderr index 261c33754e70e..3071bad1324b8 100644 --- a/tests/ui/mismatched_target_os_unix.stderr +++ b/tests/ui/mismatched_target_os_unix.stderr @@ -1,5 +1,5 @@ error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:4:1 + --> tests/ui/mismatched_target_os_unix.rs:4:1 | LL | #[cfg(linux)] | ^^^^^^-----^^ @@ -11,7 +11,7 @@ LL | #[cfg(linux)] = help: to override `-D warnings` add `#[allow(clippy::mismatched_target_os)]` error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:7:1 + --> tests/ui/mismatched_target_os_unix.rs:7:1 | LL | #[cfg(freebsd)] | ^^^^^^-------^^ @@ -21,7 +21,7 @@ LL | #[cfg(freebsd)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:10:1 + --> tests/ui/mismatched_target_os_unix.rs:10:1 | LL | #[cfg(dragonfly)] | ^^^^^^---------^^ @@ -31,7 +31,7 @@ LL | #[cfg(dragonfly)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:13:1 + --> tests/ui/mismatched_target_os_unix.rs:13:1 | LL | #[cfg(openbsd)] | ^^^^^^-------^^ @@ -41,7 +41,7 @@ LL | #[cfg(openbsd)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:16:1 + --> tests/ui/mismatched_target_os_unix.rs:16:1 | LL | #[cfg(netbsd)] | ^^^^^^------^^ @@ -51,7 +51,7 @@ LL | #[cfg(netbsd)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:19:1 + --> tests/ui/mismatched_target_os_unix.rs:19:1 | LL | #[cfg(macos)] | ^^^^^^-----^^ @@ -61,7 +61,7 @@ LL | #[cfg(macos)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:22:1 + --> tests/ui/mismatched_target_os_unix.rs:22:1 | LL | #[cfg(ios)] | ^^^^^^---^^ @@ -71,7 +71,7 @@ LL | #[cfg(ios)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:25:1 + --> tests/ui/mismatched_target_os_unix.rs:25:1 | LL | #[cfg(android)] | ^^^^^^-------^^ @@ -81,7 +81,7 @@ LL | #[cfg(android)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:28:1 + --> tests/ui/mismatched_target_os_unix.rs:28:1 | LL | #[cfg(emscripten)] | ^^^^^^----------^^ @@ -91,7 +91,7 @@ LL | #[cfg(emscripten)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:31:1 + --> tests/ui/mismatched_target_os_unix.rs:31:1 | LL | #[cfg(fuchsia)] | ^^^^^^-------^^ @@ -101,7 +101,7 @@ LL | #[cfg(fuchsia)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:34:1 + --> tests/ui/mismatched_target_os_unix.rs:34:1 | LL | #[cfg(haiku)] | ^^^^^^-----^^ @@ -111,7 +111,7 @@ LL | #[cfg(haiku)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:37:1 + --> tests/ui/mismatched_target_os_unix.rs:37:1 | LL | #[cfg(illumos)] | ^^^^^^-------^^ @@ -121,7 +121,7 @@ LL | #[cfg(illumos)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:40:1 + --> tests/ui/mismatched_target_os_unix.rs:40:1 | LL | #[cfg(l4re)] | ^^^^^^----^^ @@ -131,7 +131,7 @@ LL | #[cfg(l4re)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:43:1 + --> tests/ui/mismatched_target_os_unix.rs:43:1 | LL | #[cfg(redox)] | ^^^^^^-----^^ @@ -141,7 +141,7 @@ LL | #[cfg(redox)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:46:1 + --> tests/ui/mismatched_target_os_unix.rs:46:1 | LL | #[cfg(solaris)] | ^^^^^^-------^^ @@ -151,7 +151,7 @@ LL | #[cfg(solaris)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:49:1 + --> tests/ui/mismatched_target_os_unix.rs:49:1 | LL | #[cfg(vxworks)] | ^^^^^^-------^^ @@ -161,7 +161,7 @@ LL | #[cfg(vxworks)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:53:1 + --> tests/ui/mismatched_target_os_unix.rs:53:1 | LL | #[cfg(all(not(any(solaris, linux)), freebsd))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mismatching_type_param_order.stderr b/tests/ui/mismatching_type_param_order.stderr index 8edbe329503ac..214d9d734d1bb 100644 --- a/tests/ui/mismatching_type_param_order.stderr +++ b/tests/ui/mismatching_type_param_order.stderr @@ -1,5 +1,5 @@ error: `Foo` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:11:20 + --> tests/ui/mismatching_type_param_order.rs:11:20 | LL | impl Foo {} | ^ @@ -9,7 +9,7 @@ LL | impl Foo {} = help: to override `-D warnings` add `#[allow(clippy::mismatching_type_param_order)]` error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:11:23 + --> tests/ui/mismatching_type_param_order.rs:11:23 | LL | impl Foo {} | ^ @@ -17,7 +17,7 @@ LL | impl Foo {} = help: try `B`, or a name that does not conflict with `Foo`'s generic params error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:16:23 + --> tests/ui/mismatching_type_param_order.rs:16:23 | LL | impl Foo {} | ^ @@ -25,7 +25,7 @@ LL | impl Foo {} = help: try `B`, or a name that does not conflict with `Foo`'s generic params error: `FooLifetime` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:28:44 + --> tests/ui/mismatching_type_param_order.rs:28:44 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | ^ @@ -33,7 +33,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} = help: try `A`, or a name that does not conflict with `FooLifetime`'s generic params error: `FooLifetime` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:28:47 + --> tests/ui/mismatching_type_param_order.rs:28:47 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | ^ @@ -41,7 +41,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} = help: try `B`, or a name that does not conflict with `FooLifetime`'s generic params error: `FooEnum` has a similarly named generic type parameter `C` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:46:27 + --> tests/ui/mismatching_type_param_order.rs:46:27 | LL | impl FooEnum {} | ^ @@ -49,7 +49,7 @@ LL | impl FooEnum {} = help: try `A`, or a name that does not conflict with `FooEnum`'s generic params error: `FooEnum` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:46:30 + --> tests/ui/mismatching_type_param_order.rs:46:30 | LL | impl FooEnum {} | ^ @@ -57,7 +57,7 @@ LL | impl FooEnum {} = help: try `B`, or a name that does not conflict with `FooEnum`'s generic params error: `FooEnum` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:46:33 + --> tests/ui/mismatching_type_param_order.rs:46:33 | LL | impl FooEnum {} | ^ @@ -65,7 +65,7 @@ LL | impl FooEnum {} = help: try `C`, or a name that does not conflict with `FooEnum`'s generic params error: `FooUnion` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:60:31 + --> tests/ui/mismatching_type_param_order.rs:60:31 | LL | impl FooUnion where A: Copy {} | ^ @@ -73,7 +73,7 @@ LL | impl FooUnion where A: Copy {} = help: try `A`, or a name that does not conflict with `FooUnion`'s generic params error: `FooUnion` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:60:34 + --> tests/ui/mismatching_type_param_order.rs:60:34 | LL | impl FooUnion where A: Copy {} | ^ diff --git a/tests/ui/misnamed_getters.stderr b/tests/ui/misnamed_getters.stderr index 120a3f3112ef1..056fa2be92151 100644 --- a/tests/ui/misnamed_getters.stderr +++ b/tests/ui/misnamed_getters.stderr @@ -1,5 +1,5 @@ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:12:5 + --> tests/ui/misnamed_getters.rs:12:5 | LL | / fn a(&self) -> &u8 { LL | | @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::misnamed_getters)]` error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:17:5 + --> tests/ui/misnamed_getters.rs:17:5 | LL | / fn a_mut(&mut self) -> &mut u8 { LL | | @@ -23,7 +23,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:22:5 + --> tests/ui/misnamed_getters.rs:22:5 | LL | / fn b(self) -> u8 { LL | | @@ -33,7 +33,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:27:5 + --> tests/ui/misnamed_getters.rs:27:5 | LL | / fn b_mut(&mut self) -> &mut u8 { LL | | @@ -43,7 +43,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:32:5 + --> tests/ui/misnamed_getters.rs:32:5 | LL | / fn c(&self) -> &u8 { LL | | @@ -53,7 +53,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:37:5 + --> tests/ui/misnamed_getters.rs:37:5 | LL | / fn c_mut(&mut self) -> &mut u8 { LL | | @@ -63,7 +63,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:49:5 + --> tests/ui/misnamed_getters.rs:49:5 | LL | / unsafe fn a(&self) -> &u8 { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:53:5 + --> tests/ui/misnamed_getters.rs:53:5 | LL | / unsafe fn a_mut(&mut self) -> &mut u8 { LL | | @@ -83,7 +83,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:58:5 + --> tests/ui/misnamed_getters.rs:58:5 | LL | / unsafe fn b(self) -> u8 { LL | | @@ -93,7 +93,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:63:5 + --> tests/ui/misnamed_getters.rs:63:5 | LL | / unsafe fn b_mut(&mut self) -> &mut u8 { LL | | @@ -103,7 +103,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:76:5 + --> tests/ui/misnamed_getters.rs:76:5 | LL | / unsafe fn a_unchecked(&self) -> &u8 { LL | | @@ -113,7 +113,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:80:5 + --> tests/ui/misnamed_getters.rs:80:5 | LL | / unsafe fn a_unchecked_mut(&mut self) -> &mut u8 { LL | | @@ -123,7 +123,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:85:5 + --> tests/ui/misnamed_getters.rs:85:5 | LL | / unsafe fn b_unchecked(self) -> u8 { LL | | @@ -133,7 +133,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:90:5 + --> tests/ui/misnamed_getters.rs:90:5 | LL | / unsafe fn b_unchecked_mut(&mut self) -> &mut u8 { LL | | @@ -143,7 +143,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:123:5 + --> tests/ui/misnamed_getters.rs:123:5 | LL | / fn a(&self) -> &u8 { LL | | @@ -153,7 +153,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:127:5 + --> tests/ui/misnamed_getters.rs:127:5 | LL | / fn a_mut(&mut self) -> &mut u8 { LL | | @@ -163,7 +163,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:132:5 + --> tests/ui/misnamed_getters.rs:132:5 | LL | / fn d(&self) -> &u8 { LL | | @@ -173,7 +173,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:136:5 + --> tests/ui/misnamed_getters.rs:136:5 | LL | / fn d_mut(&mut self) -> &mut u8 { LL | | diff --git a/tests/ui/missing_assert_message.stderr b/tests/ui/missing_assert_message.stderr index e07f52e3f66c6..c4fb7e3b154e4 100644 --- a/tests/ui/missing_assert_message.stderr +++ b/tests/ui/missing_assert_message.stderr @@ -1,5 +1,5 @@ error: assert without any message - --> $DIR/missing_assert_message.rs:12:5 + --> tests/ui/missing_assert_message.rs:12:5 | LL | assert!(foo()); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | assert!(foo()); = help: to override `-D warnings` add `#[allow(clippy::missing_assert_message)]` error: assert without any message - --> $DIR/missing_assert_message.rs:14:5 + --> tests/ui/missing_assert_message.rs:14:5 | LL | assert_eq!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | assert_eq!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:16:5 + --> tests/ui/missing_assert_message.rs:16:5 | LL | assert_ne!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | assert_ne!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:18:5 + --> tests/ui/missing_assert_message.rs:18:5 | LL | debug_assert!(foo()); | ^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | debug_assert!(foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:20:5 + --> tests/ui/missing_assert_message.rs:20:5 | LL | debug_assert_eq!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | debug_assert_eq!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:22:5 + --> tests/ui/missing_assert_message.rs:22:5 | LL | debug_assert_ne!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | debug_assert_ne!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:28:5 + --> tests/ui/missing_assert_message.rs:28:5 | LL | assert!(bar!(true)); | ^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | assert!(bar!(true)); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:30:5 + --> tests/ui/missing_assert_message.rs:30:5 | LL | assert!(bar!(true, false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | assert!(bar!(true, false)); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:32:5 + --> tests/ui/missing_assert_message.rs:32:5 | LL | assert_eq!(bar!(true), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | assert_eq!(bar!(true), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:34:5 + --> tests/ui/missing_assert_message.rs:34:5 | LL | assert_ne!(bar!(true, true), bar!(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | assert_ne!(bar!(true, true), bar!(true)); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:40:5 + --> tests/ui/missing_assert_message.rs:40:5 | LL | assert!(foo(),); | ^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | assert!(foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:42:5 + --> tests/ui/missing_assert_message.rs:42:5 | LL | assert_eq!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | assert_eq!(foo(), foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:44:5 + --> tests/ui/missing_assert_message.rs:44:5 | LL | assert_ne!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | assert_ne!(foo(), foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:46:5 + --> tests/ui/missing_assert_message.rs:46:5 | LL | debug_assert!(foo(),); | ^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | debug_assert!(foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:48:5 + --> tests/ui/missing_assert_message.rs:48:5 | LL | debug_assert_eq!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | debug_assert_eq!(foo(), foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:50:5 + --> tests/ui/missing_assert_message.rs:50:5 | LL | debug_assert_ne!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing_asserts_for_indexing.stderr b/tests/ui/missing_asserts_for_indexing.stderr index 61dce6ccc6c6a..2e63cd4a0e503 100644 --- a/tests/ui/missing_asserts_for_indexing.stderr +++ b/tests/ui/missing_asserts_for_indexing.stderr @@ -1,5 +1,5 @@ error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:30:5 + --> tests/ui/missing_asserts_for_indexing.rs:30:5 | LL | assert!(v.len() < 5); | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -7,27 +7,27 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:5 + --> tests/ui/missing_asserts_for_indexing.rs:30:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:12 + --> tests/ui/missing_asserts_for_indexing.rs:30:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:19 + --> tests/ui/missing_asserts_for_indexing.rs:30:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:26 + --> tests/ui/missing_asserts_for_indexing.rs:30:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:33 + --> tests/ui/missing_asserts_for_indexing.rs:30:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ @@ -36,7 +36,7 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:36:5 + --> tests/ui/missing_asserts_for_indexing.rs:36:5 | LL | assert!(v.len() <= 5); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -44,34 +44,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:5 + --> tests/ui/missing_asserts_for_indexing.rs:36:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:12 + --> tests/ui/missing_asserts_for_indexing.rs:36:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:19 + --> tests/ui/missing_asserts_for_indexing.rs:36:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:26 + --> tests/ui/missing_asserts_for_indexing.rs:36:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:33 + --> tests/ui/missing_asserts_for_indexing.rs:36:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:42:5 + --> tests/ui/missing_asserts_for_indexing.rs:42:5 | LL | assert!(v.len() > 3); | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -79,34 +79,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:5 + --> tests/ui/missing_asserts_for_indexing.rs:42:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:12 + --> tests/ui/missing_asserts_for_indexing.rs:42:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:19 + --> tests/ui/missing_asserts_for_indexing.rs:42:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:26 + --> tests/ui/missing_asserts_for_indexing.rs:42:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:33 + --> tests/ui/missing_asserts_for_indexing.rs:42:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:48:5 + --> tests/ui/missing_asserts_for_indexing.rs:48:5 | LL | assert!(v.len() >= 4); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -114,34 +114,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:5 + --> tests/ui/missing_asserts_for_indexing.rs:48:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:12 + --> tests/ui/missing_asserts_for_indexing.rs:48:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:19 + --> tests/ui/missing_asserts_for_indexing.rs:48:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:26 + --> tests/ui/missing_asserts_for_indexing.rs:48:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:33 + --> tests/ui/missing_asserts_for_indexing.rs:48:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:66:13 + --> tests/ui/missing_asserts_for_indexing.rs:66:13 | LL | assert!(v.len() >= 3); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 3)` @@ -152,19 +152,19 @@ LL | | let _ = v[1..4]; | |___________________^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:66:13 + --> tests/ui/missing_asserts_for_indexing.rs:66:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:68:13 + --> tests/ui/missing_asserts_for_indexing.rs:68:13 | LL | let _ = v[1..4]; | ^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:80:13 + --> tests/ui/missing_asserts_for_indexing.rs:80:13 | LL | assert!(v.len() >= 4); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -175,19 +175,19 @@ LL | | let _ = v[1..=4]; | |____________________^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:80:13 + --> tests/ui/missing_asserts_for_indexing.rs:80:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:82:13 + --> tests/ui/missing_asserts_for_indexing.rs:82:13 | LL | let _ = v[1..=4]; | ^^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:95:13 + --> tests/ui/missing_asserts_for_indexing.rs:95:13 | LL | assert!(v1.len() >= 12); | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` @@ -196,19 +196,19 @@ LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:95:13 + --> tests/ui/missing_asserts_for_indexing.rs:95:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:95:21 + --> tests/ui/missing_asserts_for_indexing.rs:95:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:97:13 + --> tests/ui/missing_asserts_for_indexing.rs:97:13 | LL | assert!(v2.len() >= 15); | ----------------------- help: provide the highest index that is indexed with: `assert!(v2.len() > 15)` @@ -217,19 +217,19 @@ LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:97:13 + --> tests/ui/missing_asserts_for_indexing.rs:97:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:97:21 + --> tests/ui/missing_asserts_for_indexing.rs:97:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:103:13 + --> tests/ui/missing_asserts_for_indexing.rs:103:13 | LL | assert!(v1.len() >= 12); | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` @@ -238,19 +238,19 @@ LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:103:13 + --> tests/ui/missing_asserts_for_indexing.rs:103:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:103:21 + --> tests/ui/missing_asserts_for_indexing.rs:103:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:127:13 + --> tests/ui/missing_asserts_for_indexing.rs:127:13 | LL | assert!(v1.len() == 2); | ---------------------- help: provide the highest index that is indexed with: `assert!(v1.len() == 3)` @@ -259,24 +259,24 @@ LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:127:13 + --> tests/ui/missing_asserts_for_indexing.rs:127:13 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:127:21 + --> tests/ui/missing_asserts_for_indexing.rs:127:21 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:127:29 + --> tests/ui/missing_asserts_for_indexing.rs:127:29 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:131:13 + --> tests/ui/missing_asserts_for_indexing.rs:131:13 | LL | assert!(2 == v3.len()); | ---------------------- help: provide the highest index that is indexed with: `assert!(v3.len() == 3)` @@ -285,17 +285,17 @@ LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:131:13 + --> tests/ui/missing_asserts_for_indexing.rs:131:13 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:131:21 + --> tests/ui/missing_asserts_for_indexing.rs:131:21 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:131:29 + --> tests/ui/missing_asserts_for_indexing.rs:131:29 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ diff --git a/tests/ui/missing_asserts_for_indexing_unfixable.stderr b/tests/ui/missing_asserts_for_indexing_unfixable.stderr index 12e0542279836..b575e09966ce1 100644 --- a/tests/ui/missing_asserts_for_indexing_unfixable.stderr +++ b/tests/ui/missing_asserts_for_indexing_unfixable.stderr @@ -1,32 +1,32 @@ error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:5 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v.len() > 4);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:5 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:12 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:19 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:26 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:33 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ @@ -35,7 +35,7 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:10:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | LL | let _ = v[0]; | _____________^ @@ -45,19 +45,19 @@ LL | | let _ = v[1..4]; | = help: consider asserting the length before indexing: `assert!(v.len() > 3);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:10:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:12:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:12:13 | LL | let _ = v[1..4]; | ^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:16:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:16:13 | LL | let a = v[0]; | _____________^ @@ -68,112 +68,112 @@ LL | | let c = v[2]; | = help: consider asserting the length before indexing: `assert!(v.len() > 2);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:16:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:16:13 | LL | let a = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:18:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:18:13 | LL | let b = v[1]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:19:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:19:13 | LL | let c = v[2]; | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:24:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v1.len() > 12);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:24:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:24:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:25:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:25:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:25:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:31:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:31:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:31:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:40:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:13 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(f.v.len() > 1);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:40:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:13 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:40:22 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:22 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:54:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:13 | LL | let _ = x[0] + x[1]; | ^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(x.len() > 1);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:54:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:13 | LL | let _ = x[0] + x[1]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:54:20 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:20 | LL | let _ = x[0] + x[1]; | ^^^^ diff --git a/tests/ui/missing_const_for_fn/could_be_const.stderr b/tests/ui/missing_const_for_fn/could_be_const.stderr index 4d01e5ce17034..082459fd82120 100644 --- a/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -1,5 +1,5 @@ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:14:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:14:5 | LL | / pub fn new() -> Self { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::missing_const_for_fn)]` error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:20:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:20:5 | LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:27:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:27:1 | LL | / fn one() -> i32 { LL | | @@ -30,7 +30,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:33:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:33:1 | LL | / fn two() -> i32 { LL | | @@ -40,7 +40,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:40:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:40:1 | LL | / fn string() -> String { LL | | @@ -49,7 +49,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:46:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:46:1 | LL | / unsafe fn four() -> i32 { LL | | @@ -58,7 +58,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:52:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:52:1 | LL | / fn generic(t: T) -> T { LL | | @@ -67,7 +67,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:61:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:61:1 | LL | / fn generic_arr(t: [T; 1]) -> T { LL | | @@ -76,7 +76,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:75:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:75:9 | LL | / pub fn b(self, a: &A) -> B { LL | | @@ -85,7 +85,7 @@ LL | | } | |_________^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:85:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:85:5 | LL | / fn const_fn_stabilized_before_msrv(byte: u8) { LL | | @@ -94,7 +94,7 @@ LL | | } | |_____^ error: this could be a `const fn` - --> $DIR/missing_const_for_fn/could_be_const.rs:97:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:97:1 | LL | / fn msrv_1_46() -> i32 { LL | | diff --git a/tests/ui/missing_doc.stderr b/tests/ui/missing_doc.stderr index 1d8007fa5b0fc..7e66e2097e90f 100644 --- a/tests/ui/missing_doc.stderr +++ b/tests/ui/missing_doc.stderr @@ -1,5 +1,5 @@ error: missing documentation for a type alias - --> $DIR/missing_doc.rs:16:1 + --> tests/ui/missing_doc.rs:16:1 | LL | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | type Typedef = String; = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a module - --> $DIR/missing_doc.rs:19:1 + --> tests/ui/missing_doc.rs:19:1 | LL | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing_doc.rs:25:1 + --> tests/ui/missing_doc.rs:25:1 | LL | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing_doc.rs:39:1 + --> tests/ui/missing_doc.rs:39:1 | LL | / enum Baz { LL | | BazA { a: isize, b: isize }, @@ -29,43 +29,43 @@ LL | | } | |_^ error: missing documentation for a variant - --> $DIR/missing_doc.rs:40:5 + --> tests/ui/missing_doc.rs:40:5 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc.rs:40:12 + --> tests/ui/missing_doc.rs:40:12 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc.rs:40:22 + --> tests/ui/missing_doc.rs:40:22 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing_doc.rs:41:5 + --> tests/ui/missing_doc.rs:41:5 | LL | BarB, | ^^^^ error: missing documentation for a constant - --> $DIR/missing_doc.rs:65:1 + --> tests/ui/missing_doc.rs:65:1 | LL | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing_doc.rs:74:1 + --> tests/ui/missing_doc.rs:74:1 | LL | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing_doc.rs:83:1 + --> tests/ui/missing_doc.rs:83:1 | LL | / mod internal_impl { LL | | /// dox @@ -77,13 +77,13 @@ LL | | } | |_^ error: missing documentation for a function - --> $DIR/missing_doc.rs:88:5 + --> tests/ui/missing_doc.rs:88:5 | LL | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing_doc.rs:94:9 + --> tests/ui/missing_doc.rs:94:9 | LL | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing_doc_crate_missing.stderr b/tests/ui/missing_doc_crate_missing.stderr index 3aa9781c2f1da..a421fb986d3a5 100644 --- a/tests/ui/missing_doc_crate_missing.stderr +++ b/tests/ui/missing_doc_crate_missing.stderr @@ -1,5 +1,5 @@ error: missing documentation for the crate - --> $DIR/missing_doc_crate_missing.rs:1:1 + --> tests/ui/missing_doc_crate_missing.rs:1:1 | LL | / #![warn(clippy::missing_docs_in_private_items)] LL | | diff --git a/tests/ui/missing_doc_impl.stderr b/tests/ui/missing_doc_impl.stderr index e303b7b7d9fdb..e2052c346df8f 100644 --- a/tests/ui/missing_doc_impl.stderr +++ b/tests/ui/missing_doc_impl.stderr @@ -1,5 +1,5 @@ error: missing documentation for a struct - --> $DIR/missing_doc_impl.rs:13:1 + --> tests/ui/missing_doc_impl.rs:13:1 | LL | / struct Foo { LL | | a: isize, @@ -11,25 +11,25 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a struct field - --> $DIR/missing_doc_impl.rs:14:5 + --> tests/ui/missing_doc_impl.rs:14:5 | LL | a: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc_impl.rs:15:5 + --> tests/ui/missing_doc_impl.rs:15:5 | LL | b: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc_impl.rs:20:5 + --> tests/ui/missing_doc_impl.rs:20:5 | LL | b: isize, | ^^^^^^^^ error: missing documentation for an associated function - --> $DIR/missing_doc_impl.rs:67:5 + --> tests/ui/missing_doc_impl.rs:67:5 | LL | / pub fn new() -> Self { LL | | Foo { a: 0, b: 0 } @@ -37,13 +37,13 @@ LL | | } | |_____^ error: missing documentation for an associated function - --> $DIR/missing_doc_impl.rs:70:5 + --> tests/ui/missing_doc_impl.rs:70:5 | LL | fn bar() {} | ^^^^^^^^^^^ error: missing documentation for an associated function - --> $DIR/missing_doc_impl.rs:78:5 + --> tests/ui/missing_doc_impl.rs:78:5 | LL | / fn foo2() -> u32 { LL | | 1 diff --git a/tests/ui/missing_fields_in_debug.stderr b/tests/ui/missing_fields_in_debug.stderr index 481b2c6321778..6f8a9abe9228d 100644 --- a/tests/ui/missing_fields_in_debug.stderr +++ b/tests/ui/missing_fields_in_debug.stderr @@ -1,5 +1,5 @@ error: manual `Debug` impl does not include all fields - --> $DIR/missing_fields_in_debug.rs:13:1 + --> tests/ui/missing_fields_in_debug.rs:13:1 | LL | / impl fmt::Debug for NamedStruct1Ignored { LL | | @@ -11,7 +11,7 @@ LL | | } | |_^ | note: this field is unused - --> $DIR/missing_fields_in_debug.rs:10:5 + --> tests/ui/missing_fields_in_debug.rs:10:5 | LL | hidden: u32, | ^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | hidden: u32, = help: to override `-D warnings` add `#[allow(clippy::missing_fields_in_debug)]` error: manual `Debug` impl does not include all fields - --> $DIR/missing_fields_in_debug.rs:32:1 + --> tests/ui/missing_fields_in_debug.rs:32:1 | LL | / impl fmt::Debug for NamedStructMultipleIgnored { LL | | @@ -33,17 +33,17 @@ LL | | } | |_^ | note: this field is unused - --> $DIR/missing_fields_in_debug.rs:26:5 + --> tests/ui/missing_fields_in_debug.rs:26:5 | LL | hidden: u32, | ^^^^^^^^^^^ note: this field is unused - --> $DIR/missing_fields_in_debug.rs:27:5 + --> tests/ui/missing_fields_in_debug.rs:27:5 | LL | hidden2: String, | ^^^^^^^^^^^^^^^ note: this field is unused - --> $DIR/missing_fields_in_debug.rs:29:5 + --> tests/ui/missing_fields_in_debug.rs:29:5 | LL | hidden4: ((((u8), u16), u32), u64), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | hidden4: ((((u8), u16), u32), u64), = help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields error: manual `Debug` impl does not include all fields - --> $DIR/missing_fields_in_debug.rs:94:1 + --> tests/ui/missing_fields_in_debug.rs:94:1 | LL | / impl fmt::Debug for MultiExprDebugImpl { LL | | @@ -63,7 +63,7 @@ LL | | } | |_^ | note: this field is unused - --> $DIR/missing_fields_in_debug.rs:90:5 + --> tests/ui/missing_fields_in_debug.rs:90:5 | LL | b: String, | ^^^^^^^^^ diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index da2a2a7fedd46..c2bb37141a025 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,5 +1,5 @@ error: missing `#[inline]` for a function - --> $DIR/missing_inline.rs:20:1 + --> tests/ui/missing_inline.rs:20:1 | LL | pub fn pub_foo() {} | ^^^^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | pub fn pub_foo() {} = help: to override `-D warnings` add `#[allow(clippy::missing_inline_in_public_items)]` error: missing `#[inline]` for a default trait method - --> $DIR/missing_inline.rs:39:5 + --> tests/ui/missing_inline.rs:39:5 | LL | fn PubBar_b() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:55:5 + --> tests/ui/missing_inline.rs:55:5 | LL | fn PubBar_a() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:58:5 + --> tests/ui/missing_inline.rs:58:5 | LL | fn PubBar_b() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:61:5 + --> tests/ui/missing_inline.rs:61:5 | LL | fn PubBar_c() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:73:5 + --> tests/ui/missing_inline.rs:73:5 | LL | pub fn PubFooImpl() {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing_panics_doc.stderr b/tests/ui/missing_panics_doc.stderr index efee485508ec8..c6a939d86f7c7 100644 --- a/tests/ui/missing_panics_doc.stderr +++ b/tests/ui/missing_panics_doc.stderr @@ -1,11 +1,11 @@ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:13:1 + --> tests/ui/missing_panics_doc.rs:13:1 | LL | pub fn unwrap() { | ^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:15:5 + --> tests/ui/missing_panics_doc.rs:15:5 | LL | result.unwrap() | ^^^^^^^^^^^^^^^ @@ -13,133 +13,133 @@ LL | result.unwrap() = help: to override `-D warnings` add `#[allow(clippy::missing_panics_doc)]` error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:19:1 + --> tests/ui/missing_panics_doc.rs:19:1 | LL | pub fn panic() { | ^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:20:5 + --> tests/ui/missing_panics_doc.rs:20:5 | LL | panic!("This function panics") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:24:1 + --> tests/ui/missing_panics_doc.rs:24:1 | LL | pub fn inner_body(opt: Option) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:27:13 + --> tests/ui/missing_panics_doc.rs:27:13 | LL | panic!() | ^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:33:1 + --> tests/ui/missing_panics_doc.rs:33:1 | LL | pub fn unreachable_and_panic() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:34:39 + --> tests/ui/missing_panics_doc.rs:34:39 | LL | if true { unreachable!() } else { panic!() } | ^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:38:1 + --> tests/ui/missing_panics_doc.rs:38:1 | LL | pub fn assert_eq() { | ^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:40:5 + --> tests/ui/missing_panics_doc.rs:40:5 | LL | assert_eq!(x, 0); | ^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:44:1 + --> tests/ui/missing_panics_doc.rs:44:1 | LL | pub fn assert_ne() { | ^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:46:5 + --> tests/ui/missing_panics_doc.rs:46:5 | LL | assert_ne!(x, 0); | ^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:151:5 + --> tests/ui/missing_panics_doc.rs:151:5 | LL | pub fn option_unwrap(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:153:9 + --> tests/ui/missing_panics_doc.rs:153:9 | LL | o.unwrap() | ^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:156:5 + --> tests/ui/missing_panics_doc.rs:156:5 | LL | pub fn option_expect(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:158:9 + --> tests/ui/missing_panics_doc.rs:158:9 | LL | o.expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:161:5 + --> tests/ui/missing_panics_doc.rs:161:5 | LL | pub fn result_unwrap(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:163:9 + --> tests/ui/missing_panics_doc.rs:163:9 | LL | res.unwrap() | ^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:166:5 + --> tests/ui/missing_panics_doc.rs:166:5 | LL | pub fn result_expect(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:168:9 + --> tests/ui/missing_panics_doc.rs:168:9 | LL | res.expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:171:5 + --> tests/ui/missing_panics_doc.rs:171:5 | LL | pub fn last_unwrap(v: &[u32]) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:172:10 + --> tests/ui/missing_panics_doc.rs:172:10 | LL | *v.last().unwrap() | ^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:175:5 + --> tests/ui/missing_panics_doc.rs:175:5 | LL | pub fn last_expect(v: &[u32]) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:176:10 + --> tests/ui/missing_panics_doc.rs:176:10 | LL | *v.last().expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing_spin_loop.stderr b/tests/ui/missing_spin_loop.stderr index a84c19d592617..12f4b53a3d187 100644 --- a/tests/ui/missing_spin_loop.stderr +++ b/tests/ui/missing_spin_loop.stderr @@ -1,5 +1,5 @@ error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:10:37 + --> tests/ui/missing_spin_loop.rs:10:37 | LL | while b.load(Ordering::Acquire) {} | ^^ help: try: `{ std::hint::spin_loop() }` @@ -8,31 +8,31 @@ LL | while b.load(Ordering::Acquire) {} = help: to override `-D warnings` add `#[allow(clippy::missing_spin_loop)]` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:12:37 + --> tests/ui/missing_spin_loop.rs:12:37 | LL | while !b.load(Ordering::SeqCst) {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:14:46 + --> tests/ui/missing_spin_loop.rs:14:46 | LL | while b.load(Ordering::Acquire) == false {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:16:49 + --> tests/ui/missing_spin_loop.rs:16:49 | LL | while { true == b.load(Ordering::Acquire) } {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:18:93 + --> tests/ui/missing_spin_loop.rs:18:93 | LL | while b.compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed) != Ok(true) {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:20:94 + --> tests/ui/missing_spin_loop.rs:20:94 | LL | while Ok(false) != b.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed) {} | ^^ help: try: `{ std::hint::spin_loop() }` diff --git a/tests/ui/missing_spin_loop_no_std.stderr b/tests/ui/missing_spin_loop_no_std.stderr index d84d06088ba35..7911620d32c50 100644 --- a/tests/ui/missing_spin_loop_no_std.stderr +++ b/tests/ui/missing_spin_loop_no_std.stderr @@ -1,5 +1,5 @@ error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop_no_std.rs:12:37 + --> tests/ui/missing_spin_loop_no_std.rs:12:37 | LL | while b.load(Ordering::Acquire) {} | ^^ help: try: `{ core::hint::spin_loop() }` diff --git a/tests/ui/missing_trait_methods.stderr b/tests/ui/missing_trait_methods.stderr index 3e20a51e0842f..f5d5d4418b287 100644 --- a/tests/ui/missing_trait_methods.stderr +++ b/tests/ui/missing_trait_methods.stderr @@ -1,11 +1,11 @@ error: missing trait method provided by default: `provided` - --> $DIR/missing_trait_methods.rs:22:1 + --> tests/ui/missing_trait_methods.rs:22:1 | LL | impl A for Partial {} | ^^^^^^^^^^^^^^^^^^ | help: implement the method - --> $DIR/missing_trait_methods.rs:5:5 + --> tests/ui/missing_trait_methods.rs:5:5 | LL | fn provided() {} | ^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ LL | fn provided() {} = help: to override `-D warnings` add `#[allow(clippy::missing_trait_methods)]` error: missing trait method provided by default: `b` - --> $DIR/missing_trait_methods.rs:25:1 + --> tests/ui/missing_trait_methods.rs:25:1 | LL | impl B for Partial { | ^^^^^^^^^^^^^^^^^^ | help: implement the method - --> $DIR/missing_trait_methods.rs:15:5 + --> tests/ui/missing_trait_methods.rs:15:5 | LL | fn b<'a, T: AsRef<[u8]>>(a: &'a T) -> &'a [u8] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mistyped_literal_suffix.stderr b/tests/ui/mistyped_literal_suffix.stderr index ecd73497a8e78..56bfb06d8e669 100644 --- a/tests/ui/mistyped_literal_suffix.stderr +++ b/tests/ui/mistyped_literal_suffix.stderr @@ -1,5 +1,5 @@ error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:16:18 + --> tests/ui/mistyped_literal_suffix.rs:16:18 | LL | let fail14 = 2_32; | ^^^^ help: did you mean to write: `2_i32` @@ -7,91 +7,91 @@ LL | let fail14 = 2_32; = note: `#[deny(clippy::mistyped_literal_suffixes)]` on by default error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:17:18 + --> tests/ui/mistyped_literal_suffix.rs:17:18 | LL | let fail15 = 4_64; | ^^^^ help: did you mean to write: `4_i64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:18:18 + --> tests/ui/mistyped_literal_suffix.rs:18:18 | LL | let fail16 = 7_8; // | ^^^ help: did you mean to write: `7_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:19:18 + --> tests/ui/mistyped_literal_suffix.rs:19:18 | LL | let fail17 = 23_16; // | ^^^^^ help: did you mean to write: `23_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:22:18 + --> tests/ui/mistyped_literal_suffix.rs:22:18 | LL | let fail20 = 2__8; // | ^^^^ help: did you mean to write: `2_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:23:18 + --> tests/ui/mistyped_literal_suffix.rs:23:18 | LL | let fail21 = 4___16; // | ^^^^^^ help: did you mean to write: `4_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:26:18 + --> tests/ui/mistyped_literal_suffix.rs:26:18 | LL | let fail25 = 1E2_32; | ^^^^^^ help: did you mean to write: `1E2_f32` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:27:18 + --> tests/ui/mistyped_literal_suffix.rs:27:18 | LL | let fail26 = 43E7_64; | ^^^^^^^ help: did you mean to write: `43E7_f64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:28:18 + --> tests/ui/mistyped_literal_suffix.rs:28:18 | LL | let fail27 = 243E17_32; | ^^^^^^^^^ help: did you mean to write: `243E17_f32` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:29:18 + --> tests/ui/mistyped_literal_suffix.rs:29:18 | LL | let fail28 = 241251235E723_64; | ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:33:18 + --> tests/ui/mistyped_literal_suffix.rs:33:18 | LL | let fail30 = 127_8; // should be i8 | ^^^^^ help: did you mean to write: `127_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:34:18 + --> tests/ui/mistyped_literal_suffix.rs:34:18 | LL | let fail31 = 240_8; // should be u8 | ^^^^^ help: did you mean to write: `240_u8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:36:18 + --> tests/ui/mistyped_literal_suffix.rs:36:18 | LL | let fail33 = 0x1234_16; | ^^^^^^^^^ help: did you mean to write: `0x1234_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:37:18 + --> tests/ui/mistyped_literal_suffix.rs:37:18 | LL | let fail34 = 0xABCD_16; | ^^^^^^^^^ help: did you mean to write: `0xABCD_u16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:39:18 + --> tests/ui/mistyped_literal_suffix.rs:39:18 | LL | let fail36 = 0xFFFF_FFFF_FFFF_FFFF_64; // u64 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to write: `0xFFFF_FFFF_FFFF_FFFF_u64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:45:13 + --> tests/ui/mistyped_literal_suffix.rs:45:13 | LL | let _ = 1.12345E1_32; | ^^^^^^^^^^^^ help: did you mean to write: `1.123_45E1_f32` diff --git a/tests/ui/mixed_read_write_in_expression.stderr b/tests/ui/mixed_read_write_in_expression.stderr index 3dad98815c618..796d4ccd26b72 100644 --- a/tests/ui/mixed_read_write_in_expression.stderr +++ b/tests/ui/mixed_read_write_in_expression.stderr @@ -1,11 +1,11 @@ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:14:9 + --> tests/ui/mixed_read_write_in_expression.rs:14:9 | LL | } + x; | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:12:9 + --> tests/ui/mixed_read_write_in_expression.rs:12:9 | LL | x = 1; | ^^^^^ @@ -13,37 +13,37 @@ LL | x = 1; = help: to override `-D warnings` add `#[allow(clippy::mixed_read_write_in_expression)]` error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:18:5 + --> tests/ui/mixed_read_write_in_expression.rs:18:5 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:20:9 + --> tests/ui/mixed_read_write_in_expression.rs:20:9 | LL | x = 20; | ^^^^^^ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:32:12 + --> tests/ui/mixed_read_write_in_expression.rs:32:12 | LL | a: x, | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:35:13 + --> tests/ui/mixed_read_write_in_expression.rs:35:13 | LL | x = 6; | ^^^^^ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:42:9 + --> tests/ui/mixed_read_write_in_expression.rs:42:9 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:44:13 + --> tests/ui/mixed_read_write_in_expression.rs:44:13 | LL | x = 20; | ^^^^^^ diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index d5856614f91f1..455f5372747a4 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,5 +1,5 @@ error: module has the same name as its containing module - --> $DIR/module_inception.rs:5:9 + --> tests/ui/module_inception.rs:5:9 | LL | / pub mod bar2 { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::module_inception)]` error: module has the same name as its containing module - --> $DIR/module_inception.rs:12:5 + --> tests/ui/module_inception.rs:12:5 | LL | / pub mod foo2 { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: module has the same name as its containing module - --> $DIR/module_inception.rs:20:9 + --> tests/ui/module_inception.rs:20:9 | LL | / mod bar { LL | | @@ -30,7 +30,7 @@ LL | | } | |_________^ error: module has the same name as its containing module - --> $DIR/module_inception.rs:26:5 + --> tests/ui/module_inception.rs:26:5 | LL | / mod foo { LL | | diff --git a/tests/ui/module_name_repetitions.stderr b/tests/ui/module_name_repetitions.stderr index 1854d3a859a7a..bffb08f6f879f 100644 --- a/tests/ui/module_name_repetitions.stderr +++ b/tests/ui/module_name_repetitions.stderr @@ -1,5 +1,5 @@ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:8:12 + --> tests/ui/module_name_repetitions.rs:8:12 | LL | pub fn foo_bar() {} | ^^^^^^^ @@ -8,25 +8,25 @@ LL | pub fn foo_bar() {} = help: to override `-D warnings` add `#[allow(clippy::module_name_repetitions)]` error: item name ends with its containing module's name - --> $DIR/module_name_repetitions.rs:11:12 + --> tests/ui/module_name_repetitions.rs:11:12 | LL | pub fn bar_foo() {} | ^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:13:16 + --> tests/ui/module_name_repetitions.rs:13:16 | LL | pub struct FooCake; | ^^^^^^^ error: item name ends with its containing module's name - --> $DIR/module_name_repetitions.rs:15:14 + --> tests/ui/module_name_repetitions.rs:15:14 | LL | pub enum CakeFoo {} | ^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:17:16 + --> tests/ui/module_name_repetitions.rs:17:16 | LL | pub struct Foo7Bar; | ^^^^^^^ diff --git a/tests/ui/modulo_arithmetic_float.stderr b/tests/ui/modulo_arithmetic_float.stderr index 46c8d0288a358..fa3a64cfb7146 100644 --- a/tests/ui/modulo_arithmetic_float.stderr +++ b/tests/ui/modulo_arithmetic_float.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on constants with different signs: `-1.600 % 2.100` - --> $DIR/modulo_arithmetic_float.rs:6:5 + --> tests/ui/modulo_arithmetic_float.rs:6:5 | LL | -1.6 % 2.1; | ^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | -1.6 % 2.1; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on constants with different signs: `1.600 % -2.100` - --> $DIR/modulo_arithmetic_float.rs:9:5 + --> tests/ui/modulo_arithmetic_float.rs:9:5 | LL | 1.6 % -2.1; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | 1.6 % -2.1; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on constants with different signs: `-1.200 % 3.400` - --> $DIR/modulo_arithmetic_float.rs:12:5 + --> tests/ui/modulo_arithmetic_float.rs:12:5 | LL | (1.1 - 2.3) % (1.1 + 2.3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | (1.1 - 2.3) % (1.1 + 2.3); = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on constants with different signs: `3.400 % -1.200` - --> $DIR/modulo_arithmetic_float.rs:15:5 + --> tests/ui/modulo_arithmetic_float.rs:15:5 | LL | (1.1 + 2.3) % (1.1 - 2.3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | (1.1 + 2.3) % (1.1 - 2.3); = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:22:5 + --> tests/ui/modulo_arithmetic_float.rs:22:5 | LL | a_f32 % b_f32; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | a_f32 % b_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:25:5 + --> tests/ui/modulo_arithmetic_float.rs:25:5 | LL | b_f32 % a_f32; | ^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | b_f32 % a_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:28:5 + --> tests/ui/modulo_arithmetic_float.rs:28:5 | LL | b_f32 %= a_f32; | ^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | b_f32 %= a_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:34:5 + --> tests/ui/modulo_arithmetic_float.rs:34:5 | LL | a_f64 % b_f64; | ^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | a_f64 % b_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:37:5 + --> tests/ui/modulo_arithmetic_float.rs:37:5 | LL | b_f64 % a_f64; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | b_f64 % a_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:40:5 + --> tests/ui/modulo_arithmetic_float.rs:40:5 | LL | b_f64 %= a_f64; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/modulo_arithmetic_integral.stderr b/tests/ui/modulo_arithmetic_integral.stderr index 033a016c0e6f1..f1cfe791a03b0 100644 --- a/tests/ui/modulo_arithmetic_integral.stderr +++ b/tests/ui/modulo_arithmetic_integral.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:8:5 + --> tests/ui/modulo_arithmetic_integral.rs:8:5 | LL | a % b; | ^^^^^ @@ -10,7 +10,7 @@ LL | a % b; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:11:5 + --> tests/ui/modulo_arithmetic_integral.rs:11:5 | LL | b % a; | ^^^^^ @@ -19,7 +19,7 @@ LL | b % a; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:14:5 + --> tests/ui/modulo_arithmetic_integral.rs:14:5 | LL | b %= a; | ^^^^^^ @@ -28,7 +28,7 @@ LL | b %= a; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:20:5 + --> tests/ui/modulo_arithmetic_integral.rs:20:5 | LL | a_i8 % b_i8; | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | a_i8 % b_i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:23:5 + --> tests/ui/modulo_arithmetic_integral.rs:23:5 | LL | b_i8 %= a_i8; | ^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | b_i8 %= a_i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:29:5 + --> tests/ui/modulo_arithmetic_integral.rs:29:5 | LL | a_i16 % b_i16; | ^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | a_i16 % b_i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:32:5 + --> tests/ui/modulo_arithmetic_integral.rs:32:5 | LL | b_i16 %= a_i16; | ^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | b_i16 %= a_i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:38:5 + --> tests/ui/modulo_arithmetic_integral.rs:38:5 | LL | a_i32 % b_i32; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | a_i32 % b_i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:41:5 + --> tests/ui/modulo_arithmetic_integral.rs:41:5 | LL | b_i32 %= a_i32; | ^^^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | b_i32 %= a_i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:47:5 + --> tests/ui/modulo_arithmetic_integral.rs:47:5 | LL | a_i64 % b_i64; | ^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | a_i64 % b_i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:50:5 + --> tests/ui/modulo_arithmetic_integral.rs:50:5 | LL | b_i64 %= a_i64; | ^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | b_i64 %= a_i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:56:5 + --> tests/ui/modulo_arithmetic_integral.rs:56:5 | LL | a_i128 % b_i128; | ^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | a_i128 % b_i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:59:5 + --> tests/ui/modulo_arithmetic_integral.rs:59:5 | LL | b_i128 %= a_i128; | ^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | b_i128 %= a_i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:65:5 + --> tests/ui/modulo_arithmetic_integral.rs:65:5 | LL | a_isize % b_isize; | ^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | a_isize % b_isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:68:5 + --> tests/ui/modulo_arithmetic_integral.rs:68:5 | LL | b_isize %= a_isize; | ^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | b_isize %= a_isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:74:5 + --> tests/ui/modulo_arithmetic_integral.rs:74:5 | LL | a % b; | ^^^^^ @@ -145,7 +145,7 @@ LL | a % b; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:77:5 + --> tests/ui/modulo_arithmetic_integral.rs:77:5 | LL | b %= a; | ^^^^^^ diff --git a/tests/ui/modulo_arithmetic_integral_const.stderr b/tests/ui/modulo_arithmetic_integral_const.stderr index 47ed2261a7b66..722d9b83660ee 100644 --- a/tests/ui/modulo_arithmetic_integral_const.stderr +++ b/tests/ui/modulo_arithmetic_integral_const.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:11:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:11:5 | LL | -1 % 2; | ^^^^^^ @@ -10,7 +10,7 @@ LL | -1 % 2; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:14:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:14:5 | LL | 1 % -2; | ^^^^^^ @@ -19,7 +19,7 @@ LL | 1 % -2; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 3` - --> $DIR/modulo_arithmetic_integral_const.rs:17:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:17:5 | LL | (1 - 2) % (1 + 2); | ^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | (1 - 2) % (1 + 2); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `3 % -1` - --> $DIR/modulo_arithmetic_integral_const.rs:20:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:20:5 | LL | (1 + 2) % (1 - 2); | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | (1 + 2) % (1 - 2); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-35 % 300000` - --> $DIR/modulo_arithmetic_integral_const.rs:23:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:23:5 | LL | 35 * (7 - 4 * 2) % (-500 * -600); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | 35 * (7 - 4 * 2) % (-500 * -600); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:27:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:27:5 | LL | -1i8 % 2i8; | ^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | -1i8 % 2i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:30:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:30:5 | LL | 1i8 % -2i8; | ^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | 1i8 % -2i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:33:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:33:5 | LL | -1i16 % 2i16; | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | -1i16 % 2i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:36:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:36:5 | LL | 1i16 % -2i16; | ^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | 1i16 % -2i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:39:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:39:5 | LL | -1i32 % 2i32; | ^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | -1i32 % 2i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:42:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:42:5 | LL | 1i32 % -2i32; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | 1i32 % -2i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:45:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:45:5 | LL | -1i64 % 2i64; | ^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | -1i64 % 2i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:48:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:48:5 | LL | 1i64 % -2i64; | ^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | 1i64 % -2i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:51:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:51:5 | LL | -1i128 % 2i128; | ^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | -1i128 % 2i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:54:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:54:5 | LL | 1i128 % -2i128; | ^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | 1i128 % -2i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:57:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:57:5 | LL | -1isize % 2isize; | ^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | -1isize % 2isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:60:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:60:5 | LL | 1isize % -2isize; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 06bbb0f5d9a80..aedcf24eae71e 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/modulo_one.rs:15:5 + --> tests/ui/modulo_one.rs:15:5 | LL | i32::MIN % (-1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow @@ -7,13 +7,13 @@ LL | i32::MIN % (-1); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/modulo_one.rs:33:5 + --> tests/ui/modulo_one.rs:33:5 | LL | INT_MIN % NEG_ONE; | ^^^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:8:5 + --> tests/ui/modulo_one.rs:8:5 | LL | 10 % 1; | ^^^^^^ @@ -22,31 +22,31 @@ LL | 10 % 1; = help: to override `-D warnings` add `#[allow(clippy::modulo_one)]` error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:11:5 + --> tests/ui/modulo_one.rs:11:5 | LL | 10 % -1; | ^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:15:5 + --> tests/ui/modulo_one.rs:15:5 | LL | i32::MIN % (-1); | ^^^^^^^^^^^^^^^ error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:24:5 + --> tests/ui/modulo_one.rs:24:5 | LL | 2 % ONE; | ^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:28:5 + --> tests/ui/modulo_one.rs:28:5 | LL | 2 % NEG_ONE; | ^^^^^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:33:5 + --> tests/ui/modulo_one.rs:33:5 | LL | INT_MIN % NEG_ONE; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/multi_assignments.stderr b/tests/ui/multi_assignments.stderr index 9719b5e66847b..53c22fcdb4c07 100644 --- a/tests/ui/multi_assignments.stderr +++ b/tests/ui/multi_assignments.stderr @@ -1,5 +1,5 @@ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:4:5 + --> tests/ui/multi_assignments.rs:4:5 | LL | a = b = c; | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | a = b = c; = help: to override `-D warnings` add `#[allow(clippy::multi_assignments)]` error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:7:5 + --> tests/ui/multi_assignments.rs:7:5 | LL | a = b = c = d; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:7:9 + --> tests/ui/multi_assignments.rs:7:9 | LL | a = b = c = d; | ^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:10:5 + --> tests/ui/multi_assignments.rs:10:5 | LL | a = b = { c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:12:5 + --> tests/ui/multi_assignments.rs:12:5 | LL | a = { b = c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:14:5 + --> tests/ui/multi_assignments.rs:14:5 | LL | a = (b = c); | ^^^^^^^^^^^ diff --git a/tests/ui/multiple_unsafe_ops_per_block.stderr b/tests/ui/multiple_unsafe_ops_per_block.stderr index 4803a5089ab25..cff85ae115e08 100644 --- a/tests/ui/multiple_unsafe_ops_per_block.stderr +++ b/tests/ui/multiple_unsafe_ops_per_block.stderr @@ -1,5 +1,5 @@ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:36:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:36:5 | LL | / unsafe { LL | | STATIC += 1; @@ -8,12 +8,12 @@ LL | | } | |_____^ | note: modification of a mutable static occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:37:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:37:9 | LL | STATIC += 1; | ^^^^^^^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:38:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:38:9 | LL | not_very_safe(); | ^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | not_very_safe(); = help: to override `-D warnings` add `#[allow(clippy::multiple_unsafe_ops_per_block)]` error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:45:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:45:5 | LL | / unsafe { LL | | drop(u.u); @@ -30,18 +30,18 @@ LL | | } | |_____^ | note: union field access occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:46:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:46:14 | LL | drop(u.u); | ^^^ note: raw pointer dereference occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:47:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:47:9 | LL | *raw_ptr(); | ^^^^^^^^^^ error: this `unsafe` block contains 3 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:52:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:52:5 | LL | / unsafe { LL | | asm!("nop"); @@ -51,23 +51,23 @@ LL | | } | |_____^ | note: inline assembly used here - --> $DIR/multiple_unsafe_ops_per_block.rs:53:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:53:9 | LL | asm!("nop"); | ^^^^^^^^^^^ note: unsafe method call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:54:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:54:9 | LL | sample.not_very_safe(); | ^^^^^^^^^^^^^^^^^^^^^^ note: modification of a mutable static occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:55:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:55:9 | LL | STATIC = 0; | ^^^^^^^^^^ error: this `unsafe` block contains 6 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:61:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:61:5 | LL | / unsafe { LL | | drop(u.u); @@ -79,55 +79,55 @@ LL | | } | |_____^ | note: union field access occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:62:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:62:14 | LL | drop(u.u); | ^^^ note: access of a mutable static occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:63:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:63:14 | LL | drop(STATIC); | ^^^^^^ note: unsafe method call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:64:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:64:9 | LL | sample.not_very_safe(); | ^^^^^^^^^^^^^^^^^^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:65:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:65:9 | LL | not_very_safe(); | ^^^^^^^^^^^^^^^ note: raw pointer dereference occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:66:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:66:9 | LL | *raw_ptr(); | ^^^^^^^^^^ note: inline assembly used here - --> $DIR/multiple_unsafe_ops_per_block.rs:67:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:67:9 | LL | asm!("nop"); | ^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:105:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:105:5 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:105:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:105:14 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: raw pointer dereference occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:105:39 + --> tests/ui/multiple_unsafe_ops_per_block.rs:105:39 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:123:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:123:5 | LL | / unsafe { LL | | x(); @@ -136,18 +136,18 @@ LL | | } | |_____^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:124:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:124:9 | LL | x(); | ^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:125:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:125:9 | LL | x(); | ^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:134:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:134:9 | LL | / unsafe { LL | | T::X(); @@ -156,18 +156,18 @@ LL | | } | |_________^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:135:13 + --> tests/ui/multiple_unsafe_ops_per_block.rs:135:13 | LL | T::X(); | ^^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:136:13 + --> tests/ui/multiple_unsafe_ops_per_block.rs:136:13 | LL | T::X(); | ^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:144:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:144:5 | LL | / unsafe { LL | | x.0(); @@ -176,12 +176,12 @@ LL | | } | |_____^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:145:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:145:9 | LL | x.0(); | ^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:146:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:146:9 | LL | x.0(); | ^^^^^ diff --git a/tests/ui/must_use_candidates.stderr b/tests/ui/must_use_candidates.stderr index 98175dbd45848..c64636ba44258 100644 --- a/tests/ui/must_use_candidates.stderr +++ b/tests/ui/must_use_candidates.stderr @@ -1,5 +1,5 @@ error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:11:1 + --> tests/ui/must_use_candidates.rs:11:1 | LL | pub fn pure(i: u8) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8` @@ -8,25 +8,25 @@ LL | pub fn pure(i: u8) -> u8 { = help: to override `-D warnings` add `#[allow(clippy::must_use_candidate)]` error: this method could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:16:5 + --> tests/ui/must_use_candidates.rs:16:5 | LL | pub fn inherent_pure(&self) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:47:1 + --> tests/ui/must_use_candidates.rs:47:1 | LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:59:1 + --> tests/ui/must_use_candidates.rs:59:1 | LL | pub fn rcd(_x: Rc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc) -> bool` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:67:1 + --> tests/ui/must_use_candidates.rs:67:1 | LL | pub fn arcd(_x: Arc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc) -> bool` diff --git a/tests/ui/must_use_unit.stderr b/tests/ui/must_use_unit.stderr index f2ee185857d3e..c2ee2edda7dc5 100644 --- a/tests/ui/must_use_unit.stderr +++ b/tests/ui/must_use_unit.stderr @@ -1,5 +1,5 @@ error: this unit-returning function has a `#[must_use]` attribute - --> $DIR/must_use_unit.rs:10:1 + --> tests/ui/must_use_unit.rs:10:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -10,7 +10,7 @@ LL | pub fn must_use_default() {} = help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]` error: this unit-returning function has a `#[must_use]` attribute - --> $DIR/must_use_unit.rs:13:1 + --> tests/ui/must_use_unit.rs:13:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -18,7 +18,7 @@ LL | pub fn must_use_unit() -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this unit-returning function has a `#[must_use]` attribute - --> $DIR/must_use_unit.rs:16:1 + --> tests/ui/must_use_unit.rs:16:1 | LL | #[must_use = "With note"] | ------------------------- help: remove the attribute diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index 38f47b9ad7b52..34fe91b5b3acb 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -1,11 +1,11 @@ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:7:39 + --> tests/ui/mut_from_ref.rs:7:39 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:7:29 + --> tests/ui/mut_from_ref.rs:7:29 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ @@ -13,61 +13,61 @@ LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { = help: to override `-D warnings` add `#[allow(clippy::mut_from_ref)]` error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:14:25 + --> tests/ui/mut_from_ref.rs:14:25 | LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:14:16 + --> tests/ui/mut_from_ref.rs:14:16 | LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:24:21 + --> tests/ui/mut_from_ref.rs:24:21 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:24:12 + --> tests/ui/mut_from_ref.rs:24:12 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:29:50 + --> tests/ui/mut_from_ref.rs:29:50 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:29:25 + --> tests/ui/mut_from_ref.rs:29:25 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:34:67 + --> tests/ui/mut_from_ref.rs:34:67 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:34:27 + --> tests/ui/mut_from_ref.rs:34:27 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:49:35 + --> tests/ui/mut_from_ref.rs:49:35 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:49:26 + --> tests/ui/mut_from_ref.rs:49:26 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^ diff --git a/tests/ui/mut_key.stderr b/tests/ui/mut_key.stderr index 48eeaff78a789..e54c3075d4f13 100644 --- a/tests/ui/mut_key.stderr +++ b/tests/ui/mut_key.stderr @@ -1,5 +1,5 @@ error: mutable key type - --> $DIR/mut_key.rs:31:32 + --> tests/ui/mut_key.rs:31:32 | LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,97 +8,97 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash = help: to override `-D warnings` add `#[allow(clippy::mutable_key_type)]` error: mutable key type - --> $DIR/mut_key.rs:31:72 + --> tests/ui/mut_key.rs:31:72 | LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { | ^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:35:5 + --> tests/ui/mut_key.rs:35:5 | LL | let _other: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:63:22 + --> tests/ui/mut_key.rs:63:22 | LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:76:5 + --> tests/ui/mut_key.rs:76:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:78:5 + --> tests/ui/mut_key.rs:78:5 | LL | let _map = HashMap::<&mut Cell, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:80:5 + --> tests/ui/mut_key.rs:80:5 | LL | let _map = HashMap::<&mut usize, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:83:5 + --> tests/ui/mut_key.rs:83:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:85:5 + --> tests/ui/mut_key.rs:85:5 | LL | let _map = HashMap::, ()>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:87:5 + --> tests/ui/mut_key.rs:87:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:89:5 + --> tests/ui/mut_key.rs:89:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:91:5 + --> tests/ui/mut_key.rs:91:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:93:5 + --> tests/ui/mut_key.rs:93:5 | LL | let _map = HashMap::>>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:95:5 + --> tests/ui/mut_key.rs:95:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:98:5 + --> tests/ui/mut_key.rs:98:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:100:5 + --> tests/ui/mut_key.rs:100:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:102:5 + --> tests/ui/mut_key.rs:102:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index 5ed9cd1aff99e..810c0c967437f 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,5 +1,5 @@ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:14:11 + --> tests/ui/mut_mut.rs:14:11 | LL | fn fun(x: &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | fn fun(x: &mut &mut u32) -> bool { = help: to override `-D warnings` add `#[allow(clippy::mut_mut)]` error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:31:17 + --> tests/ui/mut_mut.rs:31:17 | LL | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:46:25 + --> tests/ui/mut_mut.rs:46:25 | LL | let mut z = inline!(&mut $(&mut 3u32)); | ^ @@ -22,37 +22,37 @@ LL | let mut z = inline!(&mut $(&mut 3u32)); = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: this expression mutably borrows a mutable reference. Consider reborrowing - --> $DIR/mut_mut.rs:33:21 + --> tests/ui/mut_mut.rs:33:21 | LL | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:37:32 + --> tests/ui/mut_mut.rs:37:32 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:37:16 + --> tests/ui/mut_mut.rs:37:16 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:42:37 + --> tests/ui/mut_mut.rs:42:37 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:42:16 + --> tests/ui/mut_mut.rs:42:16 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:42:21 + --> tests/ui/mut_mut.rs:42:21 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ diff --git a/tests/ui/mut_mutex_lock.stderr b/tests/ui/mut_mutex_lock.stderr index 819602882766d..a3d4905c04cb7 100644 --- a/tests/ui/mut_mutex_lock.stderr +++ b/tests/ui/mut_mutex_lock.stderr @@ -1,5 +1,5 @@ error: calling `&mut Mutex::lock` unnecessarily locks an exclusive (mutable) reference - --> $DIR/mut_mutex_lock.rs:10:33 + --> tests/ui/mut_mutex_lock.rs:10:33 | LL | let mut value = value_mutex.lock().unwrap(); | ^^^^ help: change this to: `get_mut` diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index 42f8a161f74f7..6f93b0ebe6fcc 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -1,5 +1,5 @@ error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:8:9 + --> tests/ui/mut_range_bound.rs:8:9 | LL | m = 5; | ^ @@ -9,7 +9,7 @@ LL | m = 5; = help: to override `-D warnings` add `#[allow(clippy::mut_range_bound)]` error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:17:9 + --> tests/ui/mut_range_bound.rs:17:9 | LL | m *= 2; | ^ @@ -17,7 +17,7 @@ LL | m *= 2; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:27:9 + --> tests/ui/mut_range_bound.rs:27:9 | LL | m = 5; | ^ @@ -25,7 +25,7 @@ LL | m = 5; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:30:9 + --> tests/ui/mut_range_bound.rs:30:9 | LL | n = 7; | ^ @@ -33,7 +33,7 @@ LL | n = 7; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:46:22 + --> tests/ui/mut_range_bound.rs:46:22 | LL | let n = &mut m; | ^ @@ -41,7 +41,7 @@ LL | let n = &mut m; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:81:9 + --> tests/ui/mut_range_bound.rs:81:9 | LL | m = 2; | ^ @@ -49,7 +49,7 @@ LL | m = 2; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:93:13 + --> tests/ui/mut_range_bound.rs:93:13 | LL | n = 1; | ^ diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 87db08e2a7420..474221329c258 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,5 +1,5 @@ error: the function `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:30:34 + --> tests/ui/mut_reference.rs:30:34 | LL | takes_an_immutable_reference(&mut 42); | ^^^^^^^ @@ -8,13 +8,13 @@ LL | takes_an_immutable_reference(&mut 42); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]` error: the function `as_ptr` doesn't need a mutable reference - --> $DIR/mut_reference.rs:34:12 + --> tests/ui/mut_reference.rs:34:12 | LL | as_ptr(&mut 42); | ^^^^^^^ error: the method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:39:44 + --> tests/ui/mut_reference.rs:39:44 | LL | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 91f73d30b5386..683a7b939db3a 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,5 +1,5 @@ error: consider using an `AtomicBool` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:8:5 + --> tests/ui/mutex_atomic.rs:8:5 | LL | Mutex::new(true); | ^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | Mutex::new(true); = help: to override `-D warnings` add `#[allow(clippy::mutex_atomic)]` error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:11:5 + --> tests/ui/mutex_atomic.rs:11:5 | LL | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:13:5 + --> tests/ui/mutex_atomic.rs:13:5 | LL | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:16:5 + --> tests/ui/mutex_atomic.rs:16:5 | LL | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:18:5 + --> tests/ui/mutex_atomic.rs:18:5 | LL | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicU32` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:20:5 + --> tests/ui/mutex_atomic.rs:20:5 | LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ @@ -41,31 +41,31 @@ LL | Mutex::new(0u32); = help: to override `-D warnings` add `#[allow(clippy::mutex_integer)]` error: consider using an `AtomicI32` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:23:5 + --> tests/ui/mutex_atomic.rs:23:5 | LL | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: consider using an `AtomicU8` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:26:5 + --> tests/ui/mutex_atomic.rs:26:5 | LL | Mutex::new(0u8); | ^^^^^^^^^^^^^^^ error: consider using an `AtomicI16` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:28:5 + --> tests/ui/mutex_atomic.rs:28:5 | LL | Mutex::new(0i16); | ^^^^^^^^^^^^^^^^ error: consider using an `AtomicI8` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:30:25 + --> tests/ui/mutex_atomic.rs:30:25 | LL | let _x: Mutex = Mutex::new(0); | ^^^^^^^^^^^^^ error: consider using an `AtomicI64` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:33:5 + --> tests/ui/mutex_atomic.rs:33:5 | LL | Mutex::new(X); | ^^^^^^^^^^^^^ diff --git a/tests/ui/needless_arbitrary_self_type.stderr b/tests/ui/needless_arbitrary_self_type.stderr index fe2ac34f79f67..c653267f7525b 100644 --- a/tests/ui/needless_arbitrary_self_type.stderr +++ b/tests/ui/needless_arbitrary_self_type.stderr @@ -1,5 +1,5 @@ error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:10:16 + --> tests/ui/needless_arbitrary_self_type.rs:10:16 | LL | pub fn bad(self: Self) { | ^^^^^^^^^^ help: consider to change this parameter to: `self` @@ -8,31 +8,31 @@ LL | pub fn bad(self: Self) { = help: to override `-D warnings` add `#[allow(clippy::needless_arbitrary_self_type)]` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:18:20 + --> tests/ui/needless_arbitrary_self_type.rs:18:20 | LL | pub fn mut_bad(mut self: Self) { | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `mut self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:26:20 + --> tests/ui/needless_arbitrary_self_type.rs:26:20 | LL | pub fn ref_bad(self: &Self) { | ^^^^^^^^^^^ help: consider to change this parameter to: `&self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:34:38 + --> tests/ui/needless_arbitrary_self_type.rs:34:38 | LL | pub fn ref_bad_with_lifetime<'a>(self: &'a Self) { | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:42:24 + --> tests/ui/needless_arbitrary_self_type.rs:42:24 | LL | pub fn mut_ref_bad(self: &mut Self) { | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:50:42 + --> tests/ui/needless_arbitrary_self_type.rs:50:42 | LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) { | ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self` diff --git a/tests/ui/needless_arbitrary_self_type_unfixable.stderr b/tests/ui/needless_arbitrary_self_type_unfixable.stderr index e91359a3cc182..b50e005756290 100644 --- a/tests/ui/needless_arbitrary_self_type_unfixable.stderr +++ b/tests/ui/needless_arbitrary_self_type_unfixable.stderr @@ -1,5 +1,5 @@ error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type_unfixable.rs:42:31 + --> tests/ui/needless_arbitrary_self_type_unfixable.rs:42:31 | LL | fn call_with_mut_self(self: &mut Self) {} | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` diff --git a/tests/ui/needless_bitwise_bool.stderr b/tests/ui/needless_bitwise_bool.stderr index b1fc1a7a95851..f29d4492540f9 100644 --- a/tests/ui/needless_bitwise_bool.stderr +++ b/tests/ui/needless_bitwise_bool.stderr @@ -1,5 +1,5 @@ error: use of bitwise operator instead of lazy operator between booleans - --> $DIR/needless_bitwise_bool.rs:22:8 + --> tests/ui/needless_bitwise_bool.rs:22:8 | LL | if y & !x { | ^^^^^^ help: try: `y && !x` diff --git a/tests/ui/needless_bool/fixable.stderr b/tests/ui/needless_bool/fixable.stderr index 67018d8d70639..9746e931f50f0 100644 --- a/tests/ui/needless_bool/fixable.stderr +++ b/tests/ui/needless_bool/fixable.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:41:5 + --> tests/ui/needless_bool/fixable.rs:41:5 | LL | / if x { LL | | true @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:46:5 + --> tests/ui/needless_bool/fixable.rs:46:5 | LL | / if x { LL | | false @@ -22,7 +22,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:51:5 + --> tests/ui/needless_bool/fixable.rs:51:5 | LL | / if x && y { LL | | false @@ -32,7 +32,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!(x && y)` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:59:5 + --> tests/ui/needless_bool/fixable.rs:59:5 | LL | / if a == b { LL | | false @@ -42,7 +42,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a != b` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:64:5 + --> tests/ui/needless_bool/fixable.rs:64:5 | LL | / if a != b { LL | | false @@ -52,7 +52,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a == b` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:69:5 + --> tests/ui/needless_bool/fixable.rs:69:5 | LL | / if a < b { LL | | false @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a >= b` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:74:5 + --> tests/ui/needless_bool/fixable.rs:74:5 | LL | / if a <= b { LL | | false @@ -72,7 +72,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a > b` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:79:5 + --> tests/ui/needless_bool/fixable.rs:79:5 | LL | / if a > b { LL | | false @@ -82,7 +82,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a <= b` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:84:5 + --> tests/ui/needless_bool/fixable.rs:84:5 | LL | / if a >= b { LL | | false @@ -92,7 +92,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a < b` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:112:5 + --> tests/ui/needless_bool/fixable.rs:112:5 | LL | / if x { LL | | return true; @@ -102,7 +102,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:120:5 + --> tests/ui/needless_bool/fixable.rs:120:5 | LL | / if x { LL | | return false; @@ -112,7 +112,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:128:5 + --> tests/ui/needless_bool/fixable.rs:128:5 | LL | / if x && y { LL | | return true; @@ -122,7 +122,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:136:5 + --> tests/ui/needless_bool/fixable.rs:136:5 | LL | / if x && y { LL | | return false; @@ -132,7 +132,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/needless_bool/fixable.rs:144:8 + --> tests/ui/needless_bool/fixable.rs:144:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -141,25 +141,25 @@ LL | if x == true {}; = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool/fixable.rs:148:8 + --> tests/ui/needless_bool/fixable.rs:148:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/needless_bool/fixable.rs:158:8 + --> tests/ui/needless_bool/fixable.rs:158:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool/fixable.rs:159:8 + --> tests/ui/needless_bool/fixable.rs:159:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:168:12 + --> tests/ui/needless_bool/fixable.rs:168:12 | LL | } else if returns_bool() { | ____________^ @@ -170,7 +170,7 @@ LL | | }; | |_____^ help: you can reduce it to: `{ !returns_bool() }` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:181:5 + --> tests/ui/needless_bool/fixable.rs:181:5 | LL | / if unsafe { no(4) } & 1 != 0 { LL | | true @@ -180,13 +180,13 @@ LL | | }; | |_____^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:186:30 + --> tests/ui/needless_bool/fixable.rs:186:30 | LL | let _brackets_unneeded = if unsafe { no(4) } & 1 != 0 { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `unsafe { no(4) } & 1 != 0` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool/fixable.rs:189:9 + --> tests/ui/needless_bool/fixable.rs:189:9 | LL | if unsafe { no(4) } & 1 != 0 { true } else { false } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` diff --git a/tests/ui/needless_bool/simple.stderr b/tests/ui/needless_bool/simple.stderr index 6846565b68e1d..bf30a56f43e7b 100644 --- a/tests/ui/needless_bool/simple.stderr +++ b/tests/ui/needless_bool/simple.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression will always return true - --> $DIR/needless_bool/simple.rs:14:5 + --> tests/ui/needless_bool/simple.rs:14:5 | LL | / if x { LL | | true @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression will always return false - --> $DIR/needless_bool/simple.rs:19:5 + --> tests/ui/needless_bool/simple.rs:19:5 | LL | / if x { LL | | false @@ -22,7 +22,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return true - --> $DIR/needless_bool/simple.rs:34:5 + --> tests/ui/needless_bool/simple.rs:34:5 | LL | / if x { LL | | return true; @@ -32,7 +32,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return false - --> $DIR/needless_bool/simple.rs:42:5 + --> tests/ui/needless_bool/simple.rs:42:5 | LL | / if x { LL | | return false; diff --git a/tests/ui/needless_bool_assign.stderr b/tests/ui/needless_bool_assign.stderr index 244a88e6691fd..2d80dded39c31 100644 --- a/tests/ui/needless_bool_assign.stderr +++ b/tests/ui/needless_bool_assign.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression assigns a bool literal - --> $DIR/needless_bool_assign.rs:13:5 + --> tests/ui/needless_bool_assign.rs:13:5 | LL | / if random() && random() { LL | | a.field = true; @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::needless_bool_assign)]` error: this if-then-else expression assigns a bool literal - --> $DIR/needless_bool_assign.rs:18:5 + --> tests/ui/needless_bool_assign.rs:18:5 | LL | / if random() && random() { LL | | a.field = false; @@ -22,7 +22,7 @@ LL | | } | |_____^ help: you can reduce it to: `a.field = !(random() && random());` error: this if-then-else expression assigns a bool literal - --> $DIR/needless_bool_assign.rs:32:5 + --> tests/ui/needless_bool_assign.rs:32:5 | LL | / if random() { LL | | a.field = true; @@ -32,7 +32,7 @@ LL | | } | |_____^ help: you can reduce it to: `random(); a.field = true;` error: this `if` has identical blocks - --> $DIR/needless_bool_assign.rs:32:17 + --> tests/ui/needless_bool_assign.rs:32:17 | LL | if random() { | _________________^ @@ -41,7 +41,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/needless_bool_assign.rs:34:12 + --> tests/ui/needless_bool_assign.rs:34:12 | LL | } else { | ____________^ diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index a21ed8382c14e..f31412b054ce3 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,5 +1,5 @@ error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:15:15 + --> tests/ui/needless_borrow.rs:15:15 | LL | let _ = x(&&a); // warn | ^^^ help: change this to: `&a` @@ -8,157 +8,157 @@ LL | let _ = x(&&a); // warn = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:19:13 + --> tests/ui/needless_borrow.rs:19:13 | LL | mut_ref(&mut &mut b); // warn | ^^^^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:31:13 + --> tests/ui/needless_borrow.rs:31:13 | LL | &&a | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:33:15 + --> tests/ui/needless_borrow.rs:33:15 | LL | 46 => &&a, | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:39:27 + --> tests/ui/needless_borrow.rs:39:27 | LL | break &ref_a; | ^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:46:15 + --> tests/ui/needless_borrow.rs:46:15 | LL | let _ = x(&&&a); | ^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:47:15 + --> tests/ui/needless_borrow.rs:47:15 | LL | let _ = x(&mut &&a); | ^^^^^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:48:15 + --> tests/ui/needless_borrow.rs:48:15 | LL | let _ = x(&&&mut b); | ^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:49:15 + --> tests/ui/needless_borrow.rs:49:15 | LL | let _ = x(&&ref_a); | ^^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:52:11 + --> tests/ui/needless_borrow.rs:52:11 | LL | x(&b); | ^^ help: change this to: `b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:59:13 + --> tests/ui/needless_borrow.rs:59:13 | LL | mut_ref(&mut x); | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:60:13 + --> tests/ui/needless_borrow.rs:60:13 | LL | mut_ref(&mut &mut x); | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:61:23 + --> tests/ui/needless_borrow.rs:61:23 | LL | let y: &mut i32 = &mut x; | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:62:23 + --> tests/ui/needless_borrow.rs:62:23 | LL | let y: &mut i32 = &mut &mut x; | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:71:14 + --> tests/ui/needless_borrow.rs:71:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:77:14 + --> tests/ui/needless_borrow.rs:77:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:89:13 + --> tests/ui/needless_borrow.rs:89:13 | LL | let _ = (&x).0; | ^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:91:22 + --> tests/ui/needless_borrow.rs:91:22 | LL | let _ = unsafe { (&*x).0 }; | ^^^^^ help: change this to: `(*x)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:101:5 + --> tests/ui/needless_borrow.rs:101:5 | LL | (&&()).foo(); | ^^^^^^ help: change this to: `(&())` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:110:5 + --> tests/ui/needless_borrow.rs:110:5 | LL | (&&5).foo(); | ^^^^^ help: change this to: `(&5)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:136:23 + --> tests/ui/needless_borrow.rs:136:23 | LL | let x: (&str,) = (&"",); | ^^^ help: change this to: `""` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:178:13 + --> tests/ui/needless_borrow.rs:178:13 | LL | (&self.f)() | ^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:187:13 + --> tests/ui/needless_borrow.rs:187:13 | LL | (&mut self.f)() | ^^^^^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:224:22 + --> tests/ui/needless_borrow.rs:224:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:231:22 + --> tests/ui/needless_borrow.rs:231:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:235:22 + --> tests/ui/needless_borrow.rs:235:22 | LL | let _ = &mut (&mut x.u).x; | ^^^^^^^^^^ help: change this to: `x.u` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:236:22 + --> tests/ui/needless_borrow.rs:236:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` diff --git a/tests/ui/needless_borrow_pat.stderr b/tests/ui/needless_borrow_pat.stderr index ce3a36e35b857..2ad6944903967 100644 --- a/tests/ui/needless_borrow_pat.stderr +++ b/tests/ui/needless_borrow_pat.stderr @@ -1,5 +1,5 @@ error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:59:14 + --> tests/ui/needless_borrow_pat.rs:59:14 | LL | Some(ref x) => x, | ^^^^^ help: try: `x` @@ -8,7 +8,7 @@ LL | Some(ref x) => x, = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:67:14 + --> tests/ui/needless_borrow_pat.rs:67:14 | LL | Some(ref x) => *x, | ^^^^^ @@ -19,7 +19,7 @@ LL | Some(x) => x, | ~ ~ error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:74:14 + --> tests/ui/needless_borrow_pat.rs:74:14 | LL | Some(ref x) => { | ^^^^^ @@ -33,19 +33,19 @@ LL ~ f1(x); | error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:85:14 + --> tests/ui/needless_borrow_pat.rs:85:14 | LL | Some(ref x) => m1!(x), | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:91:15 + --> tests/ui/needless_borrow_pat.rs:91:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:97:10 + --> tests/ui/needless_borrow_pat.rs:97:10 | LL | let (ref y,) = (&x,); | ^^^^^ @@ -58,13 +58,13 @@ LL ~ let _: &String = y; | error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:108:14 + --> tests/ui/needless_borrow_pat.rs:108:14 | LL | Some(ref x) => x.0, | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:119:14 + --> tests/ui/needless_borrow_pat.rs:119:14 | LL | E::A(ref x) | E::B(ref x) => *x, | ^^^^^ ^^^^^ @@ -75,13 +75,13 @@ LL | E::A(x) | E::B(x) => x, | ~ ~ ~ error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:126:21 + --> tests/ui/needless_borrow_pat.rs:126:21 | LL | if let Some(ref x) = Some(&String::new()); | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:135:12 + --> tests/ui/needless_borrow_pat.rs:135:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { | ^^^^^ @@ -95,13 +95,13 @@ LL ~ x | error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:143:11 + --> tests/ui/needless_borrow_pat.rs:143:11 | LL | fn f(&ref x: &&String) { | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:152:11 + --> tests/ui/needless_borrow_pat.rs:152:11 | LL | fn f(&ref x: &&String) { | ^^^^^ diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index 15261cfce0c35..b8181e2805c9c 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -1,5 +1,5 @@ error: this pattern takes a reference on something that is being dereferenced - --> $DIR/needless_borrowed_ref.rs:30:34 + --> tests/ui/needless_borrowed_ref.rs:30:34 | LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ @@ -13,7 +13,7 @@ LL + let _ = v.iter_mut().filter(|a| a.is_empty()); | error: this pattern takes a reference on something that is being dereferenced - --> $DIR/needless_borrowed_ref.rs:34:17 + --> tests/ui/needless_borrowed_ref.rs:34:17 | LL | if let Some(&ref v) = thingy {} | ^^^^^^ @@ -25,7 +25,7 @@ LL + if let Some(v) = thingy {} | error: this pattern takes a reference on something that is being dereferenced - --> $DIR/needless_borrowed_ref.rs:36:14 + --> tests/ui/needless_borrowed_ref.rs:36:14 | LL | if let &[&ref a, ref b] = slice_of_refs {} | ^^^^^^ @@ -37,7 +37,7 @@ LL + if let &[a, ref b] = slice_of_refs {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:38:9 + --> tests/ui/needless_borrowed_ref.rs:38:9 | LL | let &[ref a, ..] = &array; | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + let [a, ..] = &array; | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:39:9 + --> tests/ui/needless_borrowed_ref.rs:39:9 | LL | let &[ref a, ref b, ..] = &array; | ^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + let [a, b, ..] = &array; | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:41:12 + --> tests/ui/needless_borrowed_ref.rs:41:12 | LL | if let &[ref a, ref b] = slice {} | ^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + if let [a, b] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:42:12 + --> tests/ui/needless_borrowed_ref.rs:42:12 | LL | if let &[ref a, ref b] = &vec[..] {} | ^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + if let [a, b] = &vec[..] {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:44:12 + --> tests/ui/needless_borrowed_ref.rs:44:12 | LL | if let &[ref a, ref b, ..] = slice {} | ^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + if let [a, b, ..] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:45:12 + --> tests/ui/needless_borrowed_ref.rs:45:12 | LL | if let &[ref a, .., ref b] = slice {} | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + if let [a, .., b] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:46:12 + --> tests/ui/needless_borrowed_ref.rs:46:12 | LL | if let &[.., ref a, ref b] = slice {} | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + if let [.., a, b] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:48:12 + --> tests/ui/needless_borrowed_ref.rs:48:12 | LL | if let &[ref a, _] = slice {} | ^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + if let [a, _] = slice {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:50:12 + --> tests/ui/needless_borrowed_ref.rs:50:12 | LL | if let &(ref a, ref b, ref c) = &tuple {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + if let (a, b, c) = &tuple {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:51:12 + --> tests/ui/needless_borrowed_ref.rs:51:12 | LL | if let &(ref a, _, ref c) = &tuple {} | ^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + if let (a, _, c) = &tuple {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:52:12 + --> tests/ui/needless_borrowed_ref.rs:52:12 | LL | if let &(ref a, ..) = &tuple {} | ^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL + if let (a, ..) = &tuple {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:54:12 + --> tests/ui/needless_borrowed_ref.rs:54:12 | LL | if let &TupleStruct(ref a, ..) = &tuple_struct {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + if let TupleStruct(a, ..) = &tuple_struct {} | error: dereferencing a struct pattern where every field's pattern takes a reference - --> $DIR/needless_borrowed_ref.rs:56:12 + --> tests/ui/needless_borrowed_ref.rs:56:12 | LL | if let &Struct { | ____________^ @@ -200,7 +200,7 @@ LL ~ c: renamed, | error: dereferencing a struct pattern where every field's pattern takes a reference - --> $DIR/needless_borrowed_ref.rs:63:12 + --> tests/ui/needless_borrowed_ref.rs:63:12 | LL | if let &Struct { ref a, b: _, .. } = &s {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/needless_borrows_for_generic_args.stderr b/tests/ui/needless_borrows_for_generic_args.stderr index e2cde2c59a6e0..83c076f8d863a 100644 --- a/tests/ui/needless_borrows_for_generic_args.stderr +++ b/tests/ui/needless_borrows_for_generic_args.stderr @@ -1,5 +1,5 @@ error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:16:37 + --> tests/ui/needless_borrows_for_generic_args.rs:16:37 | LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` @@ -8,67 +8,67 @@ LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::needless_borrows_for_generic_args)]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:17:33 + --> tests/ui/needless_borrows_for_generic_args.rs:17:33 | LL | let _ = Path::new(".").join(&&"."); | ^^^^^ help: change this to: `"."` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:21:33 + --> tests/ui/needless_borrows_for_generic_args.rs:21:33 | LL | let _ = std::fs::write("x", &"".to_string()); | ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:36:27 + --> tests/ui/needless_borrows_for_generic_args.rs:36:27 | LL | deref_target_is_x(&X); | ^^ help: change this to: `X` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:49:30 + --> tests/ui/needless_borrows_for_generic_args.rs:49:30 | LL | multiple_constraints(&[[""]]); | ^^^^^^^ help: change this to: `[[""]]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:69:49 + --> tests/ui/needless_borrows_for_generic_args.rs:69:49 | LL | multiple_constraints_normalizes_to_same(&X, X); | ^^ help: change this to: `X` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:127:24 + --> tests/ui/needless_borrows_for_generic_args.rs:127:24 | LL | takes_iter(&mut x) | ^^^^^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:136:41 + --> tests/ui/needless_borrows_for_generic_args.rs:136:41 | LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:144:41 + --> tests/ui/needless_borrows_for_generic_args.rs:144:41 | LL | let _ = std::fs::write("x", &arg); | ^^^^ help: change this to: `arg` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:145:41 + --> tests/ui/needless_borrows_for_generic_args.rs:145:41 | LL | let _ = std::fs::write("x", &loc); | ^^^^ help: change this to: `loc` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:167:11 + --> tests/ui/needless_borrows_for_generic_args.rs:167:11 | LL | f(&x); | ^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:247:13 + --> tests/ui/needless_borrows_for_generic_args.rs:247:13 | LL | foo(&a); | ^^ help: change this to: `a` diff --git a/tests/ui/needless_collect.stderr b/tests/ui/needless_collect.stderr index 2c21fc5965d56..ea317896d3684 100644 --- a/tests/ui/needless_collect.stderr +++ b/tests/ui/needless_collect.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:9:29 + --> tests/ui/needless_collect.rs:9:29 | LL | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` @@ -8,109 +8,109 @@ LL | let len = sample.iter().collect::>().len(); = help: to override `-D warnings` add `#[allow(clippy::needless_collect)]` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:10:22 + --> tests/ui/needless_collect.rs:10:22 | LL | if sample.iter().collect::>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:13:28 + --> tests/ui/needless_collect.rs:13:28 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:18:35 + --> tests/ui/needless_collect.rs:18:35 | LL | sample.iter().map(|x| (x, x)).collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:19:35 + --> tests/ui/needless_collect.rs:19:35 | LL | sample.iter().map(|x| (x, x)).collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:26:19 + --> tests/ui/needless_collect.rs:26:19 | LL | sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:27:19 + --> tests/ui/needless_collect.rs:27:19 | LL | sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:28:28 + --> tests/ui/needless_collect.rs:28:28 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:29:19 + --> tests/ui/needless_collect.rs:29:19 | LL | sample.iter().collect::>().contains(&&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:32:19 + --> tests/ui/needless_collect.rs:32:19 | LL | sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:33:19 + --> tests/ui/needless_collect.rs:33:19 | LL | sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:38:27 + --> tests/ui/needless_collect.rs:38:27 | LL | let _ = sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:39:27 + --> tests/ui/needless_collect.rs:39:27 | LL | let _ = sample.iter().collect::>().contains(&&0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &0)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:61:27 + --> tests/ui/needless_collect.rs:61:27 | LL | let _ = sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:62:27 + --> tests/ui/needless_collect.rs:62:27 | LL | let _ = sample.iter().collect::>().contains(&&0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &0)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:66:40 + --> tests/ui/needless_collect.rs:66:40 | LL | Vec::::new().extend((0..10).collect::>()); | ^^^^^^^^^^^^^^^^^^^^ help: remove this call error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:67:20 + --> tests/ui/needless_collect.rs:67:20 | LL | foo((0..10).collect::>()); | ^^^^^^^^^^^^^^^^^^^^ help: remove this call error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:68:49 + --> tests/ui/needless_collect.rs:68:49 | LL | bar((0..10).collect::>(), (0..10).collect::>()); | ^^^^^^^^^^^^^^^^^^^^ help: remove this call error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:69:37 + --> tests/ui/needless_collect.rs:69:37 | LL | baz((0..10), (), ('a'..='z').collect::>()) | ^^^^^^^^^^^^^^^^^^^^ help: remove this call diff --git a/tests/ui/needless_collect_indirect.stderr b/tests/ui/needless_collect_indirect.stderr index 3d1ad2a1cfa55..0cce718a1ac7a 100644 --- a/tests/ui/needless_collect_indirect.stderr +++ b/tests/ui/needless_collect_indirect.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:9:39 + --> tests/ui/needless_collect_indirect.rs:9:39 | LL | let indirect_iter = sample.iter().collect::>(); | ^^^^^^^ @@ -18,7 +18,7 @@ LL ~ sample.iter().map(|x| (x, x + 1)).collect::>(); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:13:38 + --> tests/ui/needless_collect_indirect.rs:13:38 | LL | let indirect_len = sample.iter().collect::>(); | ^^^^^^^ @@ -34,7 +34,7 @@ LL ~ sample.iter().count(); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:16:40 + --> tests/ui/needless_collect_indirect.rs:16:40 | LL | let indirect_empty = sample.iter().collect::>(); | ^^^^^^^ @@ -50,7 +50,7 @@ LL ~ sample.iter().next().is_none(); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:19:43 + --> tests/ui/needless_collect_indirect.rs:19:43 | LL | let indirect_contains = sample.iter().collect::>(); | ^^^^^^^ @@ -66,7 +66,7 @@ LL ~ sample.iter().any(|x| x == &5); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:32:48 + --> tests/ui/needless_collect_indirect.rs:32:48 | LL | let non_copy_contains = sample.into_iter().collect::>(); | ^^^^^^^ @@ -82,7 +82,7 @@ LL ~ sample.into_iter().any(|x| x == a); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:62:51 + --> tests/ui/needless_collect_indirect.rs:62:51 | LL | let buffer: Vec<&str> = string.split('/').collect(); | ^^^^^^^ @@ -98,7 +98,7 @@ LL ~ string.split('/').count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:68:55 + --> tests/ui/needless_collect_indirect.rs:68:55 | LL | let indirect_len: VecDeque<_> = sample.iter().collect(); | ^^^^^^^ @@ -114,7 +114,7 @@ LL ~ sample.iter().count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:74:57 + --> tests/ui/needless_collect_indirect.rs:74:57 | LL | let indirect_len: LinkedList<_> = sample.iter().collect(); | ^^^^^^^ @@ -130,7 +130,7 @@ LL ~ sample.iter().count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:80:57 + --> tests/ui/needless_collect_indirect.rs:80:57 | LL | let indirect_len: BinaryHeap<_> = sample.iter().collect(); | ^^^^^^^ @@ -146,7 +146,7 @@ LL ~ sample.iter().count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:141:59 + --> tests/ui/needless_collect_indirect.rs:141:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -164,7 +164,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == i); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:167:59 + --> tests/ui/needless_collect_indirect.rs:167:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -182,7 +182,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:197:63 + --> tests/ui/needless_collect_indirect.rs:197:63 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -200,7 +200,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:234:59 + --> tests/ui/needless_collect_indirect.rs:234:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -218,7 +218,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:260:26 + --> tests/ui/needless_collect_indirect.rs:260:26 | LL | let w = v.iter().collect::>(); | ^^^^^^^ @@ -235,7 +235,7 @@ LL ~ for _ in 0..v.iter().count() { | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:283:30 + --> tests/ui/needless_collect_indirect.rs:283:30 | LL | let mut w = v.iter().collect::>(); | ^^^^^^^ @@ -252,7 +252,7 @@ LL ~ while 1 == v.iter().count() { | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:306:30 + --> tests/ui/needless_collect_indirect.rs:306:30 | LL | let mut w = v.iter().collect::>(); | ^^^^^^^ diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 31b5dc2808da1..ec7c9ba39a72a 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -1,5 +1,5 @@ error: this `else` block is redundant - --> $DIR/needless_continue.rs:30:16 + --> tests/ui/needless_continue.rs:30:16 | LL | } else { | ________________^ @@ -38,7 +38,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::needless_continue)]` error: there is no need for an explicit `else` block for this `if` expression - --> $DIR/needless_continue.rs:46:9 + --> tests/ui/needless_continue.rs:46:9 | LL | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { LL | | @@ -60,7 +60,7 @@ LL | | } } error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:60:9 + --> tests/ui/needless_continue.rs:60:9 | LL | continue; | ^^^^^^^^^ @@ -68,7 +68,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:68:9 + --> tests/ui/needless_continue.rs:68:9 | LL | continue; | ^^^^^^^^^ @@ -76,7 +76,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:76:9 + --> tests/ui/needless_continue.rs:76:9 | LL | continue | ^^^^^^^^ @@ -84,7 +84,7 @@ LL | continue = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:85:9 + --> tests/ui/needless_continue.rs:85:9 | LL | continue | ^^^^^^^^ @@ -92,7 +92,7 @@ LL | continue = help: consider dropping the `continue` expression error: this `else` block is redundant - --> $DIR/needless_continue.rs:136:24 + --> tests/ui/needless_continue.rs:136:24 | LL | } else { | ________________________^ @@ -117,7 +117,7 @@ LL | | } } error: there is no need for an explicit `else` block for this `if` expression - --> $DIR/needless_continue.rs:143:17 + --> tests/ui/needless_continue.rs:143:17 | LL | / if condition() { LL | | diff --git a/tests/ui/needless_doc_main.stderr b/tests/ui/needless_doc_main.stderr index 84256548671d1..7e362cf377ce4 100644 --- a/tests/ui/needless_doc_main.stderr +++ b/tests/ui/needless_doc_main.stderr @@ -1,5 +1,5 @@ error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:7:5 + --> tests/ui/needless_doc_main.rs:7:5 | LL | /// fn main() { | _____^ @@ -13,7 +13,7 @@ LL | | /// } = help: to override `-D warnings` add `#[allow(clippy::needless_doctest_main)]` error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:16:5 + --> tests/ui/needless_doc_main.rs:16:5 | LL | /// fn main() -> () { | _____^ @@ -23,7 +23,7 @@ LL | | /// } | |_____^ error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:24:5 + --> tests/ui/needless_doc_main.rs:24:5 | LL | /// fn main() { | _____^ @@ -33,7 +33,7 @@ LL | | /// } | |_____^ error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:32:5 + --> tests/ui/needless_doc_main.rs:32:5 | LL | /// // the fn is not always the first line | _____^ diff --git a/tests/ui/needless_else.stderr b/tests/ui/needless_else.stderr index 66552109c48e1..77ead31b31cc9 100644 --- a/tests/ui/needless_else.stderr +++ b/tests/ui/needless_else.stderr @@ -1,5 +1,5 @@ error: this `else` branch is empty - --> $DIR/needless_else.rs:23:7 + --> tests/ui/needless_else.rs:23:7 | LL | } else { | _______^ diff --git a/tests/ui/needless_for_each_fixable.stderr b/tests/ui/needless_for_each_fixable.stderr index 3b5163b0171a9..21342d0525618 100644 --- a/tests/ui/needless_for_each_fixable.stderr +++ b/tests/ui/needless_for_each_fixable.stderr @@ -1,5 +1,5 @@ error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:15:5 + --> tests/ui/needless_for_each_fixable.rs:15:5 | LL | / v.iter().for_each(|elem| { LL | | acc += elem; @@ -16,7 +16,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:18:5 + --> tests/ui/needless_for_each_fixable.rs:18:5 | LL | / v.into_iter().for_each(|elem| { LL | | acc += elem; @@ -31,7 +31,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:22:5 + --> tests/ui/needless_for_each_fixable.rs:22:5 | LL | / [1, 2, 3].iter().for_each(|elem| { LL | | acc += elem; @@ -46,7 +46,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:27:5 + --> tests/ui/needless_for_each_fixable.rs:27:5 | LL | / hash_map.iter().for_each(|(k, v)| { LL | | acc += k + v; @@ -61,7 +61,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:30:5 + --> tests/ui/needless_for_each_fixable.rs:30:5 | LL | / hash_map.iter_mut().for_each(|(k, v)| { LL | | acc += *k + *v; @@ -76,7 +76,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:33:5 + --> tests/ui/needless_for_each_fixable.rs:33:5 | LL | / hash_map.keys().for_each(|k| { LL | | acc += k; @@ -91,7 +91,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:36:5 + --> tests/ui/needless_for_each_fixable.rs:36:5 | LL | / hash_map.values().for_each(|v| { LL | | acc += v; @@ -106,7 +106,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:43:5 + --> tests/ui/needless_for_each_fixable.rs:43:5 | LL | / my_vec().iter().for_each(|elem| { LL | | acc += elem; diff --git a/tests/ui/needless_for_each_unfixable.stderr b/tests/ui/needless_for_each_unfixable.stderr index 24a22e232485b..9d3f639efbf27 100644 --- a/tests/ui/needless_for_each_unfixable.stderr +++ b/tests/ui/needless_for_each_unfixable.stderr @@ -1,5 +1,5 @@ error: needless use of `for_each` - --> $DIR/needless_for_each_unfixable.rs:8:5 + --> tests/ui/needless_for_each_unfixable.rs:8:5 | LL | / v.iter().for_each(|v| { LL | | diff --git a/tests/ui/needless_if.stderr b/tests/ui/needless_if.stderr index 9a911b4dbaccc..9beae596ee39d 100644 --- a/tests/ui/needless_if.stderr +++ b/tests/ui/needless_if.stderr @@ -1,5 +1,5 @@ error: this `if` branch is empty - --> $DIR/needless_if.rs:27:5 + --> tests/ui/needless_if.rs:27:5 | LL | if (true) {} | ^^^^^^^^^^^^ help: you can remove it @@ -8,13 +8,13 @@ LL | if (true) {} = help: to override `-D warnings` add `#[allow(clippy::needless_if)]` error: this `if` branch is empty - --> $DIR/needless_if.rs:29:5 + --> tests/ui/needless_if.rs:29:5 | LL | if maybe_side_effect() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `maybe_side_effect();` error: this `if` branch is empty - --> $DIR/needless_if.rs:34:5 + --> tests/ui/needless_if.rs:34:5 | LL | / if { LL | | return; @@ -29,7 +29,7 @@ LL + }); | error: this `if` branch is empty - --> $DIR/needless_if.rs:50:5 + --> tests/ui/needless_if.rs:50:5 | LL | / if { LL | | if let true = true @@ -54,19 +54,19 @@ LL + } && true); | error: this `if` branch is empty - --> $DIR/needless_if.rs:94:5 + --> tests/ui/needless_if.rs:94:5 | LL | if { maybe_side_effect() } {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() });` error: this `if` branch is empty - --> $DIR/needless_if.rs:96:5 + --> tests/ui/needless_if.rs:96:5 | LL | if { maybe_side_effect() } && true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() } && true);` error: this `if` branch is empty - --> $DIR/needless_if.rs:100:5 + --> tests/ui/needless_if.rs:100:5 | LL | if true {} | ^^^^^^^^^^ help: you can remove it: `true;` diff --git a/tests/ui/needless_late_init.stderr b/tests/ui/needless_late_init.stderr index 602b1a683e51d..1695784030d02 100644 --- a/tests/ui/needless_late_init.stderr +++ b/tests/ui/needless_late_init.stderr @@ -1,5 +1,5 @@ error: unneeded late initialization - --> $DIR/needless_late_init.rs:27:5 + --> tests/ui/needless_late_init.rs:27:5 | LL | let a; | ^^^^^^ created here @@ -14,7 +14,7 @@ LL | let a = "zero"; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:30:5 + --> tests/ui/needless_late_init.rs:30:5 | LL | let b; | ^^^^^^ created here @@ -28,7 +28,7 @@ LL | let b = 1; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:31:5 + --> tests/ui/needless_late_init.rs:31:5 | LL | let c; | ^^^^^^ created here @@ -42,7 +42,7 @@ LL | let c = 2; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:35:5 + --> tests/ui/needless_late_init.rs:35:5 | LL | let d: usize; | ^^^^^^^^^^^^^ created here @@ -55,7 +55,7 @@ LL | let d: usize = 1; | ~~~~~~~~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:38:5 + --> tests/ui/needless_late_init.rs:38:5 | LL | let e; | ^^^^^^ created here @@ -68,7 +68,7 @@ LL | let e = format!("{}", d); | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:43:5 + --> tests/ui/needless_late_init.rs:43:5 | LL | let a; | ^^^^^^ @@ -89,7 +89,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:52:5 + --> tests/ui/needless_late_init.rs:52:5 | LL | let b; | ^^^^^^ @@ -110,7 +110,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:59:5 + --> tests/ui/needless_late_init.rs:59:5 | LL | let d; | ^^^^^^ @@ -131,7 +131,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:67:5 + --> tests/ui/needless_late_init.rs:67:5 | LL | let e; | ^^^^^^ @@ -152,7 +152,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:74:5 + --> tests/ui/needless_late_init.rs:74:5 | LL | let f; | ^^^^^^ @@ -168,7 +168,7 @@ LL + 1 => "three", | error: unneeded late initialization - --> $DIR/needless_late_init.rs:80:5 + --> tests/ui/needless_late_init.rs:80:5 | LL | let g: usize; | ^^^^^^^^^^^^^ @@ -188,7 +188,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:88:5 + --> tests/ui/needless_late_init.rs:88:5 | LL | let x; | ^^^^^^ created here @@ -202,7 +202,7 @@ LL | let x = 1; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:92:5 + --> tests/ui/needless_late_init.rs:92:5 | LL | let x; | ^^^^^^ created here @@ -216,7 +216,7 @@ LL | let x = SignificantDrop; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:96:5 + --> tests/ui/needless_late_init.rs:96:5 | LL | let x; | ^^^^^^ created here @@ -230,7 +230,7 @@ LL | let x = SignificantDrop; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:115:5 + --> tests/ui/needless_late_init.rs:115:5 | LL | let a; | ^^^^^^ @@ -251,7 +251,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:132:5 + --> tests/ui/needless_late_init.rs:132:5 | LL | let a; | ^^^^^^ diff --git a/tests/ui/needless_lifetimes.stderr b/tests/ui/needless_lifetimes.stderr index 7051a2604b917..f325d27b8c753 100644 --- a/tests/ui/needless_lifetimes.stderr +++ b/tests/ui/needless_lifetimes.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a, 'b - --> $DIR/needless_lifetimes.rs:17:23 + --> tests/ui/needless_lifetimes.rs:17:23 | LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} | ^^ ^^ ^^ ^^ @@ -13,7 +13,7 @@ LL + fn distinct_lifetimes(_x: &u8, _y: &u8, _z: u8) {} | error: the following explicit lifetimes could be elided: 'a, 'b - --> $DIR/needless_lifetimes.rs:19:24 + --> tests/ui/needless_lifetimes.rs:19:24 | LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} | ^^ ^^ ^^ ^^ @@ -25,7 +25,7 @@ LL + fn distinct_and_static(_x: &u8, _y: &u8, _z: &'static u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:29:15 + --> tests/ui/needless_lifetimes.rs:29:15 | LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { | ^^ ^^ ^^ @@ -37,7 +37,7 @@ LL + fn in_and_out(x: &u8, _y: u8) -> &u8 { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:41:31 + --> tests/ui/needless_lifetimes.rs:41:31 | LL | fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { | ^^ ^^ @@ -49,7 +49,7 @@ LL + fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:48:27 + --> tests/ui/needless_lifetimes.rs:48:27 | LL | fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 { | ^^ ^^ @@ -61,7 +61,7 @@ LL + fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:65:26 + --> tests/ui/needless_lifetimes.rs:65:26 | LL | fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { | ^^ ^^ @@ -73,7 +73,7 @@ LL + fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:72:22 + --> tests/ui/needless_lifetimes.rs:72:22 | LL | fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> { | ^^ ^^ @@ -85,7 +85,7 @@ LL + fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:81:21 + --> tests/ui/needless_lifetimes.rs:81:21 | LL | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { | ^^ ^^ ^^ @@ -97,7 +97,7 @@ LL + fn deep_reference_3(x: &u8, _y: u8) -> Result<&u8, ()> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:86:28 + --> tests/ui/needless_lifetimes.rs:86:28 | LL | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> | ^^ ^^ ^^ @@ -109,7 +109,7 @@ LL + fn where_clause_without_lt(x: &u8, _y: u8) -> Result<&u8, ()> | error: the following explicit lifetimes could be elided: 'a, 'b - --> $DIR/needless_lifetimes.rs:98:21 + --> tests/ui/needless_lifetimes.rs:98:21 | LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} | ^^ ^^ ^^ ^^ @@ -121,7 +121,7 @@ LL + fn lifetime_param_2(_x: Ref<'_>, _y: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:122:15 + --> tests/ui/needless_lifetimes.rs:122:15 | LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> | ^^ ^^ ^^ @@ -133,7 +133,7 @@ LL + fn fn_bound_2(_m: Lt<'_, I>, _f: F) -> Lt<'_, I> | error: the following explicit lifetimes could be elided: 's - --> $DIR/needless_lifetimes.rs:152:21 + --> tests/ui/needless_lifetimes.rs:152:21 | LL | fn self_and_out<'s>(&'s self) -> &'s u8 { | ^^ ^^ ^^ @@ -145,7 +145,7 @@ LL + fn self_and_out(&self) -> &u8 { | error: the following explicit lifetimes could be elided: 't - --> $DIR/needless_lifetimes.rs:159:30 + --> tests/ui/needless_lifetimes.rs:159:30 | LL | fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { | ^^ ^^ @@ -157,7 +157,7 @@ LL + fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 { | error: the following explicit lifetimes could be elided: 's - --> $DIR/needless_lifetimes.rs:166:26 + --> tests/ui/needless_lifetimes.rs:166:26 | LL | fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 { | ^^ ^^ @@ -169,7 +169,7 @@ LL + fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 { | error: the following explicit lifetimes could be elided: 's, 't - --> $DIR/needless_lifetimes.rs:170:29 + --> tests/ui/needless_lifetimes.rs:170:29 | LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} | ^^ ^^ ^^ ^^ @@ -181,7 +181,7 @@ LL + fn distinct_self_and_in(&self, _x: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:189:19 + --> tests/ui/needless_lifetimes.rs:189:19 | LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { | ^^ ^^ ^^ @@ -193,7 +193,7 @@ LL + fn struct_with_lt(_foo: Foo<'_>) -> &str { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:207:25 + --> tests/ui/needless_lifetimes.rs:207:25 | LL | fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { | ^^ ^^ @@ -205,7 +205,7 @@ LL + fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:215:21 + --> tests/ui/needless_lifetimes.rs:215:21 | LL | fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str { | ^^ ^^ @@ -217,7 +217,7 @@ LL + fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:230:22 + --> tests/ui/needless_lifetimes.rs:230:22 | LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { | ^^ ^^ ^^ @@ -229,7 +229,7 @@ LL + fn trait_obj_elided2(_arg: &dyn Drop) -> &str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:236:18 + --> tests/ui/needless_lifetimes.rs:236:18 | LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { | ^^ ^^ ^^ @@ -241,7 +241,7 @@ LL + fn alias_with_lt(_foo: FooAlias<'_>) -> &str { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:254:24 + --> tests/ui/needless_lifetimes.rs:254:24 | LL | fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { | ^^ ^^ @@ -253,7 +253,7 @@ LL + fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:262:20 + --> tests/ui/needless_lifetimes.rs:262:20 | LL | fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str { | ^^ ^^ @@ -265,7 +265,7 @@ LL + fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:266:30 + --> tests/ui/needless_lifetimes.rs:266:30 | LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { | ^^ ^^ ^ @@ -277,7 +277,7 @@ LL + fn named_input_elided_output(_arg: &str) -> &str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:274:19 + --> tests/ui/needless_lifetimes.rs:274:19 | LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { | ^^ ^^ @@ -289,7 +289,7 @@ LL + fn trait_bound_ok>(_: &u8, _: T) { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:310:24 + --> tests/ui/needless_lifetimes.rs:310:24 | LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { | ^^ ^^ ^^ @@ -301,7 +301,7 @@ LL + fn out_return_type_lts(e: &str) -> Cow<'_> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:317:24 + --> tests/ui/needless_lifetimes.rs:317:24 | LL | fn needless_lt<'a>(x: &'a u8) {} | ^^ ^^ @@ -313,7 +313,7 @@ LL + fn needless_lt(x: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:321:24 + --> tests/ui/needless_lifetimes.rs:321:24 | LL | fn needless_lt<'a>(_x: &'a u8) {} | ^^ ^^ @@ -325,7 +325,7 @@ LL + fn needless_lt(_x: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:334:16 + --> tests/ui/needless_lifetimes.rs:334:16 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { | ^^ ^^ ^^ @@ -337,7 +337,7 @@ LL + fn baz(&self) -> impl Foo + '_ { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:366:55 + --> tests/ui/needless_lifetimes.rs:366:55 | LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 { | ^^ ^^ ^^ @@ -349,7 +349,7 @@ LL + fn impl_trait_elidable_nested_anonymous_lifetimes(i: &i32, f: impl Fn(& | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:375:26 + --> tests/ui/needless_lifetimes.rs:375:26 | LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 { | ^^ ^^ ^^ @@ -361,7 +361,7 @@ LL + fn generics_elidable &i32>(i: &i32, f: T) -> &i32 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:387:32 + --> tests/ui/needless_lifetimes.rs:387:32 | LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32 | ^^ ^^ ^^ @@ -373,7 +373,7 @@ LL + fn where_clause_elidadable(i: &i32, f: T) -> &i32 | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:402:28 + --> tests/ui/needless_lifetimes.rs:402:28 | LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 { | ^^ ^^ ^^ @@ -385,7 +385,7 @@ LL + fn pointer_fn_elidable(i: &i32, f: fn(&i32) -> &i32) -> &i32 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:415:28 + --> tests/ui/needless_lifetimes.rs:415:28 | LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { | ^^ ^^ @@ -397,7 +397,7 @@ LL + fn nested_fn_pointer_3(_: &i32) -> fn(fn(&i32) -> &i32) -> i32 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:418:28 + --> tests/ui/needless_lifetimes.rs:418:28 | LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { | ^^ ^^ @@ -409,7 +409,7 @@ LL + fn nested_fn_pointer_4(_: &i32) -> impl Fn(fn(&i32)) { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:440:21 + --> tests/ui/needless_lifetimes.rs:440:21 | LL | fn implicit<'a>(&'a self) -> &'a () { | ^^ ^^ ^^ @@ -421,7 +421,7 @@ LL + fn implicit(&self) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:443:25 + --> tests/ui/needless_lifetimes.rs:443:25 | LL | fn implicit_mut<'a>(&'a mut self) -> &'a () { | ^^ ^^ ^^ @@ -433,7 +433,7 @@ LL + fn implicit_mut(&mut self) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:454:31 + --> tests/ui/needless_lifetimes.rs:454:31 | LL | fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a () { | ^^ ^^ ^^ @@ -445,7 +445,7 @@ LL + fn lifetime_elsewhere(self: Box, here: &()) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:460:21 + --> tests/ui/needless_lifetimes.rs:460:21 | LL | fn implicit<'a>(&'a self) -> &'a (); | ^^ ^^ ^^ @@ -457,7 +457,7 @@ LL + fn implicit(&self) -> &(); | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:461:30 + --> tests/ui/needless_lifetimes.rs:461:30 | LL | fn implicit_provided<'a>(&'a self) -> &'a () { | ^^ ^^ ^^ @@ -469,7 +469,7 @@ LL + fn implicit_provided(&self) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:470:31 + --> tests/ui/needless_lifetimes.rs:470:31 | LL | fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a (); | ^^ ^^ ^^ @@ -481,7 +481,7 @@ LL + fn lifetime_elsewhere(self: Box, here: &()) -> &(); | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:471:40 + --> tests/ui/needless_lifetimes.rs:471:40 | LL | fn lifetime_elsewhere_provided<'a>(self: Box, here: &'a ()) -> &'a () { | ^^ ^^ ^^ @@ -493,7 +493,7 @@ LL + fn lifetime_elsewhere_provided(self: Box, here: &()) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:480:12 + --> tests/ui/needless_lifetimes.rs:480:12 | LL | fn foo<'a>(x: &'a u8, y: &'_ u8) {} | ^^ ^^ @@ -505,7 +505,7 @@ LL + fn foo(x: &u8, y: &'_ u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:482:12 + --> tests/ui/needless_lifetimes.rs:482:12 | LL | fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {} | ^^ ^^ @@ -517,7 +517,7 @@ LL + fn bar(x: &u8, y: &'_ u8, z: &'_ u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:489:18 + --> tests/ui/needless_lifetimes.rs:489:18 | LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { | ^^ ^^ ^^ @@ -529,7 +529,7 @@ LL + fn one_input(x: &u8) -> &u8 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:494:42 + --> tests/ui/needless_lifetimes.rs:494:42 | LL | fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: &'b u8) -> &'b u8 { | ^^ ^^ @@ -541,7 +541,7 @@ LL + fn multiple_inputs_output_not_elided<'b>(x: &u8, y: &'b u8, z: &'b u8) | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:510:22 + --> tests/ui/needless_lifetimes.rs:510:22 | LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { | ^^ ^^ ^^ diff --git a/tests/ui/needless_match.stderr b/tests/ui/needless_match.stderr index 736926b4415bc..5bcab467aeae3 100644 --- a/tests/ui/needless_match.stderr +++ b/tests/ui/needless_match.stderr @@ -1,5 +1,5 @@ error: this match expression is unnecessary - --> $DIR/needless_match.rs:15:18 + --> tests/ui/needless_match.rs:15:18 | LL | let _: i32 = match i { | __________________^ @@ -14,7 +14,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_match)]` error: this match expression is unnecessary - --> $DIR/needless_match.rs:22:19 + --> tests/ui/needless_match.rs:22:19 | LL | let _: &str = match s { | ___________________^ @@ -25,7 +25,7 @@ LL | | }; | |_____^ help: replace it with: `s` error: this match expression is unnecessary - --> $DIR/needless_match.rs:31:21 + --> tests/ui/needless_match.rs:31:21 | LL | let _: Simple = match se { | _____________________^ @@ -37,7 +37,7 @@ LL | | }; | |_____^ help: replace it with: `se` error: this match expression is unnecessary - --> $DIR/needless_match.rs:53:26 + --> tests/ui/needless_match.rs:53:26 | LL | let _: Option = match x { | __________________________^ @@ -47,7 +47,7 @@ LL | | }; | |_____^ help: replace it with: `x` error: this match expression is unnecessary - --> $DIR/needless_match.rs:69:31 + --> tests/ui/needless_match.rs:69:31 | LL | let _: Result = match Ok(1) { | _______________________________^ @@ -57,7 +57,7 @@ LL | | }; | |_____^ help: replace it with: `Ok(1)` error: this match expression is unnecessary - --> $DIR/needless_match.rs:73:31 + --> tests/ui/needless_match.rs:73:31 | LL | let _: Result = match func_ret_err(0_i32) { | _______________________________^ @@ -67,25 +67,25 @@ LL | | }; | |_____^ help: replace it with: `func_ret_err(0_i32)` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:86:13 + --> tests/ui/needless_match.rs:86:13 | LL | let _ = if let Some(a) = Some(1) { Some(a) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:121:31 + --> tests/ui/needless_match.rs:121:31 | LL | let _: Result = if let Err(e) = x { Err(e) } else { x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:122:31 + --> tests/ui/needless_match.rs:122:31 | LL | let _: Result = if let Ok(val) = x { Ok(val) } else { x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:129:21 + --> tests/ui/needless_match.rs:129:21 | LL | let _: Simple = if let Simple::A = x { | _____________________^ @@ -98,7 +98,7 @@ LL | | }; | |_____^ help: replace it with: `x` error: this match expression is unnecessary - --> $DIR/needless_match.rs:168:26 + --> tests/ui/needless_match.rs:168:26 | LL | let _: Complex = match ce { | __________________________^ @@ -111,7 +111,7 @@ LL | | }; | |_________^ help: replace it with: `ce` error: this match expression is unnecessary - --> $DIR/needless_match.rs:252:17 + --> tests/ui/needless_match.rs:252:17 | LL | let _ = match e { | _________________^ @@ -121,7 +121,7 @@ LL | | }; | |_________^ help: replace it with: `e` error: this match expression is unnecessary - --> $DIR/needless_match.rs:258:17 + --> tests/ui/needless_match.rs:258:17 | LL | let _ = match e { | _________________^ diff --git a/tests/ui/needless_option_as_deref.stderr b/tests/ui/needless_option_as_deref.stderr index 024d30c1717c2..a05d0aa9276ac 100644 --- a/tests/ui/needless_option_as_deref.stderr +++ b/tests/ui/needless_option_as_deref.stderr @@ -1,5 +1,5 @@ error: derefed type is same as origin - --> $DIR/needless_option_as_deref.rs:7:29 + --> tests/ui/needless_option_as_deref.rs:7:29 | LL | let _: Option<&usize> = Some(&1).as_deref(); | ^^^^^^^^^^^^^^^^^^^ help: try: `Some(&1)` @@ -8,13 +8,13 @@ LL | let _: Option<&usize> = Some(&1).as_deref(); = help: to override `-D warnings` add `#[allow(clippy::needless_option_as_deref)]` error: derefed type is same as origin - --> $DIR/needless_option_as_deref.rs:8:33 + --> tests/ui/needless_option_as_deref.rs:8:33 | LL | let _: Option<&mut usize> = Some(&mut 1).as_deref_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(&mut 1)` error: derefed type is same as origin - --> $DIR/needless_option_as_deref.rs:12:13 + --> tests/ui/needless_option_as_deref.rs:12:13 | LL | let _ = x.as_deref_mut(); | ^^^^^^^^^^^^^^^^ help: try: `x` diff --git a/tests/ui/needless_option_take.stderr b/tests/ui/needless_option_take.stderr index bf43a18e7115c..4a73ccb86d081 100644 --- a/tests/ui/needless_option_take.stderr +++ b/tests/ui/needless_option_take.stderr @@ -1,5 +1,5 @@ error: called `Option::take()` on a temporary value - --> $DIR/needless_option_take.rs:12:5 + --> tests/ui/needless_option_take.rs:12:5 | LL | x.as_ref().take(); | ^^^^^^^^^^^^^^^^^ help: try: `x.as_ref()` diff --git a/tests/ui/needless_parens_on_range_literals.stderr b/tests/ui/needless_parens_on_range_literals.stderr index c73564e210c06..d293ecce69fbd 100644 --- a/tests/ui/needless_parens_on_range_literals.stderr +++ b/tests/ui/needless_parens_on_range_literals.stderr @@ -1,5 +1,5 @@ error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:7:13 + --> tests/ui/needless_parens_on_range_literals.rs:7:13 | LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'a'` @@ -8,31 +8,31 @@ LL | let _ = ('a')..=('z'); = help: to override `-D warnings` add `#[allow(clippy::needless_parens_on_range_literals)]` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:7:21 + --> tests/ui/needless_parens_on_range_literals.rs:7:21 | LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'z'` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:8:18 + --> tests/ui/needless_parens_on_range_literals.rs:8:18 | LL | let _ = 'a'..('z'); | ^^^^^ help: try: `'z'` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:10:19 + --> tests/ui/needless_parens_on_range_literals.rs:10:19 | LL | let _ = (1.)..(2.); | ^^^^ help: try: `2.` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:11:13 + --> tests/ui/needless_parens_on_range_literals.rs:11:13 | LL | let _ = ('a')..; | ^^^^^ help: try: `'a'` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:12:15 + --> tests/ui/needless_parens_on_range_literals.rs:12:15 | LL | let _ = ..('z'); | ^^^^^ help: try: `'z'` diff --git a/tests/ui/needless_pass_by_ref_mut.stderr b/tests/ui/needless_pass_by_ref_mut.stderr index 5d1e9515de125..89dad3e60b143 100644 --- a/tests/ui/needless_pass_by_ref_mut.stderr +++ b/tests/ui/needless_pass_by_ref_mut.stderr @@ -1,5 +1,5 @@ error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:12:11 + --> tests/ui/needless_pass_by_ref_mut.rs:12:11 | LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` @@ -8,79 +8,79 @@ LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:37:12 + --> tests/ui/needless_pass_by_ref_mut.rs:37:12 | LL | fn foo6(s: &mut Vec) { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:50:29 + --> tests/ui/needless_pass_by_ref_mut.rs:50:29 | LL | fn mushroom(&self, vec: &mut Vec) -> usize { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:55:31 + --> tests/ui/needless_pass_by_ref_mut.rs:55:31 | LL | fn badger(&mut self, vec: &mut Vec) -> usize { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:132:16 + --> tests/ui/needless_pass_by_ref_mut.rs:132:16 | LL | async fn a1(x: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:136:16 + --> tests/ui/needless_pass_by_ref_mut.rs:136:16 | LL | async fn a2(x: &mut i32, y: String) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:140:16 + --> tests/ui/needless_pass_by_ref_mut.rs:140:16 | LL | async fn a3(x: &mut i32, y: String, z: String) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:144:16 + --> tests/ui/needless_pass_by_ref_mut.rs:144:16 | LL | async fn a4(x: &mut i32, y: i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:148:24 + --> tests/ui/needless_pass_by_ref_mut.rs:148:24 | LL | async fn a5(x: i32, y: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:152:24 + --> tests/ui/needless_pass_by_ref_mut.rs:152:24 | LL | async fn a6(x: i32, y: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:156:32 + --> tests/ui/needless_pass_by_ref_mut.rs:156:32 | LL | async fn a7(x: i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:160:24 + --> tests/ui/needless_pass_by_ref_mut.rs:160:24 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:160:45 + --> tests/ui/needless_pass_by_ref_mut.rs:160:45 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:194:16 + --> tests/ui/needless_pass_by_ref_mut.rs:194:16 | LL | fn cfg_warn(s: &mut u32) {} | ^^^^^^^^ help: consider changing to: `&u32` @@ -88,7 +88,7 @@ LL | fn cfg_warn(s: &mut u32) {} = note: this is cfg-gated and may require further changes error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:200:20 + --> tests/ui/needless_pass_by_ref_mut.rs:200:20 | LL | fn cfg_warn(s: &mut u32) {} | ^^^^^^^^ help: consider changing to: `&u32` @@ -96,19 +96,19 @@ LL | fn cfg_warn(s: &mut u32) {} = note: this is cfg-gated and may require further changes error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:214:39 + --> tests/ui/needless_pass_by_ref_mut.rs:214:39 | LL | async fn inner_async2(x: &mut i32, y: &mut u32) { | ^^^^^^^^ help: consider changing to: `&u32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:222:26 + --> tests/ui/needless_pass_by_ref_mut.rs:222:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:241:34 + --> tests/ui/needless_pass_by_ref_mut.rs:241:34 | LL | pub async fn call_in_closure1(n: &mut str) { | ^^^^^^^^ help: consider changing to: `&str` @@ -116,7 +116,7 @@ LL | pub async fn call_in_closure1(n: &mut str) { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:253:25 + --> tests/ui/needless_pass_by_ref_mut.rs:253:25 | LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() { | ^^^^^^^^^^ help: consider changing to: `&usize` @@ -124,7 +124,7 @@ LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:260:20 + --> tests/ui/needless_pass_by_ref_mut.rs:260:20 | LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { | ^^^^^^^^^^ help: consider changing to: `&usize` @@ -132,7 +132,7 @@ LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:271:26 + --> tests/ui/needless_pass_by_ref_mut.rs:271:26 | LL | pub async fn closure4(n: &mut usize) { | ^^^^^^^^^^ help: consider changing to: `&usize` @@ -140,61 +140,61 @@ LL | pub async fn closure4(n: &mut usize) { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:311:18 + --> tests/ui/needless_pass_by_ref_mut.rs:311:18 | LL | fn _empty_tup(x: &mut (())) {} | ^^^^^^^^^ help: consider changing to: `&()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:312:19 + --> tests/ui/needless_pass_by_ref_mut.rs:312:19 | LL | fn _single_tup(x: &mut ((i32,))) {} | ^^^^^^^^^^^^^ help: consider changing to: `&(i32,)` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:313:18 + --> tests/ui/needless_pass_by_ref_mut.rs:313:18 | LL | fn _multi_tup(x: &mut ((i32, u32))) {} | ^^^^^^^^^^^^^^^^^ help: consider changing to: `&(i32, u32)` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:314:11 + --> tests/ui/needless_pass_by_ref_mut.rs:314:11 | LL | fn _fn(x: &mut (fn())) {} | ^^^^^^^^^^^ help: consider changing to: `&fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:316:23 + --> tests/ui/needless_pass_by_ref_mut.rs:316:23 | LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "Rust" fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:317:20 + --> tests/ui/needless_pass_by_ref_mut.rs:317:20 | LL | fn _extern_c_fn(x: &mut extern "C" fn()) {} | ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "C" fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:318:18 + --> tests/ui/needless_pass_by_ref_mut.rs:318:18 | LL | fn _unsafe_fn(x: &mut unsafe fn()) {} | ^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:319:25 + --> tests/ui/needless_pass_by_ref_mut.rs:319:25 | LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:320:20 + --> tests/ui/needless_pass_by_ref_mut.rs:320:20 | LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn(i32)` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:321:20 + --> tests/ui/needless_pass_by_ref_mut.rs:321:20 | LL | fn _fn_with_ret(x: &mut unsafe extern "C" fn() -> (i32)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn() -> (i32)` diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 1c3a63d661f68..827a200ba6819 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,5 +1,5 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:18:23 + --> tests/ui/needless_pass_by_value.rs:18:23 | LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` @@ -8,55 +8,55 @@ LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec $DIR/needless_pass_by_value.rs:34:11 + --> tests/ui/needless_pass_by_value.rs:34:11 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:34:22 + --> tests/ui/needless_pass_by_value.rs:34:22 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:42:71 + --> tests/ui/needless_pass_by_value.rs:42:71 | LL | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:55:18 + --> tests/ui/needless_pass_by_value.rs:55:18 | LL | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option>` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:69:24 + --> tests/ui/needless_pass_by_value.rs:69:24 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:69:36 + --> tests/ui/needless_pass_by_value.rs:69:36 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:87:49 + --> tests/ui/needless_pass_by_value.rs:87:49 | LL | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:18 + --> tests/ui/needless_pass_by_value.rs:90:18 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:29 + --> tests/ui/needless_pass_by_value.rs:90:29 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ @@ -71,13 +71,13 @@ LL | let _ = t.to_string(); | ~~~~~~~~~~~~~ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:40 + --> tests/ui/needless_pass_by_value.rs:90:40 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:53 + --> tests/ui/needless_pass_by_value.rs:90:53 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ @@ -92,85 +92,85 @@ LL | let _ = v.to_owned(); | ~~~~~~~~~~~~ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:107:12 + --> tests/ui/needless_pass_by_value.rs:107:12 | LL | s: String, | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:109:12 + --> tests/ui/needless_pass_by_value.rs:109:12 | LL | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:119:23 + --> tests/ui/needless_pass_by_value.rs:119:23 | LL | fn baz(&self, _u: U, _s: Self) {} | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:119:30 + --> tests/ui/needless_pass_by_value.rs:119:30 | LL | fn baz(&self, _u: U, _s: Self) {} | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:143:24 + --> tests/ui/needless_pass_by_value.rs:143:24 | LL | fn bar_copy(x: u32, y: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:29 + --> tests/ui/needless_pass_by_value.rs:150:29 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:45 + --> tests/ui/needless_pass_by_value.rs:150:45 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:61 + --> tests/ui/needless_pass_by_value.rs:150:61 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:165:40 + --> tests/ui/needless_pass_by_value.rs:165:40 | LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {} | ^ help: consider taking a reference instead: `&S` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:171:20 + --> tests/ui/needless_pass_by_value.rs:171:20 | LL | fn more_fun(_item: impl Club<'static, i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` diff --git a/tests/ui/needless_pub_self.stderr b/tests/ui/needless_pub_self.stderr index c1f6b908b53d4..0bff2e4b8b71b 100644 --- a/tests/ui/needless_pub_self.stderr +++ b/tests/ui/needless_pub_self.stderr @@ -1,5 +1,5 @@ error: unnecessary `pub(self)` - --> $DIR/needless_pub_self.rs:13:1 + --> tests/ui/needless_pub_self.rs:13:1 | LL | pub(self) fn a() {} | ^^^^^^^^^ help: remove it @@ -8,13 +8,13 @@ LL | pub(self) fn a() {} = help: to override `-D warnings` add `#[allow(clippy::needless_pub_self)]` error: unnecessary `pub(in self)` - --> $DIR/needless_pub_self.rs:14:1 + --> tests/ui/needless_pub_self.rs:14:1 | LL | pub(in self) fn b() {} | ^^^^^^^^^^^^ help: remove it error: unnecessary `pub(self)` - --> $DIR/needless_pub_self.rs:20:5 + --> tests/ui/needless_pub_self.rs:20:5 | LL | pub(self) fn f() {} | ^^^^^^^^^ help: remove it diff --git a/tests/ui/needless_question_mark.stderr b/tests/ui/needless_question_mark.stderr index bf090302ef7eb..0a1cb59797086 100644 --- a/tests/ui/needless_question_mark.stderr +++ b/tests/ui/needless_question_mark.stderr @@ -1,5 +1,5 @@ error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:20:12 + --> tests/ui/needless_question_mark.rs:20:12 | LL | return Some(to.magic?); | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` @@ -8,67 +8,67 @@ LL | return Some(to.magic?); = help: to override `-D warnings` add `#[allow(clippy::needless_question_mark)]` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:28:12 + --> tests/ui/needless_question_mark.rs:28:12 | LL | return Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:33:5 + --> tests/ui/needless_question_mark.rs:33:5 | LL | Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:38:21 + --> tests/ui/needless_question_mark.rs:38:21 | LL | to.and_then(|t| Some(t.magic?)) | ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:47:9 + --> tests/ui/needless_question_mark.rs:47:9 | LL | Some(t.magic?) | ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:52:12 + --> tests/ui/needless_question_mark.rs:52:12 | LL | return Ok(tr.magic?); | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:59:12 + --> tests/ui/needless_question_mark.rs:59:12 | LL | return Ok(tr.magic?) | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:63:5 + --> tests/ui/needless_question_mark.rs:63:5 | LL | Ok(tr.magic?) | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:67:21 + --> tests/ui/needless_question_mark.rs:67:21 | LL | tr.and_then(|t| Ok(t.magic?)) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:75:9 + --> tests/ui/needless_question_mark.rs:75:9 | LL | Ok(t.magic?) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:82:16 + --> tests/ui/needless_question_mark.rs:82:16 | LL | return Ok(t.magic?); | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:117:27 + --> tests/ui/needless_question_mark.rs:117:27 | LL | || -> Option<_> { Some(Some($expr)?) }() | ^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `Some($expr)` @@ -79,19 +79,19 @@ LL | let _x = some_and_qmark_in_macro!(x?); = note: this error originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:128:5 + --> tests/ui/needless_question_mark.rs:128:5 | LL | Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:136:5 + --> tests/ui/needless_question_mark.rs:136:5 | LL | Ok(s.magic?) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `s.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:140:7 + --> tests/ui/needless_question_mark.rs:140:7 | LL | { Some(a?) } | ^^^^^^^^ help: try removing question mark and `Some()`: `a` diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index 0d8893c261961..dc2cf437e02ea 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -1,5 +1,5 @@ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:15:14 + --> tests/ui/needless_range_loop.rs:15:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | for in &vec { | ~~~~~~ ~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:26:14 + --> tests/ui/needless_range_loop.rs:26:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | for in &vec { | ~~~~~~ ~~~~ error: the loop variable `j` is only used to index `STATIC` - --> $DIR/needless_range_loop.rs:32:14 + --> tests/ui/needless_range_loop.rs:32:14 | LL | for j in 0..4 { | ^^^^ @@ -34,7 +34,7 @@ LL | for in &STATIC { | ~~~~~~ ~~~~~~~ error: the loop variable `j` is only used to index `CONST` - --> $DIR/needless_range_loop.rs:37:14 + --> tests/ui/needless_range_loop.rs:37:14 | LL | for j in 0..4 { | ^^^^ @@ -45,7 +45,7 @@ LL | for in &CONST { | ~~~~~~ ~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:42:14 + --> tests/ui/needless_range_loop.rs:42:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for (i, ) in vec.iter().enumerate() { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec2` - --> $DIR/needless_range_loop.rs:51:14 + --> tests/ui/needless_range_loop.rs:51:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | for in vec2.iter().take(vec.len()) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:56:14 + --> tests/ui/needless_range_loop.rs:56:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | for in vec.iter().skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:61:14 + --> tests/ui/needless_range_loop.rs:61:14 | LL | for i in 0..MAX_LEN { | ^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | for in vec.iter().take(MAX_LEN) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:66:14 + --> tests/ui/needless_range_loop.rs:66:14 | LL | for i in 0..=MAX_LEN { | ^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | for in vec.iter().take(MAX_LEN + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:71:14 + --> tests/ui/needless_range_loop.rs:71:14 | LL | for i in 5..10 { | ^^^^^ @@ -111,7 +111,7 @@ LL | for in vec.iter().take(10).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:76:14 + --> tests/ui/needless_range_loop.rs:76:14 | LL | for i in 5..=10 { | ^^^^^^ @@ -122,7 +122,7 @@ LL | for in vec.iter().take(10 + 1).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:81:14 + --> tests/ui/needless_range_loop.rs:81:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | for (i, ) in vec.iter().enumerate().skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:86:14 + --> tests/ui/needless_range_loop.rs:86:14 | LL | for i in 5..10 { | ^^^^^ @@ -144,7 +144,7 @@ LL | for (i, ) in vec.iter().enumerate().take(10).skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:92:14 + --> tests/ui/needless_range_loop.rs:92:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ diff --git a/tests/ui/needless_range_loop2.stderr b/tests/ui/needless_range_loop2.stderr index 3d1d9e1bff432..353f30b1b26dc 100644 --- a/tests/ui/needless_range_loop2.stderr +++ b/tests/ui/needless_range_loop2.stderr @@ -1,5 +1,5 @@ error: the loop variable `i` is only used to index `ns` - --> $DIR/needless_range_loop2.rs:11:14 + --> tests/ui/needless_range_loop2.rs:11:14 | LL | for i in 3..10 { | ^^^^^ @@ -12,7 +12,7 @@ LL | for in ns.iter().take(10).skip(3) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `ms` - --> $DIR/needless_range_loop2.rs:34:14 + --> tests/ui/needless_range_loop2.rs:34:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | for in &mut ms { | ~~~~~~ ~~~~~~~ error: the loop variable `i` is only used to index `ms` - --> $DIR/needless_range_loop2.rs:41:14 + --> tests/ui/needless_range_loop2.rs:41:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for in &mut ms { | ~~~~~~ ~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop2.rs:66:14 + --> tests/ui/needless_range_loop2.rs:66:14 | LL | for i in x..x + 4 { | ^^^^^^^^ @@ -45,7 +45,7 @@ LL | for in vec.iter_mut().skip(x).take(4) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop2.rs:74:14 + --> tests/ui/needless_range_loop2.rs:74:14 | LL | for i in x..=x + 4 { | ^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for in vec.iter_mut().skip(x).take(4 + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `arr` - --> $DIR/needless_range_loop2.rs:81:14 + --> tests/ui/needless_range_loop2.rs:81:14 | LL | for i in 0..3 { | ^^^^ @@ -67,7 +67,7 @@ LL | for in &arr { | ~~~~~~ ~~~~ error: the loop variable `i` is only used to index `arr` - --> $DIR/needless_range_loop2.rs:86:14 + --> tests/ui/needless_range_loop2.rs:86:14 | LL | for i in 0..2 { | ^^^^ @@ -78,7 +78,7 @@ LL | for in arr.iter().take(2) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `arr` - --> $DIR/needless_range_loop2.rs:91:14 + --> tests/ui/needless_range_loop2.rs:91:14 | LL | for i in 1..3 { | ^^^^ diff --git a/tests/ui/needless_raw_string.stderr b/tests/ui/needless_raw_string.stderr index b2188698564f9..7d3451a03c75c 100644 --- a/tests/ui/needless_raw_string.stderr +++ b/tests/ui/needless_raw_string.stderr @@ -1,5 +1,5 @@ error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:5:5 + --> tests/ui/needless_raw_string.rs:5:5 | LL | r#"aaa"#; | ^^^^^^^^ @@ -13,7 +13,7 @@ LL + "aaa"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:8:5 + --> tests/ui/needless_raw_string.rs:8:5 | LL | br#"aaa"#; | ^^^^^^^^^ @@ -25,7 +25,7 @@ LL + b"aaa"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:11:5 + --> tests/ui/needless_raw_string.rs:11:5 | LL | cr#"aaa"#; | ^^^^^^^^^ @@ -37,7 +37,7 @@ LL + c"aaa"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:15:5 + --> tests/ui/needless_raw_string.rs:15:5 | LL | / r#" LL | | a @@ -56,7 +56,7 @@ LL ~ "; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:21:5 + --> tests/ui/needless_raw_string.rs:21:5 | LL | r"no hashes"; | ^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL + "no hashes"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:22:5 + --> tests/ui/needless_raw_string.rs:22:5 | LL | br"no hashes"; | ^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL + b"no hashes"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:23:5 + --> tests/ui/needless_raw_string.rs:23:5 | LL | cr"no hashes"; | ^^^^^^^^^^^^^ diff --git a/tests/ui/needless_raw_string_hashes.stderr b/tests/ui/needless_raw_string_hashes.stderr index c74eff8161e94..96864f612c098 100644 --- a/tests/ui/needless_raw_string_hashes.stderr +++ b/tests/ui/needless_raw_string_hashes.stderr @@ -1,5 +1,5 @@ error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:5:5 + --> tests/ui/needless_raw_string_hashes.rs:5:5 | LL | r#"\aaa"#; | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + r"\aaa"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:6:5 + --> tests/ui/needless_raw_string_hashes.rs:6:5 | LL | r##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + r#"Hello "world"!"#; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:7:5 + --> tests/ui/needless_raw_string_hashes.rs:7:5 | LL | r######" "### "## "# "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + r####" "### "## "# "####; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:8:5 + --> tests/ui/needless_raw_string_hashes.rs:8:5 | LL | r######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + r###" "aa" "# "## "###; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:9:5 + --> tests/ui/needless_raw_string_hashes.rs:9:5 | LL | br#"\aaa"#; | ^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + br"\aaa"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:10:5 + --> tests/ui/needless_raw_string_hashes.rs:10:5 | LL | br##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + br#"Hello "world"!"#; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:11:5 + --> tests/ui/needless_raw_string_hashes.rs:11:5 | LL | br######" "### "## "# "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + br####" "### "## "# "####; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:12:5 + --> tests/ui/needless_raw_string_hashes.rs:12:5 | LL | br######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + br###" "aa" "# "## "###; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:13:5 + --> tests/ui/needless_raw_string_hashes.rs:13:5 | LL | cr#"\aaa"#; | ^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + cr"\aaa"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:14:5 + --> tests/ui/needless_raw_string_hashes.rs:14:5 | LL | cr##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + cr#"Hello "world"!"#; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:15:5 + --> tests/ui/needless_raw_string_hashes.rs:15:5 | LL | cr######" "### "## "# "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + cr####" "### "## "# "####; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:16:5 + --> tests/ui/needless_raw_string_hashes.rs:16:5 | LL | cr######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + cr###" "aa" "# "## "###; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:18:5 + --> tests/ui/needless_raw_string_hashes.rs:18:5 | LL | / r#" LL | | \a @@ -164,7 +164,7 @@ LL ~ "; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:24:5 + --> tests/ui/needless_raw_string_hashes.rs:24:5 | LL | r###"rust"###; | ^^^^^^^^^^^^^ @@ -176,7 +176,7 @@ LL + r"rust"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:25:5 + --> tests/ui/needless_raw_string_hashes.rs:25:5 | LL | r#"hello world"#; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index cc48831115d9f..758ff6d985cd8 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -1,5 +1,5 @@ error: unneeded `return` statement - --> $DIR/needless_return.rs:26:5 + --> tests/ui/needless_return.rs:26:5 | LL | return true; | ^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:30:5 + --> tests/ui/needless_return.rs:30:5 | LL | return true; | ^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:35:5 + --> tests/ui/needless_return.rs:35:5 | LL | return true;;; | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:40:5 + --> tests/ui/needless_return.rs:40:5 | LL | return true;; ; ; | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:45:9 + --> tests/ui/needless_return.rs:45:9 | LL | return true; | ^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:47:9 + --> tests/ui/needless_return.rs:47:9 | LL | return false; | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + false | error: unneeded `return` statement - --> $DIR/needless_return.rs:53:17 + --> tests/ui/needless_return.rs:53:17 | LL | true => return false, | ^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | true => false, | ~~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:55:13 + --> tests/ui/needless_return.rs:55:13 | LL | return true; | ^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:62:9 + --> tests/ui/needless_return.rs:62:9 | LL | return true; | ^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:64:16 + --> tests/ui/needless_return.rs:64:16 | LL | let _ = || return true; | ^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | let _ = || true; | ~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:68:5 + --> tests/ui/needless_return.rs:68:5 | LL | return the_answer!(); | ^^^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL + the_answer!() | error: unneeded `return` statement - --> $DIR/needless_return.rs:71:21 + --> tests/ui/needless_return.rs:71:21 | LL | fn test_void_fun() { | _____________________^ @@ -146,7 +146,7 @@ LL + fn test_void_fun() { | error: unneeded `return` statement - --> $DIR/needless_return.rs:76:11 + --> tests/ui/needless_return.rs:76:11 | LL | if b { | ___________^ @@ -161,7 +161,7 @@ LL + if b { | error: unneeded `return` statement - --> $DIR/needless_return.rs:78:13 + --> tests/ui/needless_return.rs:78:13 | LL | } else { | _____________^ @@ -176,7 +176,7 @@ LL + } else { | error: unneeded `return` statement - --> $DIR/needless_return.rs:86:14 + --> tests/ui/needless_return.rs:86:14 | LL | _ => return, | ^^^^^^ @@ -187,7 +187,7 @@ LL | _ => (), | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:94:24 + --> tests/ui/needless_return.rs:94:24 | LL | let _ = 42; | ________________________^ @@ -202,7 +202,7 @@ LL + let _ = 42; | error: unneeded `return` statement - --> $DIR/needless_return.rs:97:14 + --> tests/ui/needless_return.rs:97:14 | LL | _ => return, | ^^^^^^ @@ -213,7 +213,7 @@ LL | _ => (), | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:110:9 + --> tests/ui/needless_return.rs:110:9 | LL | return String::from("test"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL + String::from("test") | error: unneeded `return` statement - --> $DIR/needless_return.rs:112:9 + --> tests/ui/needless_return.rs:112:9 | LL | return String::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -237,7 +237,7 @@ LL + String::new() | error: unneeded `return` statement - --> $DIR/needless_return.rs:134:32 + --> tests/ui/needless_return.rs:134:32 | LL | bar.unwrap_or_else(|_| return) | ^^^^^^ @@ -248,7 +248,7 @@ LL | bar.unwrap_or_else(|_| {}) | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:138:21 + --> tests/ui/needless_return.rs:138:21 | LL | let _ = || { | _____________________^ @@ -263,7 +263,7 @@ LL + let _ = || { | error: unneeded `return` statement - --> $DIR/needless_return.rs:141:20 + --> tests/ui/needless_return.rs:141:20 | LL | let _ = || return; | ^^^^^^ @@ -274,7 +274,7 @@ LL | let _ = || {}; | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:147:32 + --> tests/ui/needless_return.rs:147:32 | LL | res.unwrap_or_else(|_| return Foo) | ^^^^^^^^^^ @@ -285,7 +285,7 @@ LL | res.unwrap_or_else(|_| Foo) | ~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:156:5 + --> tests/ui/needless_return.rs:156:5 | LL | return true; | ^^^^^^^^^^^ @@ -297,7 +297,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:160:5 + --> tests/ui/needless_return.rs:160:5 | LL | return true; | ^^^^^^^^^^^ @@ -309,7 +309,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:165:9 + --> tests/ui/needless_return.rs:165:9 | LL | return true; | ^^^^^^^^^^^ @@ -321,7 +321,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:167:9 + --> tests/ui/needless_return.rs:167:9 | LL | return false; | ^^^^^^^^^^^^ @@ -333,7 +333,7 @@ LL + false | error: unneeded `return` statement - --> $DIR/needless_return.rs:173:17 + --> tests/ui/needless_return.rs:173:17 | LL | true => return false, | ^^^^^^^^^^^^ @@ -344,7 +344,7 @@ LL | true => false, | ~~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:175:13 + --> tests/ui/needless_return.rs:175:13 | LL | return true; | ^^^^^^^^^^^ @@ -356,7 +356,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:182:9 + --> tests/ui/needless_return.rs:182:9 | LL | return true; | ^^^^^^^^^^^ @@ -368,7 +368,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:184:16 + --> tests/ui/needless_return.rs:184:16 | LL | let _ = || return true; | ^^^^^^^^^^^ @@ -379,7 +379,7 @@ LL | let _ = || true; | ~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:188:5 + --> tests/ui/needless_return.rs:188:5 | LL | return the_answer!(); | ^^^^^^^^^^^^^^^^^^^^ @@ -391,7 +391,7 @@ LL + the_answer!() | error: unneeded `return` statement - --> $DIR/needless_return.rs:191:33 + --> tests/ui/needless_return.rs:191:33 | LL | async fn async_test_void_fun() { | _________________________________^ @@ -406,7 +406,7 @@ LL + async fn async_test_void_fun() { | error: unneeded `return` statement - --> $DIR/needless_return.rs:196:11 + --> tests/ui/needless_return.rs:196:11 | LL | if b { | ___________^ @@ -421,7 +421,7 @@ LL + if b { | error: unneeded `return` statement - --> $DIR/needless_return.rs:198:13 + --> tests/ui/needless_return.rs:198:13 | LL | } else { | _____________^ @@ -436,7 +436,7 @@ LL + } else { | error: unneeded `return` statement - --> $DIR/needless_return.rs:206:14 + --> tests/ui/needless_return.rs:206:14 | LL | _ => return, | ^^^^^^ @@ -447,7 +447,7 @@ LL | _ => (), | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:219:9 + --> tests/ui/needless_return.rs:219:9 | LL | return String::from("test"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL + String::from("test") | error: unneeded `return` statement - --> $DIR/needless_return.rs:221:9 + --> tests/ui/needless_return.rs:221:9 | LL | return String::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -471,7 +471,7 @@ LL + String::new() | error: unneeded `return` statement - --> $DIR/needless_return.rs:237:5 + --> tests/ui/needless_return.rs:237:5 | LL | return format!("Hello {}", "world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +483,7 @@ LL + format!("Hello {}", "world!") | error: unneeded `return` statement - --> $DIR/needless_return.rs:249:9 + --> tests/ui/needless_return.rs:249:9 | LL | return true; | ^^^^^^^^^^^ @@ -497,7 +497,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:251:9 + --> tests/ui/needless_return.rs:251:9 | LL | return false; | ^^^^^^^^^^^^ @@ -509,7 +509,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:258:13 + --> tests/ui/needless_return.rs:258:13 | LL | return 10; | ^^^^^^^^^ @@ -524,7 +524,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:261:13 + --> tests/ui/needless_return.rs:261:13 | LL | return 100; | ^^^^^^^^^^ @@ -537,7 +537,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:269:9 + --> tests/ui/needless_return.rs:269:9 | LL | return 0; | ^^^^^^^^ @@ -549,7 +549,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:276:13 + --> tests/ui/needless_return.rs:276:13 | LL | return *(x as *const isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -564,7 +564,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:278:13 + --> tests/ui/needless_return.rs:278:13 | LL | return !*(x as *const isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -577,7 +577,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:285:20 + --> tests/ui/needless_return.rs:285:20 | LL | let _ = 42; | ____________________^ @@ -594,7 +594,7 @@ LL + let _ = 42; | error: unneeded `return` statement - --> $DIR/needless_return.rs:292:20 + --> tests/ui/needless_return.rs:292:20 | LL | let _ = 42; return; | ^^^^^^^ @@ -606,7 +606,7 @@ LL + let _ = 42; | error: unneeded `return` statement - --> $DIR/needless_return.rs:304:9 + --> tests/ui/needless_return.rs:304:9 | LL | return Ok(format!("ok!")); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -618,7 +618,7 @@ LL + Ok(format!("ok!")) | error: unneeded `return` statement - --> $DIR/needless_return.rs:306:9 + --> tests/ui/needless_return.rs:306:9 | LL | return Err(format!("err!")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -630,7 +630,7 @@ LL + Err(format!("err!")) | error: unneeded `return` statement - --> $DIR/needless_return.rs:312:9 + --> tests/ui/needless_return.rs:312:9 | LL | return if true { 1 } else { 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -642,7 +642,7 @@ LL + if true { 1 } else { 2 } | error: unneeded `return` statement - --> $DIR/needless_return.rs:316:9 + --> tests/ui/needless_return.rs:316:9 | LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/needless_return_with_question_mark.stderr b/tests/ui/needless_return_with_question_mark.stderr index 17aa212ae8d7a..76dd5f953bc67 100644 --- a/tests/ui/needless_return_with_question_mark.stderr +++ b/tests/ui/needless_return_with_question_mark.stderr @@ -1,5 +1,5 @@ error: unneeded `return` statement with `?` operator - --> $DIR/needless_return_with_question_mark.rs:29:5 + --> tests/ui/needless_return_with_question_mark.rs:29:5 | LL | return Err(())?; | ^^^^^^^ help: remove it @@ -8,7 +8,7 @@ LL | return Err(())?; = help: to override `-D warnings` add `#[allow(clippy::needless_return_with_question_mark)]` error: unneeded `return` statement with `?` operator - --> $DIR/needless_return_with_question_mark.rs:69:9 + --> tests/ui/needless_return_with_question_mark.rs:69:9 | LL | return Err(())?; | ^^^^^^^ help: remove it diff --git a/tests/ui/needless_splitn.stderr b/tests/ui/needless_splitn.stderr index f347ca760dbe2..ffd82c3fcb13a 100644 --- a/tests/ui/needless_splitn.stderr +++ b/tests/ui/needless_splitn.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:13:13 + --> tests/ui/needless_splitn.rs:13:13 | LL | let _ = str.splitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` @@ -8,73 +8,73 @@ LL | let _ = str.splitn(2, '=').next(); = help: to override `-D warnings` add `#[allow(clippy::needless_splitn)]` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:14:13 + --> tests/ui/needless_splitn.rs:14:13 | LL | let _ = str.splitn(2, '=').nth(0); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:17:18 + --> tests/ui/needless_splitn.rs:17:18 | LL | let (_, _) = str.splitn(3, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:20:13 + --> tests/ui/needless_splitn.rs:20:13 | LL | let _ = str.rsplitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^^ help: try: `str.rsplit('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:21:13 + --> tests/ui/needless_splitn.rs:21:13 | LL | let _ = str.rsplitn(2, '=').nth(0); | ^^^^^^^^^^^^^^^^^^^ help: try: `str.rsplit('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:24:18 + --> tests/ui/needless_splitn.rs:24:18 | LL | let (_, _) = str.rsplitn(3, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: try: `str.rsplit('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:26:13 + --> tests/ui/needless_splitn.rs:26:13 | LL | let _ = str.splitn(5, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:27:13 + --> tests/ui/needless_splitn.rs:27:13 | LL | let _ = str.splitn(5, '=').nth(3); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:33:13 + --> tests/ui/needless_splitn.rs:33:13 | LL | let _ = s.splitn(2, '=').next()?; | ^^^^^^^^^^^^^^^^ help: try: `s.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:34:13 + --> tests/ui/needless_splitn.rs:34:13 | LL | let _ = s.splitn(2, '=').nth(0)?; | ^^^^^^^^^^^^^^^^ help: try: `s.split('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:35:13 + --> tests/ui/needless_splitn.rs:35:13 | LL | let _ = s.rsplitn(2, '=').next()?; | ^^^^^^^^^^^^^^^^^ help: try: `s.rsplit('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:36:13 + --> tests/ui/needless_splitn.rs:36:13 | LL | let _ = s.rsplitn(2, '=').nth(0)?; | ^^^^^^^^^^^^^^^^^ help: try: `s.rsplit('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:44:13 + --> tests/ui/needless_splitn.rs:44:13 | LL | let _ = "key=value".splitn(2, '=').nth(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split('=')` diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 60aeb04938702..1f482f09e4143 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,5 +1,5 @@ error: struct update has no effect, all the fields in the struct have already been specified - --> $DIR/needless_update.rs:19:23 + --> tests/ui/needless_update.rs:19:23 | LL | S { a: 1, b: 1, ..base }; | ^^^^ diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index c64d96b4b2032..d4f7f14f59a39 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,5 +1,5 @@ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:16:21 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:16:21 | LL | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | let _not_less = !(a_value < another_value); = help: to override `-D warnings` add `#[allow(clippy::neg_cmp_op_on_partial_ord)]` error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:21:30 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:21:30 | LL | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:25:24 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:25:24 | LL | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:29:33 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:29:33 | LL | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index abfc94f97701f..13226c7c37b3f 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -1,5 +1,5 @@ error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:28:5 + --> tests/ui/neg_multiply.rs:28:5 | LL | x * -1; | ^^^^^^ help: consider using: `-x` @@ -8,43 +8,43 @@ LL | x * -1; = help: to override `-D warnings` add `#[allow(clippy::neg_multiply)]` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:30:5 + --> tests/ui/neg_multiply.rs:30:5 | LL | -1 * x; | ^^^^^^ help: consider using: `-x` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:32:11 + --> tests/ui/neg_multiply.rs:32:11 | LL | 100 + x * -1; | ^^^^^^ help: consider using: `-x` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:34:5 + --> tests/ui/neg_multiply.rs:34:5 | LL | (100 + x) * -1; | ^^^^^^^^^^^^^^ help: consider using: `-(100 + x)` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:36:5 + --> tests/ui/neg_multiply.rs:36:5 | LL | -1 * 17; | ^^^^^^^ help: consider using: `-17` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:38:14 + --> tests/ui/neg_multiply.rs:38:14 | LL | 0xcafe | 0xff00 * -1; | ^^^^^^^^^^^ help: consider using: `-0xff00` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:40:5 + --> tests/ui/neg_multiply.rs:40:5 | LL | 3_usize as i32 * -1; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:41:5 + --> tests/ui/neg_multiply.rs:41:5 | LL | (3_usize as i32) * -1; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)` diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 3982f36cea9f8..440a2b5aabaae 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,5 +1,5 @@ error: this loop never actually loops - --> $DIR/never_loop.rs:12:5 + --> tests/ui/never_loop.rs:12:5 | LL | / loop { LL | | @@ -13,7 +13,7 @@ LL | | } = note: `#[deny(clippy::never_loop)]` on by default error: this loop never actually loops - --> $DIR/never_loop.rs:36:5 + --> tests/ui/never_loop.rs:36:5 | LL | / loop { LL | | @@ -24,7 +24,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:57:5 + --> tests/ui/never_loop.rs:57:5 | LL | / loop { LL | | @@ -36,7 +36,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:60:9 + --> tests/ui/never_loop.rs:60:9 | LL | / while i == 0 { LL | | @@ -46,7 +46,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:73:9 + --> tests/ui/never_loop.rs:73:9 | LL | / loop { LL | | @@ -58,7 +58,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:110:5 + --> tests/ui/never_loop.rs:110:5 | LL | / while let Some(y) = x { LL | | @@ -68,7 +68,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:118:5 + --> tests/ui/never_loop.rs:118:5 | LL | / for x in 0..10 { LL | | @@ -85,7 +85,7 @@ LL | if let Some(x) = (0..10).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: this loop never actually loops - --> $DIR/never_loop.rs:167:5 + --> tests/ui/never_loop.rs:167:5 | LL | / 'outer: while a { LL | | @@ -97,7 +97,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:183:9 + --> tests/ui/never_loop.rs:183:9 | LL | / while false { LL | | @@ -106,7 +106,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:235:13 + --> tests/ui/never_loop.rs:235:13 | LL | let _ = loop { | _____________^ @@ -119,7 +119,7 @@ LL | | }; | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:257:5 + --> tests/ui/never_loop.rs:257:5 | LL | / 'a: loop { LL | | @@ -131,7 +131,7 @@ LL | | } | |_____^ error: sub-expression diverges - --> $DIR/never_loop.rs:261:17 + --> tests/ui/never_loop.rs:261:17 | LL | break 'a; | ^^^^^^^^ @@ -140,7 +140,7 @@ LL | break 'a; = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: this loop never actually loops - --> $DIR/never_loop.rs:294:13 + --> tests/ui/never_loop.rs:294:13 | LL | / for _ in 0..20 { LL | | @@ -154,7 +154,7 @@ LL | if let Some(_) = (0..20).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: this loop never actually loops - --> $DIR/never_loop.rs:378:13 + --> tests/ui/never_loop.rs:378:13 | LL | / 'c: loop { LL | | @@ -163,7 +163,7 @@ LL | | } | |_____________^ error: this loop never actually loops - --> $DIR/never_loop.rs:389:5 + --> tests/ui/never_loop.rs:389:5 | LL | / loop { LL | | @@ -172,7 +172,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:393:5 + --> tests/ui/never_loop.rs:393:5 | LL | / loop { LL | | diff --git a/tests/ui/new_ret_no_self.stderr b/tests/ui/new_ret_no_self.stderr index 8436e101ff97f..d440a9f45fcdb 100644 --- a/tests/ui/new_ret_no_self.stderr +++ b/tests/ui/new_ret_no_self.stderr @@ -1,5 +1,5 @@ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:50:5 + --> tests/ui/new_ret_no_self.rs:50:5 | LL | / pub fn new(_: String) -> impl R { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::new_ret_no_self)]` error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:84:5 + --> tests/ui/new_ret_no_self.rs:84:5 | LL | / pub fn new() -> u32 { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:94:5 + --> tests/ui/new_ret_no_self.rs:94:5 | LL | / pub fn new(_: String) -> u32 { LL | | @@ -30,7 +30,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:131:5 + --> tests/ui/new_ret_no_self.rs:131:5 | LL | / pub fn new() -> (u32, u32) { LL | | @@ -39,7 +39,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:159:5 + --> tests/ui/new_ret_no_self.rs:159:5 | LL | / pub fn new() -> *mut V { LL | | @@ -48,7 +48,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:178:5 + --> tests/ui/new_ret_no_self.rs:178:5 | LL | / pub fn new() -> Option { LL | | @@ -57,19 +57,19 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:232:9 + --> tests/ui/new_ret_no_self.rs:232:9 | LL | fn new() -> String; | ^^^^^^^^^^^^^^^^^^^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:245:9 + --> tests/ui/new_ret_no_self.rs:245:9 | LL | fn new(_: String) -> String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:281:9 + --> tests/ui/new_ret_no_self.rs:281:9 | LL | / fn new() -> (u32, u32) { LL | | @@ -78,7 +78,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:309:9 + --> tests/ui/new_ret_no_self.rs:309:9 | LL | / fn new() -> *mut V { LL | | @@ -87,7 +87,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:380:9 + --> tests/ui/new_ret_no_self.rs:380:9 | LL | / fn new(t: T) -> impl Into { LL | | @@ -96,7 +96,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:402:9 + --> tests/ui/new_ret_no_self.rs:402:9 | LL | / fn new(t: T) -> impl Trait2<(), i32> { LL | | diff --git a/tests/ui/new_ret_no_self_overflow.stderr b/tests/ui/new_ret_no_self_overflow.stderr index c0d6a74a51dee..77c1b64ebc8e3 100644 --- a/tests/ui/new_ret_no_self_overflow.stderr +++ b/tests/ui/new_ret_no_self_overflow.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow evaluating the requirement `::Output == issue10041::X` - --> $DIR/new_ret_no_self_overflow.rs:20:25 + --> tests/ui/new_ret_no_self_overflow.rs:20:25 | LL | pub fn new() -> X { | ^ diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 6652a2642051b..a30830ae7b2e9 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,5 +1,5 @@ error: you should consider adding a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:12:5 + --> tests/ui/new_without_default.rs:12:5 | LL | / pub fn new() -> Foo { LL | | @@ -20,7 +20,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:22:5 + --> tests/ui/new_without_default.rs:22:5 | LL | / pub fn new() -> Self { LL | | @@ -38,7 +38,7 @@ LL + } | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:87:5 + --> tests/ui/new_without_default.rs:87:5 | LL | / pub fn new() -> LtKo<'c> { LL | | @@ -56,7 +56,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Const` - --> $DIR/new_without_default.rs:120:5 + --> tests/ui/new_without_default.rs:120:5 | LL | / pub const fn new() -> Const { LL | | Const @@ -73,7 +73,7 @@ LL + } | error: you should consider adding a `Default` implementation for `NewNotEqualToDerive` - --> $DIR/new_without_default.rs:180:5 + --> tests/ui/new_without_default.rs:180:5 | LL | / pub fn new() -> Self { LL | | @@ -91,7 +91,7 @@ LL + } | error: you should consider adding a `Default` implementation for `FooGenerics` - --> $DIR/new_without_default.rs:189:5 + --> tests/ui/new_without_default.rs:189:5 | LL | / pub fn new() -> Self { LL | | @@ -109,7 +109,7 @@ LL + } | error: you should consider adding a `Default` implementation for `BarGenerics` - --> $DIR/new_without_default.rs:197:5 + --> tests/ui/new_without_default.rs:197:5 | LL | / pub fn new() -> Self { LL | | @@ -127,7 +127,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:209:9 + --> tests/ui/new_without_default.rs:209:9 | LL | / pub fn new() -> Self { LL | | @@ -147,7 +147,7 @@ LL ~ impl Foo { | error: you should consider adding a `Default` implementation for `MyStruct` - --> $DIR/new_without_default.rs:255:5 + --> tests/ui/new_without_default.rs:255:5 | LL | / pub fn new() -> Self { LL | | Self { _kv: None } diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 8140ba1feee9c..c7c8eecd054bc 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,5 +1,5 @@ error: statement with no effect - --> $DIR/no_effect.rs:122:5 + --> tests/ui/no_effect.rs:122:5 | LL | 0; | ^^ @@ -8,151 +8,151 @@ LL | 0; = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect - --> $DIR/no_effect.rs:125:5 + --> tests/ui/no_effect.rs:125:5 | LL | s2; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:127:5 + --> tests/ui/no_effect.rs:127:5 | LL | Unit; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:129:5 + --> tests/ui/no_effect.rs:129:5 | LL | Tuple(0); | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:131:5 + --> tests/ui/no_effect.rs:131:5 | LL | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:133:5 + --> tests/ui/no_effect.rs:133:5 | LL | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:135:5 + --> tests/ui/no_effect.rs:135:5 | LL | Union { a: 0 }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:137:5 + --> tests/ui/no_effect.rs:137:5 | LL | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:139:5 + --> tests/ui/no_effect.rs:139:5 | LL | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:141:5 + --> tests/ui/no_effect.rs:141:5 | LL | 5 + 6; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:143:5 + --> tests/ui/no_effect.rs:143:5 | LL | *&42; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:145:5 + --> tests/ui/no_effect.rs:145:5 | LL | &6; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:147:5 + --> tests/ui/no_effect.rs:147:5 | LL | (5, 6, 7); | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:149:5 + --> tests/ui/no_effect.rs:149:5 | LL | ..; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:151:5 + --> tests/ui/no_effect.rs:151:5 | LL | 5..; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:153:5 + --> tests/ui/no_effect.rs:153:5 | LL | ..5; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:155:5 + --> tests/ui/no_effect.rs:155:5 | LL | 5..6; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:157:5 + --> tests/ui/no_effect.rs:157:5 | LL | 5..=6; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:159:5 + --> tests/ui/no_effect.rs:159:5 | LL | [42, 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:161:5 + --> tests/ui/no_effect.rs:161:5 | LL | [42, 55][1]; | ^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:163:5 + --> tests/ui/no_effect.rs:163:5 | LL | (42, 55).1; | ^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:165:5 + --> tests/ui/no_effect.rs:165:5 | LL | [42; 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:167:5 + --> tests/ui/no_effect.rs:167:5 | LL | [42; 55][13]; | ^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:170:5 + --> tests/ui/no_effect.rs:170:5 | LL | || x += 5; | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:173:5 + --> tests/ui/no_effect.rs:173:5 | LL | FooString { s: s }; | ^^^^^^^^^^^^^^^^^^^ error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:175:9 + --> tests/ui/no_effect.rs:175:9 | LL | let _unused = 1; | ^^^^^^^ @@ -161,19 +161,19 @@ LL | let _unused = 1; = help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]` error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:178:9 + --> tests/ui/no_effect.rs:178:9 | LL | let _penguin = || println!("Some helpful closure"); | ^^^^^^^^ error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:180:9 + --> tests/ui/no_effect.rs:180:9 | LL | let _duck = Struct { field: 0 }; | ^^^^^ error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:182:9 + --> tests/ui/no_effect.rs:182:9 | LL | let _cat = [2, 4, 6, 8][2]; | ^^^^ diff --git a/tests/ui/no_effect_replace.stderr b/tests/ui/no_effect_replace.stderr index e1162f04f8571..ded86c5c5b8d2 100644 --- a/tests/ui/no_effect_replace.stderr +++ b/tests/ui/no_effect_replace.stderr @@ -1,5 +1,5 @@ error: replacing text with itself - --> $DIR/no_effect_replace.rs:4:13 + --> tests/ui/no_effect_replace.rs:4:13 | LL | let _ = "12345".replace('1', "1"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1"); = help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]` error: replacing text with itself - --> $DIR/no_effect_replace.rs:7:13 + --> tests/ui/no_effect_replace.rs:7:13 | LL | let _ = "12345".replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:9:13 + --> tests/ui/no_effect_replace.rs:9:13 | LL | let _ = String::new().replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:12:13 + --> tests/ui/no_effect_replace.rs:12:13 | LL | let _ = "12345".replacen('1', "1", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:14:13 + --> tests/ui/no_effect_replace.rs:14:13 | LL | let _ = "12345".replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:16:13 + --> tests/ui/no_effect_replace.rs:16:13 | LL | let _ = String::new().replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:23:13 + --> tests/ui/no_effect_replace.rs:23:13 | LL | let _ = "hello".replace(&x.f(), &x.f()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:27:13 + --> tests/ui/no_effect_replace.rs:27:13 | LL | let _ = "hello".replace(&y(), &y()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/no_effect_return.stderr b/tests/ui/no_effect_return.stderr index aed079f09b986..3cfe375d034ad 100644 --- a/tests/ui/no_effect_return.stderr +++ b/tests/ui/no_effect_return.stderr @@ -1,5 +1,5 @@ error: statement with no effect - --> $DIR/no_effect_return.rs:9:9 + --> tests/ui/no_effect_return.rs:9:9 | LL | 0u32; | -^^^^ @@ -10,7 +10,7 @@ LL | 0u32; = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect - --> $DIR/no_effect_return.rs:18:9 + --> tests/ui/no_effect_return.rs:18:9 | LL | 0u32; | -^^^^ @@ -18,7 +18,7 @@ LL | 0u32; | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:27:9 + --> tests/ui/no_effect_return.rs:27:9 | LL | 0i32 as C; | -^^^^^^^^^ @@ -26,19 +26,19 @@ LL | 0i32 as C; | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:36:9 + --> tests/ui/no_effect_return.rs:36:9 | LL | 0u128; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect_return.rs:46:9 + --> tests/ui/no_effect_return.rs:46:9 | LL | 0u16; | ^^^^^ error: statement with no effect - --> $DIR/no_effect_return.rs:54:9 + --> tests/ui/no_effect_return.rs:54:9 | LL | [1u16]; | -^^^^^^ @@ -46,7 +46,7 @@ LL | [1u16]; | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:62:9 + --> tests/ui/no_effect_return.rs:62:9 | LL | ControlFlow::Break::<()>(()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | ControlFlow::Break::<()>(()); | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:80:9 + --> tests/ui/no_effect_return.rs:80:9 | LL | (); | ^^^ error: statement with no effect - --> $DIR/no_effect_return.rs:89:9 + --> tests/ui/no_effect_return.rs:89:9 | LL | (); | ^^^ diff --git a/tests/ui/no_mangle_with_rust_abi.stderr b/tests/ui/no_mangle_with_rust_abi.stderr index 62d53c8395fd9..27b8b39a21a22 100644 --- a/tests/ui/no_mangle_with_rust_abi.stderr +++ b/tests/ui/no_mangle_with_rust_abi.stderr @@ -1,5 +1,5 @@ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:6:1 + --> tests/ui/no_mangle_with_rust_abi.rs:6:1 | LL | fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | extern "Rust" fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:11:1 + --> tests/ui/no_mangle_with_rust_abi.rs:11:1 | LL | pub fn rust_abi_fn_two(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | pub extern "Rust" fn rust_abi_fn_two(arg_one: u32, arg_two: usize) {} | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:17:1 + --> tests/ui/no_mangle_with_rust_abi.rs:17:1 | LL | pub unsafe fn rust_abi_fn_three(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | pub unsafe extern "Rust" fn rust_abi_fn_three(arg_one: u32, arg_two: usize) | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:23:1 + --> tests/ui/no_mangle_with_rust_abi.rs:23:1 | LL | unsafe fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | unsafe extern "Rust" fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:27:1 + --> tests/ui/no_mangle_with_rust_abi.rs:27:1 | LL | / fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lines( LL | | diff --git a/tests/ui/non_canonical_clone_impl.stderr b/tests/ui/non_canonical_clone_impl.stderr index 44196751b053b..8eff322fa2d74 100644 --- a/tests/ui/non_canonical_clone_impl.stderr +++ b/tests/ui/non_canonical_clone_impl.stderr @@ -1,5 +1,5 @@ error: non-canonical implementation of `clone` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:9:29 + --> tests/ui/non_canonical_clone_impl.rs:9:29 | LL | fn clone(&self) -> Self { | _____________________________^ @@ -11,7 +11,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::non_canonical_clone_impl)]` error: unnecessary implementation of `clone_from` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:13:5 + --> tests/ui/non_canonical_clone_impl.rs:13:5 | LL | / fn clone_from(&mut self, source: &Self) { LL | | source.clone(); @@ -20,7 +20,7 @@ LL | | } | |_____^ help: remove it error: non-canonical implementation of `clone` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:80:29 + --> tests/ui/non_canonical_clone_impl.rs:80:29 | LL | fn clone(&self) -> Self { | _____________________________^ @@ -29,7 +29,7 @@ LL | | } | |_____^ help: change this to: `{ *self }` error: unnecessary implementation of `clone_from` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:84:5 + --> tests/ui/non_canonical_clone_impl.rs:84:5 | LL | / fn clone_from(&mut self, source: &Self) { LL | | source.clone(); diff --git a/tests/ui/non_canonical_partial_ord_impl.stderr b/tests/ui/non_canonical_partial_ord_impl.stderr index 05cc717b9ba1d..a15379c5b1a5e 100644 --- a/tests/ui/non_canonical_partial_ord_impl.stderr +++ b/tests/ui/non_canonical_partial_ord_impl.stderr @@ -1,5 +1,5 @@ error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl.rs:16:1 + --> tests/ui/non_canonical_partial_ord_impl.rs:16:1 | LL | / impl PartialOrd for A { LL | | fn partial_cmp(&self, other: &Self) -> Option { @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::non_canonical_partial_ord_impl)]` error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl.rs:50:1 + --> tests/ui/non_canonical_partial_ord_impl.rs:50:1 | LL | / impl PartialOrd for C { LL | | fn partial_cmp(&self, _: &Self) -> Option { diff --git a/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr b/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr index 4978d7a873960..8dd7face6ef4e 100644 --- a/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr +++ b/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr @@ -1,5 +1,5 @@ error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl_fully_qual.rs:23:1 + --> tests/ui/non_canonical_partial_ord_impl_fully_qual.rs:23:1 | LL | / impl PartialOrd for A { LL | | fn partial_cmp(&self, other: &Self) -> Option { @@ -16,7 +16,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::non_canonical_partial_ord_impl)]` error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl_fully_qual.rs:46:1 + --> tests/ui/non_canonical_partial_ord_impl_fully_qual.rs:46:1 | LL | / impl PartialOrd for B { LL | | fn partial_cmp(&self, other: &Self) -> Option { diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 1b78124a90318..d9c745f466b7b 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,5 +1,5 @@ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:28:9 + --> tests/ui/non_expressive_names.rs:28:9 | LL | let _1 = 1; | ^^ @@ -8,31 +8,31 @@ LL | let _1 = 1; = help: to override `-D warnings` add `#[allow(clippy::just_underscores_and_digits)]` error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:29:9 + --> tests/ui/non_expressive_names.rs:29:9 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:30:9 + --> tests/ui/non_expressive_names.rs:30:9 | LL | let __1___2 = 12; | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:51:13 + --> tests/ui/non_expressive_names.rs:51:13 | LL | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:52:13 + --> tests/ui/non_expressive_names.rs:52:13 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:53:13 + --> tests/ui/non_expressive_names.rs:53:13 | LL | let __1___2 = 12; | ^^^^^^^ diff --git a/tests/ui/non_minimal_cfg.stderr b/tests/ui/non_minimal_cfg.stderr index c33c35ed8df94..707ff51d430c9 100644 --- a/tests/ui/non_minimal_cfg.stderr +++ b/tests/ui/non_minimal_cfg.stderr @@ -1,5 +1,5 @@ error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:3:7 + --> tests/ui/non_minimal_cfg.rs:3:7 | LL | #[cfg(all(windows))] | ^^^^^^^^^^^^ help: try: `windows` @@ -8,19 +8,19 @@ LL | #[cfg(all(windows))] = help: to override `-D warnings` add `#[allow(clippy::non_minimal_cfg)]` error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:6:7 + --> tests/ui/non_minimal_cfg.rs:6:7 | LL | #[cfg(any(windows))] | ^^^^^^^^^^^^ help: try: `windows` error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:9:11 + --> tests/ui/non_minimal_cfg.rs:9:11 | LL | #[cfg(all(any(unix), all(not(windows))))] | ^^^^^^^^^ help: try: `unix` error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:9:22 + --> tests/ui/non_minimal_cfg.rs:9:22 | LL | #[cfg(all(any(unix), all(not(windows))))] | ^^^^^^^^^^^^^^^^^ help: try: `not(windows)` diff --git a/tests/ui/non_minimal_cfg2.stderr b/tests/ui/non_minimal_cfg2.stderr index 036d38c22f48d..6d86e931edce9 100644 --- a/tests/ui/non_minimal_cfg2.stderr +++ b/tests/ui/non_minimal_cfg2.stderr @@ -1,5 +1,5 @@ error: unneeded sub `cfg` when there is no condition - --> $DIR/non_minimal_cfg2.rs:3:7 + --> tests/ui/non_minimal_cfg2.rs:3:7 | LL | #[cfg(all())] | ^^^^^ diff --git a/tests/ui/non_octal_unix_permissions.stderr b/tests/ui/non_octal_unix_permissions.stderr index 83688c1b4517c..890b308a1dc56 100644 --- a/tests/ui/non_octal_unix_permissions.stderr +++ b/tests/ui/non_octal_unix_permissions.stderr @@ -1,5 +1,5 @@ error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:12:18 + --> tests/ui/non_octal_unix_permissions.rs:12:18 | LL | options.mode(440); | ^^^ help: consider using an octal literal instead: `0o440` @@ -8,19 +8,19 @@ LL | options.mode(440); = help: to override `-D warnings` add `#[allow(clippy::non_octal_unix_permissions)]` error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:17:47 + --> tests/ui/non_octal_unix_permissions.rs:17:47 | LL | let _permissions = Permissions::from_mode(647); | ^^^ help: consider using an octal literal instead: `0o647` error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:26:26 + --> tests/ui/non_octal_unix_permissions.rs:26:26 | LL | permissions.set_mode(644); | ^^^ help: consider using an octal literal instead: `0o644` error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:33:18 + --> tests/ui/non_octal_unix_permissions.rs:33:18 | LL | builder.mode(755); | ^^^ help: consider using an octal literal instead: `0o755` diff --git a/tests/ui/non_send_fields_in_send_ty.stderr b/tests/ui/non_send_fields_in_send_ty.stderr index 1ea76196af938..b4466f484fb37 100644 --- a/tests/ui/non_send_fields_in_send_ty.stderr +++ b/tests/ui/non_send_fields_in_send_ty.stderr @@ -1,11 +1,11 @@ error: some fields in `RingBuffer` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:17:1 + --> tests/ui/non_send_fields_in_send_ty.rs:17:1 | LL | unsafe impl Send for RingBuffer {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `data` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:12:5 + --> tests/ui/non_send_fields_in_send_ty.rs:12:5 | LL | data: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,155 +14,155 @@ LL | data: Vec>, = help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]` error: some fields in `MvccRwLock` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:26:1 + --> tests/ui/non_send_fields_in_send_ty.rs:26:1 | LL | unsafe impl Send for MvccRwLock {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `lock` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:23:5 + --> tests/ui/non_send_fields_in_send_ty.rs:23:5 | LL | lock: Mutex>, | ^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Mutex>: Send` error: some fields in `ArcGuard` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:35:1 + --> tests/ui/non_send_fields_in_send_ty.rs:35:1 | LL | unsafe impl Send for ArcGuard {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `head` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:32:5 + --> tests/ui/non_send_fields_in_send_ty.rs:32:5 | LL | head: Arc, | ^^^^^^^^^^^^^ = help: add bounds on type parameter `RC` that satisfy `Arc: Send` error: some fields in `DeviceHandle` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:52:1 + --> tests/ui/non_send_fields_in_send_ty.rs:52:1 | LL | unsafe impl Send for DeviceHandle {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `context` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:48:5 + --> tests/ui/non_send_fields_in_send_ty.rs:48:5 | LL | context: T, | ^^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `NoGeneric` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:60:1 + --> tests/ui/non_send_fields_in_send_ty.rs:60:1 | LL | unsafe impl Send for NoGeneric {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `rc_is_not_send` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:57:5 + --> tests/ui/non_send_fields_in_send_ty.rs:57:5 | LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: some fields in `MultiField` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:69:1 + --> tests/ui/non_send_fields_in_send_ty.rs:69:1 | LL | unsafe impl Send for MultiField {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:64:5 + --> tests/ui/non_send_fields_in_send_ty.rs:64:5 | LL | field1: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field2` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:65:5 + --> tests/ui/non_send_fields_in_send_ty.rs:65:5 | LL | field2: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field3` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:66:5 + --> tests/ui/non_send_fields_in_send_ty.rs:66:5 | LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `MyOption` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:77:1 + --> tests/ui/non_send_fields_in_send_ty.rs:77:1 | LL | unsafe impl Send for MyOption {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:73:12 + --> tests/ui/non_send_fields_in_send_ty.rs:73:12 | LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `MultiParam` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:90:1 + --> tests/ui/non_send_fields_in_send_ty.rs:90:1 | LL | unsafe impl Send for MultiParam {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `vec` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:87:5 + --> tests/ui/non_send_fields_in_send_ty.rs:87:5 | LL | vec: Vec<(A, B)>, | ^^^^^^^^^^^^^^^^ = help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send` error: some fields in `HeuristicTest` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:109:1 + --> tests/ui/non_send_fields_in_send_ty.rs:109:1 | LL | unsafe impl Send for HeuristicTest {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field4` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:104:5 + --> tests/ui/non_send_fields_in_send_ty.rs:104:5 | LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: some fields in `AttrTest3` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:129:1 + --> tests/ui/non_send_fields_in_send_ty.rs:129:1 | LL | unsafe impl Send for AttrTest3 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:124:11 + --> tests/ui/non_send_fields_in_send_ty.rs:124:11 | LL | Enum2(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `Complex` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:138:1 + --> tests/ui/non_send_fields_in_send_ty.rs:138:1 | LL | unsafe impl

Send for Complex {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:134:5 + --> tests/ui/non_send_fields_in_send_ty.rs:134:5 | LL | field1: A, | ^^^^^^^^^ = help: add `P: Send` bound in `Send` impl error: some fields in `Complex>` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:142:1 + --> tests/ui/non_send_fields_in_send_ty.rs:142:1 | LL | unsafe impl Send for Complex> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field2` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:135:5 + --> tests/ui/non_send_fields_in_send_ty.rs:135:5 | LL | field2: B, | ^^^^^^^^^ diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr index a317c8328d947..954e23452665d 100644 --- a/tests/ui/nonminimal_bool.stderr +++ b/tests/ui/nonminimal_bool.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:18:13 + --> tests/ui/nonminimal_bool.rs:18:13 | LL | let _ = !true; | ^^^^^ help: try: `false` @@ -8,43 +8,43 @@ LL | let _ = !true; = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:21:13 + --> tests/ui/nonminimal_bool.rs:21:13 | LL | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:23:13 + --> tests/ui/nonminimal_bool.rs:23:13 | LL | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:25:13 + --> tests/ui/nonminimal_bool.rs:25:13 | LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:30:13 + --> tests/ui/nonminimal_bool.rs:30:13 | LL | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `a || !b` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:32:13 + --> tests/ui/nonminimal_bool.rs:32:13 | LL | let _ = !(!a || b); | ^^^^^^^^^^ help: try: `a && !b` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:34:13 + --> tests/ui/nonminimal_bool.rs:34:13 | LL | let _ = !a && !(b && c); | ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:43:13 + --> tests/ui/nonminimal_bool.rs:43:13 | LL | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:45:13 + --> tests/ui/nonminimal_bool.rs:45:13 | LL | let _ = a == b || c == 5 || a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | let _ = a == b || c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:47:13 + --> tests/ui/nonminimal_bool.rs:47:13 | LL | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:49:13 + --> tests/ui/nonminimal_bool.rs:49:13 | LL | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL | let _ = a != b || c != d; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:51:13 + --> tests/ui/nonminimal_bool.rs:51:13 | LL | let _ = a != b && !(a != b && c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,43 +109,43 @@ LL | let _ = a != b && c != d; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:82:8 + --> tests/ui/nonminimal_bool.rs:82:8 | LL | if matches!(true, true) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:162:8 + --> tests/ui/nonminimal_bool.rs:162:8 | LL | if !(12 == a) {} | ^^^^^^^^^^ help: try: `12 != a` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:163:8 + --> tests/ui/nonminimal_bool.rs:163:8 | LL | if !(a == 12) {} | ^^^^^^^^^^ help: try: `a != 12` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:164:8 + --> tests/ui/nonminimal_bool.rs:164:8 | LL | if !(12 != a) {} | ^^^^^^^^^^ help: try: `12 == a` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:165:8 + --> tests/ui/nonminimal_bool.rs:165:8 | LL | if !(a != 12) {} | ^^^^^^^^^^ help: try: `a == 12` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:169:8 + --> tests/ui/nonminimal_bool.rs:169:8 | LL | if !b == true {} | ^^^^^^^^^^ help: try: `b != true` error: this comparison might be written more concisely - --> $DIR/nonminimal_bool.rs:169:8 + --> tests/ui/nonminimal_bool.rs:169:8 | LL | if !b == true {} | ^^^^^^^^^^ help: try simplifying it as shown: `b != true` @@ -154,61 +154,61 @@ LL | if !b == true {} = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against true are unnecessary - --> $DIR/nonminimal_bool.rs:169:8 + --> tests/ui/nonminimal_bool.rs:169:8 | LL | if !b == true {} | ^^^^^^^^^^ help: try simplifying it as shown: `!b` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:170:8 + --> tests/ui/nonminimal_bool.rs:170:8 | LL | if !b != true {} | ^^^^^^^^^^ help: try: `b == true` error: inequality checks against true can be replaced by a negation - --> $DIR/nonminimal_bool.rs:170:8 + --> tests/ui/nonminimal_bool.rs:170:8 | LL | if !b != true {} | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:171:8 + --> tests/ui/nonminimal_bool.rs:171:8 | LL | if true == !b {} | ^^^^^^^^^^ help: try: `true != b` error: this comparison might be written more concisely - --> $DIR/nonminimal_bool.rs:171:8 + --> tests/ui/nonminimal_bool.rs:171:8 | LL | if true == !b {} | ^^^^^^^^^^ help: try simplifying it as shown: `true != b` error: equality checks against true are unnecessary - --> $DIR/nonminimal_bool.rs:171:8 + --> tests/ui/nonminimal_bool.rs:171:8 | LL | if true == !b {} | ^^^^^^^^^^ help: try simplifying it as shown: `!b` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:172:8 + --> tests/ui/nonminimal_bool.rs:172:8 | LL | if true != !b {} | ^^^^^^^^^^ help: try: `true == b` error: inequality checks against true can be replaced by a negation - --> $DIR/nonminimal_bool.rs:172:8 + --> tests/ui/nonminimal_bool.rs:172:8 | LL | if true != !b {} | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:173:8 + --> tests/ui/nonminimal_bool.rs:173:8 | LL | if !b == !c {} | ^^^^^^^^ help: try: `b == c` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:174:8 + --> tests/ui/nonminimal_bool.rs:174:8 | LL | if !b != !c {} | ^^^^^^^^ help: try: `b != c` diff --git a/tests/ui/nonminimal_bool_methods.stderr b/tests/ui/nonminimal_bool_methods.stderr index d47bbf7e0799a..ede88ba529cdc 100644 --- a/tests/ui/nonminimal_bool_methods.stderr +++ b/tests/ui/nonminimal_bool_methods.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:8:13 + --> tests/ui/nonminimal_bool_methods.rs:8:13 | LL | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` @@ -8,73 +8,73 @@ LL | let _ = !a.is_some(); = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:10:13 + --> tests/ui/nonminimal_bool_methods.rs:10:13 | LL | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:12:13 + --> tests/ui/nonminimal_bool_methods.rs:12:13 | LL | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:14:13 + --> tests/ui/nonminimal_bool_methods.rs:14:13 | LL | let _ = !b.is_ok(); | ^^^^^^^^^^ help: try: `b.is_err()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:16:13 + --> tests/ui/nonminimal_bool_methods.rs:16:13 | LL | let _ = !(a.is_some() && !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:17:13 + --> tests/ui/nonminimal_bool_methods.rs:17:13 | LL | let _ = !(a.is_some() || !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:18:26 + --> tests/ui/nonminimal_bool_methods.rs:18:26 | LL | let _ = !(!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:19:25 + --> tests/ui/nonminimal_bool_methods.rs:19:25 | LL | let _ = (!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:20:23 + --> tests/ui/nonminimal_bool_methods.rs:20:23 | LL | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:92:8 + --> tests/ui/nonminimal_bool_methods.rs:92:8 | LL | if !res.is_ok() {} | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:93:8 + --> tests/ui/nonminimal_bool_methods.rs:93:8 | LL | if !res.is_err() {} | ^^^^^^^^^^^^^ help: try: `res.is_ok()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:96:8 + --> tests/ui/nonminimal_bool_methods.rs:96:8 | LL | if !res.is_some() {} | ^^^^^^^^^^^^^^ help: try: `res.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:97:8 + --> tests/ui/nonminimal_bool_methods.rs:97:8 | LL | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` diff --git a/tests/ui/numbered_fields.stderr b/tests/ui/numbered_fields.stderr index 76f5e082f326c..96426cab1e623 100644 --- a/tests/ui/numbered_fields.stderr +++ b/tests/ui/numbered_fields.stderr @@ -1,5 +1,5 @@ error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:17:13 + --> tests/ui/numbered_fields.rs:17:13 | LL | let _ = TupleStruct { | _____________^ @@ -13,7 +13,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::init_numbered_fields)]` error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:24:13 + --> tests/ui/numbered_fields.rs:24:13 | LL | let _ = TupleStruct { | _____________^ diff --git a/tests/ui/obfuscated_if_else.stderr b/tests/ui/obfuscated_if_else.stderr index abf5adce44466..d4c2f9b331a82 100644 --- a/tests/ui/obfuscated_if_else.stderr +++ b/tests/ui/obfuscated_if_else.stderr @@ -1,5 +1,5 @@ error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` - --> $DIR/obfuscated_if_else.rs:4:5 + --> tests/ui/obfuscated_if_else.rs:4:5 | LL | true.then_some("a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` diff --git a/tests/ui/octal_escapes.stderr b/tests/ui/octal_escapes.stderr index d2161582b827d..7ed9ee3ae2f4f 100644 --- a/tests/ui/octal_escapes.stderr +++ b/tests/ui/octal_escapes.stderr @@ -1,5 +1,5 @@ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:5:17 + --> tests/ui/octal_escapes.rs:5:17 | LL | let _bad1 = "\033[0m"; | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _bad1 = "\x0033[0m"; | ~~~~~~~~~~~ error: octal-looking escape in byte string literal - --> $DIR/octal_escapes.rs:7:17 + --> tests/ui/octal_escapes.rs:7:17 | LL | let _bad2 = b"\033[0m"; | ^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _bad2 = b"\x0033[0m"; | ~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:9:17 + --> tests/ui/octal_escapes.rs:9:17 | LL | let _bad3 = "\\\033[0m"; | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _bad3 = "\\\x0033[0m"; | ~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:12:17 + --> tests/ui/octal_escapes.rs:12:17 | LL | let _bad4 = "\01234567"; | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _bad4 = "\x001234567"; | ~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:14:17 + --> tests/ui/octal_escapes.rs:14:17 | LL | let _bad5 = "\0\03"; | ^^^^^^^ @@ -81,7 +81,7 @@ LL | let _bad5 = "\0\x003"; | ~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:16:17 + --> tests/ui/octal_escapes.rs:16:17 | LL | let _bad6 = "Text-\055\077-MoreText"; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _bad6 = "Text-\x0055\x0077-MoreText"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:18:17 + --> tests/ui/octal_escapes.rs:18:17 | LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | let _bad7 = "EvenMoreText-\x001\x002-ShortEscapes"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:20:17 + --> tests/ui/octal_escapes.rs:20:17 | LL | let _bad8 = "锈\01锈"; | ^^^^^^^^^ @@ -129,7 +129,7 @@ LL | let _bad8 = "锈\x001锈"; | ~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:22:17 + --> tests/ui/octal_escapes.rs:22:17 | LL | let _bad9 = "锈\011锈"; | ^^^^^^^^^^ diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index ac2b6dcc83b52..2fd4f007d06d9 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -1,5 +1,5 @@ error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:16:5 + --> tests/ui/ok_expect.rs:16:5 | LL | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | res.ok().expect("disaster!"); = help: to override `-D warnings` add `#[allow(clippy::ok_expect)]` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:23:5 + --> tests/ui/ok_expect.rs:23:5 | LL | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | res3.ok().expect("whoof"); = help: you can call `expect()` directly on the `Result` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:26:5 + --> tests/ui/ok_expect.rs:26:5 | LL | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | res4.ok().expect("argh"); = help: you can call `expect()` directly on the `Result` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:29:5 + --> tests/ui/ok_expect.rs:29:5 | LL | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | res5.ok().expect("oops"); = help: you can call `expect()` directly on the `Result` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:32:5 + --> tests/ui/ok_expect.rs:32:5 | LL | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/only_used_in_recursion.stderr b/tests/ui/only_used_in_recursion.stderr index 85eee99c01c59..a3aee2697f380 100644 --- a/tests/ui/only_used_in_recursion.stderr +++ b/tests/ui/only_used_in_recursion.stderr @@ -1,11 +1,11 @@ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:11:27 + --> tests/ui/only_used_in_recursion.rs:11:27 | LL | fn _one_unused(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:13:53 + --> tests/ui/only_used_in_recursion.rs:13:53 | LL | if flag == 0 { 0 } else { _one_unused(flag - 1, a) } | ^ @@ -13,181 +13,181 @@ LL | if flag == 0 { 0 } else { _one_unused(flag - 1, a) } = help: to override `-D warnings` add `#[allow(clippy::only_used_in_recursion)]` error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:16:27 + --> tests/ui/only_used_in_recursion.rs:16:27 | LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:19:53 + --> tests/ui/only_used_in_recursion.rs:19:53 | LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:16:35 + --> tests/ui/only_used_in_recursion.rs:16:35 | LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:19:56 + --> tests/ui/only_used_in_recursion.rs:19:56 | LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:22:26 + --> tests/ui/only_used_in_recursion.rs:22:26 | LL | fn _with_calc(flag: u32, a: i64) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:27:32 + --> tests/ui/only_used_in_recursion.rs:27:32 | LL | _with_calc(flag - 1, (-a + 10) * 5) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:36:33 + --> tests/ui/only_used_in_recursion.rs:36:33 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:42:38 + --> tests/ui/only_used_in_recursion.rs:42:38 | LL | _used_with_unused(flag - 1, -a, a + b) | ^ ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:36:41 + --> tests/ui/only_used_in_recursion.rs:36:41 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:42:45 + --> tests/ui/only_used_in_recursion.rs:42:45 | LL | _used_with_unused(flag - 1, -a, a + b) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:46:35 + --> tests/ui/only_used_in_recursion.rs:46:35 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:52:39 + --> tests/ui/only_used_in_recursion.rs:52:39 | LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:46:43 + --> tests/ui/only_used_in_recursion.rs:46:43 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:52:43 + --> tests/ui/only_used_in_recursion.rs:52:43 | LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:56:30 + --> tests/ui/only_used_in_recursion.rs:56:30 | LL | fn _not_primitive(flag: u32, b: String) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:58:56 + --> tests/ui/only_used_in_recursion.rs:58:56 | LL | if flag == 0 { 0 } else { _not_primitive(flag - 1, b) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:64:29 + --> tests/ui/only_used_in_recursion.rs:64:29 | LL | fn _method(flag: usize, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:66:59 + --> tests/ui/only_used_in_recursion.rs:66:59 | LL | if flag == 0 { 0 } else { Self::_method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:69:22 + --> tests/ui/only_used_in_recursion.rs:69:22 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { | ^^^^ | note: parameter used here - --> $DIR/only_used_in_recursion.rs:72:35 + --> tests/ui/only_used_in_recursion.rs:72:35 | LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^^^^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:69:41 + --> tests/ui/only_used_in_recursion.rs:69:41 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:72:63 + --> tests/ui/only_used_in_recursion.rs:72:63 | LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:82:26 + --> tests/ui/only_used_in_recursion.rs:82:26 | LL | fn method(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:84:58 + --> tests/ui/only_used_in_recursion.rs:84:58 | LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:87:38 + --> tests/ui/only_used_in_recursion.rs:87:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:89:62 + --> tests/ui/only_used_in_recursion.rs:89:62 | LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:114:26 + --> tests/ui/only_used_in_recursion.rs:114:26 | LL | fn method(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:116:58 + --> tests/ui/only_used_in_recursion.rs:116:58 | LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:119:38 + --> tests/ui/only_used_in_recursion.rs:119:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:121:62 + --> tests/ui/only_used_in_recursion.rs:121:62 | LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ diff --git a/tests/ui/only_used_in_recursion2.stderr b/tests/ui/only_used_in_recursion2.stderr index 3ddd9758c26fd..e39460c7e8f3e 100644 --- a/tests/ui/only_used_in_recursion2.stderr +++ b/tests/ui/only_used_in_recursion2.stderr @@ -1,11 +1,11 @@ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:3:35 + --> tests/ui/only_used_in_recursion2.rs:3:35 | LL | fn _with_inner(flag: u32, a: u32, b: u32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:11:52 + --> tests/ui/only_used_in_recursion2.rs:11:52 | LL | if flag == 0 { 0 } else { _with_inner(flag, a, b + x) } | ^ @@ -13,49 +13,49 @@ LL | if flag == 0 { 0 } else { _with_inner(flag, a, b + x) } = help: to override `-D warnings` add `#[allow(clippy::only_used_in_recursion)]` error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:5:25 + --> tests/ui/only_used_in_recursion2.rs:5:25 | LL | fn inner(flag: u32, a: u32) -> u32 { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:7:47 + --> tests/ui/only_used_in_recursion2.rs:7:47 | LL | if flag == 0 { 0 } else { inner(flag, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:14:34 + --> tests/ui/only_used_in_recursion2.rs:14:34 | LL | fn _with_closure(a: Option, b: u32, f: impl Fn(u32, u32) -> Option) -> u32 { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:17:32 + --> tests/ui/only_used_in_recursion2.rs:17:32 | LL | _with_closure(Some(x), b, f) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:65:37 + --> tests/ui/only_used_in_recursion2.rs:65:37 | LL | fn overwritten_param(flag: u32, mut a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:74:29 + --> tests/ui/only_used_in_recursion2.rs:74:29 | LL | overwritten_param(flag, a) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:77:32 + --> tests/ui/only_used_in_recursion2.rs:77:32 | LL | fn field_direct(flag: u32, mut a: (usize,)) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:83:32 + --> tests/ui/only_used_in_recursion2.rs:83:32 | LL | field_direct(flag - 1, a) | ^ diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index f03e24b840054..c5b68730a8f26 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -1,5 +1,5 @@ error: needlessly taken reference of both operands - --> $DIR/op_ref.rs:11:15 + --> tests/ui/op_ref.rs:11:15 | LL | let foo = &5 - &6; | ^^^^^^^ @@ -12,7 +12,7 @@ LL | let foo = 5 - 6; | ~ ~ error: taken reference of right operand - --> $DIR/op_ref.rs:58:13 + --> tests/ui/op_ref.rs:58:13 | LL | let z = x & &y; | ^^^^-- @@ -20,7 +20,7 @@ LL | let z = x & &y; | help: use the right value directly: `y` error: taken reference of right operand - --> $DIR/op_ref.rs:92:17 + --> tests/ui/op_ref.rs:92:17 | LL | let _ = one * &self; | ^^^^^^----- @@ -28,7 +28,7 @@ LL | let _ = one * &self; | help: use the right value directly: `self` error: taken reference of right operand - --> $DIR/op_ref.rs:94:17 + --> tests/ui/op_ref.rs:94:17 | LL | let _ = two + &three; | ^^^^^^------ diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 4f84d1d09f984..19755bce46c86 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,5 +1,5 @@ error: file opened with `truncate` and `read` - --> $DIR/open_options.rs:17:5 + --> tests/ui/open_options.rs:17:5 | LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,43 +8,43 @@ LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); = help: to override `-D warnings` add `#[allow(clippy::nonsensical_open_options)]` error: file opened with `append` and `truncate` - --> $DIR/open_options.rs:20:5 + --> tests/ui/open_options.rs:20:5 | LL | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method `read` is called more than once - --> $DIR/open_options.rs:23:35 + --> tests/ui/open_options.rs:23:35 | LL | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^ error: the method `create` is called more than once - --> $DIR/open_options.rs:28:10 + --> tests/ui/open_options.rs:28:10 | LL | .create(false) | ^^^^^^^^^^^^^ error: the method `write` is called more than once - --> $DIR/open_options.rs:31:36 + --> tests/ui/open_options.rs:31:36 | LL | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^ error: the method `append` is called more than once - --> $DIR/open_options.rs:33:37 + --> tests/ui/open_options.rs:33:37 | LL | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^ error: the method `truncate` is called more than once - --> $DIR/open_options.rs:35:39 + --> tests/ui/open_options.rs:35:39 | LL | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^ error: the method `read` is called more than once - --> $DIR/open_options.rs:38:41 + --> tests/ui/open_options.rs:38:41 | LL | std::fs::File::options().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^ diff --git a/tests/ui/open_options_fixable.stderr b/tests/ui/open_options_fixable.stderr index e327661713bfb..fc54320fc07d3 100644 --- a/tests/ui/open_options_fixable.stderr +++ b/tests/ui/open_options_fixable.stderr @@ -1,5 +1,5 @@ error: file opened with `create`, but `truncate` behavior not defined - --> $DIR/open_options_fixable.rs:5:24 + --> tests/ui/open_options_fixable.rs:5:24 | LL | OpenOptions::new().create(true).open("foo.txt"); | ^^^^^^^^^^^^- help: add: `.truncate(true)` diff --git a/tests/ui/option_as_ref_cloned.stderr b/tests/ui/option_as_ref_cloned.stderr index ea03da3b69fab..5892f2bdec56e 100644 --- a/tests/ui/option_as_ref_cloned.stderr +++ b/tests/ui/option_as_ref_cloned.stderr @@ -1,5 +1,5 @@ error: cloning an `Option<_>` using `.as_ref().cloned()` - --> $DIR/option_as_ref_cloned.rs:7:31 + --> tests/ui/option_as_ref_cloned.rs:7:31 | LL | let _: Option = x.as_ref().cloned(); | ^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | let _: Option = x.clone(); | ~~~~~ error: cloning an `Option<_>` using `.as_mut().cloned()` - --> $DIR/option_as_ref_cloned.rs:8:31 + --> tests/ui/option_as_ref_cloned.rs:8:31 | LL | let _: Option = x.as_mut().cloned(); | ^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _: Option = x.clone(); | ~~~~~ error: cloning an `Option<_>` using `.as_ref().cloned()` - --> $DIR/option_as_ref_cloned.rs:11:32 + --> tests/ui/option_as_ref_cloned.rs:11:32 | LL | let _: Option<&String> = y.as_ref().cloned(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/option_as_ref_deref.stderr b/tests/ui/option_as_ref_deref.stderr index 036b8c749e417..8b7f47a1b9af0 100644 --- a/tests/ui/option_as_ref_deref.stderr +++ b/tests/ui/option_as_ref_deref.stderr @@ -1,5 +1,5 @@ error: called `.as_ref().map(Deref::deref)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:11:13 + --> tests/ui/option_as_ref_deref.rs:11:13 | LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.clone().as_deref()` @@ -8,7 +8,7 @@ LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len); = help: to override `-D warnings` add `#[allow(clippy::option_as_ref_deref)]` error: called `.as_ref().map(Deref::deref)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:14:13 + --> tests/ui/option_as_ref_deref.rs:14:13 | LL | let _ = opt.clone() | _____________^ @@ -18,97 +18,97 @@ LL | | ) | |_________^ help: consider using as_deref: `opt.clone().as_deref()` error: called `.as_mut().map(DerefMut::deref_mut)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:20:13 + --> tests/ui/option_as_ref_deref.rs:20:13 | LL | let _ = opt.as_mut().map(DerefMut::deref_mut); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_ref().map(String::as_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:22:13 + --> tests/ui/option_as_ref_deref.rs:22:13 | LL | let _ = opt.as_ref().map(String::as_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_ref().map(|x| x.as_str())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:23:13 + --> tests/ui/option_as_ref_deref.rs:23:13 | LL | let _ = opt.as_ref().map(|x| x.as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_mut().map(String::as_mut_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:24:13 + --> tests/ui/option_as_ref_deref.rs:24:13 | LL | let _ = opt.as_mut().map(String::as_mut_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_mut().map(|x| x.as_mut_str())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:25:13 + --> tests/ui/option_as_ref_deref.rs:25:13 | LL | let _ = opt.as_mut().map(|x| x.as_mut_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_ref().map(CString::as_c_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:26:13 + --> tests/ui/option_as_ref_deref.rs:26:13 | LL | let _ = Some(CString::new(vec![]).unwrap()).as_ref().map(CString::as_c_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(CString::new(vec![]).unwrap()).as_deref()` error: called `.as_ref().map(OsString::as_os_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:27:13 + --> tests/ui/option_as_ref_deref.rs:27:13 | LL | let _ = Some(OsString::new()).as_ref().map(OsString::as_os_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(OsString::new()).as_deref()` error: called `.as_ref().map(PathBuf::as_path)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:28:13 + --> tests/ui/option_as_ref_deref.rs:28:13 | LL | let _ = Some(PathBuf::new()).as_ref().map(PathBuf::as_path); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(PathBuf::new()).as_deref()` error: called `.as_ref().map(Vec::as_slice)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:29:13 + --> tests/ui/option_as_ref_deref.rs:29:13 | LL | let _ = Some(Vec::<()>::new()).as_ref().map(Vec::as_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(Vec::<()>::new()).as_deref()` error: called `.as_mut().map(Vec::as_mut_slice)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:30:13 + --> tests/ui/option_as_ref_deref.rs:30:13 | LL | let _ = Some(Vec::<()>::new()).as_mut().map(Vec::as_mut_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `Some(Vec::<()>::new()).as_deref_mut()` error: called `.as_ref().map(|x| x.deref())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:32:13 + --> tests/ui/option_as_ref_deref.rs:32:13 | LL | let _ = opt.as_ref().map(|x| x.deref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_mut().map(|x| x.deref_mut())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:33:13 + --> tests/ui/option_as_ref_deref.rs:33:13 | LL | let _ = opt.clone().as_mut().map(|x| x.deref_mut()).map(|x| x.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.clone().as_deref_mut()` error: called `.as_ref().map(|x| &**x)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:40:13 + --> tests/ui/option_as_ref_deref.rs:40:13 | LL | let _ = opt.as_ref().map(|x| &**x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_mut().map(|x| &mut **x)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:41:13 + --> tests/ui/option_as_ref_deref.rs:41:13 | LL | let _ = opt.as_mut().map(|x| &mut **x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_ref().map(std::ops::Deref::deref)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:44:13 + --> tests/ui/option_as_ref_deref.rs:44:13 | LL | let _ = opt.as_ref().map(std::ops::Deref::deref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_ref().map(String::as_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:56:13 + --> tests/ui/option_as_ref_deref.rs:56:13 | LL | let _ = opt.as_ref().map(String::as_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` diff --git a/tests/ui/option_env_unwrap.stderr b/tests/ui/option_env_unwrap.stderr index de31d0c7f095f..169523269fbb5 100644 --- a/tests/ui/option_env_unwrap.stderr +++ b/tests/ui/option_env_unwrap.stderr @@ -1,5 +1,5 @@ error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:10:13 + --> tests/ui/option_env_unwrap.rs:10:13 | LL | let _ = option_env!("PATH").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = option_env!("PATH").unwrap(); = help: to override `-D warnings` add `#[allow(clippy::option_env_unwrap)]` error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:11:13 + --> tests/ui/option_env_unwrap.rs:11:13 | LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set = help: consider using the `env!` macro instead error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:12:13 + --> tests/ui/option_env_unwrap.rs:12:13 | LL | let _ = option_env!("__Y__do_not_use").unwrap(); // This test only works if you don't have a __Y__do_not_use env variable in your env... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = option_env!("__Y__do_not_use").unwrap(); // This test only work = help: consider using the `env!` macro instead error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:13:21 + --> tests/ui/option_env_unwrap.rs:13:21 | LL | let _ = inline!(option_env!($"PATH").unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = inline!(option_env!($"PATH").unwrap()); = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:14:21 + --> tests/ui/option_env_unwrap.rs:14:21 | LL | let _ = inline!(option_env!($"PATH").expect($"environment variable PATH isn't set")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | let _ = inline!(option_env!($"PATH").expect($"environment variable PATH = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:15:13 + --> tests/ui/option_env_unwrap.rs:15:13 | LL | let _ = external!(option_env!($"PATH").unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = external!(option_env!($"PATH").unwrap()); = note: this error originates in the macro `external` (in Nightly builds, run with -Z macro-backtrace for more info) error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:16:13 + --> tests/ui/option_env_unwrap.rs:16:13 | LL | let _ = external!(option_env!($"PATH").expect($"environment variable PATH isn't set")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/option_filter_map.stderr b/tests/ui/option_filter_map.stderr index 6a0fc10822bdf..401ac2b2296da 100644 --- a/tests/ui/option_filter_map.stderr +++ b/tests/ui/option_filter_map.stderr @@ -1,5 +1,5 @@ error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:5:27 + --> tests/ui/option_filter_map.rs:5:27 | LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,37 +8,37 @@ LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap); = help: to override `-D warnings` add `#[allow(clippy::option_filter_map)]` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:7:27 + --> tests/ui/option_filter_map.rs:7:27 | LL | let _ = Some(Some(1)).filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:9:35 + --> tests/ui/option_filter_map.rs:9:35 | LL | let _ = Some(1).map(odds_out).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:11:35 + --> tests/ui/option_filter_map.rs:11:35 | LL | let _ = Some(1).map(odds_out).filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:14:39 + --> tests/ui/option_filter_map.rs:14:39 | LL | let _ = vec![Some(1)].into_iter().filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:16:39 + --> tests/ui/option_filter_map.rs:16:39 | LL | let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:21:10 + --> tests/ui/option_filter_map.rs:21:10 | LL | .filter(Option::is_some) | __________^ @@ -47,7 +47,7 @@ LL | | .map(Option::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:27:10 + --> tests/ui/option_filter_map.rs:27:10 | LL | .filter(|o| o.is_some()) | __________^ diff --git a/tests/ui/option_if_let_else.stderr b/tests/ui/option_if_let_else.stderr index e053d356ff24e..a794dca762f17 100644 --- a/tests/ui/option_if_let_else.stderr +++ b/tests/ui/option_if_let_else.stderr @@ -1,5 +1,5 @@ error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:10:5 + --> tests/ui/option_if_let_else.rs:10:5 | LL | / if let Some(x) = string { LL | | (true, x) @@ -12,19 +12,19 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:28:13 + --> tests/ui/option_if_let_else.rs:28:13 | LL | let _ = if let Some(s) = *string { s.len() } else { 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:29:13 + --> tests/ui/option_if_let_else.rs:29:13 | LL | let _ = if let Some(s) = &num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:30:13 + --> tests/ui/option_if_let_else.rs:30:13 | LL | let _ = if let Some(s) = &mut num { | _____________^ @@ -44,13 +44,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:36:13 + --> tests/ui/option_if_let_else.rs:36:13 | LL | let _ = if let Some(ref s) = num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:37:13 + --> tests/ui/option_if_let_else.rs:37:13 | LL | let _ = if let Some(mut s) = num { | _____________^ @@ -70,7 +70,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:43:13 + --> tests/ui/option_if_let_else.rs:43:13 | LL | let _ = if let Some(ref mut s) = num { | _____________^ @@ -90,7 +90,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:52:5 + --> tests/ui/option_if_let_else.rs:52:5 | LL | / if let Some(x) = arg { LL | | let y = x * x; @@ -109,7 +109,7 @@ LL + }) | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:65:13 + --> tests/ui/option_if_let_else.rs:65:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -121,7 +121,7 @@ LL | | }; | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:74:13 + --> tests/ui/option_if_let_else.rs:74:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x); | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:107:13 + --> tests/ui/option_if_let_else.rs:107:13 | LL | / if let Some(idx) = s.find('.') { LL | | vec![s[..idx].to_string(), s[idx..].to_string()] @@ -154,7 +154,7 @@ LL | | } | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:118:5 + --> tests/ui/option_if_let_else.rs:118:5 | LL | / if let Ok(binding) = variable { LL | | println!("Ok {binding}"); @@ -177,13 +177,13 @@ LL + }) | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:142:13 + --> tests/ui/option_if_let_else.rs:142:13 | LL | let _ = if let Some(x) = optional { x + 2 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:152:13 + --> tests/ui/option_if_let_else.rs:152:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -205,13 +205,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:180:13 + --> tests/ui/option_if_let_else.rs:180:13 | LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:184:13 + --> tests/ui/option_if_let_else.rs:184:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -231,7 +231,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:223:13 + --> tests/ui/option_if_let_else.rs:223:13 | LL | let _ = match s { | _____________^ @@ -241,7 +241,7 @@ LL | | }; | |_____^ help: try: `s.map_or(1, |string| string.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:227:13 + --> tests/ui/option_if_let_else.rs:227:13 | LL | let _ = match Some(10) { | _____________^ @@ -251,7 +251,7 @@ LL | | }; | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:233:13 + --> tests/ui/option_if_let_else.rs:233:13 | LL | let _ = match res { | _____________^ @@ -261,7 +261,7 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:237:13 + --> tests/ui/option_if_let_else.rs:237:13 | LL | let _ = match res { | _____________^ @@ -271,13 +271,13 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:241:13 + --> tests/ui/option_if_let_else.rs:241:13 | LL | let _ = if let Ok(a) = res { a + 1 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:258:17 + --> tests/ui/option_if_let_else.rs:258:17 | LL | let _ = match initial { | _________________^ @@ -287,7 +287,7 @@ LL | | }; | |_________^ help: try: `initial.as_ref().map_or(42, |value| do_something(value))` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:265:17 + --> tests/ui/option_if_let_else.rs:265:17 | LL | let _ = match initial { | _________________^ @@ -297,7 +297,7 @@ LL | | }; | |_________^ help: try: `initial.as_mut().map_or(42, |value| do_something2(value))` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:288:24 + --> tests/ui/option_if_let_else.rs:288:24 | LL | let mut _hashmap = if let Some(hm) = &opt { | ________________________^ @@ -308,7 +308,7 @@ LL | | }; | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:294:19 + --> tests/ui/option_if_let_else.rs:294:19 | LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())` diff --git a/tests/ui/option_map_or_err_ok.stderr b/tests/ui/option_map_or_err_ok.stderr index 381601cb6b3aa..1971af80aa8d4 100644 --- a/tests/ui/option_map_or_err_ok.stderr +++ b/tests/ui/option_map_or_err_ok.stderr @@ -1,5 +1,5 @@ error: called `map_or(Err(_), Ok)` on an `Option` value - --> $DIR/option_map_or_err_ok.rs:5:13 + --> tests/ui/option_map_or_err_ok.rs:5:13 | LL | let _ = x.map_or(Err("a"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `x.ok_or("a")` diff --git a/tests/ui/option_map_or_none.stderr b/tests/ui/option_map_or_none.stderr index d58ff83c3da27..cba29861296f3 100644 --- a/tests/ui/option_map_or_none.stderr +++ b/tests/ui/option_map_or_none.stderr @@ -1,5 +1,5 @@ error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:10:26 + --> tests/ui/option_map_or_none.rs:10:26 | LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `map`: `opt.map(|x| x + 1)` @@ -8,7 +8,7 @@ LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); = help: to override `-D warnings` add `#[allow(clippy::option_map_or_none)]` error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:13:26 + --> tests/ui/option_map_or_none.rs:13:26 | LL | let _: Option = opt.map_or(None, |x| { | __________________________^ @@ -17,13 +17,13 @@ LL | | }); | |_________________________^ help: consider using `map`: `opt.map(|x| x + 1)` error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:17:26 + --> tests/ui/option_map_or_none.rs:17:26 | LL | let _: Option = opt.map_or(None, bar); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `and_then`: `opt.and_then(bar)` error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:18:26 + --> tests/ui/option_map_or_none.rs:18:26 | LL | let _: Option = opt.map_or(None, |x| { | __________________________^ @@ -43,7 +43,7 @@ LL ~ }); | error: called `map_or(None, Some)` on a `Result` value - --> $DIR/option_map_or_none.rs:25:26 + --> tests/ui/option_map_or_none.rs:25:26 | LL | let _: Option = r.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `r.ok()` diff --git a/tests/ui/option_map_unit_fn_fixable.stderr b/tests/ui/option_map_unit_fn_fixable.stderr index 34aca31e95c97..5fd3dfd071c2f 100644 --- a/tests/ui/option_map_unit_fn_fixable.stderr +++ b/tests/ui/option_map_unit_fn_fixable.stderr @@ -1,5 +1,5 @@ error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:37:5 + --> tests/ui/option_map_unit_fn_fixable.rs:37:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -10,7 +10,7 @@ LL | x.field.map(do_nothing); = help: to override `-D warnings` add `#[allow(clippy::option_map_unit_fn)]` error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:39:5 + --> tests/ui/option_map_unit_fn_fixable.rs:39:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -18,7 +18,7 @@ LL | x.field.map(do_nothing); | help: try: `if let Some(x_field) = x.field { do_nothing(x_field) }` error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:41:5 + --> tests/ui/option_map_unit_fn_fixable.rs:41:5 | LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | x.field.map(diverge); | help: try: `if let Some(x_field) = x.field { diverge(x_field) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:47:5 + --> tests/ui/option_map_unit_fn_fixable.rs:47:5 | LL | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -34,7 +34,7 @@ LL | x.field.map(|value| x.do_option_nothing(value + captured)); | help: try: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:49:5 + --> tests/ui/option_map_unit_fn_fixable.rs:49:5 | LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -42,7 +42,7 @@ LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | help: try: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:52:5 + --> tests/ui/option_map_unit_fn_fixable.rs:52:5 | LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -50,7 +50,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | help: try: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:54:5 + --> tests/ui/option_map_unit_fn_fixable.rs:54:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -58,7 +58,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | help: try: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:56:5 + --> tests/ui/option_map_unit_fn_fixable.rs:56:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -66,7 +66,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | help: try: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:58:5 + --> tests/ui/option_map_unit_fn_fixable.rs:58:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -74,7 +74,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | help: try: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:61:5 + --> tests/ui/option_map_unit_fn_fixable.rs:61:5 | LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -82,7 +82,7 @@ LL | x.field.map(|value| diverge(value + captured)); | help: try: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:63:5 + --> tests/ui/option_map_unit_fn_fixable.rs:63:5 | LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -90,7 +90,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | help: try: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:65:5 + --> tests/ui/option_map_unit_fn_fixable.rs:65:5 | LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -98,7 +98,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | help: try: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:67:5 + --> tests/ui/option_map_unit_fn_fixable.rs:67:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -106,7 +106,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | help: try: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:72:5 + --> tests/ui/option_map_unit_fn_fixable.rs:72:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -114,7 +114,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | help: try: `if let Some(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:74:5 + --> tests/ui/option_map_unit_fn_fixable.rs:74:5 | LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -122,7 +122,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | help: try: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:76:5 + --> tests/ui/option_map_unit_fn_fixable.rs:76:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -130,7 +130,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | help: try: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:79:5 + --> tests/ui/option_map_unit_fn_fixable.rs:79:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -138,7 +138,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | help: try: `if let Some(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:81:5 + --> tests/ui/option_map_unit_fn_fixable.rs:81:5 | LL | option().map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^- @@ -146,7 +146,7 @@ LL | option().map(do_nothing); | help: try: `if let Some(a) = option() { do_nothing(a) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:83:5 + --> tests/ui/option_map_unit_fn_fixable.rs:83:5 | LL | option().map(|value| println!("{:?}", value)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- diff --git a/tests/ui/option_map_unit_fn_unfixable.stderr b/tests/ui/option_map_unit_fn_unfixable.stderr index a53f5889c58da..66271036113ca 100644 --- a/tests/ui/option_map_unit_fn_unfixable.stderr +++ b/tests/ui/option_map_unit_fn_unfixable.stderr @@ -1,23 +1,23 @@ error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:17:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:17:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:19:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:19:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:23:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:23:5 | LL | x.field.map(|value| { | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:27:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:27:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^ not found in this scope diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index fcae9655dbf7f..0cd048e400e40 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,77 +1,77 @@ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:4:10 + --> tests/ui/option_option.rs:4:10 | LL | const C: Option> = None; | ^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/option_option.rs:1:9 + --> tests/ui/option_option.rs:1:9 | LL | #![deny(clippy::option_option)] | ^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:6:11 + --> tests/ui/option_option.rs:6:11 | LL | static S: Option> = None; | ^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:9:13 + --> tests/ui/option_option.rs:9:13 | LL | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:12:16 + --> tests/ui/option_option.rs:12:16 | LL | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:17:27 + --> tests/ui/option_option.rs:17:27 | LL | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:23:30 + --> tests/ui/option_option.rs:23:30 | LL | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:29:8 + --> tests/ui/option_option.rs:29:8 | LL | x: Option>, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:34:23 + --> tests/ui/option_option.rs:34:23 | LL | fn struct_fn() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:41:22 + --> tests/ui/option_option.rs:41:22 | LL | fn trait_fn() -> Option>; | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:46:11 + --> tests/ui/option_option.rs:46:11 | LL | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:48:17 + --> tests/ui/option_option.rs:48:17 | LL | Struct { x: Option> }, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:90:14 + --> tests/ui/option_option.rs:90:14 | LL | foo: Option>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr index afa4b7628112d..b5a30f2992316 100644 --- a/tests/ui/or_fun_call.stderr +++ b/tests/ui/or_fun_call.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:52:22 + --> tests/ui/or_fun_call.rs:52:22 | LL | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(make)` @@ -8,7 +8,7 @@ LL | with_constructor.unwrap_or(make()); = help: to override `-D warnings` add `#[allow(clippy::or_fun_call)]` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:55:14 + --> tests/ui/or_fun_call.rs:55:14 | LL | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` @@ -17,175 +17,175 @@ LL | with_new.unwrap_or(Vec::new()); = help: to override `-D warnings` add `#[allow(clippy::unwrap_or_default)]` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:58:21 + --> tests/ui/or_fun_call.rs:58:21 | LL | with_const_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| Vec::with_capacity(12))` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:61:14 + --> tests/ui/or_fun_call.rs:61:14 | LL | with_err.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| make())` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:64:19 + --> tests/ui/or_fun_call.rs:64:19 | LL | with_err_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| Vec::with_capacity(12))` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:67:24 + --> tests/ui/or_fun_call.rs:67:24 | LL | with_default_trait.unwrap_or(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:70:23 + --> tests/ui/or_fun_call.rs:70:23 | LL | with_default_type.unwrap_or(u64::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:73:18 + --> tests/ui/or_fun_call.rs:73:18 | LL | self_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(::default)` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:76:18 + --> tests/ui/or_fun_call.rs:76:18 | LL | real_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:79:14 + --> tests/ui/or_fun_call.rs:79:14 | LL | with_vec.unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:82:21 + --> tests/ui/or_fun_call.rs:82:21 | LL | without_default.unwrap_or(Foo::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(Foo::new)` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:85:19 + --> tests/ui/or_fun_call.rs:85:19 | LL | map.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:88:23 + --> tests/ui/or_fun_call.rs:88:23 | LL | map_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:91:21 + --> tests/ui/or_fun_call.rs:91:21 | LL | btree.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:94:25 + --> tests/ui/or_fun_call.rs:94:25 | LL | btree_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:97:21 + --> tests/ui/or_fun_call.rs:97:21 | LL | let _ = stringy.unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:105:21 + --> tests/ui/or_fun_call.rs:105:21 | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| map[&1])` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:107:21 + --> tests/ui/or_fun_call.rs:107:21 | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| map[&1])` error: use of `or` followed by a function call - --> $DIR/or_fun_call.rs:131:35 + --> tests/ui/or_fun_call.rs:131:35 | LL | let _ = Some("a".to_string()).or(Some("b".to_string())); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_else(|| Some("b".to_string()))` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:170:14 + --> tests/ui/or_fun_call.rs:170:14 | LL | None.unwrap_or(ptr_to_ref(s)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| ptr_to_ref(s))` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:176:14 + --> tests/ui/or_fun_call.rs:176:14 | LL | None.unwrap_or(unsafe { ptr_to_ref(s) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:178:14 + --> tests/ui/or_fun_call.rs:178:14 | LL | None.unwrap_or( unsafe { ptr_to_ref(s) } ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` error: use of `map_or` followed by a function call - --> $DIR/or_fun_call.rs:253:25 + --> tests/ui/or_fun_call.rs:253:25 | LL | let _ = Some(4).map_or(g(), |v| v); | ^^^^^^^^^^^^^^^^^^ help: try: `map_or_else(g, |v| v)` error: use of `map_or` followed by a function call - --> $DIR/or_fun_call.rs:254:25 + --> tests/ui/or_fun_call.rs:254:25 | LL | let _ = Some(4).map_or(g(), f); | ^^^^^^^^^^^^^^ help: try: `map_or_else(g, f)` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:285:18 + --> tests/ui/or_fun_call.rs:285:18 | LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:288:28 + --> tests/ui/or_fun_call.rs:288:28 | LL | with_default_trait.unwrap_or_else(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:291:27 + --> tests/ui/or_fun_call.rs:291:27 | LL | with_default_type.unwrap_or_else(u64::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:294:22 + --> tests/ui/or_fun_call.rs:294:22 | LL | real_default.unwrap_or_else(::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/or_fun_call.rs:297:23 + --> tests/ui/or_fun_call.rs:297:23 | LL | map.entry(42).or_insert_with(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/or_fun_call.rs:300:25 + --> tests/ui/or_fun_call.rs:300:25 | LL | btree.entry(42).or_insert_with(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:303:25 + --> tests/ui/or_fun_call.rs:303:25 | LL | let _ = stringy.unwrap_or_else(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` diff --git a/tests/ui/or_then_unwrap.stderr b/tests/ui/or_then_unwrap.stderr index 99e4488c040df..f454316068f26 100644 --- a/tests/ui/or_then_unwrap.stderr +++ b/tests/ui/or_then_unwrap.stderr @@ -1,5 +1,5 @@ error: found `.or(Some(…)).unwrap()` - --> $DIR/or_then_unwrap.rs:22:20 + --> tests/ui/or_then_unwrap.rs:22:20 | LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` @@ -8,13 +8,13 @@ LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint = help: to override `-D warnings` add `#[allow(clippy::or_then_unwrap)]` error: found `.or(Ok(…)).unwrap()` - --> $DIR/or_then_unwrap.rs:25:20 + --> tests/ui/or_then_unwrap.rs:25:20 | LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` error: found `.or(Some(…)).unwrap()` - --> $DIR/or_then_unwrap.rs:29:31 + --> tests/ui/or_then_unwrap.rs:29:31 | LL | let _ = option.map(|v| v).or(Some("fallback")).unwrap().to_string().chars(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` diff --git a/tests/ui/out_of_bounds_indexing/issue-3102.stderr b/tests/ui/out_of_bounds_indexing/issue-3102.stderr index 15b728e1daf54..8bf0152601dfd 100644 --- a/tests/ui/out_of_bounds_indexing/issue-3102.stderr +++ b/tests/ui/out_of_bounds_indexing/issue-3102.stderr @@ -1,5 +1,5 @@ error: range is out of bounds - --> $DIR/out_of_bounds_indexing/issue-3102.rs:9:13 + --> tests/ui/out_of_bounds_indexing/issue-3102.rs:9:13 | LL | &x[num..10]; | ^^ @@ -8,7 +8,7 @@ LL | &x[num..10]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> $DIR/out_of_bounds_indexing/issue-3102.rs:12:8 + --> tests/ui/out_of_bounds_indexing/issue-3102.rs:12:8 | LL | &x[10..num]; | ^^ diff --git a/tests/ui/out_of_bounds_indexing/simple.stderr b/tests/ui/out_of_bounds_indexing/simple.stderr index 00c401cdbfb20..87d1d574dcb85 100644 --- a/tests/ui/out_of_bounds_indexing/simple.stderr +++ b/tests/ui/out_of_bounds_indexing/simple.stderr @@ -1,5 +1,5 @@ error: range is out of bounds - --> $DIR/out_of_bounds_indexing/simple.rs:7:11 + --> tests/ui/out_of_bounds_indexing/simple.rs:7:11 | LL | &x[..=4]; | ^ @@ -8,31 +8,31 @@ LL | &x[..=4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> $DIR/out_of_bounds_indexing/simple.rs:10:11 + --> tests/ui/out_of_bounds_indexing/simple.rs:10:11 | LL | &x[1..5]; | ^ error: range is out of bounds - --> $DIR/out_of_bounds_indexing/simple.rs:12:8 + --> tests/ui/out_of_bounds_indexing/simple.rs:12:8 | LL | &x[5..]; | ^ error: range is out of bounds - --> $DIR/out_of_bounds_indexing/simple.rs:14:10 + --> tests/ui/out_of_bounds_indexing/simple.rs:14:10 | LL | &x[..5]; | ^ error: range is out of bounds - --> $DIR/out_of_bounds_indexing/simple.rs:16:8 + --> tests/ui/out_of_bounds_indexing/simple.rs:16:8 | LL | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> $DIR/out_of_bounds_indexing/simple.rs:18:12 + --> tests/ui/out_of_bounds_indexing/simple.rs:18:12 | LL | &x[0..=4]; | ^ diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index b3cab8a210983..c14532bad5ab7 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,5 +1,5 @@ error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:5:8 + --> tests/ui/overflow_check_conditional.rs:5:8 | LL | if a + b < a {} | ^^^^^^^^^ @@ -8,43 +8,43 @@ LL | if a + b < a {} = help: to override `-D warnings` add `#[allow(clippy::overflow_check_conditional)]` error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:8:8 + --> tests/ui/overflow_check_conditional.rs:8:8 | LL | if a > a + b {} | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:10:8 + --> tests/ui/overflow_check_conditional.rs:10:8 | LL | if a + b < b {} | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:12:8 + --> tests/ui/overflow_check_conditional.rs:12:8 | LL | if b > a + b {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:14:8 + --> tests/ui/overflow_check_conditional.rs:14:8 | LL | if a - b > b {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:16:8 + --> tests/ui/overflow_check_conditional.rs:16:8 | LL | if b < a - b {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:18:8 + --> tests/ui/overflow_check_conditional.rs:18:8 | LL | if a - b > a {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:20:8 + --> tests/ui/overflow_check_conditional.rs:20:8 | LL | if a < a - b {} | ^^^^^^^^^ diff --git a/tests/ui/overly_complex_bool_expr.stderr b/tests/ui/overly_complex_bool_expr.stderr index dc62d0e1dbd2d..21dd5ade53563 100644 --- a/tests/ui/overly_complex_bool_expr.stderr +++ b/tests/ui/overly_complex_bool_expr.stderr @@ -1,11 +1,11 @@ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:11:13 + --> tests/ui/overly_complex_bool_expr.rs:11:13 | LL | let _ = a && b || a; | ^^^^^^^^^^^ help: it would look like the following: `a` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:11:18 + --> tests/ui/overly_complex_bool_expr.rs:11:18 | LL | let _ = a && b || a; | ^ @@ -13,49 +13,49 @@ LL | let _ = a && b || a; = help: to override `-D warnings` add `#[allow(clippy::overly_complex_bool_expr)]` error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:14:13 + --> tests/ui/overly_complex_bool_expr.rs:14:13 | LL | let _ = false && a; | ^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:14:22 + --> tests/ui/overly_complex_bool_expr.rs:14:22 | LL | let _ = false && a; | ^ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:25:13 + --> tests/ui/overly_complex_bool_expr.rs:25:13 | LL | let _ = a == b && a != b; | ^^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:25:13 + --> tests/ui/overly_complex_bool_expr.rs:25:13 | LL | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:27:13 + --> tests/ui/overly_complex_bool_expr.rs:27:13 | LL | let _ = a < b && a >= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:27:13 + --> tests/ui/overly_complex_bool_expr.rs:27:13 | LL | let _ = a < b && a >= b; | ^^^^^ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:29:13 + --> tests/ui/overly_complex_bool_expr.rs:29:13 | LL | let _ = a > b && a <= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:29:13 + --> tests/ui/overly_complex_bool_expr.rs:29:13 | LL | let _ = a > b && a <= b; | ^^^^^ diff --git a/tests/ui/panic_in_result_fn.stderr b/tests/ui/panic_in_result_fn.stderr index d55c5cf36f626..cd2234bdfb13c 100644 --- a/tests/ui/panic_in_result_fn.stderr +++ b/tests/ui/panic_in_result_fn.stderr @@ -1,5 +1,5 @@ error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn.rs:6:5 + --> tests/ui/panic_in_result_fn.rs:6:5 | LL | / fn result_with_panic() -> Result // should emit lint LL | | @@ -10,7 +10,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn.rs:9:9 + --> tests/ui/panic_in_result_fn.rs:9:9 | LL | panic!("error"); | ^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | panic!("error"); = help: to override `-D warnings` add `#[allow(clippy::panic_in_result_fn)]` error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn.rs:53:1 + --> tests/ui/panic_in_result_fn.rs:53:1 | LL | / fn function_result_with_panic() -> Result // should emit lint LL | | @@ -29,7 +29,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn.rs:56:5 + --> tests/ui/panic_in_result_fn.rs:56:5 | LL | panic!("error"); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/panic_in_result_fn_assertions.stderr b/tests/ui/panic_in_result_fn_assertions.stderr index a80e6f27abcb4..cdb7762510d9c 100644 --- a/tests/ui/panic_in_result_fn_assertions.stderr +++ b/tests/ui/panic_in_result_fn_assertions.stderr @@ -1,5 +1,5 @@ error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn_assertions.rs:7:5 + --> tests/ui/panic_in_result_fn_assertions.rs:7:5 | LL | / fn result_with_assert_with_message(x: i32) -> Result // should emit lint LL | | @@ -11,7 +11,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn_assertions.rs:10:9 + --> tests/ui/panic_in_result_fn_assertions.rs:10:9 | LL | assert!(x == 5, "wrong argument"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | assert!(x == 5, "wrong argument"); = help: to override `-D warnings` add `#[allow(clippy::panic_in_result_fn)]` error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn_assertions.rs:14:5 + --> tests/ui/panic_in_result_fn_assertions.rs:14:5 | LL | / fn result_with_assert_eq(x: i32) -> Result // should emit lint LL | | @@ -31,13 +31,13 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn_assertions.rs:17:9 + --> tests/ui/panic_in_result_fn_assertions.rs:17:9 | LL | assert_eq!(x, 5); | ^^^^^^^^^^^^^^^^ error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn_assertions.rs:21:5 + --> tests/ui/panic_in_result_fn_assertions.rs:21:5 | LL | / fn result_with_assert_ne(x: i32) -> Result // should emit lint LL | | @@ -49,7 +49,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn_assertions.rs:24:9 + --> tests/ui/panic_in_result_fn_assertions.rs:24:9 | LL | assert_ne!(x, 1); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/panicking_macros.stderr b/tests/ui/panicking_macros.stderr index 59ce57d0b3dae..06025859c0c6d 100644 --- a/tests/ui/panicking_macros.stderr +++ b/tests/ui/panicking_macros.stderr @@ -1,5 +1,5 @@ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:23:5 + --> tests/ui/panicking_macros.rs:23:5 | LL | panic!(); | ^^^^^^^^ @@ -8,19 +8,19 @@ LL | panic!(); = help: to override `-D warnings` add `#[allow(clippy::panic)]` error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:26:5 + --> tests/ui/panicking_macros.rs:26:5 | LL | panic!("message"); | ^^^^^^^^^^^^^^^^^ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:28:5 + --> tests/ui/panicking_macros.rs:28:5 | LL | panic!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:35:5 + --> tests/ui/panicking_macros.rs:35:5 | LL | todo!(); | ^^^^^^^ @@ -29,19 +29,19 @@ LL | todo!(); = help: to override `-D warnings` add `#[allow(clippy::todo)]` error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:38:5 + --> tests/ui/panicking_macros.rs:38:5 | LL | todo!("message"); | ^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:40:5 + --> tests/ui/panicking_macros.rs:40:5 | LL | todo!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:47:5 + --> tests/ui/panicking_macros.rs:47:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ @@ -50,19 +50,19 @@ LL | unimplemented!(); = help: to override `-D warnings` add `#[allow(clippy::unimplemented)]` error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:50:5 + --> tests/ui/panicking_macros.rs:50:5 | LL | unimplemented!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:52:5 + --> tests/ui/panicking_macros.rs:52:5 | LL | unimplemented!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:59:5 + --> tests/ui/panicking_macros.rs:59:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ @@ -71,37 +71,37 @@ LL | unreachable!(); = help: to override `-D warnings` add `#[allow(clippy::unreachable)]` error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:62:5 + --> tests/ui/panicking_macros.rs:62:5 | LL | unreachable!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:64:5 + --> tests/ui/panicking_macros.rs:64:5 | LL | unreachable!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:71:5 + --> tests/ui/panicking_macros.rs:71:5 | LL | panic!(); | ^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:73:5 + --> tests/ui/panicking_macros.rs:73:5 | LL | todo!(); | ^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:75:5 + --> tests/ui/panicking_macros.rs:75:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:77:5 + --> tests/ui/panicking_macros.rs:77:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/partial_pub_fields.stderr b/tests/ui/partial_pub_fields.stderr index a152287403b75..af3b2f7587578 100644 --- a/tests/ui/partial_pub_fields.stderr +++ b/tests/ui/partial_pub_fields.stderr @@ -1,5 +1,5 @@ error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:10:9 + --> tests/ui/partial_pub_fields.rs:10:9 | LL | pub paths: HashMap, | ^^^ @@ -9,7 +9,7 @@ LL | pub paths: HashMap, = help: to override `-D warnings` add `#[allow(clippy::partial_pub_fields)]` error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:17:9 + --> tests/ui/partial_pub_fields.rs:17:9 | LL | b: u8, | ^ @@ -17,7 +17,7 @@ LL | b: u8, = help: consider using public field here error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:21:27 + --> tests/ui/partial_pub_fields.rs:21:27 | LL | pub struct Point(i32, pub i32); | ^^^ @@ -25,7 +25,7 @@ LL | pub struct Point(i32, pub i32); = help: consider using private field here error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:26:9 + --> tests/ui/partial_pub_fields.rs:26:9 | LL | pub pos: u32, | ^^^ diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index 2210e706d930d..dc01a375060b9 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -1,5 +1,5 @@ error: re-implementing `PartialEq::ne` is unnecessary - --> $DIR/partialeq_ne_impl.rs:9:5 + --> tests/ui/partialeq_ne_impl.rs:9:5 | LL | / fn ne(&self, _: &Foo) -> bool { LL | | diff --git a/tests/ui/partialeq_to_none.stderr b/tests/ui/partialeq_to_none.stderr index 50ce15001f40f..b588fbf32b606 100644 --- a/tests/ui/partialeq_to_none.stderr +++ b/tests/ui/partialeq_to_none.stderr @@ -1,5 +1,5 @@ error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:14:8 + --> tests/ui/partialeq_to_none.rs:14:8 | LL | if f != None { "yay" } else { "nay" } | ^^^^^^^^^ help: use `Option::is_some()` instead: `f.is_some()` @@ -8,55 +8,55 @@ LL | if f != None { "yay" } else { "nay" } = help: to override `-D warnings` add `#[allow(clippy::partialeq_to_none)]` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:44:13 + --> tests/ui/partialeq_to_none.rs:44:13 | LL | let _ = x == None; | ^^^^^^^^^ help: use `Option::is_none()` instead: `x.is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:45:13 + --> tests/ui/partialeq_to_none.rs:45:13 | LL | let _ = x != None; | ^^^^^^^^^ help: use `Option::is_some()` instead: `x.is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:46:13 + --> tests/ui/partialeq_to_none.rs:46:13 | LL | let _ = None == x; | ^^^^^^^^^ help: use `Option::is_none()` instead: `x.is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:47:13 + --> tests/ui/partialeq_to_none.rs:47:13 | LL | let _ = None != x; | ^^^^^^^^^ help: use `Option::is_some()` instead: `x.is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:49:8 + --> tests/ui/partialeq_to_none.rs:49:8 | LL | if foobar() == None {} | ^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `foobar().is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:51:8 + --> tests/ui/partialeq_to_none.rs:51:8 | LL | if bar().ok() != None {} | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `bar().ok().is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:53:13 + --> tests/ui/partialeq_to_none.rs:53:13 | LL | let _ = Some(1 + 2) != None; | ^^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `Some(1 + 2).is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:55:13 + --> tests/ui/partialeq_to_none.rs:55:13 | LL | let _ = { Some(0) } == None; | ^^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `{ Some(0) }.is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:57:13 + --> tests/ui/partialeq_to_none.rs:57:13 | LL | let _ = { | _____________^ @@ -78,31 +78,31 @@ LL ~ }.is_some(); | error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:67:13 + --> tests/ui/partialeq_to_none.rs:67:13 | LL | let _ = optref() == &&None; | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `optref().is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:68:13 + --> tests/ui/partialeq_to_none.rs:68:13 | LL | let _ = &&None != optref(); | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `optref().is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:69:13 + --> tests/ui/partialeq_to_none.rs:69:13 | LL | let _ = **optref() == None; | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `optref().is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:70:13 + --> tests/ui/partialeq_to_none.rs:70:13 | LL | let _ = &None != *optref(); | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `optref().is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:73:13 + --> tests/ui/partialeq_to_none.rs:73:13 | LL | let _ = None != *x; | ^^^^^^^^^^ help: use `Option::is_some()` instead: `(*x).is_some()` diff --git a/tests/ui/path_buf_push_overwrite.stderr b/tests/ui/path_buf_push_overwrite.stderr index f96ce0de77931..c9f36ecf48f60 100644 --- a/tests/ui/path_buf_push_overwrite.stderr +++ b/tests/ui/path_buf_push_overwrite.stderr @@ -1,5 +1,5 @@ error: calling `push` with '/' or '\' (file system root) will overwrite the previous path definition - --> $DIR/path_buf_push_overwrite.rs:6:12 + --> tests/ui/path_buf_push_overwrite.rs:6:12 | LL | x.push("/bar"); | ^^^^^^ help: try: `"bar"` diff --git a/tests/ui/path_ends_with_ext.stderr b/tests/ui/path_ends_with_ext.stderr index a73ab4d08e9c5..deab71ff76268 100644 --- a/tests/ui/path_ends_with_ext.stderr +++ b/tests/ui/path_ends_with_ext.stderr @@ -1,5 +1,5 @@ error: this looks like a failed attempt at checking for the file extension - --> $DIR/path_ends_with_ext.rs:11:5 + --> tests/ui/path_ends_with_ext.rs:11:5 | LL | path.ends_with(".md"); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `path.extension().is_some_and(|ext| ext == "md")` @@ -8,7 +8,7 @@ LL | path.ends_with(".md"); = help: to override `-D warnings` add `#[allow(clippy::path_ends_with_ext)]` error: this looks like a failed attempt at checking for the file extension - --> $DIR/path_ends_with_ext.rs:32:5 + --> tests/ui/path_ends_with_ext.rs:32:5 | LL | path.ends_with(".md") | ^^^^^^^^^^^^^^^^^^^^^ help: try: `path.extension().map_or(false, |ext| ext == "md")` diff --git a/tests/ui/pattern_type_mismatch/mutability.stderr b/tests/ui/pattern_type_mismatch/mutability.stderr index 39bdad891c313..e795ded7386d2 100644 --- a/tests/ui/pattern_type_mismatch/mutability.stderr +++ b/tests/ui/pattern_type_mismatch/mutability.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/mutability.rs:9:9 + --> tests/ui/pattern_type_mismatch/mutability.rs:9:9 | LL | Some(_) => (), | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(_) => (), = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/mutability.rs:16:9 + --> tests/ui/pattern_type_mismatch/mutability.rs:16:9 | LL | Some(_) => (), | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr b/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr index bb63492c473fb..e1aec2497cd15 100644 --- a/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_alternatives.rs:15:12 + --> tests/ui/pattern_type_mismatch/pattern_alternatives.rs:15:12 | LL | if let Value::B | Value::A(_) = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | if let Value::B | Value::A(_) = ref_value {} = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_alternatives.rs:17:34 + --> tests/ui/pattern_type_mismatch/pattern_alternatives.rs:17:34 | LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_alternatives.rs:19:32 + --> tests/ui/pattern_type_mismatch/pattern_alternatives.rs:19:32 | LL | if let Value::B | Value::A(Some(_)) = *ref_value {} | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_structs.stderr b/tests/ui/pattern_type_mismatch/pattern_structs.stderr index 043c669f25027..e5d6e9ed6f819 100644 --- a/tests/ui/pattern_type_mismatch/pattern_structs.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_structs.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:13:9 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:13:9 | LL | let Struct { .. } = ref_value; | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let Struct { .. } = ref_value; = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:15:33 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:15:33 | LL | if let &Struct { ref_inner: Some(_) } = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &Struct { ref_inner: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:17:32 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:17:32 | LL | if let Struct { ref_inner: Some(_) } = *ref_value {} | ^^^^^^^ @@ -25,7 +25,7 @@ LL | if let Struct { ref_inner: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:35:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:35:12 | LL | if let StructEnum::Var { .. } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let StructEnum::Var { .. } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:37:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:37:12 | LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:39:42 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:39:42 | LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:41:41 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:41:41 | LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} | ^^^^^^^ @@ -57,7 +57,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_structs.rs:43:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:43:12 | LL | if let StructEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr index b204b0b80b53e..9ecf12a1d639f 100644 --- a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:11:9 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:11:9 | LL | let TupleStruct(_) = ref_value; | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let TupleStruct(_) = ref_value; = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:13:25 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:13:25 | LL | if let &TupleStruct(Some(_)) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &TupleStruct(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:15:24 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:15:24 | LL | if let TupleStruct(Some(_)) = *ref_value {} | ^^^^^^^ @@ -25,7 +25,7 @@ LL | if let TupleStruct(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:33:12 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:33:12 | LL | if let TupleEnum::Var(_) = ref_value {} | ^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let TupleEnum::Var(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:35:28 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:35:28 | LL | if let &TupleEnum::Var(Some(_)) = ref_value {} | ^^^^^^^ @@ -41,7 +41,7 @@ LL | if let &TupleEnum::Var(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:37:27 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:37:27 | LL | if let TupleEnum::Var(Some(_)) = *ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let TupleEnum::Var(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:39:12 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:39:12 | LL | if let TupleEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | if let TupleEnum::Empty = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:55:9 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:55:9 | LL | let (_a, _b) = ref_value; | ^^^^^^^^ @@ -65,7 +65,7 @@ LL | let (_a, _b) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:57:18 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:57:18 | LL | if let &(_a, Some(_)) = ref_value {} | ^^^^^^^ @@ -73,7 +73,7 @@ LL | if let &(_a, Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/pattern_tuples.rs:59:17 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:59:17 | LL | if let (_a, Some(_)) = *ref_value {} | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/syntax.stderr b/tests/ui/pattern_type_mismatch/syntax.stderr index 4a6db7bf02c62..9186a01b9c75f 100644 --- a/tests/ui/pattern_type_mismatch/syntax.stderr +++ b/tests/ui/pattern_type_mismatch/syntax.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:11:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:11:9 | LL | Some(_) => (), | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(_) => (), = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:31:12 + --> tests/ui/pattern_type_mismatch/syntax.rs:31:12 | LL | if let Some(_) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let Some(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:43:15 + --> tests/ui/pattern_type_mismatch/syntax.rs:43:15 | LL | while let Some(_) = ref_value { | ^^^^^^^ @@ -25,7 +25,7 @@ LL | while let Some(_) = ref_value { = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:62:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:62:9 | LL | for (_a, _b) in slice.iter() {} | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | for (_a, _b) in slice.iter() {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:73:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:73:9 | LL | let (_n, _m) = ref_value; | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | let (_n, _m) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:83:12 + --> tests/ui/pattern_type_mismatch/syntax.rs:83:12 | LL | fn foo((_a, _b): &(i32, i32)) {} | ^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn foo((_a, _b): &(i32, i32)) {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:98:10 + --> tests/ui/pattern_type_mismatch/syntax.rs:98:10 | LL | foo(|(_a, _b)| ()); | ^^^^^^^^ @@ -57,7 +57,7 @@ LL | foo(|(_a, _b)| ()); = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:115:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:115:9 | LL | Some(_) => (), | ^^^^^^^ @@ -65,7 +65,7 @@ LL | Some(_) => (), = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_type_mismatch/syntax.rs:136:17 + --> tests/ui/pattern_type_mismatch/syntax.rs:136:17 | LL | Some(_) => (), | ^^^^^^^ diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index 2f608bbc18fae..fa4cf7f835622 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -1,5 +1,5 @@ error: the `y @ _` pattern can be written as just `y` - --> $DIR/patterns.rs:14:9 + --> tests/ui/patterns.rs:14:9 | LL | y @ _ => (), | ^^^^^ help: try: `y` @@ -8,13 +8,13 @@ LL | y @ _ => (), = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern)]` error: the `x @ _` pattern can be written as just `x` - --> $DIR/patterns.rs:29:9 + --> tests/ui/patterns.rs:29:9 | LL | ref mut x @ _ => { | ^^^^^^^^^^^^^ help: try: `ref mut x` error: the `x @ _` pattern can be written as just `x` - --> $DIR/patterns.rs:37:9 + --> tests/ui/patterns.rs:37:9 | LL | ref x @ _ => println!("vec: {:?}", x), | ^^^^^^^^^ help: try: `ref x` diff --git a/tests/ui/permissions_set_readonly_false.stderr b/tests/ui/permissions_set_readonly_false.stderr index bd34463084a4a..4e0a8e39db7f0 100644 --- a/tests/ui/permissions_set_readonly_false.stderr +++ b/tests/ui/permissions_set_readonly_false.stderr @@ -1,5 +1,5 @@ error: call to `set_readonly` with argument `false` - --> $DIR/permissions_set_readonly_false.rs:19:5 + --> tests/ui/permissions_set_readonly_false.rs:19:5 | LL | permissions.set_readonly(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index bd0cbccc787c8..47e61326219d9 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,5 +1,5 @@ error: operator precedence can trip the unwary - --> $DIR/precedence.rs:16:5 + --> tests/ui/precedence.rs:16:5 | LL | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` @@ -8,67 +8,67 @@ LL | 1 << 2 + 3; = help: to override `-D warnings` add `#[allow(clippy::precedence)]` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:17:5 + --> tests/ui/precedence.rs:17:5 | LL | 1 + 2 << 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:18:5 + --> tests/ui/precedence.rs:18:5 | LL | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:19:5 + --> tests/ui/precedence.rs:19:5 | LL | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:20:5 + --> tests/ui/precedence.rs:20:5 | LL | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:21:5 + --> tests/ui/precedence.rs:21:5 | LL | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:22:5 + --> tests/ui/precedence.rs:22:5 | LL | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:23:5 + --> tests/ui/precedence.rs:23:5 | LL | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:24:5 + --> tests/ui/precedence.rs:24:5 | LL | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:51:13 + --> tests/ui/precedence.rs:51:13 | LL | let _ = -1.0_f64.cos().cos(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().cos())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:52:13 + --> tests/ui/precedence.rs:52:13 | LL | let _ = -1.0_f64.cos().sin(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().sin())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:53:13 + --> tests/ui/precedence.rs:53:13 | LL | let _ = -1.0_f64.sin().cos(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.sin().cos())` diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index bb8d945081e16..a8374241c8312 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -1,5 +1,5 @@ error: use of `Debug`-based formatting - --> $DIR/print.rs:11:20 + --> tests/ui/print.rs:11:20 | LL | write!(f, "{:?}", 43.1415) | ^^^^ @@ -8,7 +8,7 @@ LL | write!(f, "{:?}", 43.1415) = help: to override `-D warnings` add `#[allow(clippy::use_debug)]` error: use of `println!` - --> $DIR/print.rs:25:5 + --> tests/ui/print.rs:25:5 | LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ @@ -17,37 +17,37 @@ LL | println!("Hello"); = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `print!` - --> $DIR/print.rs:28:5 + --> tests/ui/print.rs:28:5 | LL | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:31:5 + --> tests/ui/print.rs:31:5 | LL | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:34:5 + --> tests/ui/print.rs:34:5 | LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:34:19 + --> tests/ui/print.rs:34:19 | LL | print!("Hello {:?}", "World"); | ^^^^ error: use of `print!` - --> $DIR/print.rs:38:5 + --> tests/ui/print.rs:38:5 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:38:19 + --> tests/ui/print.rs:38:19 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^ diff --git a/tests/ui/print_in_format_impl.stderr b/tests/ui/print_in_format_impl.stderr index 57f06dc1143f3..3fb6b3f9c9110 100644 --- a/tests/ui/print_in_format_impl.stderr +++ b/tests/ui/print_in_format_impl.stderr @@ -1,5 +1,5 @@ error: use of `print!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:20:9 + --> tests/ui/print_in_format_impl.rs:20:9 | LL | print!("{}", 1); | ^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` @@ -8,37 +8,37 @@ LL | print!("{}", 1); = help: to override `-D warnings` add `#[allow(clippy::print_in_format_impl)]` error: use of `println!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:23:9 + --> tests/ui/print_in_format_impl.rs:23:9 | LL | println!("{}", 2); | ^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `eprint!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:25:9 + --> tests/ui/print_in_format_impl.rs:25:9 | LL | eprint!("{}", 3); | ^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` error: use of `eprintln!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:27:9 + --> tests/ui/print_in_format_impl.rs:27:9 | LL | eprintln!("{}", 4); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `println!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:30:13 + --> tests/ui/print_in_format_impl.rs:30:13 | LL | println!("nested"); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `print!` in `Display` impl - --> $DIR/print_in_format_impl.rs:44:9 + --> tests/ui/print_in_format_impl.rs:44:9 | LL | print!("Display"); | ^^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` error: use of `println!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:55:9 + --> tests/ui/print_in_format_impl.rs:55:9 | LL | println!("UnnamedFormatter"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(..)` diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index 8c011d7bc0a6f..c4cbb8bed7074 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:27:24 + --> tests/ui/print_literal.rs:27:24 | LL | print!("Hello {}", "world"); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + print!("Hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:30:36 + --> tests/ui/print_literal.rs:30:36 | LL | println!("Hello {} {}", world, "world"); | ^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {} world", world); | error: literal with an empty format string - --> $DIR/print_literal.rs:32:26 + --> tests/ui/print_literal.rs:32:26 | LL | println!("Hello {}", "world"); | ^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("Hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:34:26 + --> tests/ui/print_literal.rs:34:26 | LL | println!("{} {:.4}", "a literal", 5); | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("a literal {:.4}", 5); | error: literal with an empty format string - --> $DIR/print_literal.rs:40:25 + --> tests/ui/print_literal.rs:40:25 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!("hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:42:25 + --> tests/ui/print_literal.rs:42:25 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + println!("world hello"); | error: literal with an empty format string - --> $DIR/print_literal.rs:46:35 + --> tests/ui/print_literal.rs:46:35 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + println!("hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:48:35 + --> tests/ui/print_literal.rs:48:35 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + println!("world hello"); | error: literal with an empty format string - --> $DIR/print_literal.rs:56:20 + --> tests/ui/print_literal.rs:56:20 | LL | println!("{}", "{} \x00 \u{ab123} \\\u{ab123} {:?}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + println!("{{}} \x00 \u{ab123} \\\u{ab123} {{:?}}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:57:20 + --> tests/ui/print_literal.rs:57:20 | LL | println!("{}", "\\\u{1234}"); | ^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + println!("\\\u{1234}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:61:20 + --> tests/ui/print_literal.rs:61:20 | LL | println!("{}", r"\u{ab123} \u{{"); | ^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + println!("\\u{{ab123}} \\u{{{{"); | error: literal with an empty format string - --> $DIR/print_literal.rs:62:21 + --> tests/ui/print_literal.rs:62:21 | LL | println!(r"{}", r"\u{ab123} \u{{"); | ^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + println!(r"\u{{ab123}} \u{{{{"); | error: literal with an empty format string - --> $DIR/print_literal.rs:63:20 + --> tests/ui/print_literal.rs:63:20 | LL | println!("{}", r"\{ab123} \u{{"); | ^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + println!("\\{{ab123}} \\u{{{{"); | error: literal with an empty format string - --> $DIR/print_literal.rs:64:20 + --> tests/ui/print_literal.rs:64:20 | LL | println!("{}", "\\u{ab123}"); | ^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL + println!("\\u{{ab123}}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:65:20 + --> tests/ui/print_literal.rs:65:20 | LL | println!("{}", "\\\\u{1234}"); | ^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + println!("\\\\u{{1234}}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:67:35 + --> tests/ui/print_literal.rs:67:35 | LL | println!("mixed: {} {world}", "{hello}"); | ^^^^^^^^^ diff --git a/tests/ui/print_stderr.stderr b/tests/ui/print_stderr.stderr index 7de16331067ec..17019b886905a 100644 --- a/tests/ui/print_stderr.stderr +++ b/tests/ui/print_stderr.stderr @@ -1,5 +1,5 @@ error: use of `eprintln!` - --> $DIR/print_stderr.rs:4:5 + --> tests/ui/print_stderr.rs:4:5 | LL | eprintln!("Hello"); | ^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | eprintln!("Hello"); = help: to override `-D warnings` add `#[allow(clippy::print_stderr)]` error: use of `eprint!` - --> $DIR/print_stderr.rs:8:5 + --> tests/ui/print_stderr.rs:8:5 | LL | eprint!("World"); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 7ff6a5f060d0b..9b07299e61d36 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,5 +1,5 @@ error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:7:5 + --> tests/ui/print_with_newline.rs:7:5 | LL | print!("Hello\n"); | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("Hello"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:10:5 + --> tests/ui/print_with_newline.rs:10:5 | LL | print!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {}", "world"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:12:5 + --> tests/ui/print_with_newline.rs:12:5 | LL | print!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("Hello {} {}", "world", "#2"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:14:5 + --> tests/ui/print_with_newline.rs:14:5 | LL | print!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("{}", 1265); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:16:5 + --> tests/ui/print_with_newline.rs:16:5 | LL | print!("\n"); | ^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!(); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:39:5 + --> tests/ui/print_with_newline.rs:39:5 | LL | print!("\\\n"); | ^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + println!("\\"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:48:5 + --> tests/ui/print_with_newline.rs:48:5 | LL | / print!( LL | | @@ -90,7 +90,7 @@ LL ~ | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:53:5 + --> tests/ui/print_with_newline.rs:53:5 | LL | / print!( LL | | @@ -107,7 +107,7 @@ LL ~ | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:63:5 + --> tests/ui/print_with_newline.rs:63:5 | LL | print!("\\r\n"); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index c89e64f665a75..17de05fa25a42 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -1,5 +1,5 @@ error: empty string literal in `println!` - --> $DIR/println_empty_string.rs:5:5 + --> tests/ui/println_empty_string.rs:5:5 | LL | println!(""); | ^^^^^^^^^--^ @@ -10,7 +10,7 @@ LL | println!(""); = help: to override `-D warnings` add `#[allow(clippy::println_empty_string)]` error: empty string literal in `println!` - --> $DIR/println_empty_string.rs:8:14 + --> tests/ui/println_empty_string.rs:8:14 | LL | _ => println!(""), | ^^^^^^^^^--^ @@ -18,7 +18,7 @@ LL | _ => println!(""), | help: remove the empty string error: empty string literal in `eprintln!` - --> $DIR/println_empty_string.rs:12:5 + --> tests/ui/println_empty_string.rs:12:5 | LL | eprintln!(""); | ^^^^^^^^^^--^ @@ -26,7 +26,7 @@ LL | eprintln!(""); | help: remove the empty string error: empty string literal in `eprintln!` - --> $DIR/println_empty_string.rs:15:14 + --> tests/ui/println_empty_string.rs:15:14 | LL | _ => eprintln!(""), | ^^^^^^^^^^--^ diff --git a/tests/ui/proc_macro.stderr b/tests/ui/proc_macro.stderr index 122374ea804dd..4314a5bb4d1cd 100644 --- a/tests/ui/proc_macro.stderr +++ b/tests/ui/proc_macro.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::PI` found - --> $DIR/proc_macro.rs:9:14 + --> tests/ui/proc_macro.rs:9:14 | LL | let _x = 3.14; | ^^^^ diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index 35bd850920590..0342130c992be 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,5 +1,5 @@ error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:14:14 + --> tests/ui/ptr_arg.rs:14:14 | LL | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` @@ -8,49 +8,49 @@ LL | fn do_vec(x: &Vec) { = help: to override `-D warnings` add `#[allow(clippy::ptr_arg)]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:20:18 + --> tests/ui/ptr_arg.rs:20:18 | LL | fn do_vec_mut(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:25:19 + --> tests/ui/ptr_arg.rs:25:19 | LL | fn do_vec_mut2(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:31:14 + --> tests/ui/ptr_arg.rs:31:14 | LL | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:36:18 + --> tests/ui/ptr_arg.rs:36:18 | LL | fn do_str_mut(x: &mut String) { | ^^^^^^^^^^^ help: change this to: `&mut str` error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:41:15 + --> tests/ui/ptr_arg.rs:41:15 | LL | fn do_path(x: &PathBuf) { | ^^^^^^^^ help: change this to: `&Path` error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:46:19 + --> tests/ui/ptr_arg.rs:46:19 | LL | fn do_path_mut(x: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:55:18 + --> tests/ui/ptr_arg.rs:55:18 | LL | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:69:14 + --> tests/ui/ptr_arg.rs:69:14 | LL | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ @@ -68,7 +68,7 @@ LL ~ x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:79:18 + --> tests/ui/ptr_arg.rs:79:18 | LL | fn str_cloned(x: &String) -> String { | ^^^^^^^ @@ -85,7 +85,7 @@ LL ~ x.to_owned() | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:88:19 + --> tests/ui/ptr_arg.rs:88:19 | LL | fn path_cloned(x: &PathBuf) -> PathBuf { | ^^^^^^^^ @@ -102,7 +102,7 @@ LL ~ x.to_path_buf() | error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:97:44 + --> tests/ui/ptr_arg.rs:97:44 | LL | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ @@ -117,19 +117,19 @@ LL ~ let c = y; | error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:112:25 + --> tests/ui/ptr_arg.rs:112:25 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:142:66 + --> tests/ui/ptr_arg.rs:142:66 | LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec, _s: &String) {} | ^^^^^^^ help: change this to: `&str` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:172:21 + --> tests/ui/ptr_arg.rs:172:21 | LL | fn foo_vec(vec: &Vec) { | ^^^^^^^^ @@ -143,7 +143,7 @@ LL ~ let _ = vec.to_owned().clone(); | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:178:23 + --> tests/ui/ptr_arg.rs:178:23 | LL | fn foo_path(path: &PathBuf) { | ^^^^^^^^ @@ -157,7 +157,7 @@ LL ~ let _ = path.to_path_buf().clone(); | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:184:21 + --> tests/ui/ptr_arg.rs:184:21 | LL | fn foo_str(str: &PathBuf) { | ^^^^^^^^ @@ -171,43 +171,43 @@ LL ~ let _ = str.to_path_buf().clone(); | error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:191:29 + --> tests/ui/ptr_arg.rs:191:29 | LL | fn mut_vec_slice_methods(v: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:254:17 + --> tests/ui/ptr_arg.rs:254:17 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:254:35 + --> tests/ui/ptr_arg.rs:254:35 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^ help: change this to: `&mut str` error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:254:51 + --> tests/ui/ptr_arg.rs:254:51 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:280:39 + --> tests/ui/ptr_arg.rs:280:39 | LL | fn cow_elided_lifetime<'a>(input: &'a Cow) -> &'a str { | ^^^^^^^^^^^^ help: change this to: `&str` error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:286:36 + --> tests/ui/ptr_arg.rs:286:36 | LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str { | ^^^^^^^^^^^^^^^^ help: change this to: `&str` error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:290:40 + --> tests/ui/ptr_arg.rs:290:40 | LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str { | ^^^^^^^^^^^^^^^^ help: change this to: `&str` diff --git a/tests/ui/ptr_as_ptr.stderr b/tests/ui/ptr_as_ptr.stderr index ef64347e9350c..e162f35baf551 100644 --- a/tests/ui/ptr_as_ptr.stderr +++ b/tests/ui/ptr_as_ptr.stderr @@ -1,5 +1,5 @@ error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:18:33 + --> tests/ui/ptr_as_ptr.rs:18:33 | LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::issue_11278_a::T) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `Box::into_raw(Box::new(o)).cast::>()` @@ -8,37 +8,37 @@ LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::i = help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:27:13 + --> tests/ui/ptr_as_ptr.rs:27:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:28:13 + --> tests/ui/ptr_as_ptr.rs:28:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:33:17 + --> tests/ui/ptr_as_ptr.rs:33:17 | LL | let _ = *ptr_ptr as *const i32; | ^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `(*ptr_ptr).cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:46:25 + --> tests/ui/ptr_as_ptr.rs:46:25 | LL | let _: *const i32 = ptr as *const _; | ^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:47:23 + --> tests/ui/ptr_as_ptr.rs:47:23 | LL | let _: *mut i32 = mut_ptr as _; | ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:50:21 + --> tests/ui/ptr_as_ptr.rs:50:21 | LL | let _ = inline!($ptr as *const i32); | ^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `$ptr.cast::()` @@ -46,157 +46,157 @@ LL | let _ = inline!($ptr as *const i32); = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:71:13 + --> tests/ui/ptr_as_ptr.rs:71:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:72:13 + --> tests/ui/ptr_as_ptr.rs:72:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:79:9 + --> tests/ui/ptr_as_ptr.rs:79:9 | LL | ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:83:9 + --> tests/ui/ptr_as_ptr.rs:83:9 | LL | std::ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:88:9 + --> tests/ui/ptr_as_ptr.rs:88:9 | LL | ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:92:9 + --> tests/ui/ptr_as_ptr.rs:92:9 | LL | core::ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:97:9 + --> tests/ui/ptr_as_ptr.rs:97:9 | LL | ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:101:9 + --> tests/ui/ptr_as_ptr.rs:101:9 | LL | std::ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:106:9 + --> tests/ui/ptr_as_ptr.rs:106:9 | LL | ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:110:9 + --> tests/ui/ptr_as_ptr.rs:110:9 | LL | core::ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:117:9 + --> tests/ui/ptr_as_ptr.rs:117:9 | LL | ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:121:9 + --> tests/ui/ptr_as_ptr.rs:121:9 | LL | std::ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:126:9 + --> tests/ui/ptr_as_ptr.rs:126:9 | LL | ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:130:9 + --> tests/ui/ptr_as_ptr.rs:130:9 | LL | core::ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:135:9 + --> tests/ui/ptr_as_ptr.rs:135:9 | LL | ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:139:9 + --> tests/ui/ptr_as_ptr.rs:139:9 | LL | std::ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:144:9 + --> tests/ui/ptr_as_ptr.rs:144:9 | LL | ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:148:9 + --> tests/ui/ptr_as_ptr.rs:148:9 | LL | core::ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:155:9 + --> tests/ui/ptr_as_ptr.rs:155:9 | LL | ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:159:9 + --> tests/ui/ptr_as_ptr.rs:159:9 | LL | std::ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:164:9 + --> tests/ui/ptr_as_ptr.rs:164:9 | LL | ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:168:9 + --> tests/ui/ptr_as_ptr.rs:168:9 | LL | core::ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:173:9 + --> tests/ui/ptr_as_ptr.rs:173:9 | LL | ptr::null() as _ | ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:177:9 + --> tests/ui/ptr_as_ptr.rs:177:9 | LL | std::ptr::null() as _ | ^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:182:9 + --> tests/ui/ptr_as_ptr.rs:182:9 | LL | ptr::null() as _ | ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:186:9 + --> tests/ui/ptr_as_ptr.rs:186:9 | LL | core::ptr::null() as _ | ^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()` diff --git a/tests/ui/ptr_cast_constness.stderr b/tests/ui/ptr_cast_constness.stderr index a4bf778ad19d1..8e2bec527ffb6 100644 --- a/tests/ui/ptr_cast_constness.stderr +++ b/tests/ui/ptr_cast_constness.stderr @@ -1,5 +1,5 @@ error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:10:41 + --> tests/ui/ptr_cast_constness.rs:10:41 | LL | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` @@ -8,37 +8,37 @@ LL | let _: &mut T = std::mem::transmute(p as *mut T); = help: to override `-D warnings` add `#[allow(clippy::ptr_cast_constness)]` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:11:19 + --> tests/ui/ptr_cast_constness.rs:11:19 | LL | let _ = &mut *(p as *mut T); | ^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:26:17 + --> tests/ui/ptr_cast_constness.rs:26:17 | LL | let _ = *ptr_ptr as *mut u32; | ^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(*ptr_ptr).cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:29:13 + --> tests/ui/ptr_cast_constness.rs:29:13 | LL | let _ = ptr as *mut u32; | ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:30:13 + --> tests/ui/ptr_cast_constness.rs:30:13 | LL | let _ = mut_ptr as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:59:13 + --> tests/ui/ptr_cast_constness.rs:59:13 | LL | let _ = ptr as *mut u32; | ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:60:13 + --> tests/ui/ptr_cast_constness.rs:60:13 | LL | let _ = mut_ptr as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` diff --git a/tests/ui/ptr_eq.stderr b/tests/ui/ptr_eq.stderr index 2a384accac57f..bf8c2b5c08fb4 100644 --- a/tests/ui/ptr_eq.stderr +++ b/tests/ui/ptr_eq.stderr @@ -1,5 +1,5 @@ error: use `std::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq.rs:19:13 + --> tests/ui/ptr_eq.rs:19:13 | LL | let _ = a as *const _ as usize == b as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` @@ -8,7 +8,7 @@ LL | let _ = a as *const _ as usize == b as *const _ as usize; = help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]` error: use `std::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq.rs:20:13 + --> tests/ui/ptr_eq.rs:20:13 | LL | let _ = a as *const _ == b as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` diff --git a/tests/ui/ptr_eq_no_std.stderr b/tests/ui/ptr_eq_no_std.stderr index 3e289f5be613e..0463b75b720b9 100644 --- a/tests/ui/ptr_eq_no_std.stderr +++ b/tests/ui/ptr_eq_no_std.stderr @@ -1,5 +1,5 @@ error: use `core::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq_no_std.rs:31:13 + --> tests/ui/ptr_eq_no_std.rs:31:13 | LL | let _ = a as *const _ as usize == b as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(a, b)` @@ -8,7 +8,7 @@ LL | let _ = a as *const _ as usize == b as *const _ as usize; = help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]` error: use `core::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq_no_std.rs:32:13 + --> tests/ui/ptr_eq_no_std.rs:32:13 | LL | let _ = a as *const _ == b as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(a, b)` diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index e99053846795d..87ff10adc9467 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -1,5 +1,5 @@ error: use of `offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:12:17 + --> tests/ui/ptr_offset_with_cast.rs:12:17 | LL | let _ = ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` @@ -8,7 +8,7 @@ LL | let _ = ptr.offset(offset_usize as isize); = help: to override `-D warnings` add `#[allow(clippy::ptr_offset_with_cast)]` error: use of `wrapping_offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:16:17 + --> tests/ui/ptr_offset_with_cast.rs:16:17 | LL | let _ = ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` diff --git a/tests/ui/pub_use.stderr b/tests/ui/pub_use.stderr index f6f5db9a18004..e332a864c5292 100644 --- a/tests/ui/pub_use.stderr +++ b/tests/ui/pub_use.stderr @@ -1,5 +1,5 @@ error: using `pub use` - --> $DIR/pub_use.rs:10:5 + --> tests/ui/pub_use.rs:10:5 | LL | pub use inner::Test; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pub_with_shorthand.stderr b/tests/ui/pub_with_shorthand.stderr index 423b0508092f4..8978244c4c04a 100644 --- a/tests/ui/pub_with_shorthand.stderr +++ b/tests/ui/pub_with_shorthand.stderr @@ -1,5 +1,5 @@ error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:13:1 + --> tests/ui/pub_with_shorthand.rs:13:1 | LL | pub(self) fn a() {} | ^^^^^^^^^ help: add it: `pub(in self)` @@ -8,19 +8,19 @@ LL | pub(self) fn a() {} = help: to override `-D warnings` add `#[allow(clippy::pub_with_shorthand)]` error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:19:5 + --> tests/ui/pub_with_shorthand.rs:19:5 | LL | pub(super) fn e() {} | ^^^^^^^^^^ help: add it: `pub(in super)` error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:20:5 + --> tests/ui/pub_with_shorthand.rs:20:5 | LL | pub(self) fn f() {} | ^^^^^^^^^ help: add it: `pub(in self)` error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:21:5 + --> tests/ui/pub_with_shorthand.rs:21:5 | LL | pub(crate) fn k() {} | ^^^^^^^^^^ help: add it: `pub(in crate)` diff --git a/tests/ui/pub_without_shorthand.stderr b/tests/ui/pub_without_shorthand.stderr index 4fb11cb3d4ad3..e37c731732ba5 100644 --- a/tests/ui/pub_without_shorthand.stderr +++ b/tests/ui/pub_without_shorthand.stderr @@ -1,5 +1,5 @@ error: usage of `pub` with `in` - --> $DIR/pub_without_shorthand.rs:14:1 + --> tests/ui/pub_without_shorthand.rs:14:1 | LL | pub(in self) fn b() {} | ^^^^^^^^^^^^ help: remove it: `pub(self)` @@ -8,13 +8,13 @@ LL | pub(in self) fn b() {} = help: to override `-D warnings` add `#[allow(clippy::pub_without_shorthand)]` error: usage of `pub` with `in` - --> $DIR/pub_without_shorthand.rs:18:5 + --> tests/ui/pub_without_shorthand.rs:18:5 | LL | pub(in super) fn d() {} | ^^^^^^^^^^^^^ help: remove it: `pub(super)` error: usage of `pub` with `in` - --> $DIR/pub_without_shorthand.rs:22:5 + --> tests/ui/pub_without_shorthand.rs:22:5 | LL | pub(in crate) fn m() {} | ^^^^^^^^^^^^^ help: remove it: `pub(crate)` diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index 7b7b85d08e63c..4fcccdf5512fc 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -1,5 +1,5 @@ error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:7:5 + --> tests/ui/question_mark.rs:7:5 | LL | / if a.is_none() { LL | | return None; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::question_mark)]` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:52:9 + --> tests/ui/question_mark.rs:52:9 | LL | / if (self.opt).is_none() { LL | | return None; @@ -18,7 +18,7 @@ LL | | } | |_________^ help: replace it with: `(self.opt)?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:56:9 + --> tests/ui/question_mark.rs:56:9 | LL | / if self.opt.is_none() { LL | | return None @@ -26,7 +26,7 @@ LL | | } | |_________^ help: replace it with: `self.opt?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:60:17 + --> tests/ui/question_mark.rs:60:17 | LL | let _ = if self.opt.is_none() { | _________________^ @@ -37,7 +37,7 @@ LL | | }; | |_________^ help: replace it with: `Some(self.opt?)` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:66:17 + --> tests/ui/question_mark.rs:66:17 | LL | let _ = if let Some(x) = self.opt { | _________________^ @@ -48,7 +48,7 @@ LL | | }; | |_________^ help: replace it with: `self.opt?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:83:9 + --> tests/ui/question_mark.rs:83:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -56,7 +56,7 @@ LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:91:9 + --> tests/ui/question_mark.rs:91:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -64,7 +64,7 @@ LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:99:9 + --> tests/ui/question_mark.rs:99:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -72,7 +72,7 @@ LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:106:26 + --> tests/ui/question_mark.rs:106:26 | LL | let v: &Vec<_> = if let Some(ref v) = self.opt { | __________________________^ @@ -83,7 +83,7 @@ LL | | }; | |_________^ help: replace it with: `self.opt.as_ref()?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:116:17 + --> tests/ui/question_mark.rs:116:17 | LL | let v = if let Some(v) = self.opt { | _________________^ @@ -94,7 +94,7 @@ LL | | }; | |_________^ help: replace it with: `self.opt?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:131:5 + --> tests/ui/question_mark.rs:131:5 | LL | / if f().is_none() { LL | | return None; @@ -102,13 +102,13 @@ LL | | } | |_____^ help: replace it with: `f()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:143:13 + --> tests/ui/question_mark.rs:143:13 | LL | let _ = if let Ok(x) = x { x } else { return x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:145:5 + --> tests/ui/question_mark.rs:145:5 | LL | / if x.is_err() { LL | | return x; @@ -116,7 +116,7 @@ LL | | } | |_____^ help: replace it with: `x?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:213:5 + --> tests/ui/question_mark.rs:213:5 | LL | / if let Err(err) = func_returning_result() { LL | | return Err(err); @@ -124,7 +124,7 @@ LL | | } | |_____^ help: replace it with: `func_returning_result()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:220:5 + --> tests/ui/question_mark.rs:220:5 | LL | / if let Err(err) = func_returning_result() { LL | | return Err(err); @@ -132,7 +132,7 @@ LL | | } | |_____^ help: replace it with: `func_returning_result()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:297:13 + --> tests/ui/question_mark.rs:297:13 | LL | / if a.is_none() { LL | | return None; diff --git a/tests/ui/question_mark_used.stderr b/tests/ui/question_mark_used.stderr index b4e256ddb9ebe..53cb59c021667 100644 --- a/tests/ui/question_mark_used.stderr +++ b/tests/ui/question_mark_used.stderr @@ -1,5 +1,5 @@ error: question mark operator was used - --> $DIR/question_mark_used.rs:11:5 + --> tests/ui/question_mark_used.rs:11:5 | LL | other_function()?; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 78ef17b5ba79d..8c71a209700e1 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,5 +1,5 @@ error: it is more idiomatic to use `v1.iter().enumerate()` - --> $DIR/range.rs:6:14 + --> tests/ui/range.rs:6:14 | LL | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/range_contains.stderr b/tests/ui/range_contains.stderr index 349adea2193cc..58ed1292ac7c9 100644 --- a/tests/ui/range_contains.stderr +++ b/tests/ui/range_contains.stderr @@ -1,5 +1,5 @@ error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:13:5 + --> tests/ui/range_contains.rs:13:5 | LL | x >= 8 && x < 12; | ^^^^^^^^^^^^^^^^ help: use: `(8..12).contains(&x)` @@ -8,121 +8,121 @@ LL | x >= 8 && x < 12; = help: to override `-D warnings` add `#[allow(clippy::manual_range_contains)]` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:14:5 + --> tests/ui/range_contains.rs:14:5 | LL | x < 42 && x >= 21; | ^^^^^^^^^^^^^^^^^ help: use: `(21..42).contains(&x)` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:15:5 + --> tests/ui/range_contains.rs:15:5 | LL | 100 > x && 1 <= x; | ^^^^^^^^^^^^^^^^^ help: use: `(1..100).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:18:5 + --> tests/ui/range_contains.rs:18:5 | LL | x >= 9 && x <= 99; | ^^^^^^^^^^^^^^^^^ help: use: `(9..=99).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:19:5 + --> tests/ui/range_contains.rs:19:5 | LL | x <= 33 && x >= 1; | ^^^^^^^^^^^^^^^^^ help: use: `(1..=33).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:20:5 + --> tests/ui/range_contains.rs:20:5 | LL | 999 >= x && 1 <= x; | ^^^^^^^^^^^^^^^^^^ help: use: `(1..=999).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:23:5 + --> tests/ui/range_contains.rs:23:5 | LL | x < 8 || x >= 12; | ^^^^^^^^^^^^^^^^ help: use: `!(8..12).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:24:5 + --> tests/ui/range_contains.rs:24:5 | LL | x >= 42 || x < 21; | ^^^^^^^^^^^^^^^^^ help: use: `!(21..42).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:25:5 + --> tests/ui/range_contains.rs:25:5 | LL | 100 <= x || 1 > x; | ^^^^^^^^^^^^^^^^^ help: use: `!(1..100).contains(&x)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:28:5 + --> tests/ui/range_contains.rs:28:5 | LL | x < 9 || x > 99; | ^^^^^^^^^^^^^^^ help: use: `!(9..=99).contains(&x)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:29:5 + --> tests/ui/range_contains.rs:29:5 | LL | x > 33 || x < 1; | ^^^^^^^^^^^^^^^ help: use: `!(1..=33).contains(&x)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:30:5 + --> tests/ui/range_contains.rs:30:5 | LL | 999 < x || 1 > x; | ^^^^^^^^^^^^^^^^ help: use: `!(1..=999).contains(&x)` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:45:5 + --> tests/ui/range_contains.rs:45:5 | LL | y >= 0. && y < 1.; | ^^^^^^^^^^^^^^^^^ help: use: `(0. ..1.).contains(&y)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:46:5 + --> tests/ui/range_contains.rs:46:5 | LL | y < 0. || y > 1.; | ^^^^^^^^^^^^^^^^ help: use: `!(0. ..=1.).contains(&y)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:49:5 + --> tests/ui/range_contains.rs:49:5 | LL | x >= -10 && x <= 10; | ^^^^^^^^^^^^^^^^^^^ help: use: `(-10..=10).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:51:5 + --> tests/ui/range_contains.rs:51:5 | LL | y >= -3. && y <= 3.; | ^^^^^^^^^^^^^^^^^^^ help: use: `(-3. ..=3.).contains(&y)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:56:30 + --> tests/ui/range_contains.rs:56:30 | LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&z)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:56:5 + --> tests/ui/range_contains.rs:56:5 | LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:57:29 + --> tests/ui/range_contains.rs:57:29 | LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10); | ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&z)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:57:5 + --> tests/ui/range_contains.rs:57:5 | LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10); | ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&x)` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:76:5 + --> tests/ui/range_contains.rs:76:5 | LL | x >= 8 && x < 35; | ^^^^^^^^^^^^^^^^ help: use: `(8..35).contains(&x)` diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index c5c9b145db855..0b1883bc5ff22 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,5 +1,5 @@ error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:29:14 + --> tests/ui/range_plus_minus_one.rs:29:14 | LL | for _ in 0..3 + 1 {} | ^^^^^^^^ help: use: `0..=3` @@ -8,25 +8,25 @@ LL | for _ in 0..3 + 1 {} = help: to override `-D warnings` add `#[allow(clippy::range_plus_one)]` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:32:14 + --> tests/ui/range_plus_minus_one.rs:32:14 | LL | for _ in 0..1 + 5 {} | ^^^^^^^^ help: use: `0..=5` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:35:14 + --> tests/ui/range_plus_minus_one.rs:35:14 | LL | for _ in 1..1 + 1 {} | ^^^^^^^^ help: use: `1..=1` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:41:14 + --> tests/ui/range_plus_minus_one.rs:41:14 | LL | for _ in 0..(1 + f()) {} | ^^^^^^^^^^^^ help: use: `0..=f()` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:45:13 + --> tests/ui/range_plus_minus_one.rs:45:13 | LL | let _ = ..=11 - 1; | ^^^^^^^^^ help: use: `..11` @@ -35,25 +35,25 @@ LL | let _ = ..=11 - 1; = help: to override `-D warnings` add `#[allow(clippy::range_minus_one)]` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:46:13 + --> tests/ui/range_plus_minus_one.rs:46:13 | LL | let _ = ..=(11 - 1); | ^^^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:47:13 + --> tests/ui/range_plus_minus_one.rs:47:13 | LL | let _ = (1..11 + 1); | ^^^^^^^^^^^ help: use: `(1..=11)` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:48:13 + --> tests/ui/range_plus_minus_one.rs:48:13 | LL | let _ = (f() + 1)..(f() + 1); | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:52:14 + --> tests/ui/range_plus_minus_one.rs:52:14 | LL | for _ in 1..ONE + ONE {} | ^^^^^^^^^^^^ help: use: `1..=ONE` diff --git a/tests/ui/rc_buffer.stderr b/tests/ui/rc_buffer.stderr index 04080326ae0f0..922f09288bf38 100644 --- a/tests/ui/rc_buffer.stderr +++ b/tests/ui/rc_buffer.stderr @@ -1,5 +1,5 @@ error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:11:11 + --> tests/ui/rc_buffer.rs:11:11 | LL | bad1: Rc, | ^^^^^^^^^^ help: try: `Rc` @@ -8,43 +8,43 @@ LL | bad1: Rc, = help: to override `-D warnings` add `#[allow(clippy::rc_buffer)]` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:12:11 + --> tests/ui/rc_buffer.rs:12:11 | LL | bad2: Rc, | ^^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:13:11 + --> tests/ui/rc_buffer.rs:13:11 | LL | bad3: Rc>, | ^^^^^^^^^^^ help: try: `Rc<[u8]>` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:14:11 + --> tests/ui/rc_buffer.rs:14:11 | LL | bad4: Rc, | ^^^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:20:17 + --> tests/ui/rc_buffer.rs:20:17 | LL | fn func_bad1(_: Rc) {} | ^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:21:17 + --> tests/ui/rc_buffer.rs:21:17 | LL | fn func_bad2(_: Rc) {} | ^^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:22:17 + --> tests/ui/rc_buffer.rs:22:17 | LL | fn func_bad3(_: Rc>) {} | ^^^^^^^^^^^ help: try: `Rc<[u8]>` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:23:17 + --> tests/ui/rc_buffer.rs:23:17 | LL | fn func_bad4(_: Rc) {} | ^^^^^^^^^^^^ help: try: `Rc` diff --git a/tests/ui/rc_buffer_arc.stderr b/tests/ui/rc_buffer_arc.stderr index 52522dd725f4f..5ef5da2f67f84 100644 --- a/tests/ui/rc_buffer_arc.stderr +++ b/tests/ui/rc_buffer_arc.stderr @@ -1,5 +1,5 @@ error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:10:11 + --> tests/ui/rc_buffer_arc.rs:10:11 | LL | bad1: Arc, | ^^^^^^^^^^^ help: try: `Arc` @@ -8,43 +8,43 @@ LL | bad1: Arc, = help: to override `-D warnings` add `#[allow(clippy::rc_buffer)]` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:11:11 + --> tests/ui/rc_buffer_arc.rs:11:11 | LL | bad2: Arc, | ^^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:12:11 + --> tests/ui/rc_buffer_arc.rs:12:11 | LL | bad3: Arc>, | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:13:11 + --> tests/ui/rc_buffer_arc.rs:13:11 | LL | bad4: Arc, | ^^^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:19:17 + --> tests/ui/rc_buffer_arc.rs:19:17 | LL | fn func_bad1(_: Arc) {} | ^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:20:17 + --> tests/ui/rc_buffer_arc.rs:20:17 | LL | fn func_bad2(_: Arc) {} | ^^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:21:17 + --> tests/ui/rc_buffer_arc.rs:21:17 | LL | fn func_bad3(_: Arc>) {} | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:22:17 + --> tests/ui/rc_buffer_arc.rs:22:17 | LL | fn func_bad4(_: Arc) {} | ^^^^^^^^^^^^^ help: try: `Arc` diff --git a/tests/ui/rc_clone_in_vec_init/arc.stderr b/tests/ui/rc_clone_in_vec_init/arc.stderr index a5d050ad8f16d..1078a97542f2c 100644 --- a/tests/ui/rc_clone_in_vec_init/arc.stderr +++ b/tests/ui/rc_clone_in_vec_init/arc.stderr @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/arc.rs:9:13 + --> tests/ui/rc_clone_in_vec_init/arc.rs:9:13 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/arc.rs:19:21 + --> tests/ui/rc_clone_in_vec_init/arc.rs:19:21 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/arc.rs:27:13 + --> tests/ui/rc_clone_in_vec_init/arc.rs:27:13 | LL | let v = vec![ | _____________^ @@ -77,7 +77,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/arc.rs:38:14 + --> tests/ui/rc_clone_in_vec_init/arc.rs:38:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_clone_in_vec_init/rc.stderr b/tests/ui/rc_clone_in_vec_init/rc.stderr index fbf4517c1d229..702266d62d2c3 100644 --- a/tests/ui/rc_clone_in_vec_init/rc.stderr +++ b/tests/ui/rc_clone_in_vec_init/rc.stderr @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/rc.rs:10:13 + --> tests/ui/rc_clone_in_vec_init/rc.rs:10:13 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/rc.rs:20:21 + --> tests/ui/rc_clone_in_vec_init/rc.rs:20:21 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/rc.rs:28:13 + --> tests/ui/rc_clone_in_vec_init/rc.rs:28:13 | LL | let v = vec![ | _____________^ @@ -77,7 +77,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/rc.rs:39:14 + --> tests/ui/rc_clone_in_vec_init/rc.rs:39:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_clone_in_vec_init/weak.stderr b/tests/ui/rc_clone_in_vec_init/weak.stderr index 658b308d68c53..68ca2a7eb848c 100644 --- a/tests/ui/rc_clone_in_vec_init/weak.stderr +++ b/tests/ui/rc_clone_in_vec_init/weak.stderr @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:10:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:10:13 | LL | let v = vec![SyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:13:14 + --> tests/ui/rc_clone_in_vec_init/weak.rs:13:14 | LL | let v2 = vec![UnSyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:17:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:17:13 | LL | let v = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:20:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:20:13 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:30:21 + --> tests/ui/rc_clone_in_vec_init/weak.rs:30:21 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:33:22 + --> tests/ui/rc_clone_in_vec_init/weak.rs:33:22 | LL | let v2 = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:41:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:41:13 | LL | let v = vec![ | _____________^ @@ -169,7 +169,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc_clone_in_vec_init/weak.rs:52:14 + --> tests/ui/rc_clone_in_vec_init/weak.rs:52:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_mutex.stderr b/tests/ui/rc_mutex.stderr index 50922fb67e492..9aa18336df00c 100644 --- a/tests/ui/rc_mutex.stderr +++ b/tests/ui/rc_mutex.stderr @@ -1,5 +1,5 @@ error: usage of `Rc>` - --> $DIR/rc_mutex.rs:8:10 + --> tests/ui/rc_mutex.rs:8:10 | LL | foo: Rc>, | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | foo: Rc>, = help: to override `-D warnings` add `#[allow(clippy::rc_mutex)]` error: usage of `Rc>` - --> $DIR/rc_mutex.rs:27:18 + --> tests/ui/rc_mutex.rs:27:18 | LL | fn test1(foo: Rc>) {} | ^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn test1(foo: Rc>) {} = help: consider using `Rc>` or `Arc>` instead error: usage of `Rc>` - --> $DIR/rc_mutex.rs:29:15 + --> tests/ui/rc_mutex.rs:29:15 | LL | fn test2(foo: Rc>) {} | ^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn test2(foo: Rc>) {} = help: consider using `Rc>` or `Arc>` instead error: usage of `Rc>` - --> $DIR/rc_mutex.rs:31:15 + --> tests/ui/rc_mutex.rs:31:15 | LL | fn test3(foo: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/read_line_without_trim.stderr b/tests/ui/read_line_without_trim.stderr index 8d46e0f790781..7d0ac26c3c505 100644 --- a/tests/ui/read_line_without_trim.stderr +++ b/tests/ui/read_line_without_trim.stderr @@ -1,5 +1,5 @@ error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:12:25 + --> tests/ui/read_line_without_trim.rs:12:25 | LL | let _x: i32 = input.parse().unwrap(); | ----- ^^^^^^^ @@ -7,7 +7,7 @@ LL | let _x: i32 = input.parse().unwrap(); | help: try: `input.trim_end()` | note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:11:5 + --> tests/ui/read_line_without_trim.rs:11:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | std::io::stdin().read_line(&mut input).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::read_line_without_trim)]` error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:16:20 + --> tests/ui/read_line_without_trim.rs:16:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^ @@ -23,13 +23,13 @@ LL | let _x = input.parse::().unwrap(); | help: try: `input.trim_end()` | note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:15:5 + --> tests/ui/read_line_without_trim.rs:15:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:20:20 + --> tests/ui/read_line_without_trim.rs:20:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^ @@ -37,13 +37,13 @@ LL | let _x = input.parse::().unwrap(); | help: try: `input.trim_end()` | note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:19:5 + --> tests/ui/read_line_without_trim.rs:19:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:24:20 + --> tests/ui/read_line_without_trim.rs:24:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^ @@ -51,13 +51,13 @@ LL | let _x = input.parse::().unwrap(); | help: try: `input.trim_end()` | note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:23:5 + --> tests/ui/read_line_without_trim.rs:23:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:28:20 + --> tests/ui/read_line_without_trim.rs:28:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _x = input.parse::().unwrap(); | help: try: `input.trim_end()` | note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:27:5 + --> tests/ui/read_line_without_trim.rs:27:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/read_zero_byte_vec.stderr b/tests/ui/read_zero_byte_vec.stderr index e85aa051c34bc..e2356f1cb56be 100644 --- a/tests/ui/read_zero_byte_vec.stderr +++ b/tests/ui/read_zero_byte_vec.stderr @@ -1,5 +1,5 @@ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:21:5 + --> tests/ui/read_zero_byte_vec.rs:21:5 | LL | f.read_exact(&mut data).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data.resize(20, 0); f.read_exact(&mut data)` @@ -8,61 +8,61 @@ LL | f.read_exact(&mut data).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::read_zero_byte_vec)]` error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:27:5 + --> tests/ui/read_zero_byte_vec.rs:27:5 | LL | f.read_exact(&mut data2)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data2.resize(cap, 0); f.read_exact(&mut data2)` error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:32:5 + --> tests/ui/read_zero_byte_vec.rs:32:5 | LL | f.read_exact(&mut data3)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:37:13 + --> tests/ui/read_zero_byte_vec.rs:37:13 | LL | let _ = f.read(&mut data4)?; | ^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:43:9 + --> tests/ui/read_zero_byte_vec.rs:43:9 | LL | f.read(&mut data5) | ^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:50:9 + --> tests/ui/read_zero_byte_vec.rs:50:9 | LL | f.read(&mut data6) | ^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:84:9 + --> tests/ui/read_zero_byte_vec.rs:84:9 | LL | f.read(&mut v)?; | ^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:94:5 + --> tests/ui/read_zero_byte_vec.rs:94:5 | LL | r.read(&mut data).await.unwrap(); | ^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:99:5 + --> tests/ui/read_zero_byte_vec.rs:99:5 | LL | r.read_exact(&mut data2).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:106:5 + --> tests/ui/read_zero_byte_vec.rs:106:5 | LL | r.read(&mut data).await.unwrap(); | ^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:111:5 + --> tests/ui/read_zero_byte_vec.rs:111:5 | LL | r.read_exact(&mut data2).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/readonly_write_lock.stderr b/tests/ui/readonly_write_lock.stderr index b4a093ce9c93f..6b1ef3c4720f0 100644 --- a/tests/ui/readonly_write_lock.stderr +++ b/tests/ui/readonly_write_lock.stderr @@ -1,5 +1,5 @@ error: this write lock is used only for reading - --> $DIR/readonly_write_lock.rs:16:22 + --> tests/ui/readonly_write_lock.rs:16:22 | LL | let writer = lock.write().unwrap(); | ^^^^^^^^^^^^ help: consider using a read lock instead: `lock.read()` @@ -8,7 +8,7 @@ LL | let writer = lock.write().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::readonly_write_lock)]` error: this write lock is used only for reading - --> $DIR/readonly_write_lock.rs:23:22 + --> tests/ui/readonly_write_lock.rs:23:22 | LL | let writer = lock.write().unwrap(); | ^^^^^^^^^^^^ help: consider using a read lock instead: `lock.read()` diff --git a/tests/ui/recursive_format_impl.stderr b/tests/ui/recursive_format_impl.stderr index adb16f44a999e..f80aff01eb53e 100644 --- a/tests/ui/recursive_format_impl.stderr +++ b/tests/ui/recursive_format_impl.stderr @@ -1,5 +1,5 @@ error: using `self.to_string` in `fmt::Display` implementation will cause infinite recursion - --> $DIR/recursive_format_impl.rs:31:25 + --> tests/ui/recursive_format_impl.rs:31:25 | LL | write!(f, "{}", self.to_string()) | ^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | write!(f, "{}", self.to_string()) = help: to override `-D warnings` add `#[allow(clippy::recursive_format_impl)]` error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:77:9 + --> tests/ui/recursive_format_impl.rs:77:9 | LL | write!(f, "{}", self) | ^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | write!(f, "{}", self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:87:9 + --> tests/ui/recursive_format_impl.rs:87:9 | LL | write!(f, "{}", &self) | ^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | write!(f, "{}", &self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Debug` in `impl Debug` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:94:9 + --> tests/ui/recursive_format_impl.rs:94:9 | LL | write!(f, "{:?}", &self) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | write!(f, "{:?}", &self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:104:9 + --> tests/ui/recursive_format_impl.rs:104:9 | LL | write!(f, "{}", &&&self) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | write!(f, "{}", &&&self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:179:9 + --> tests/ui/recursive_format_impl.rs:179:9 | LL | write!(f, "{}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | write!(f, "{}", &*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Debug` in `impl Debug` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:186:9 + --> tests/ui/recursive_format_impl.rs:186:9 | LL | write!(f, "{:?}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | write!(f, "{:?}", &*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:203:9 + --> tests/ui/recursive_format_impl.rs:203:9 | LL | write!(f, "{}", *self) | ^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | write!(f, "{}", *self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:220:9 + --> tests/ui/recursive_format_impl.rs:220:9 | LL | write!(f, "{}", **&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | write!(f, "{}", **&&*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:237:9 + --> tests/ui/recursive_format_impl.rs:237:9 | LL | write!(f, "{}", &&**&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_allocation.stderr b/tests/ui/redundant_allocation.stderr index d72f6b202ec23..8a043013e07a9 100644 --- a/tests/ui/redundant_allocation.stderr +++ b/tests/ui/redundant_allocation.stderr @@ -1,5 +1,5 @@ error: usage of `Box>` - --> $DIR/redundant_allocation.rs:16:30 + --> tests/ui/redundant_allocation.rs:16:30 | LL | pub fn box_test6(foo: Box>) {} | ^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | pub fn box_test6(foo: Box>) {} = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box>` - --> $DIR/redundant_allocation.rs:20:30 + --> tests/ui/redundant_allocation.rs:20:30 | LL | pub fn box_test7(foo: Box>) {} | ^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | pub fn box_test7(foo: Box>) {} = help: consider using just `Box` or `Arc` error: usage of `Box>>` - --> $DIR/redundant_allocation.rs:24:27 + --> tests/ui/redundant_allocation.rs:24:27 | LL | pub fn box_test8() -> Box>> { | ^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | pub fn box_test8() -> Box>> { = help: consider using just `Box>` or `Rc>` error: usage of `Box>` - --> $DIR/redundant_allocation.rs:30:30 + --> tests/ui/redundant_allocation.rs:30:30 | LL | pub fn box_test9(foo: Box>) -> Box>> { | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = help: consider using just `Box` or `Arc` error: usage of `Box>>` - --> $DIR/redundant_allocation.rs:30:46 + --> tests/ui/redundant_allocation.rs:30:46 | LL | pub fn box_test9(foo: Box>) -> Box>> { | ^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = help: consider using just `Box>` or `Arc>` error: usage of `Rc>` - --> $DIR/redundant_allocation.rs:45:24 + --> tests/ui/redundant_allocation.rs:45:24 | LL | pub fn rc_test5(a: Rc>) {} | ^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | pub fn rc_test5(a: Rc>) {} = help: consider using just `Rc` or `Box` error: usage of `Rc>` - --> $DIR/redundant_allocation.rs:49:24 + --> tests/ui/redundant_allocation.rs:49:24 | LL | pub fn rc_test7(a: Rc>) {} | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | pub fn rc_test7(a: Rc>) {} = help: consider using just `Rc` or `Arc` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:53:26 + --> tests/ui/redundant_allocation.rs:53:26 | LL | pub fn rc_test8() -> Rc>> { | ^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | pub fn rc_test8() -> Rc>> { = help: consider using just `Rc>` or `Box>` error: usage of `Rc>` - --> $DIR/redundant_allocation.rs:59:29 + --> tests/ui/redundant_allocation.rs:59:29 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { | ^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = help: consider using just `Rc` or `Arc` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:59:44 + --> tests/ui/redundant_allocation.rs:59:44 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { | ^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = help: consider using just `Rc>` or `Arc>` error: usage of `Arc>` - --> $DIR/redundant_allocation.rs:74:25 + --> tests/ui/redundant_allocation.rs:74:25 | LL | pub fn arc_test5(a: Arc>) {} | ^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | pub fn arc_test5(a: Arc>) {} = help: consider using just `Arc` or `Box` error: usage of `Arc>` - --> $DIR/redundant_allocation.rs:78:25 + --> tests/ui/redundant_allocation.rs:78:25 | LL | pub fn arc_test6(a: Arc>) {} | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | pub fn arc_test6(a: Arc>) {} = help: consider using just `Arc` or `Rc` error: usage of `Arc>>` - --> $DIR/redundant_allocation.rs:82:27 + --> tests/ui/redundant_allocation.rs:82:27 | LL | pub fn arc_test8() -> Arc>> { | ^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | pub fn arc_test8() -> Arc>> { = help: consider using just `Arc>` or `Box>` error: usage of `Arc>` - --> $DIR/redundant_allocation.rs:88:30 + --> tests/ui/redundant_allocation.rs:88:30 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { | ^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = help: consider using just `Arc` or `Rc` error: usage of `Arc>>` - --> $DIR/redundant_allocation.rs:88:45 + --> tests/ui/redundant_allocation.rs:88:45 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { | ^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = help: consider using just `Arc>` or `Rc>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:114:27 + --> tests/ui/redundant_allocation.rs:114:27 | LL | pub fn test_rc_box(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | pub fn test_rc_box(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:148:31 + --> tests/ui/redundant_allocation.rs:148:31 | LL | pub fn test_rc_box_str(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL | pub fn test_rc_box_str(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:151:33 + --> tests/ui/redundant_allocation.rs:151:33 | LL | pub fn test_rc_box_slice(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | pub fn test_rc_box_slice(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:154:32 + --> tests/ui/redundant_allocation.rs:154:32 | LL | pub fn test_rc_box_path(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^ @@ -172,7 +172,7 @@ LL | pub fn test_rc_box_path(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:157:34 + --> tests/ui/redundant_allocation.rs:157:34 | LL | pub fn test_rc_box_custom(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_allocation_fixable.stderr b/tests/ui/redundant_allocation_fixable.stderr index 603600f30227d..34a1a21bdadcd 100644 --- a/tests/ui/redundant_allocation_fixable.stderr +++ b/tests/ui/redundant_allocation_fixable.stderr @@ -1,5 +1,5 @@ error: usage of `Box<&T>` - --> $DIR/redundant_allocation_fixable.rs:23:30 + --> tests/ui/redundant_allocation_fixable.rs:23:30 | LL | pub fn box_test1(foo: Box<&T>) {} | ^^^^^^^ help: try: `&T` @@ -9,7 +9,7 @@ LL | pub fn box_test1(foo: Box<&T>) {} = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box<&MyStruct>` - --> $DIR/redundant_allocation_fixable.rs:25:27 + --> tests/ui/redundant_allocation_fixable.rs:25:27 | LL | pub fn box_test2(foo: Box<&MyStruct>) {} | ^^^^^^^^^^^^^^ help: try: `&MyStruct` @@ -17,7 +17,7 @@ LL | pub fn box_test2(foo: Box<&MyStruct>) {} = note: `&MyStruct` is already a pointer, `Box<&MyStruct>` allocates a pointer on the heap error: usage of `Box<&MyEnum>` - --> $DIR/redundant_allocation_fixable.rs:27:27 + --> tests/ui/redundant_allocation_fixable.rs:27:27 | LL | pub fn box_test3(foo: Box<&MyEnum>) {} | ^^^^^^^^^^^^ help: try: `&MyEnum` @@ -25,7 +25,7 @@ LL | pub fn box_test3(foo: Box<&MyEnum>) {} = note: `&MyEnum` is already a pointer, `Box<&MyEnum>` allocates a pointer on the heap error: usage of `Box>` - --> $DIR/redundant_allocation_fixable.rs:31:30 + --> tests/ui/redundant_allocation_fixable.rs:31:30 | LL | pub fn box_test5(foo: Box>) {} | ^^^^^^^^^^^ help: try: `Box` @@ -33,7 +33,7 @@ LL | pub fn box_test5(foo: Box>) {} = note: `Box` is already on the heap, `Box>` makes an extra allocation error: usage of `Rc<&T>` - --> $DIR/redundant_allocation_fixable.rs:40:29 + --> tests/ui/redundant_allocation_fixable.rs:40:29 | LL | pub fn rc_test1(foo: Rc<&T>) {} | ^^^^^^ help: try: `&T` @@ -41,7 +41,7 @@ LL | pub fn rc_test1(foo: Rc<&T>) {} = note: `&T` is already a pointer, `Rc<&T>` allocates a pointer on the heap error: usage of `Rc<&MyStruct>` - --> $DIR/redundant_allocation_fixable.rs:42:26 + --> tests/ui/redundant_allocation_fixable.rs:42:26 | LL | pub fn rc_test2(foo: Rc<&MyStruct>) {} | ^^^^^^^^^^^^^ help: try: `&MyStruct` @@ -49,7 +49,7 @@ LL | pub fn rc_test2(foo: Rc<&MyStruct>) {} = note: `&MyStruct` is already a pointer, `Rc<&MyStruct>` allocates a pointer on the heap error: usage of `Rc<&MyEnum>` - --> $DIR/redundant_allocation_fixable.rs:44:26 + --> tests/ui/redundant_allocation_fixable.rs:44:26 | LL | pub fn rc_test3(foo: Rc<&MyEnum>) {} | ^^^^^^^^^^^ help: try: `&MyEnum` @@ -57,7 +57,7 @@ LL | pub fn rc_test3(foo: Rc<&MyEnum>) {} = note: `&MyEnum` is already a pointer, `Rc<&MyEnum>` allocates a pointer on the heap error: usage of `Rc>` - --> $DIR/redundant_allocation_fixable.rs:48:24 + --> tests/ui/redundant_allocation_fixable.rs:48:24 | LL | pub fn rc_test6(a: Rc>) {} | ^^^^^^^^^^^^ help: try: `Rc` @@ -65,7 +65,7 @@ LL | pub fn rc_test6(a: Rc>) {} = note: `Rc` is already on the heap, `Rc>` makes an extra allocation error: usage of `Arc<&T>` - --> $DIR/redundant_allocation_fixable.rs:57:30 + --> tests/ui/redundant_allocation_fixable.rs:57:30 | LL | pub fn arc_test1(foo: Arc<&T>) {} | ^^^^^^^ help: try: `&T` @@ -73,7 +73,7 @@ LL | pub fn arc_test1(foo: Arc<&T>) {} = note: `&T` is already a pointer, `Arc<&T>` allocates a pointer on the heap error: usage of `Arc<&MyStruct>` - --> $DIR/redundant_allocation_fixable.rs:59:27 + --> tests/ui/redundant_allocation_fixable.rs:59:27 | LL | pub fn arc_test2(foo: Arc<&MyStruct>) {} | ^^^^^^^^^^^^^^ help: try: `&MyStruct` @@ -81,7 +81,7 @@ LL | pub fn arc_test2(foo: Arc<&MyStruct>) {} = note: `&MyStruct` is already a pointer, `Arc<&MyStruct>` allocates a pointer on the heap error: usage of `Arc<&MyEnum>` - --> $DIR/redundant_allocation_fixable.rs:61:27 + --> tests/ui/redundant_allocation_fixable.rs:61:27 | LL | pub fn arc_test3(foo: Arc<&MyEnum>) {} | ^^^^^^^^^^^^ help: try: `&MyEnum` @@ -89,7 +89,7 @@ LL | pub fn arc_test3(foo: Arc<&MyEnum>) {} = note: `&MyEnum` is already a pointer, `Arc<&MyEnum>` allocates a pointer on the heap error: usage of `Arc>` - --> $DIR/redundant_allocation_fixable.rs:65:25 + --> tests/ui/redundant_allocation_fixable.rs:65:25 | LL | pub fn arc_test7(a: Arc>) {} | ^^^^^^^^^^^^^^ help: try: `Arc` diff --git a/tests/ui/redundant_as_str.stderr b/tests/ui/redundant_as_str.stderr index 0ea42a94a81ed..f086de5fedebb 100644 --- a/tests/ui/redundant_as_str.stderr +++ b/tests/ui/redundant_as_str.stderr @@ -1,5 +1,5 @@ error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too - --> $DIR/redundant_as_str.rs:7:29 + --> tests/ui/redundant_as_str.rs:7:29 | LL | let _redundant = string.as_str().as_bytes(); | ^^^^^^^^^^^^^^^^^ help: try: `as_bytes` @@ -8,7 +8,7 @@ LL | let _redundant = string.as_str().as_bytes(); = help: to override `-D warnings` add `#[allow(clippy::redundant_as_str)]` error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too - --> $DIR/redundant_as_str.rs:8:29 + --> tests/ui/redundant_as_str.rs:8:29 | LL | let _redundant = string.as_str().is_empty(); | ^^^^^^^^^^^^^^^^^ help: try: `is_empty` diff --git a/tests/ui/redundant_async_block.stderr b/tests/ui/redundant_async_block.stderr index adb44d7a62ef4..c6a5e2f28adae 100644 --- a/tests/ui/redundant_async_block.stderr +++ b/tests/ui/redundant_async_block.stderr @@ -1,5 +1,5 @@ error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:13:13 + --> tests/ui/redundant_async_block.rs:13:13 | LL | let x = async { f.await }; | ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f` @@ -8,49 +8,49 @@ LL | let x = async { f.await }; = help: to override `-D warnings` add `#[allow(clippy::redundant_async_block)]` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:20:16 + --> tests/ui/redundant_async_block.rs:20:16 | LL | let fut2 = async { fut1.await }; | ^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut1` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:24:16 + --> tests/ui/redundant_async_block.rs:24:16 | LL | let fut2 = async move { fut1.await }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut1` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:27:15 + --> tests/ui/redundant_async_block.rs:27:15 | LL | let fut = async { async { 42 }.await }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { 42 }` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:43:5 + --> tests/ui/redundant_async_block.rs:43:5 | LL | async move { fut.await } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:56:5 + --> tests/ui/redundant_async_block.rs:56:5 | LL | async move { fut.await } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:61:5 + --> tests/ui/redundant_async_block.rs:61:5 | LL | async { f.await } | ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:84:5 + --> tests/ui/redundant_async_block.rs:84:5 | LL | async { async { f().await + 1 }.await } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { f().await + 1 }` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:147:13 + --> tests/ui/redundant_async_block.rs:147:13 | LL | async { async { 42 }.await } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { 42 }` @@ -61,7 +61,7 @@ LL | mac!() = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:167:13 + --> tests/ui/redundant_async_block.rs:167:13 | LL | async { async { $e }.await } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { $e }` diff --git a/tests/ui/redundant_at_rest_pattern.stderr b/tests/ui/redundant_at_rest_pattern.stderr index 3a44636fc78ef..012ba550ca113 100644 --- a/tests/ui/redundant_at_rest_pattern.stderr +++ b/tests/ui/redundant_at_rest_pattern.stderr @@ -1,5 +1,5 @@ error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:9:12 + --> tests/ui/redundant_at_rest_pattern.rs:9:12 | LL | if let [a @ ..] = [()] {} | ^^^^^^^^ help: this is better represented with just the binding: `a` @@ -8,31 +8,31 @@ LL | if let [a @ ..] = [()] {} = help: to override `-D warnings` add `#[allow(clippy::redundant_at_rest_pattern)]` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:10:12 + --> tests/ui/redundant_at_rest_pattern.rs:10:12 | LL | if let [ref a @ ..] = [()] {} | ^^^^^^^^^^^^ help: this is better represented with just the binding: `ref a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:11:12 + --> tests/ui/redundant_at_rest_pattern.rs:11:12 | LL | if let [mut a @ ..] = [()] {} | ^^^^^^^^^^^^ help: this is better represented with just the binding: `mut a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:12:12 + --> tests/ui/redundant_at_rest_pattern.rs:12:12 | LL | if let [ref mut a @ ..] = [()] {} | ^^^^^^^^^^^^^^^^ help: this is better represented with just the binding: `ref mut a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:14:12 + --> tests/ui/redundant_at_rest_pattern.rs:14:12 | LL | if let [a @ ..] = &*v {} | ^^^^^^^^ help: this is better represented with just the binding: `a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:16:12 + --> tests/ui/redundant_at_rest_pattern.rs:16:12 | LL | if let [a @ ..] = s {} | ^^^^^^^^ help: this is better represented with just the binding: `a` diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index 4115fcf21228b..3c37288f55078 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -1,11 +1,11 @@ error: redundant clone - --> $DIR/redundant_clone.rs:15:42 + --> tests/ui/redundant_clone.rs:15:42 | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:15:14 + --> tests/ui/redundant_clone.rs:15:14 | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,169 +13,169 @@ LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone - --> $DIR/redundant_clone.rs:18:15 + --> tests/ui/redundant_clone.rs:18:15 | LL | let _s = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:18:14 + --> tests/ui/redundant_clone.rs:18:14 | LL | let _s = s.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:21:15 + --> tests/ui/redundant_clone.rs:21:15 | LL | let _s = s.to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:21:14 + --> tests/ui/redundant_clone.rs:21:14 | LL | let _s = s.to_string(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:24:15 + --> tests/ui/redundant_clone.rs:24:15 | LL | let _s = s.to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:24:14 + --> tests/ui/redundant_clone.rs:24:14 | LL | let _s = s.to_owned(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:26:42 + --> tests/ui/redundant_clone.rs:26:42 | LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:26:14 + --> tests/ui/redundant_clone.rs:26:14 | LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:28:42 + --> tests/ui/redundant_clone.rs:28:42 | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:28:14 + --> tests/ui/redundant_clone.rs:28:14 | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:30:29 + --> tests/ui/redundant_clone.rs:30:29 | LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:30:14 + --> tests/ui/redundant_clone.rs:30:14 | LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:32:29 + --> tests/ui/redundant_clone.rs:32:29 | LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:32:14 + --> tests/ui/redundant_clone.rs:32:14 | LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:43:19 + --> tests/ui/redundant_clone.rs:43:19 | LL | let _t = tup.0.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:43:14 + --> tests/ui/redundant_clone.rs:43:14 | LL | let _t = tup.0.clone(); | ^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:75:25 + --> tests/ui/redundant_clone.rs:75:25 | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:75:24 + --> tests/ui/redundant_clone.rs:75:24 | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^ error: redundant clone - --> $DIR/redundant_clone.rs:132:15 + --> tests/ui/redundant_clone.rs:132:15 | LL | let _s = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:132:14 + --> tests/ui/redundant_clone.rs:132:14 | LL | let _s = s.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:133:15 + --> tests/ui/redundant_clone.rs:133:15 | LL | let _t = t.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:133:14 + --> tests/ui/redundant_clone.rs:133:14 | LL | let _t = t.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:143:19 + --> tests/ui/redundant_clone.rs:143:19 | LL | let _f = f.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:143:18 + --> tests/ui/redundant_clone.rs:143:18 | LL | let _f = f.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:155:14 + --> tests/ui/redundant_clone.rs:155:14 | LL | let y = x.clone().join("matthias"); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated - --> $DIR/redundant_clone.rs:155:13 + --> tests/ui/redundant_clone.rs:155:13 | LL | let y = x.clone().join("matthias"); | ^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:209:11 + --> tests/ui/redundant_clone.rs:209:11 | LL | foo(&x.clone(), move || { | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:209:10 + --> tests/ui/redundant_clone.rs:209:10 | LL | foo(&x.clone(), move || { | ^ diff --git a/tests/ui/redundant_closure_call_early.stderr b/tests/ui/redundant_closure_call_early.stderr index be7a981dc27b8..038144a5d6134 100644 --- a/tests/ui/redundant_closure_call_early.stderr +++ b/tests/ui/redundant_closure_call_early.stderr @@ -1,5 +1,5 @@ error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_early.rs:9:17 + --> tests/ui/redundant_closure_call_early.rs:9:17 | LL | let mut k = (|m| m + 1)(i); | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let mut k = (|m| m + 1)(i); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_early.rs:14:9 + --> tests/ui/redundant_closure_call_early.rs:14:9 | LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_closure_call_fixable.stderr b/tests/ui/redundant_closure_call_fixable.stderr index 028d383ad3546..000d81f811f10 100644 --- a/tests/ui/redundant_closure_call_fixable.stderr +++ b/tests/ui/redundant_closure_call_fixable.stderr @@ -1,5 +1,5 @@ error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:16:13 + --> tests/ui/redundant_closure_call_fixable.rs:16:13 | LL | let a = (|| 42)(); | ^^^^^^^^^ help: try doing something like: `42` @@ -8,7 +8,7 @@ LL | let a = (|| 42)(); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:17:13 + --> tests/ui/redundant_closure_call_fixable.rs:17:13 | LL | let b = (async || { | _____________^ @@ -28,7 +28,7 @@ LL ~ }; | error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:22:13 + --> tests/ui/redundant_closure_call_fixable.rs:22:13 | LL | let c = (|| { | _____________^ @@ -48,13 +48,13 @@ LL ~ }; | error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:27:13 + --> tests/ui/redundant_closure_call_fixable.rs:27:13 | LL | let d = (async || something().await)(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async { something().await }` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:36:13 + --> tests/ui/redundant_closure_call_fixable.rs:36:13 | LL | (|| m!())() | ^^^^^^^^^^^ help: try doing something like: `m!()` @@ -65,7 +65,7 @@ LL | m2!(); = note: this error originates in the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:31:13 + --> tests/ui/redundant_closure_call_fixable.rs:31:13 | LL | (|| 0)() | ^^^^^^^^ help: try doing something like: `0` @@ -76,67 +76,67 @@ LL | m2!(); = note: this error originates in the macro `m` which comes from the expansion of the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:44:16 + --> tests/ui/redundant_closure_call_fixable.rs:44:16 | LL | assert_eq!((|| || 43)()(), 42); | ^^^^^^^^^^^^^^ help: try doing something like: `43` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:53:10 + --> tests/ui/redundant_closure_call_fixable.rs:53:10 | LL | dbg!((|| 42)()); | ^^^^^^^^^ help: try doing something like: `42` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:56:13 + --> tests/ui/redundant_closure_call_fixable.rs:56:13 | LL | let a = (|| || || 123)(); | ^^^^^^^^^^^^^^^^ help: try doing something like: `(|| || 123)` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:60:13 + --> tests/ui/redundant_closure_call_fixable.rs:60:13 | LL | let a = (|| || || || async || 1)()()()()(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async { 1 }` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:69:13 + --> tests/ui/redundant_closure_call_fixable.rs:69:13 | LL | let a = (|| echo!(|| echo!(|| 1)))()()(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `1` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:71:13 + --> tests/ui/redundant_closure_call_fixable.rs:71:13 | LL | let a = (|| echo!((|| 123)))()(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `123` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:84:11 + --> tests/ui/redundant_closure_call_fixable.rs:84:11 | LL | bar()((|| || 42)()(), 5); | ^^^^^^^^^^^^^^ help: try doing something like: `42` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:85:9 + --> tests/ui/redundant_closure_call_fixable.rs:85:9 | LL | foo((|| || 42)()(), 5); | ^^^^^^^^^^^^^^ help: try doing something like: `42` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:89:5 + --> tests/ui/redundant_closure_call_fixable.rs:89:5 | LL | (|| async {})().await; | ^^^^^^^^^^^^^^^ help: try doing something like: `async {}` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:98:18 + --> tests/ui/redundant_closure_call_fixable.rs:98:18 | LL | spawn_on((|| async move {})()); | ^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async move {}` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:103:28 + --> tests/ui/redundant_closure_call_fixable.rs:103:28 | LL | std::convert::identity((|| 13_i32 + 36_i32)()).leading_zeros(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `13_i32 + 36_i32` diff --git a/tests/ui/redundant_closure_call_late.stderr b/tests/ui/redundant_closure_call_late.stderr index a89bfc7703de4..023e766a5d2b5 100644 --- a/tests/ui/redundant_closure_call_late.stderr +++ b/tests/ui/redundant_closure_call_late.stderr @@ -1,5 +1,5 @@ error: closure called just once immediately after it was declared - --> $DIR/redundant_closure_call_late.rs:16:5 + --> tests/ui/redundant_closure_call_late.rs:16:5 | LL | i = redun_closure(); | ^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | i = redun_closure(); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: closure called just once immediately after it was declared - --> $DIR/redundant_closure_call_late.rs:22:5 + --> tests/ui/redundant_closure_call_late.rs:22:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ error: closure called just once immediately after it was declared - --> $DIR/redundant_closure_call_late.rs:25:5 + --> tests/ui/redundant_closure_call_late.rs:25:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_else.stderr b/tests/ui/redundant_else.stderr index af33e05a608f3..b649a210b5fa6 100644 --- a/tests/ui/redundant_else.stderr +++ b/tests/ui/redundant_else.stderr @@ -1,5 +1,5 @@ error: redundant else block - --> $DIR/redundant_else.rs:10:16 + --> tests/ui/redundant_else.rs:10:16 | LL | } else { | ________________^ @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::redundant_else)]` error: redundant else block - --> $DIR/redundant_else.rs:18:16 + --> tests/ui/redundant_else.rs:18:16 | LL | } else { | ________________^ @@ -25,7 +25,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:28:16 + --> tests/ui/redundant_else.rs:28:16 | LL | } else { | ________________^ @@ -37,7 +37,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:38:12 + --> tests/ui/redundant_else.rs:38:12 | LL | } else { | ____________^ @@ -49,7 +49,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:46:16 + --> tests/ui/redundant_else.rs:46:16 | LL | } else { | ________________^ @@ -61,7 +61,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:57:16 + --> tests/ui/redundant_else.rs:57:16 | LL | } else { | ________________^ @@ -73,7 +73,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:67:16 + --> tests/ui/redundant_else.rs:67:16 | LL | } else { | ________________^ diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 6eb1cc7531928..5323473620762 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,5 +1,5 @@ error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:33:9 + --> tests/ui/redundant_field_names.rs:33:9 | LL | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` @@ -8,43 +8,43 @@ LL | gender: gender, = help: to override `-D warnings` add `#[allow(clippy::redundant_field_names)]` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:34:9 + --> tests/ui/redundant_field_names.rs:34:9 | LL | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:55:25 + --> tests/ui/redundant_field_names.rs:55:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:56:23 + --> tests/ui/redundant_field_names.rs:56:23 | LL | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:57:21 + --> tests/ui/redundant_field_names.rs:57:21 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:57:35 + --> tests/ui/redundant_field_names.rs:57:35 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:59:32 + --> tests/ui/redundant_field_names.rs:59:32 | LL | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:88:25 + --> tests/ui/redundant_field_names.rs:88:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` diff --git a/tests/ui/redundant_guards.stderr b/tests/ui/redundant_guards.stderr index 27bd8bfabb154..93b24a713dcfa 100644 --- a/tests/ui/redundant_guards.stderr +++ b/tests/ui/redundant_guards.stderr @@ -1,5 +1,5 @@ error: redundant guard - --> $DIR/redundant_guards.rs:33:20 + --> tests/ui/redundant_guards.rs:33:20 | LL | C(x, y) if let 1 = y => .., | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + C(x, 1) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:39:20 + --> tests/ui/redundant_guards.rs:39:20 | LL | Some(x) if matches!(x, Some(1) if true) => .., | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | Some(Some(1)) if true => .., | ~~~~~~~ ~~~~~~~ error: redundant guard - --> $DIR/redundant_guards.rs:40:20 + --> tests/ui/redundant_guards.rs:40:20 | LL | Some(x) if matches!(x, Some(1)) => { | ^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL + Some(Some(1)) => { | error: redundant guard - --> $DIR/redundant_guards.rs:44:20 + --> tests/ui/redundant_guards.rs:44:20 | LL | Some(x) if let Some(1) = x => .., | ^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL + Some(Some(1)) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:45:20 + --> tests/ui/redundant_guards.rs:45:20 | LL | Some(x) if x == Some(2) => .., | ^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:46:20 + --> tests/ui/redundant_guards.rs:46:20 | LL | Some(x) if Some(2) == x => .., | ^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:71:20 + --> tests/ui/redundant_guards.rs:71:20 | LL | B { e } if matches!(e, Some(A(2))) => .., | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL + B { e: Some(A(2)) } => .., | error: redundant guard - --> $DIR/redundant_guards.rs:108:20 + --> tests/ui/redundant_guards.rs:108:20 | LL | E::A(y) if y == "not from an or pattern" => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + E::A("not from an or pattern") => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:115:14 + --> tests/ui/redundant_guards.rs:115:14 | LL | x if matches!(x, Some(0)) => .., | ^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + Some(0) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:122:14 + --> tests/ui/redundant_guards.rs:122:14 | LL | i if i == -1 => {}, | ^^^^^^^ @@ -120,7 +120,7 @@ LL + -1 => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:123:14 + --> tests/ui/redundant_guards.rs:123:14 | LL | i if i == 1 => {}, | ^^^^^^ @@ -132,7 +132,7 @@ LL + 1 => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:173:28 + --> tests/ui/redundant_guards.rs:173:28 | LL | Some(ref x) if x == &1 => {}, | ^^^^^^^ @@ -144,7 +144,7 @@ LL + Some(1) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:174:28 + --> tests/ui/redundant_guards.rs:174:28 | LL | Some(ref x) if &1 == x => {}, | ^^^^^^^ @@ -156,7 +156,7 @@ LL + Some(1) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:175:28 + --> tests/ui/redundant_guards.rs:175:28 | LL | Some(ref x) if let &2 = x => {}, | ^^^^^^^^^^ @@ -168,7 +168,7 @@ LL + Some(2) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:176:28 + --> tests/ui/redundant_guards.rs:176:28 | LL | Some(ref x) if matches!(x, &3) => {}, | ^^^^^^^^^^^^^^^ @@ -180,7 +180,7 @@ LL + Some(3) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:196:32 + --> tests/ui/redundant_guards.rs:196:32 | LL | B { ref c, .. } if c == &1 => {}, | ^^^^^^^ @@ -192,7 +192,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:197:32 + --> tests/ui/redundant_guards.rs:197:32 | LL | B { ref c, .. } if &1 == c => {}, | ^^^^^^^ @@ -204,7 +204,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:198:32 + --> tests/ui/redundant_guards.rs:198:32 | LL | B { ref c, .. } if let &1 = c => {}, | ^^^^^^^^^^ @@ -216,7 +216,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:199:32 + --> tests/ui/redundant_guards.rs:199:32 | LL | B { ref c, .. } if matches!(c, &1) => {}, | ^^^^^^^^^^^^^^^ @@ -228,7 +228,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:209:26 + --> tests/ui/redundant_guards.rs:209:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -240,7 +240,7 @@ LL + Some(Some("")) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:220:26 + --> tests/ui/redundant_guards.rs:220:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -252,7 +252,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:225:26 + --> tests/ui/redundant_guards.rs:225:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -264,7 +264,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:236:26 + --> tests/ui/redundant_guards.rs:236:26 | LL | Some(Some(x)) if x.starts_with(&[]) => {}, | ^^^^^^^^^^^^^^^^^^ @@ -276,7 +276,7 @@ LL + Some(Some([..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:241:26 + --> tests/ui/redundant_guards.rs:241:26 | LL | Some(Some(x)) if x.starts_with(&[1]) => {}, | ^^^^^^^^^^^^^^^^^^^ @@ -288,7 +288,7 @@ LL + Some(Some([1, ..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:246:26 + --> tests/ui/redundant_guards.rs:246:26 | LL | Some(Some(x)) if x.starts_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^^^ @@ -300,7 +300,7 @@ LL + Some(Some([1, 2, ..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:251:26 + --> tests/ui/redundant_guards.rs:251:26 | LL | Some(Some(x)) if x.ends_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_locals.stderr b/tests/ui/redundant_locals.stderr index 610d587ddadce..541b988eefe98 100644 --- a/tests/ui/redundant_locals.stderr +++ b/tests/ui/redundant_locals.stderr @@ -1,11 +1,11 @@ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:13:5 + --> tests/ui/redundant_locals.rs:13:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:12:9 + --> tests/ui/redundant_locals.rs:12:9 | LL | let x = 1; | ^ @@ -13,157 +13,157 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::redundant_locals)]` error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:18:5 + --> tests/ui/redundant_locals.rs:18:5 | LL | let mut x = x; | ^^^^^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:17:9 + --> tests/ui/redundant_locals.rs:17:9 | LL | let mut x = 1; | ^^^^^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:48:5 + --> tests/ui/redundant_locals.rs:48:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:47:14 + --> tests/ui/redundant_locals.rs:47:14 | LL | fn parameter(x: i32) { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:53:5 + --> tests/ui/redundant_locals.rs:53:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:52:9 + --> tests/ui/redundant_locals.rs:52:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:54:5 + --> tests/ui/redundant_locals.rs:54:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:53:9 + --> tests/ui/redundant_locals.rs:53:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:55:5 + --> tests/ui/redundant_locals.rs:55:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:54:9 + --> tests/ui/redundant_locals.rs:54:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:56:5 + --> tests/ui/redundant_locals.rs:56:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:55:9 + --> tests/ui/redundant_locals.rs:55:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:62:5 + --> tests/ui/redundant_locals.rs:62:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:60:9 + --> tests/ui/redundant_locals.rs:60:9 | LL | let a = 1; | ^ error: redundant redefinition of a binding `b` - --> $DIR/redundant_locals.rs:63:5 + --> tests/ui/redundant_locals.rs:63:5 | LL | let b = b; | ^^^^^^^^^^ | help: `b` is initially defined here - --> $DIR/redundant_locals.rs:61:9 + --> tests/ui/redundant_locals.rs:61:9 | LL | let b = 2; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:69:9 + --> tests/ui/redundant_locals.rs:69:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:68:13 + --> tests/ui/redundant_locals.rs:68:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:76:9 + --> tests/ui/redundant_locals.rs:76:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:75:13 + --> tests/ui/redundant_locals.rs:75:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:79:9 + --> tests/ui/redundant_locals.rs:79:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:78:6 + --> tests/ui/redundant_locals.rs:78:6 | LL | |x: i32| { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:98:9 + --> tests/ui/redundant_locals.rs:98:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:95:9 + --> tests/ui/redundant_locals.rs:95:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:153:5 + --> tests/ui/redundant_locals.rs:153:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:151:9 + --> tests/ui/redundant_locals.rs:151:9 | LL | let a = WithoutDrop(1); | ^ diff --git a/tests/ui/redundant_pattern_matching_drop_order.stderr b/tests/ui/redundant_pattern_matching_drop_order.stderr index 28f0244b9e87b..1a99cb9fc32b5 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.stderr +++ b/tests/ui/redundant_pattern_matching_drop_order.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:15:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:15:12 | LL | if let Ok(_) = m.lock() {} | -------^^^^^----------- help: try: `if m.lock().is_ok()` @@ -10,7 +10,7 @@ LL | if let Ok(_) = m.lock() {} = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_drop_order.rs:16:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:16:12 | LL | if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} | -------^^^^^^------------------------------------ help: try: `if Err::<(), _>(m.lock().unwrap().0).is_err()` @@ -19,7 +19,7 @@ LL | if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:19:16 + --> tests/ui/redundant_pattern_matching_drop_order.rs:19:16 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} | -------^^^^^----------------------------------------- help: try: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` @@ -28,7 +28,7 @@ LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:21:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:21:12 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { | -------^^^^^----------------------------------------- help: try: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` @@ -37,31 +37,31 @@ LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:24:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:24:12 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} | -------^^^^^----------------------------------------- help: try: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_drop_order.rs:25:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:25:12 | LL | if let Err(_) = Err::, _>(()) {} | -------^^^^^^------------------------------------------ help: try: `if Err::, _>(()).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:27:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:27:12 | LL | if let Ok(_) = Ok::<_, ()>(String::new()) {} | -------^^^^^----------------------------- help: try: `if Ok::<_, ()>(String::new()).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_drop_order.rs:28:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:28:12 | LL | if let Err(_) = Err::<(), _>((String::new(), ())) {} | -------^^^^^^------------------------------------ help: try: `if Err::<(), _>((String::new(), ())).is_err()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:31:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:31:12 | LL | if let Some(_) = Some(m.lock()) {} | -------^^^^^^^----------------- help: try: `if Some(m.lock()).is_some()` @@ -70,7 +70,7 @@ LL | if let Some(_) = Some(m.lock()) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:32:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:32:12 | LL | if let Some(_) = Some(m.lock().unwrap().0) {} | -------^^^^^^^---------------------------- help: try: `if Some(m.lock().unwrap().0).is_some()` @@ -79,7 +79,7 @@ LL | if let Some(_) = Some(m.lock().unwrap().0) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_drop_order.rs:35:16 + --> tests/ui/redundant_pattern_matching_drop_order.rs:35:16 | LL | if let None = None::> {} | -------^^^^------------------------------------ help: try: `if None::>.is_none()` @@ -88,7 +88,7 @@ LL | if let None = None::> {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_drop_order.rs:37:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:37:12 | LL | if let None = None::> { | -------^^^^------------------------------------ help: try: `if None::>.is_none()` @@ -97,25 +97,25 @@ LL | if let None = None::> { = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_drop_order.rs:41:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:41:12 | LL | if let None = None::> {} | -------^^^^------------------------------------ help: try: `if None::>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:43:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:43:12 | LL | if let Some(_) = Some(String::new()) {} | -------^^^^^^^---------------------- help: try: `if Some(String::new()).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:44:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:44:12 | LL | if let Some(_) = Some((String::new(), ())) {} | -------^^^^^^^---------------------------- help: try: `if Some((String::new(), ())).is_some()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:47:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:47:12 | LL | if let Ready(_) = Ready(m.lock()) {} | -------^^^^^^^^------------------ help: try: `if Ready(m.lock()).is_ready()` @@ -124,7 +124,7 @@ LL | if let Ready(_) = Ready(m.lock()) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:48:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:48:12 | LL | if let Ready(_) = Ready(m.lock().unwrap().0) {} | -------^^^^^^^^----------------------------- help: try: `if Ready(m.lock().unwrap().0).is_ready()` @@ -133,7 +133,7 @@ LL | if let Ready(_) = Ready(m.lock().unwrap().0) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_drop_order.rs:51:16 + --> tests/ui/redundant_pattern_matching_drop_order.rs:51:16 | LL | if let Pending = Pending::> {} | -------^^^^^^^--------------------------------------- help: try: `if Pending::>.is_pending()` @@ -142,7 +142,7 @@ LL | if let Pending = Pending::> {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_drop_order.rs:53:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:53:12 | LL | if let Pending = Pending::> { | -------^^^^^^^--------------------------------------- help: try: `if Pending::>.is_pending()` @@ -151,19 +151,19 @@ LL | if let Pending = Pending::> { = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_drop_order.rs:57:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:57:12 | LL | if let Pending = Pending::> {} | -------^^^^^^^--------------------------------------- help: try: `if Pending::>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:59:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:59:12 | LL | if let Ready(_) = Ready(String::new()) {} | -------^^^^^^^^----------------------- help: try: `if Ready(String::new()).is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:60:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:60:12 | LL | if let Ready(_) = Ready((String::new(), ())) {} | -------^^^^^^^^----------------------------- help: try: `if Ready((String::new(), ())).is_ready()` diff --git a/tests/ui/redundant_pattern_matching_if_let_true.stderr b/tests/ui/redundant_pattern_matching_if_let_true.stderr index 211a332d79a66..43d5cd07cec77 100644 --- a/tests/ui/redundant_pattern_matching_if_let_true.stderr +++ b/tests/ui/redundant_pattern_matching_if_let_true.stderr @@ -1,5 +1,5 @@ error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:22:8 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:22:8 | LL | if let true = k > 1 {} | ^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 1` @@ -8,37 +8,37 @@ LL | if let true = k > 1 {} = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:23:8 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:23:8 | LL | if let false = k > 5 {} | ^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `!(k > 5)` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:24:8 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:24:8 | LL | if let (true) = k > 1 {} | ^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 1` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:26:11 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:26:11 | LL | while let true = k > 1 { | ^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 1` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:29:11 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:29:11 | LL | while let true = condition!() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `condition!()` error: using `matches!` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:33:5 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:33:5 | LL | matches!(k > 5, true); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 5` error: using `matches!` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:34:5 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:34:5 | LL | matches!(k > 5, false); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `!(k > 5)` diff --git a/tests/ui/redundant_pattern_matching_ipaddr.stderr b/tests/ui/redundant_pattern_matching_ipaddr.stderr index 54cefa5e82b1c..a4930ad839f91 100644 --- a/tests/ui/redundant_pattern_matching_ipaddr.stderr +++ b/tests/ui/redundant_pattern_matching_ipaddr.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:15:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:15:12 | LL | if let V4(_) = &ipaddr {} | -------^^^^^---------- help: try: `if ipaddr.is_ipv4()` @@ -8,43 +8,43 @@ LL | if let V4(_) = &ipaddr {} = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:17:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:17:12 | LL | if let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:19:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:19:12 | LL | if let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:22:8 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:22:8 | LL | if matches!(V4(Ipv4Addr::LOCALHOST), V4(_)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:25:8 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:25:8 | LL | if matches!(V6(Ipv6Addr::LOCALHOST), V6(_)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:27:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:27:15 | LL | while let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:29:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:29:15 | LL | while let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:39:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:39:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { LL | | V4(_) => true, @@ -53,7 +53,7 @@ LL | | }; | |_____^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:44:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:44:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { LL | | V4(_) => false, @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:49:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:49:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { LL | | V4(_) => false, @@ -71,7 +71,7 @@ LL | | }; | |_____^ help: try: `V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:54:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:54:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { LL | | V4(_) => true, @@ -80,49 +80,49 @@ LL | | }; | |_____^ help: try: `V6(Ipv6Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:59:20 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:59:20 | LL | let _ = if let V4(_) = V4(Ipv4Addr::LOCALHOST) { | -------^^^^^-------------------------- help: try: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:67:20 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:67:20 | LL | let _ = if let V4(_) = gen_ipaddr() { | -------^^^^^--------------- help: try: `if gen_ipaddr().is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:69:19 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:69:19 | LL | } else if let V6(_) = gen_ipaddr() { | -------^^^^^--------------- help: try: `if gen_ipaddr().is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:81:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:81:12 | LL | if let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:83:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:83:12 | LL | if let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:85:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:85:15 | LL | while let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:87:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:87:15 | LL | while let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:89:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:89:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { LL | | V4(_) => true, @@ -131,7 +131,7 @@ LL | | }; | |_____^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:94:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:94:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { LL | | V4(_) => false, diff --git a/tests/ui/redundant_pattern_matching_option.stderr b/tests/ui/redundant_pattern_matching_option.stderr index a75551c56f299..575f199be42c5 100644 --- a/tests/ui/redundant_pattern_matching_option.stderr +++ b/tests/ui/redundant_pattern_matching_option.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:14:5 + --> tests/ui/redundant_pattern_matching_option.rs:14:5 | LL | matches!(maybe_some, None if !boolean) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (!boolean)` @@ -8,55 +8,55 @@ LL | matches!(maybe_some, None if !boolean) = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:18:13 + --> tests/ui/redundant_pattern_matching_option.rs:18:13 | LL | let _ = matches!(maybe_some, None if boolean || boolean2); // guard needs parentheses | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (boolean || boolean2)` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:32:12 + --> tests/ui/redundant_pattern_matching_option.rs:32:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:34:12 + --> tests/ui/redundant_pattern_matching_option.rs:34:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:36:12 + --> tests/ui/redundant_pattern_matching_option.rs:36:12 | LL | if let Some(_) = Some(42) { | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:42:15 + --> tests/ui/redundant_pattern_matching_option.rs:42:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:44:15 + --> tests/ui/redundant_pattern_matching_option.rs:44:15 | LL | while let None = Some(42) {} | ----------^^^^----------- help: try: `while Some(42).is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:46:15 + --> tests/ui/redundant_pattern_matching_option.rs:46:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:49:15 + --> tests/ui/redundant_pattern_matching_option.rs:49:15 | LL | while let Some(_) = v.pop() { | ----------^^^^^^^---------- help: try: `while v.pop().is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:57:5 + --> tests/ui/redundant_pattern_matching_option.rs:57:5 | LL | / match Some(42) { LL | | Some(_) => true, @@ -65,7 +65,7 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:62:5 + --> tests/ui/redundant_pattern_matching_option.rs:62:5 | LL | / match None::<()> { LL | | Some(_) => false, @@ -74,7 +74,7 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:67:13 + --> tests/ui/redundant_pattern_matching_option.rs:67:13 | LL | let _ = match None::<()> { | _____________^ @@ -84,55 +84,55 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:73:20 + --> tests/ui/redundant_pattern_matching_option.rs:73:20 | LL | let _ = if let Some(_) = opt { true } else { false }; | -------^^^^^^^------ help: try: `if opt.is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:79:20 + --> tests/ui/redundant_pattern_matching_option.rs:79:20 | LL | let _ = if let Some(_) = gen_opt() { | -------^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:81:19 + --> tests/ui/redundant_pattern_matching_option.rs:81:19 | LL | } else if let None = gen_opt() { | -------^^^^------------ help: try: `if gen_opt().is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:87:12 + --> tests/ui/redundant_pattern_matching_option.rs:87:12 | LL | if let Some(..) = gen_opt() {} | -------^^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:102:12 + --> tests/ui/redundant_pattern_matching_option.rs:102:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:104:12 + --> tests/ui/redundant_pattern_matching_option.rs:104:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:106:15 + --> tests/ui/redundant_pattern_matching_option.rs:106:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:108:15 + --> tests/ui/redundant_pattern_matching_option.rs:108:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:110:5 + --> tests/ui/redundant_pattern_matching_option.rs:110:5 | LL | / match Some(42) { LL | | Some(_) => true, @@ -141,7 +141,7 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:115:5 + --> tests/ui/redundant_pattern_matching_option.rs:115:5 | LL | / match None::<()> { LL | | Some(_) => false, @@ -150,19 +150,19 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:123:12 + --> tests/ui/redundant_pattern_matching_option.rs:123:12 | LL | if let None = *(&None::<()>) {} | -------^^^^----------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:124:12 + --> tests/ui/redundant_pattern_matching_option.rs:124:12 | LL | if let None = *&None::<()> {} | -------^^^^--------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:130:5 + --> tests/ui/redundant_pattern_matching_option.rs:130:5 | LL | / match x { LL | | Some(_) => true, @@ -171,7 +171,7 @@ LL | | }; | |_____^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:135:5 + --> tests/ui/redundant_pattern_matching_option.rs:135:5 | LL | / match x { LL | | None => true, @@ -180,7 +180,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:140:5 + --> tests/ui/redundant_pattern_matching_option.rs:140:5 | LL | / match x { LL | | Some(_) => false, @@ -189,7 +189,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:145:5 + --> tests/ui/redundant_pattern_matching_option.rs:145:5 | LL | / match x { LL | | None => false, @@ -198,13 +198,13 @@ LL | | }; | |_____^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:160:13 + --> tests/ui/redundant_pattern_matching_option.rs:160:13 | LL | let _ = matches!(x, Some(_)); | ^^^^^^^^^^^^^^^^^^^^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:162:13 + --> tests/ui/redundant_pattern_matching_option.rs:162:13 | LL | let _ = matches!(x, None); | ^^^^^^^^^^^^^^^^^ help: try: `x.is_none()` diff --git a/tests/ui/redundant_pattern_matching_poll.stderr b/tests/ui/redundant_pattern_matching_poll.stderr index de64331b4e8cf..2b0f087fb9939 100644 --- a/tests/ui/redundant_pattern_matching_poll.stderr +++ b/tests/ui/redundant_pattern_matching_poll.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:15:12 + --> tests/ui/redundant_pattern_matching_poll.rs:15:12 | LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try: `if Pending::<()>.is_pending()` @@ -8,49 +8,49 @@ LL | if let Pending = Pending::<()> {} = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:17:12 + --> tests/ui/redundant_pattern_matching_poll.rs:17:12 | LL | if let Ready(_) = Ready(42) {} | -------^^^^^^^^------------ help: try: `if Ready(42).is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:19:12 + --> tests/ui/redundant_pattern_matching_poll.rs:19:12 | LL | if let Ready(_) = Ready(42) { | -------^^^^^^^^------------ help: try: `if Ready(42).is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:26:8 + --> tests/ui/redundant_pattern_matching_poll.rs:26:8 | LL | if matches!(Ready(42), Ready(_)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:29:8 + --> tests/ui/redundant_pattern_matching_poll.rs:29:8 | LL | if matches!(Pending::<()>, Pending) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:31:15 + --> tests/ui/redundant_pattern_matching_poll.rs:31:15 | LL | while let Ready(_) = Ready(42) {} | ----------^^^^^^^^------------ help: try: `while Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:33:15 + --> tests/ui/redundant_pattern_matching_poll.rs:33:15 | LL | while let Pending = Ready(42) {} | ----------^^^^^^^------------ help: try: `while Ready(42).is_pending()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:35:15 + --> tests/ui/redundant_pattern_matching_poll.rs:35:15 | LL | while let Pending = Pending::<()> {} | ----------^^^^^^^---------------- help: try: `while Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:41:5 + --> tests/ui/redundant_pattern_matching_poll.rs:41:5 | LL | / match Ready(42) { LL | | Ready(_) => true, @@ -59,7 +59,7 @@ LL | | }; | |_____^ help: try: `Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:46:5 + --> tests/ui/redundant_pattern_matching_poll.rs:46:5 | LL | / match Pending::<()> { LL | | Ready(_) => false, @@ -68,7 +68,7 @@ LL | | }; | |_____^ help: try: `Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:51:13 + --> tests/ui/redundant_pattern_matching_poll.rs:51:13 | LL | let _ = match Pending::<()> { | _____________^ @@ -78,49 +78,49 @@ LL | | }; | |_____^ help: try: `Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:57:20 + --> tests/ui/redundant_pattern_matching_poll.rs:57:20 | LL | let _ = if let Ready(_) = poll { true } else { false }; | -------^^^^^^^^------- help: try: `if poll.is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:61:20 + --> tests/ui/redundant_pattern_matching_poll.rs:61:20 | LL | let _ = if let Ready(_) = gen_poll() { | -------^^^^^^^^------------- help: try: `if gen_poll().is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:63:19 + --> tests/ui/redundant_pattern_matching_poll.rs:63:19 | LL | } else if let Pending = gen_poll() { | -------^^^^^^^------------- help: try: `if gen_poll().is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:79:12 + --> tests/ui/redundant_pattern_matching_poll.rs:79:12 | LL | if let Ready(_) = Ready(42) {} | -------^^^^^^^^------------ help: try: `if Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:81:12 + --> tests/ui/redundant_pattern_matching_poll.rs:81:12 | LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try: `if Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:83:15 + --> tests/ui/redundant_pattern_matching_poll.rs:83:15 | LL | while let Ready(_) = Ready(42) {} | ----------^^^^^^^^------------ help: try: `while Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:85:15 + --> tests/ui/redundant_pattern_matching_poll.rs:85:15 | LL | while let Pending = Pending::<()> {} | ----------^^^^^^^---------------- help: try: `while Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:87:5 + --> tests/ui/redundant_pattern_matching_poll.rs:87:5 | LL | / match Ready(42) { LL | | Ready(_) => true, @@ -129,7 +129,7 @@ LL | | }; | |_____^ help: try: `Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:92:5 + --> tests/ui/redundant_pattern_matching_poll.rs:92:5 | LL | / match Pending::<()> { LL | | Ready(_) => false, diff --git a/tests/ui/redundant_pattern_matching_result.stderr b/tests/ui/redundant_pattern_matching_result.stderr index 19e7f82298ea6..991e6225ecb6d 100644 --- a/tests/ui/redundant_pattern_matching_result.stderr +++ b/tests/ui/redundant_pattern_matching_result.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:15:12 + --> tests/ui/redundant_pattern_matching_result.rs:15:12 | LL | if let Ok(_) = &result {} | -------^^^^^---------- help: try: `if result.is_ok()` @@ -8,31 +8,31 @@ LL | if let Ok(_) = &result {} = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:17:12 + --> tests/ui/redundant_pattern_matching_result.rs:17:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try: `if Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:19:12 + --> tests/ui/redundant_pattern_matching_result.rs:19:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:21:15 + --> tests/ui/redundant_pattern_matching_result.rs:21:15 | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try: `while Ok::(10).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:23:15 + --> tests/ui/redundant_pattern_matching_result.rs:23:15 | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try: `while Ok::(10).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:33:5 + --> tests/ui/redundant_pattern_matching_result.rs:33:5 | LL | / match Ok::(42) { LL | | Ok(_) => true, @@ -41,7 +41,7 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:38:5 + --> tests/ui/redundant_pattern_matching_result.rs:38:5 | LL | / match Ok::(42) { LL | | Ok(_) => false, @@ -50,7 +50,7 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:43:5 + --> tests/ui/redundant_pattern_matching_result.rs:43:5 | LL | / match Err::(42) { LL | | Ok(_) => false, @@ -59,7 +59,7 @@ LL | | }; | |_____^ help: try: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:48:5 + --> tests/ui/redundant_pattern_matching_result.rs:48:5 | LL | / match Err::(42) { LL | | Ok(_) => true, @@ -68,73 +68,73 @@ LL | | }; | |_____^ help: try: `Err::(42).is_ok()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:53:20 + --> tests/ui/redundant_pattern_matching_result.rs:53:20 | LL | let _ = if let Ok(_) = Ok::(4) { true } else { false }; | -------^^^^^--------------------- help: try: `if Ok::(4).is_ok()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:61:20 + --> tests/ui/redundant_pattern_matching_result.rs:61:20 | LL | let _ = if let Ok(_) = gen_res() { | -------^^^^^------------ help: try: `if gen_res().is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:63:19 + --> tests/ui/redundant_pattern_matching_result.rs:63:19 | LL | } else if let Err(_) = gen_res() { | -------^^^^^^------------ help: try: `if gen_res().is_err()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:86:19 + --> tests/ui/redundant_pattern_matching_result.rs:86:19 | LL | while let Some(_) = r#try!(result_opt()) {} | ----------^^^^^^^----------------------- help: try: `while r#try!(result_opt()).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:87:16 + --> tests/ui/redundant_pattern_matching_result.rs:87:16 | LL | if let Some(_) = r#try!(result_opt()) {} | -------^^^^^^^----------------------- help: try: `if r#try!(result_opt()).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:93:12 + --> tests/ui/redundant_pattern_matching_result.rs:93:12 | LL | if let Some(_) = m!() {} | -------^^^^^^^------- help: try: `if m!().is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:94:15 + --> tests/ui/redundant_pattern_matching_result.rs:94:15 | LL | while let Some(_) = m!() {} | ----------^^^^^^^------- help: try: `while m!().is_some()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:112:12 + --> tests/ui/redundant_pattern_matching_result.rs:112:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try: `if Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:114:12 + --> tests/ui/redundant_pattern_matching_result.rs:114:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:116:15 + --> tests/ui/redundant_pattern_matching_result.rs:116:15 | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try: `while Ok::(10).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:118:15 + --> tests/ui/redundant_pattern_matching_result.rs:118:15 | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try: `while Ok::(10).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:120:5 + --> tests/ui/redundant_pattern_matching_result.rs:120:5 | LL | / match Ok::(42) { LL | | Ok(_) => true, @@ -143,7 +143,7 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:125:5 + --> tests/ui/redundant_pattern_matching_result.rs:125:5 | LL | / match Err::(42) { LL | | Ok(_) => false, @@ -152,7 +152,7 @@ LL | | }; | |_____^ help: try: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:135:5 + --> tests/ui/redundant_pattern_matching_result.rs:135:5 | LL | / match x { LL | | Ok(_) => true, @@ -161,7 +161,7 @@ LL | | }; | |_____^ help: try: `x.is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:140:5 + --> tests/ui/redundant_pattern_matching_result.rs:140:5 | LL | / match x { LL | | Ok(_) => false, @@ -170,7 +170,7 @@ LL | | }; | |_____^ help: try: `x.is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:145:5 + --> tests/ui/redundant_pattern_matching_result.rs:145:5 | LL | / match x { LL | | Err(_) => true, @@ -179,7 +179,7 @@ LL | | }; | |_____^ help: try: `x.is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:150:5 + --> tests/ui/redundant_pattern_matching_result.rs:150:5 | LL | / match x { LL | | Err(_) => false, @@ -188,13 +188,13 @@ LL | | }; | |_____^ help: try: `x.is_ok()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:171:13 + --> tests/ui/redundant_pattern_matching_result.rs:171:13 | LL | let _ = matches!(x, Ok(_)); | ^^^^^^^^^^^^^^^^^^ help: try: `x.is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:173:13 + --> tests/ui/redundant_pattern_matching_result.rs:173:13 | LL | let _ = matches!(x, Err(_)); | ^^^^^^^^^^^^^^^^^^^ help: try: `x.is_err()` diff --git a/tests/ui/redundant_pub_crate.stderr b/tests/ui/redundant_pub_crate.stderr index 5d7744aa86492..8f1005ab9b73c 100644 --- a/tests/ui/redundant_pub_crate.stderr +++ b/tests/ui/redundant_pub_crate.stderr @@ -1,5 +1,5 @@ error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:6:5 + --> tests/ui/redundant_pub_crate.rs:6:5 | LL | pub(crate) fn g() {} // private due to m1 | ----------^^^^^ @@ -10,7 +10,7 @@ LL | pub(crate) fn g() {} // private due to m1 = help: to override `-D warnings` add `#[allow(clippy::redundant_pub_crate)]` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:11:9 + --> tests/ui/redundant_pub_crate.rs:11:9 | LL | pub(crate) fn g() {} // private due to m1_1 and m1 | ----------^^^^^ @@ -18,7 +18,7 @@ LL | pub(crate) fn g() {} // private due to m1_1 and m1 | help: consider using: `pub` error: pub(crate) module inside private module - --> $DIR/redundant_pub_crate.rs:15:5 + --> tests/ui/redundant_pub_crate.rs:15:5 | LL | pub(crate) mod m1_2 { | ----------^^^^^^^^^ @@ -26,7 +26,7 @@ LL | pub(crate) mod m1_2 { | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:18:9 + --> tests/ui/redundant_pub_crate.rs:18:9 | LL | pub(crate) fn g() {} // private due to m1_2 and m1 | ----------^^^^^ @@ -34,7 +34,7 @@ LL | pub(crate) fn g() {} // private due to m1_2 and m1 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:24:9 + --> tests/ui/redundant_pub_crate.rs:24:9 | LL | pub(crate) fn g() {} // private due to m1 | ----------^^^^^ @@ -42,7 +42,7 @@ LL | pub(crate) fn g() {} // private due to m1 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:31:5 + --> tests/ui/redundant_pub_crate.rs:31:5 | LL | pub(crate) fn g() {} // already crate visible due to m2 | ----------^^^^^ @@ -50,7 +50,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:36:9 + --> tests/ui/redundant_pub_crate.rs:36:9 | LL | pub(crate) fn g() {} // private due to m2_1 | ----------^^^^^ @@ -58,7 +58,7 @@ LL | pub(crate) fn g() {} // private due to m2_1 | help: consider using: `pub` error: pub(crate) module inside private module - --> $DIR/redundant_pub_crate.rs:40:5 + --> tests/ui/redundant_pub_crate.rs:40:5 | LL | pub(crate) mod m2_2 { | ----------^^^^^^^^^ @@ -66,7 +66,7 @@ LL | pub(crate) mod m2_2 { | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:43:9 + --> tests/ui/redundant_pub_crate.rs:43:9 | LL | pub(crate) fn g() {} // already crate visible due to m2_2 and m2 | ----------^^^^^ @@ -74,7 +74,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2_2 and m2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:49:9 + --> tests/ui/redundant_pub_crate.rs:49:9 | LL | pub(crate) fn g() {} // already crate visible due to m2 | ----------^^^^^ @@ -82,7 +82,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:61:9 + --> tests/ui/redundant_pub_crate.rs:61:9 | LL | pub(crate) fn g() {} // private due to m3_1 | ----------^^^^^ @@ -90,7 +90,7 @@ LL | pub(crate) fn g() {} // private due to m3_1 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:68:9 + --> tests/ui/redundant_pub_crate.rs:68:9 | LL | pub(crate) fn g() {} // already crate visible due to m3_2 | ----------^^^^^ @@ -98,7 +98,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m3_2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:81:5 + --> tests/ui/redundant_pub_crate.rs:81:5 | LL | pub(crate) fn g() {} // private: not re-exported by `pub use m4::*` | ----------^^^^^ @@ -106,7 +106,7 @@ LL | pub(crate) fn g() {} // private: not re-exported by `pub use m4::*` | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:86:9 + --> tests/ui/redundant_pub_crate.rs:86:9 | LL | pub(crate) fn g() {} // private due to m4_1 | ----------^^^^^ @@ -114,7 +114,7 @@ LL | pub(crate) fn g() {} // private due to m4_1 | help: consider using: `pub` error: pub(crate) module inside private module - --> $DIR/redundant_pub_crate.rs:90:5 + --> tests/ui/redundant_pub_crate.rs:90:5 | LL | pub(crate) mod m4_2 { | ----------^^^^^^^^^ @@ -122,7 +122,7 @@ LL | pub(crate) mod m4_2 { | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:93:9 + --> tests/ui/redundant_pub_crate.rs:93:9 | LL | pub(crate) fn g() {} // private due to m4_2 | ----------^^^^^ diff --git a/tests/ui/redundant_slicing.stderr b/tests/ui/redundant_slicing.stderr index 05287c882f7e1..269a597b32267 100644 --- a/tests/ui/redundant_slicing.stderr +++ b/tests/ui/redundant_slicing.stderr @@ -1,5 +1,5 @@ error: redundant slicing of the whole range - --> $DIR/redundant_slicing.rs:8:13 + --> tests/ui/redundant_slicing.rs:8:13 | LL | let _ = &slice[..]; // Redundant slice | ^^^^^^^^^^ help: use the original value instead: `slice` @@ -8,13 +8,13 @@ LL | let _ = &slice[..]; // Redundant slice = help: to override `-D warnings` add `#[allow(clippy::redundant_slicing)]` error: redundant slicing of the whole range - --> $DIR/redundant_slicing.rs:12:13 + --> tests/ui/redundant_slicing.rs:12:13 | LL | let _ = &(&*v)[..]; // Outer borrow is redundant | ^^^^^^^^^^ help: use the original value instead: `(&*v)` error: redundant slicing of the whole range - --> $DIR/redundant_slicing.rs:29:13 + --> tests/ui/redundant_slicing.rs:29:13 | LL | let _ = &m!(slice)[..]; | ^^^^^^^^^^^^^^ help: use the original value instead: `slice` diff --git a/tests/ui/redundant_static_lifetimes.stderr b/tests/ui/redundant_static_lifetimes.stderr index 26f50345351fe..5c5e2f2a57360 100644 --- a/tests/ui/redundant_static_lifetimes.stderr +++ b/tests/ui/redundant_static_lifetimes.stderr @@ -1,5 +1,5 @@ error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:6:17 + --> tests/ui/redundant_static_lifetimes.rs:6:17 | LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` @@ -8,103 +8,103 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removi = help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:10:21 + --> tests/ui/redundant_static_lifetimes.rs:10:21 | LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:12:32 + --> tests/ui/redundant_static_lifetimes.rs:12:32 | LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:12:47 + --> tests/ui/redundant_static_lifetimes.rs:12:47 | LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:14:17 + --> tests/ui/redundant_static_lifetimes.rs:14:17 | LL | const VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:16:20 + --> tests/ui/redundant_static_lifetimes.rs:16:20 | LL | const VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:18:19 + --> tests/ui/redundant_static_lifetimes.rs:18:19 | LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR: Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:20:19 + --> tests/ui/redundant_static_lifetimes.rs:20:19 | LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:22:19 + --> tests/ui/redundant_static_lifetimes.rs:22:19 | LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:24:25 + --> tests/ui/redundant_static_lifetimes.rs:24:25 | LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR: Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:28:29 + --> tests/ui/redundant_static_lifetimes.rs:28:29 | LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:30:25 + --> tests/ui/redundant_static_lifetimes.rs:30:25 | LL | static STATIC_VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:32:28 + --> tests/ui/redundant_static_lifetimes.rs:32:28 | LL | static STATIC_VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:34:27 + --> tests/ui/redundant_static_lifetimes.rs:34:27 | LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR: Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:36:27 + --> tests/ui/redundant_static_lifetimes.rs:36:27 | LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:38:27 + --> tests/ui/redundant_static_lifetimes.rs:38:27 | LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:40:31 + --> tests/ui/redundant_static_lifetimes.rs:40:31 | LL | static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0]; | -^^^^^^^---------- help: consider removing `'static`: `&mut [u32]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:69:16 + --> tests/ui/redundant_static_lifetimes.rs:69:16 | LL | static V: &'static u8 = &17; | -^^^^^^^--- help: consider removing `'static`: `&u8` diff --git a/tests/ui/redundant_static_lifetimes_multiple.stderr b/tests/ui/redundant_static_lifetimes_multiple.stderr index bf4d211200f3c..330703d9eff12 100644 --- a/tests/ui/redundant_static_lifetimes_multiple.stderr +++ b/tests/ui/redundant_static_lifetimes_multiple.stderr @@ -1,5 +1,5 @@ error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:4:18 + --> tests/ui/redundant_static_lifetimes_multiple.rs:4:18 | LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` @@ -8,55 +8,55 @@ LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; = help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:4:30 + --> tests/ui/redundant_static_lifetimes_multiple.rs:4:30 | LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:9:29 + --> tests/ui/redundant_static_lifetimes_multiple.rs:9:29 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:9:39 + --> tests/ui/redundant_static_lifetimes_multiple.rs:9:39 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:13:40 + --> tests/ui/redundant_static_lifetimes_multiple.rs:13:40 | LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:13:55 + --> tests/ui/redundant_static_lifetimes_multiple.rs:13:55 | LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:17:26 + --> tests/ui/redundant_static_lifetimes_multiple.rs:17:26 | LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:17:38 + --> tests/ui/redundant_static_lifetimes_multiple.rs:17:38 | LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:21:37 + --> tests/ui/redundant_static_lifetimes_multiple.rs:21:37 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:21:47 + --> tests/ui/redundant_static_lifetimes_multiple.rs:21:47 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` diff --git a/tests/ui/redundant_type_annotations.stderr b/tests/ui/redundant_type_annotations.stderr index 48df465ad4971..4768f4d3c57ce 100644 --- a/tests/ui/redundant_type_annotations.stderr +++ b/tests/ui/redundant_type_annotations.stderr @@ -1,5 +1,5 @@ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:81:9 + --> tests/ui/redundant_type_annotations.rs:81:9 | LL | let v: u32 = self.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,97 +8,97 @@ LL | let v: u32 = self.return_an_int(); = help: to override `-D warnings` add `#[allow(clippy::redundant_type_annotations)]` error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:84:9 + --> tests/ui/redundant_type_annotations.rs:84:9 | LL | let v: &u32 = self.return_a_ref(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:86:9 + --> tests/ui/redundant_type_annotations.rs:86:9 | LL | let v: &Slice = self.return_a_ref_to_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:159:5 + --> tests/ui/redundant_type_annotations.rs:159:5 | LL | let _return: String = return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:162:5 + --> tests/ui/redundant_type_annotations.rs:162:5 | LL | let _return: Pie = return_a_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:165:5 + --> tests/ui/redundant_type_annotations.rs:165:5 | LL | let _return: Pizza = return_an_enum(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:168:5 + --> tests/ui/redundant_type_annotations.rs:168:5 | LL | let _return: u32 = return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:171:5 + --> tests/ui/redundant_type_annotations.rs:171:5 | LL | let _return: String = String::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:174:5 + --> tests/ui/redundant_type_annotations.rs:174:5 | LL | let new_pie: Pie = Pie::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:177:5 + --> tests/ui/redundant_type_annotations.rs:177:5 | LL | let _return: u32 = new_pie.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:180:5 + --> tests/ui/redundant_type_annotations.rs:180:5 | LL | let _return: u32 = Pie::associated_return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:183:5 + --> tests/ui/redundant_type_annotations.rs:183:5 | LL | let _return: String = Pie::associated_return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:190:5 + --> tests/ui/redundant_type_annotations.rs:190:5 | LL | let _var: u32 = u32::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:193:5 + --> tests/ui/redundant_type_annotations.rs:193:5 | LL | let _var: u32 = 5_u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:196:5 + --> tests/ui/redundant_type_annotations.rs:196:5 | LL | let _var: &str = "test"; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:199:5 + --> tests/ui/redundant_type_annotations.rs:199:5 | LL | let _var: &[u8; 4] = b"test"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:202:5 + --> tests/ui/redundant_type_annotations.rs:202:5 | LL | let _var: bool = false; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/ref_as_ptr.stderr b/tests/ui/ref_as_ptr.stderr index 371d42df528b9..16cdaec50cff7 100644 --- a/tests/ui/ref_as_ptr.stderr +++ b/tests/ui/ref_as_ptr.stderr @@ -1,5 +1,5 @@ error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:5:13 + --> tests/ui/ref_as_ptr.rs:5:13 | LL | let _ = &1u8 as *const _; | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` @@ -8,259 +8,259 @@ LL | let _ = &1u8 as *const _; = help: to override `-D warnings` add `#[allow(clippy::ref_as_ptr)]` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:6:13 + --> tests/ui/ref_as_ptr.rs:6:13 | LL | let _ = &2u32 as *const u32; | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:7:13 + --> tests/ui/ref_as_ptr.rs:7:13 | LL | let _ = &3.0f64 as *const f64; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:9:13 + --> tests/ui/ref_as_ptr.rs:9:13 | LL | let _ = &4 as *const _ as *const f32; | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:10:13 + --> tests/ui/ref_as_ptr.rs:10:13 | LL | let _ = &5.0f32 as *const f32 as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:12:13 + --> tests/ui/ref_as_ptr.rs:12:13 | LL | let _ = &mut 6u8 as *const _; | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 6u8)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:13:13 + --> tests/ui/ref_as_ptr.rs:13:13 | LL | let _ = &mut 7u32 as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 7u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:14:13 + --> tests/ui/ref_as_ptr.rs:14:13 | LL | let _ = &mut 8.0f64 as *const f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 8.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:16:13 + --> tests/ui/ref_as_ptr.rs:16:13 | LL | let _ = &mut 9 as *const _ as *const f32; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 9)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:17:13 + --> tests/ui/ref_as_ptr.rs:17:13 | LL | let _ = &mut 10.0f32 as *const f32 as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 10.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:19:13 + --> tests/ui/ref_as_ptr.rs:19:13 | LL | let _ = &mut 11u8 as *mut _; | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 11u8)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:20:13 + --> tests/ui/ref_as_ptr.rs:20:13 | LL | let _ = &mut 12u32 as *mut u32; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 12u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:21:13 + --> tests/ui/ref_as_ptr.rs:21:13 | LL | let _ = &mut 13.0f64 as *mut f64; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 13.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:23:13 + --> tests/ui/ref_as_ptr.rs:23:13 | LL | let _ = &mut 14 as *mut _ as *const f32; | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 14)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:24:13 + --> tests/ui/ref_as_ptr.rs:24:13 | LL | let _ = &mut 15.0f32 as *mut f32 as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 15.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:26:13 + --> tests/ui/ref_as_ptr.rs:26:13 | LL | let _ = &1u8 as *const _; | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:27:13 + --> tests/ui/ref_as_ptr.rs:27:13 | LL | let _ = &2u32 as *const u32; | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:28:13 + --> tests/ui/ref_as_ptr.rs:28:13 | LL | let _ = &3.0f64 as *const f64; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:30:13 + --> tests/ui/ref_as_ptr.rs:30:13 | LL | let _ = &4 as *const _ as *const f32; | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:31:13 + --> tests/ui/ref_as_ptr.rs:31:13 | LL | let _ = &5.0f32 as *const f32 as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:34:13 + --> tests/ui/ref_as_ptr.rs:34:13 | LL | let _ = &val as *const _; | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:35:13 + --> tests/ui/ref_as_ptr.rs:35:13 | LL | let _ = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:37:13 + --> tests/ui/ref_as_ptr.rs:37:13 | LL | let _ = &val as *const _ as *const f32; | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:38:13 + --> tests/ui/ref_as_ptr.rs:38:13 | LL | let _ = &val as *const i32 as *const f64; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:41:13 + --> tests/ui/ref_as_ptr.rs:41:13 | LL | let _ = &mut val as *mut u8; | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:42:13 + --> tests/ui/ref_as_ptr.rs:42:13 | LL | let _ = &mut val as *mut _; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:44:13 + --> tests/ui/ref_as_ptr.rs:44:13 | LL | let _ = &mut val as *const u8; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:45:13 + --> tests/ui/ref_as_ptr.rs:45:13 | LL | let _ = &mut val as *const _; | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:47:13 + --> tests/ui/ref_as_ptr.rs:47:13 | LL | let _ = &mut val as *const u8 as *const f64; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:48:32 + --> tests/ui/ref_as_ptr.rs:48:32 | LL | let _: *const Option = &mut val as *const _ as *const _; | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:50:13 + --> tests/ui/ref_as_ptr.rs:50:13 | LL | let _ = &std::array::from_fn(|i| i * i) as *const [usize; 7]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:51:13 + --> tests/ui/ref_as_ptr.rs:51:13 | LL | let _ = &mut std::array::from_fn(|i| i * i) as *const [usize; 8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:52:13 + --> tests/ui/ref_as_ptr.rs:52:13 | LL | let _ = &mut std::array::from_fn(|i| i * i) as *mut [usize; 9]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:70:13 + --> tests/ui/ref_as_ptr.rs:70:13 | LL | let _ = val as *const i32; | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:71:13 + --> tests/ui/ref_as_ptr.rs:71:13 | LL | let _ = mut_val as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(mut_val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:75:13 + --> tests/ui/ref_as_ptr.rs:75:13 | LL | let _ = val as *const _; | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:76:13 + --> tests/ui/ref_as_ptr.rs:76:13 | LL | let _ = val as *const [u8]; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[u8]>(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:80:13 + --> tests/ui/ref_as_ptr.rs:80:13 | LL | let _ = val as *mut _; | ^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:81:13 + --> tests/ui/ref_as_ptr.rs:81:13 | LL | let _ = val as *mut str; | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:88:9 + --> tests/ui/ref_as_ptr.rs:88:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:92:9 + --> tests/ui/ref_as_ptr.rs:92:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:100:9 + --> tests/ui/ref_as_ptr.rs:100:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:104:9 + --> tests/ui/ref_as_ptr.rs:104:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:108:9 + --> tests/ui/ref_as_ptr.rs:108:9 | LL | self.0 as *mut _ as *mut _ | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(self.0)` diff --git a/tests/ui/ref_binding_to_reference.stderr b/tests/ui/ref_binding_to_reference.stderr index 6e8b43a3e52a5..96886f80265d8 100644 --- a/tests/ui/ref_binding_to_reference.stderr +++ b/tests/ui/ref_binding_to_reference.stderr @@ -1,5 +1,5 @@ error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:31:14 + --> tests/ui/ref_binding_to_reference.rs:31:14 | LL | Some(ref x) => x, | ^^^^^ @@ -12,7 +12,7 @@ LL | Some(x) => &x, | ~ ~~ error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:39:14 + --> tests/ui/ref_binding_to_reference.rs:39:14 | LL | Some(ref x) => { | ^^^^^ @@ -27,7 +27,7 @@ LL ~ &x | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:50:14 + --> tests/ui/ref_binding_to_reference.rs:50:14 | LL | Some(ref x) => m2!(x), | ^^^^^ @@ -38,7 +38,7 @@ LL | Some(x) => m2!(&x), | ~ ~~ error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:56:15 + --> tests/ui/ref_binding_to_reference.rs:56:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ @@ -51,7 +51,7 @@ LL ~ let _: &&String = &x; | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:63:12 + --> tests/ui/ref_binding_to_reference.rs:63:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { | ^^^^^ @@ -65,7 +65,7 @@ LL ~ x | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:71:11 + --> tests/ui/ref_binding_to_reference.rs:71:11 | LL | fn f(&ref x: &&String) { | ^^^^^ @@ -78,7 +78,7 @@ LL ~ let _: &&String = &x; | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:80:11 + --> tests/ui/ref_binding_to_reference.rs:80:11 | LL | fn f(&ref x: &&String) { | ^^^^^ diff --git a/tests/ui/ref_option_ref.stderr b/tests/ui/ref_option_ref.stderr index 6a28a68dc2bbb..1cb64e1182a55 100644 --- a/tests/ui/ref_option_ref.stderr +++ b/tests/ui/ref_option_ref.stderr @@ -1,5 +1,5 @@ error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:10:23 + --> tests/ui/ref_option_ref.rs:10:23 | LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` @@ -8,61 +8,61 @@ LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); = help: to override `-D warnings` add `#[allow(clippy::ref_option_ref)]` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:14:18 + --> tests/ui/ref_option_ref.rs:14:18 | LL | const REF_CONST: &Option<&i32> = &Some(CONST_THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:17:25 + --> tests/ui/ref_option_ref.rs:17:25 | LL | type RefOptRefU32<'a> = &'a Option<&'a u32>; | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:19:25 + --> tests/ui/ref_option_ref.rs:19:25 | LL | type RefOptRef<'a, T> = &'a Option<&'a T>; | ^^^^^^^^^^^^^^^^^ help: try: `Option<&'a T>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:22:14 + --> tests/ui/ref_option_ref.rs:22:14 | LL | fn foo(data: &Option<&u32>) {} | ^^^^^^^^^^^^^ help: try: `Option<&u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:25:23 + --> tests/ui/ref_option_ref.rs:25:23 | LL | fn bar(data: &u32) -> &Option<&u32> { | ^^^^^^^^^^^^^ help: try: `Option<&u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:31:11 + --> tests/ui/ref_option_ref.rs:31:11 | LL | data: &'a Option<&'a u32>, | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:35:32 + --> tests/ui/ref_option_ref.rs:35:32 | LL | struct StructTupleRef<'a>(u32, &'a Option<&'a u32>); | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:40:14 + --> tests/ui/ref_option_ref.rs:40:14 | LL | Variant2(&'a Option<&'a u32>), | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:50:14 + --> tests/ui/ref_option_ref.rs:50:14 | LL | type A = &'static Option<&'static Self>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'static Self>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:57:12 + --> tests/ui/ref_option_ref.rs:57:12 | LL | let x: &Option<&u32> = &None; | ^^^^^^^^^^^^^ help: try: `Option<&u32>` diff --git a/tests/ui/ref_patterns.stderr b/tests/ui/ref_patterns.stderr index 74892bac6e4f4..9e2d036e34838 100644 --- a/tests/ui/ref_patterns.stderr +++ b/tests/ui/ref_patterns.stderr @@ -1,5 +1,5 @@ error: usage of ref pattern - --> $DIR/ref_patterns.rs:8:14 + --> tests/ui/ref_patterns.rs:8:14 | LL | Some(ref opt) => {}, | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(ref opt) => {}, = help: to override `-D warnings` add `#[allow(clippy::ref_patterns)]` error: usage of ref pattern - --> $DIR/ref_patterns.rs:15:9 + --> tests/ui/ref_patterns.rs:15:9 | LL | let ref y = x; | ^^^^^ @@ -17,7 +17,7 @@ LL | let ref y = x; = help: consider using `&` for clarity instead error: usage of ref pattern - --> $DIR/ref_patterns.rs:19:21 + --> tests/ui/ref_patterns.rs:19:21 | LL | fn use_in_parameter(ref x: i32) {} | ^^^^^ diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 6d98d691d6f0a..e936208d8d7b6 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -1,5 +1,5 @@ error: trivial regex - --> $DIR/regex.rs:19:45 + --> tests/ui/regex.rs:19:45 | LL | let pipe_in_wrong_position = Regex::new("|"); | ^^^ @@ -9,7 +9,7 @@ LL | let pipe_in_wrong_position = Regex::new("|"); = help: to override `-D warnings` add `#[allow(clippy::trivial_regex)]` error: trivial regex - --> $DIR/regex.rs:21:60 + --> tests/ui/regex.rs:21:60 | LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ @@ -17,7 +17,7 @@ LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); = help: the regex is unlikely to be useful as it is error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:23:42 + --> tests/ui/regex.rs:23:42 | LL | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ @@ -26,7 +26,7 @@ LL | let wrong_char_ranice = Regex::new("[z-a]"); = help: to override `-D warnings` add `#[allow(clippy::invalid_regex)]` error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:26:37 + --> tests/ui/regex.rs:26:37 | LL | let some_unicode = Regex::new("[é-è]"); | ^^^ @@ -35,13 +35,13 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:29:33 + --> tests/ui/regex.rs:29:33 | LL | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: trivial regex - --> $DIR/regex.rs:31:53 + --> tests/ui/regex.rs:31:53 | LL | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ @@ -52,7 +52,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:33:41 + --> tests/ui/regex.rs:33:41 | LL | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:34:56 + --> tests/ui/regex.rs:34:56 | LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:46:37 + --> tests/ui/regex.rs:46:37 | LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); | ^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:47:39 + --> tests/ui/regex.rs:47:39 | LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ error: regex parse error: \b\c ^^ error: unrecognized escape sequence - --> $DIR/regex.rs:54:42 + --> tests/ui/regex.rs:54:42 | LL | let escaped_string_span = Regex::new("\\b\\c"); | ^^^^^^^^ @@ -96,19 +96,19 @@ LL | let escaped_string_span = Regex::new("\\b\\c"); = help: consider using a raw string literal: `r".."` error: regex syntax error: duplicate flag - --> $DIR/regex.rs:56:34 + --> tests/ui/regex.rs:56:34 | LL | let aux_span = Regex::new("(?ixi)"); | ^ ^ error: regex syntax error: pattern can match invalid UTF-8 - --> $DIR/regex.rs:62:53 + --> tests/ui/regex.rs:62:53 | LL | let invalid_utf8_should_lint = Regex::new("(?-u)."); | ^ error: trivial regex - --> $DIR/regex.rs:67:33 + --> tests/ui/regex.rs:67:33 | LL | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | let trivial_eq = Regex::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:70:48 + --> tests/ui/regex.rs:70:48 | LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:73:42 + --> tests/ui/regex.rs:73:42 | LL | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ @@ -132,7 +132,7 @@ LL | let trivial_starts_with = Regex::new("^foobar"); = help: consider using `str::starts_with` error: trivial regex - --> $DIR/regex.rs:76:40 + --> tests/ui/regex.rs:76:40 | LL | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ @@ -140,7 +140,7 @@ LL | let trivial_ends_with = Regex::new("foobar$"); = help: consider using `str::ends_with` error: trivial regex - --> $DIR/regex.rs:79:39 + --> tests/ui/regex.rs:79:39 | LL | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ @@ -148,7 +148,7 @@ LL | let trivial_contains = Regex::new("foobar"); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:82:39 + --> tests/ui/regex.rs:82:39 | LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:85:40 + --> tests/ui/regex.rs:85:40 | LL | let trivial_backslash = Regex::new("a\\.b"); | ^^^^^^^ @@ -164,7 +164,7 @@ LL | let trivial_backslash = Regex::new("a\\.b"); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:89:36 + --> tests/ui/regex.rs:89:36 | LL | let trivial_empty = Regex::new(""); | ^^ @@ -172,7 +172,7 @@ LL | let trivial_empty = Regex::new(""); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:92:36 + --> tests/ui/regex.rs:92:36 | LL | let trivial_empty = Regex::new("^"); | ^^^ @@ -180,7 +180,7 @@ LL | let trivial_empty = Regex::new("^"); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:95:36 + --> tests/ui/regex.rs:95:36 | LL | let trivial_empty = Regex::new("^$"); | ^^^^ @@ -188,7 +188,7 @@ LL | let trivial_empty = Regex::new("^$"); = help: consider using `str::is_empty` error: trivial regex - --> $DIR/regex.rs:98:44 + --> tests/ui/regex.rs:98:44 | LL | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index f63ad82a75753..e6659b109e520 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -1,5 +1,5 @@ error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range` - --> $DIR/rename.rs:55:9 + --> tests/ui/rename.rs:55:9 | LL | #![warn(clippy::almost_complete_letter_range)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range` @@ -8,343 +8,343 @@ LL | #![warn(clippy::almost_complete_letter_range)] = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` - --> $DIR/rename.rs:56:9 + --> tests/ui/rename.rs:56:9 | LL | #![warn(clippy::blacklisted_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names` error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_conditions` - --> $DIR/rename.rs:57:9 + --> tests/ui/rename.rs:57:9 | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_conditions` - --> $DIR/rename.rs:58:9 + --> tests/ui/rename.rs:58:9 | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::blocks_in_if_conditions` has been renamed to `clippy::blocks_in_conditions` - --> $DIR/rename.rs:59:9 + --> tests/ui/rename.rs:59:9 | LL | #![warn(clippy::blocks_in_if_conditions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` - --> $DIR/rename.rs:60:9 + --> tests/ui/rename.rs:60:9 | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` - --> $DIR/rename.rs:61:9 + --> tests/ui/rename.rs:61:9 | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` - --> $DIR/rename.rs:62:9 + --> tests/ui/rename.rs:62:9 | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` - --> $DIR/rename.rs:63:9 + --> tests/ui/rename.rs:63:9 | LL | #![warn(clippy::derive_hash_xor_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` - --> $DIR/rename.rs:64:9 + --> tests/ui/rename.rs:64:9 | LL | #![warn(clippy::disallowed_method)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods` error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` - --> $DIR/rename.rs:65:9 + --> tests/ui/rename.rs:65:9 | LL | #![warn(clippy::disallowed_type)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` - --> $DIR/rename.rs:66:9 + --> tests/ui/rename.rs:66:9 | LL | #![warn(clippy::eval_order_dependence)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression` error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` - --> $DIR/rename.rs:67:9 + --> tests/ui/rename.rs:67:9 | LL | #![warn(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion` error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` - --> $DIR/rename.rs:68:9 + --> tests/ui/rename.rs:68:9 | LL | #![warn(clippy::if_let_some_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok` error: lint `clippy::incorrect_clone_impl_on_copy_type` has been renamed to `clippy::non_canonical_clone_impl` - --> $DIR/rename.rs:69:9 + --> tests/ui/rename.rs:69:9 | LL | #![warn(clippy::incorrect_clone_impl_on_copy_type)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_clone_impl` error: lint `clippy::incorrect_partial_ord_impl_on_ord_type` has been renamed to `clippy::non_canonical_partial_ord_impl` - --> $DIR/rename.rs:70:9 + --> tests/ui/rename.rs:70:9 | LL | #![warn(clippy::incorrect_partial_ord_impl_on_ord_type)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_partial_ord_impl` error: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects` - --> $DIR/rename.rs:71:9 + --> tests/ui/rename.rs:71:9 | LL | #![warn(clippy::integer_arithmetic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects` error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr` - --> $DIR/rename.rs:72:9 + --> tests/ui/rename.rs:72:9 | LL | #![warn(clippy::logic_bug)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr` error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` - --> $DIR/rename.rs:73:9 + --> tests/ui/rename.rs:73:9 | LL | #![warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` - --> $DIR/rename.rs:74:9 + --> tests/ui/rename.rs:74:9 | LL | #![warn(clippy::option_and_then_some)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map` error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` - --> $DIR/rename.rs:75:9 + --> tests/ui/rename.rs:75:9 | LL | #![warn(clippy::option_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:76:9 + --> tests/ui/rename.rs:76:9 | LL | #![warn(clippy::option_map_unwrap_or)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:77:9 + --> tests/ui/rename.rs:77:9 | LL | #![warn(clippy::option_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` - --> $DIR/rename.rs:78:9 + --> tests/ui/rename.rs:78:9 | LL | #![warn(clippy::option_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow` - --> $DIR/rename.rs:79:9 + --> tests/ui/rename.rs:79:9 | LL | #![warn(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow` error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` - --> $DIR/rename.rs:80:9 + --> tests/ui/rename.rs:80:9 | LL | #![warn(clippy::result_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:81:9 + --> tests/ui/rename.rs:81:9 | LL | #![warn(clippy::result_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` - --> $DIR/rename.rs:82:9 + --> tests/ui/rename.rs:82:9 | LL | #![warn(clippy::result_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` - --> $DIR/rename.rs:83:9 + --> tests/ui/rename.rs:83:9 | LL | #![warn(clippy::single_char_push_str)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str` error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` - --> $DIR/rename.rs:84:9 + --> tests/ui/rename.rs:84:9 | LL | #![warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl` - --> $DIR/rename.rs:85:9 + --> tests/ui/rename.rs:85:9 | LL | #![warn(clippy::to_string_in_display)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl` error: lint `clippy::unwrap_or_else_default` has been renamed to `clippy::unwrap_or_default` - --> $DIR/rename.rs:86:9 + --> tests/ui/rename.rs:86:9 | LL | #![warn(clippy::unwrap_or_else_default)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_or_default` error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` - --> $DIR/rename.rs:87:9 + --> tests/ui/rename.rs:87:9 | LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` error: lint `clippy::cast_ref_to_mut` has been renamed to `invalid_reference_casting` - --> $DIR/rename.rs:88:9 + --> tests/ui/rename.rs:88:9 | LL | #![warn(clippy::cast_ref_to_mut)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_reference_casting` error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op` - --> $DIR/rename.rs:89:9 + --> tests/ui/rename.rs:89:9 | LL | #![warn(clippy::clone_double_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op` error: lint `clippy::cmp_nan` has been renamed to `invalid_nan_comparisons` - --> $DIR/rename.rs:90:9 + --> tests/ui/rename.rs:90:9 | LL | #![warn(clippy::cmp_nan)] | ^^^^^^^^^^^^^^^ help: use the new name: `invalid_nan_comparisons` error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` - --> $DIR/rename.rs:91:9 + --> tests/ui/rename.rs:91:9 | LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types` - --> $DIR/rename.rs:92:9 + --> tests/ui/rename.rs:92:9 | LL | #![warn(clippy::drop_copy)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types` error: lint `clippy::drop_ref` has been renamed to `dropping_references` - --> $DIR/rename.rs:93:9 + --> tests/ui/rename.rs:93:9 | LL | #![warn(clippy::drop_ref)] | ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references` error: lint `clippy::fn_null_check` has been renamed to `useless_ptr_null_checks` - --> $DIR/rename.rs:94:9 + --> tests/ui/rename.rs:94:9 | LL | #![warn(clippy::fn_null_check)] | ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `useless_ptr_null_checks` error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:95:9 + --> tests/ui/rename.rs:95:9 | LL | #![warn(clippy::for_loop_over_option)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:96:9 + --> tests/ui/rename.rs:96:9 | LL | #![warn(clippy::for_loop_over_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:97:9 + --> tests/ui/rename.rs:97:9 | LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types` - --> $DIR/rename.rs:98:9 + --> tests/ui/rename.rs:98:9 | LL | #![warn(clippy::forget_copy)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types` error: lint `clippy::forget_ref` has been renamed to `forgetting_references` - --> $DIR/rename.rs:99:9 + --> tests/ui/rename.rs:99:9 | LL | #![warn(clippy::forget_ref)] | ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references` error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` - --> $DIR/rename.rs:100:9 + --> tests/ui/rename.rs:100:9 | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` - --> $DIR/rename.rs:101:9 + --> tests/ui/rename.rs:101:9 | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` error: lint `clippy::invalid_ref` has been renamed to `invalid_value` - --> $DIR/rename.rs:102:9 + --> tests/ui/rename.rs:102:9 | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` error: lint `clippy::invalid_utf8_in_unchecked` has been renamed to `invalid_from_utf8_unchecked` - --> $DIR/rename.rs:103:9 + --> tests/ui/rename.rs:103:9 | LL | #![warn(clippy::invalid_utf8_in_unchecked)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_from_utf8_unchecked` error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` - --> $DIR/rename.rs:104:9 + --> tests/ui/rename.rs:104:9 | LL | #![warn(clippy::let_underscore_drop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop` error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` - --> $DIR/rename.rs:105:9 + --> tests/ui/rename.rs:105:9 | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` - --> $DIR/rename.rs:106:9 + --> tests/ui/rename.rs:106:9 | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` - --> $DIR/rename.rs:107:9 + --> tests/ui/rename.rs:107:9 | LL | #![warn(clippy::positional_named_format_parameters)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally` error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` - --> $DIR/rename.rs:108:9 + --> tests/ui/rename.rs:108:9 | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` error: lint `clippy::undropped_manually_drops` has been renamed to `undropped_manually_drops` - --> $DIR/rename.rs:109:9 + --> tests/ui/rename.rs:109:9 | LL | #![warn(clippy::undropped_manually_drops)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `undropped_manually_drops` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` - --> $DIR/rename.rs:110:9 + --> tests/ui/rename.rs:110:9 | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` error: lint `clippy::unused_label` has been renamed to `unused_labels` - --> $DIR/rename.rs:111:9 + --> tests/ui/rename.rs:111:9 | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` error: lint `clippy::vtable_address_comparisons` has been renamed to `ambiguous_wide_pointer_comparisons` - --> $DIR/rename.rs:112:9 + --> tests/ui/rename.rs:112:9 | LL | #![warn(clippy::vtable_address_comparisons)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `ambiguous_wide_pointer_comparisons` diff --git a/tests/ui/renamed_builtin_attr.stderr b/tests/ui/renamed_builtin_attr.stderr index 662188bbabc5a..f9108d169c718 100644 --- a/tests/ui/renamed_builtin_attr.stderr +++ b/tests/ui/renamed_builtin_attr.stderr @@ -1,5 +1,5 @@ error: usage of deprecated attribute - --> $DIR/renamed_builtin_attr.rs:1:11 + --> tests/ui/renamed_builtin_attr.rs:1:11 | LL | #[clippy::cyclomatic_complexity = "1"] | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `cognitive_complexity` diff --git a/tests/ui/repeat_once.stderr b/tests/ui/repeat_once.stderr index 895729390785a..6996dc5eee7d3 100644 --- a/tests/ui/repeat_once.stderr +++ b/tests/ui/repeat_once.stderr @@ -1,5 +1,5 @@ error: calling `repeat(1)` on slice - --> $DIR/repeat_once.rs:9:13 + --> tests/ui/repeat_once.rs:9:13 | LL | let a = [1; 5].repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `[1; 5].to_vec()` @@ -8,31 +8,31 @@ LL | let a = [1; 5].repeat(1); = help: to override `-D warnings` add `#[allow(clippy::repeat_once)]` error: calling `repeat(1)` on slice - --> $DIR/repeat_once.rs:10:13 + --> tests/ui/repeat_once.rs:10:13 | LL | let b = slice.repeat(1); | ^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `slice.to_vec()` error: calling `repeat(1)` on str - --> $DIR/repeat_once.rs:11:13 + --> tests/ui/repeat_once.rs:11:13 | LL | let c = "hello".repeat(N); | ^^^^^^^^^^^^^^^^^ help: consider using `.to_string()` instead: `"hello".to_string()` error: calling `repeat(1)` on str - --> $DIR/repeat_once.rs:12:13 + --> tests/ui/repeat_once.rs:12:13 | LL | let d = "hi".repeat(1); | ^^^^^^^^^^^^^^ help: consider using `.to_string()` instead: `"hi".to_string()` error: calling `repeat(1)` on str - --> $DIR/repeat_once.rs:13:13 + --> tests/ui/repeat_once.rs:13:13 | LL | let e = s.repeat(1); | ^^^^^^^^^^^ help: consider using `.to_string()` instead: `s.to_string()` error: calling `repeat(1)` on a string literal - --> $DIR/repeat_once.rs:14:13 + --> tests/ui/repeat_once.rs:14:13 | LL | let f = string.repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.clone()` instead: `string.clone()` diff --git a/tests/ui/repeat_vec_with_capacity.stderr b/tests/ui/repeat_vec_with_capacity.stderr index 10b5f121420e1..cec9c6ea84a27 100644 --- a/tests/ui/repeat_vec_with_capacity.stderr +++ b/tests/ui/repeat_vec_with_capacity.stderr @@ -1,5 +1,5 @@ error: repeating `Vec::with_capacity` using `vec![x; n]`, which does not retain capacity - --> $DIR/repeat_vec_with_capacity.rs:5:9 + --> tests/ui/repeat_vec_with_capacity.rs:5:9 | LL | vec![Vec::<()>::with_capacity(42); 123]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | (0..123).map(|_| Vec::<()>::with_capacity(42)).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repeating `Vec::with_capacity` using `vec![x; n]`, which does not retain capacity - --> $DIR/repeat_vec_with_capacity.rs:11:9 + --> tests/ui/repeat_vec_with_capacity.rs:11:9 | LL | vec![Vec::<()>::with_capacity(42); n]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | (0..n).map(|_| Vec::<()>::with_capacity(42)).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repeating `Vec::with_capacity` using `iter::repeat`, which does not retain capacity - --> $DIR/repeat_vec_with_capacity.rs:26:9 + --> tests/ui/repeat_vec_with_capacity.rs:26:9 | LL | std::iter::repeat(Vec::<()>::with_capacity(42)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/repl_uninit.stderr b/tests/ui/repl_uninit.stderr index c82f29adb5ac4..645c4a16a07eb 100644 --- a/tests/ui/repl_uninit.stderr +++ b/tests/ui/repl_uninit.stderr @@ -1,5 +1,5 @@ error: replacing with `mem::uninitialized()` - --> $DIR/repl_uninit.rs:15:23 + --> tests/ui/repl_uninit.rs:15:23 | LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` @@ -8,13 +8,13 @@ LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_uninit)]` error: replacing with `mem::MaybeUninit::uninit().assume_init()` - --> $DIR/repl_uninit.rs:23:23 + --> tests/ui/repl_uninit.rs:23:23 | LL | let taken_v = mem::replace(&mut v, mem::MaybeUninit::uninit().assume_init()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` error: replacing with `mem::zeroed()` - --> $DIR/repl_uninit.rs:30:23 + --> tests/ui/repl_uninit.rs:30:23 | LL | let taken_v = mem::replace(&mut v, mem::zeroed()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | let taken_v = mem::replace(&mut v, mem::zeroed()); = help: consider using a default value or the `take_mut` crate instead error: replacing with `mem::uninitialized()` - --> $DIR/repl_uninit.rs:43:28 + --> tests/ui/repl_uninit.rs:43:28 | LL | let taken_u = unsafe { mem::replace(uref, mem::uninitialized()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(uref)` diff --git a/tests/ui/reserve_after_initialization.stderr b/tests/ui/reserve_after_initialization.stderr index a910338907668..b6dbebb3f14c2 100644 --- a/tests/ui/reserve_after_initialization.stderr +++ b/tests/ui/reserve_after_initialization.stderr @@ -1,5 +1,5 @@ error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:10:5 + --> tests/ui/reserve_after_initialization.rs:10:5 | LL | / let mut v1: Vec = vec![]; LL | | v1.reserve(10); @@ -9,14 +9,14 @@ LL | | v1.reserve(10); = help: to override `-D warnings` add `#[allow(clippy::reserve_after_initialization)]` error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:17:5 + --> tests/ui/reserve_after_initialization.rs:17:5 | LL | / let mut v2: Vec = vec![]; LL | | v2.reserve(capacity); | |_________________________^ help: consider using `Vec::with_capacity(/* Space hint */)`: `let mut v2: Vec = Vec::with_capacity(capacity);` error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:35:5 + --> tests/ui/reserve_after_initialization.rs:35:5 | LL | / v5 = Vec::new(); LL | | v5.reserve(10); diff --git a/tests/ui/rest_pat_in_fully_bound_structs.stderr b/tests/ui/rest_pat_in_fully_bound_structs.stderr index a62f1d0b65f3b..d048933ddb7bc 100644 --- a/tests/ui/rest_pat_in_fully_bound_structs.stderr +++ b/tests/ui/rest_pat_in_fully_bound_structs.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> $DIR/rest_pat_in_fully_bound_structs.rs:23:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:23:9 | LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint = help: to override `-D warnings` add `#[allow(clippy::rest_pat_in_fully_bound_structs)]` error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> $DIR/rest_pat_in_fully_bound_structs.rs:25:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:25:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint = help: consider removing `..` from this binding error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> $DIR/rest_pat_in_fully_bound_structs.rs:32:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:32:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/result_filter_map.stderr b/tests/ui/result_filter_map.stderr index 4687794949d34..12eb7083b5a82 100644 --- a/tests/ui/result_filter_map.stderr +++ b/tests/ui/result_filter_map.stderr @@ -1,5 +1,5 @@ error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:13:10 + --> tests/ui/result_filter_map.rs:13:10 | LL | .filter(Result::is_ok) | __________^ @@ -11,7 +11,7 @@ LL | | .map(Result::unwrap); = help: to override `-D warnings` add `#[allow(clippy::result_filter_map)]` error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:19:10 + --> tests/ui/result_filter_map.rs:19:10 | LL | .filter(|o| o.is_ok()) | __________^ @@ -20,7 +20,7 @@ LL | | .map(|o| o.unwrap()); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:26:10 + --> tests/ui/result_filter_map.rs:26:10 | LL | .filter(Result::is_ok) | __________^ @@ -29,7 +29,7 @@ LL | | .map(Result::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:32:10 + --> tests/ui/result_filter_map.rs:32:10 | LL | .filter(|o| o.is_ok()) | __________^ diff --git a/tests/ui/result_large_err.stderr b/tests/ui/result_large_err.stderr index 6602f396a9c0d..1dff3f9efe81c 100644 --- a/tests/ui/result_large_err.stderr +++ b/tests/ui/result_large_err.stderr @@ -1,5 +1,5 @@ error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:10:23 + --> tests/ui/result_large_err.rs:10:23 | LL | pub fn large_err() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -9,7 +9,7 @@ LL | pub fn large_err() -> Result<(), [u8; 512]> { = help: to override `-D warnings` add `#[allow(clippy::result_large_err)]` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:22:21 + --> tests/ui/result_large_err.rs:22:21 | LL | pub fn ret() -> Result<(), Self> { | ^^^^^^^^^^^^^^^^ the `Err`-variant is at least 240 bytes @@ -17,7 +17,7 @@ LL | pub fn ret() -> Result<(), Self> { = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:28:26 + --> tests/ui/result_large_err.rs:28:26 | LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 240 bytes @@ -25,7 +25,7 @@ LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> { = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:34:45 + --> tests/ui/result_large_err.rs:34:45 | LL | pub fn large_err_via_type_alias(x: T) -> Fdlr { | ^^^^^^^ the `Err`-variant is at least 240 bytes @@ -33,7 +33,7 @@ LL | pub fn large_err_via_type_alias(x: T) -> Fdlr { = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:43:34 + --> tests/ui/result_large_err.rs:43:34 | LL | pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeError)> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes @@ -41,7 +41,7 @@ LL | pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeErro = help: try reducing the size of `(u128, R, FullyDefinedLargeError)`, for example by boxing large elements or replacing it with `Box<(u128, R, FullyDefinedLargeError)>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:55:34 + --> tests/ui/result_large_err.rs:55:34 | LL | _Omg([u8; 512]), | --------------- the largest variant contains at least 512 bytes @@ -52,7 +52,7 @@ LL | pub fn large_enum_error() -> Result<(), Self> { = help: try reducing the size of `LargeErrorVariants<()>`, for example by boxing large elements or replacing it with `Box>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:68:30 + --> tests/ui/result_large_err.rs:68:30 | LL | _Biggest([u8; 1024]), | -------------------- the largest variant contains at least 1024 bytes @@ -65,7 +65,7 @@ LL | fn large_enum_error() -> Result<(), Self> { = help: try reducing the size of `MultipleLargeVariants`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:75:25 + --> tests/ui/result_large_err.rs:75:25 | LL | fn large_error() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -73,7 +73,7 @@ LL | fn large_error() -> Result<(), [u8; 512]> { = help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:95:29 + --> tests/ui/result_large_err.rs:95:29 | LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -81,7 +81,7 @@ LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { = help: try reducing the size of `FullyDefinedUnionError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:105:40 + --> tests/ui/result_large_err.rs:105:40 | LL | pub fn param_large_union() -> Result<(), UnionError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -89,7 +89,7 @@ LL | pub fn param_large_union() -> Result<(), UnionError> { = help: try reducing the size of `UnionError`, for example by boxing large elements or replacing it with `Box>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:115:34 + --> tests/ui/result_large_err.rs:115:34 | LL | pub fn array_error_subst() -> Result<(), ArrayError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes @@ -97,7 +97,7 @@ LL | pub fn array_error_subst() -> Result<(), ArrayError> { = help: try reducing the size of `ArrayError`, for example by boxing large elements or replacing it with `Box>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:120:31 + --> tests/ui/result_large_err.rs:120:31 | LL | pub fn array_error() -> Result<(), ArrayError<(i32, T), U>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes diff --git a/tests/ui/result_map_or_into_option.stderr b/tests/ui/result_map_or_into_option.stderr index 201868f09efa6..4cb510d77a060 100644 --- a/tests/ui/result_map_or_into_option.stderr +++ b/tests/ui/result_map_or_into_option.stderr @@ -1,5 +1,5 @@ error: called `map_or(None, Some)` on a `Result` value - --> $DIR/result_map_or_into_option.rs:5:13 + --> tests/ui/result_map_or_into_option.rs:5:13 | LL | let _ = opt.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `opt.ok()` @@ -8,13 +8,13 @@ LL | let _ = opt.map_or(None, Some); = help: to override `-D warnings` add `#[allow(clippy::result_map_or_into_option)]` error: called `map_or_else(|_| None, Some)` on a `Result` value - --> $DIR/result_map_or_into_option.rs:7:13 + --> tests/ui/result_map_or_into_option.rs:7:13 | LL | let _ = opt.map_or_else(|_| None, Some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `opt.ok()` error: called `map_or_else(|_| None, Some)` on a `Result` value - --> $DIR/result_map_or_into_option.rs:10:13 + --> tests/ui/result_map_or_into_option.rs:10:13 | LL | let _ = opt.map_or_else(|_| { None }, Some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `opt.ok()` diff --git a/tests/ui/result_map_unit_fn_fixable.stderr b/tests/ui/result_map_unit_fn_fixable.stderr index 42ee273c2bd23..4f3bc2e954495 100644 --- a/tests/ui/result_map_unit_fn_fixable.stderr +++ b/tests/ui/result_map_unit_fn_fixable.stderr @@ -1,5 +1,5 @@ error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:34:5 + --> tests/ui/result_map_unit_fn_fixable.rs:34:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -10,7 +10,7 @@ LL | x.field.map(do_nothing); = help: to override `-D warnings` add `#[allow(clippy::result_map_unit_fn)]` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:36:5 + --> tests/ui/result_map_unit_fn_fixable.rs:36:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -18,7 +18,7 @@ LL | x.field.map(do_nothing); | help: try: `if let Ok(x_field) = x.field { do_nothing(x_field) }` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:38:5 + --> tests/ui/result_map_unit_fn_fixable.rs:38:5 | LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | x.field.map(diverge); | help: try: `if let Ok(x_field) = x.field { diverge(x_field) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:44:5 + --> tests/ui/result_map_unit_fn_fixable.rs:44:5 | LL | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -34,7 +34,7 @@ LL | x.field.map(|value| x.do_result_nothing(value + captured)); | help: try: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:46:5 + --> tests/ui/result_map_unit_fn_fixable.rs:46:5 | LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -42,7 +42,7 @@ LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | help: try: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:49:5 + --> tests/ui/result_map_unit_fn_fixable.rs:49:5 | LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -50,7 +50,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:51:5 + --> tests/ui/result_map_unit_fn_fixable.rs:51:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -58,7 +58,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:53:5 + --> tests/ui/result_map_unit_fn_fixable.rs:53:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -66,7 +66,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:55:5 + --> tests/ui/result_map_unit_fn_fixable.rs:55:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -74,7 +74,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:58:5 + --> tests/ui/result_map_unit_fn_fixable.rs:58:5 | LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -82,7 +82,7 @@ LL | x.field.map(|value| diverge(value + captured)); | help: try: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:60:5 + --> tests/ui/result_map_unit_fn_fixable.rs:60:5 | LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -90,7 +90,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | help: try: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:62:5 + --> tests/ui/result_map_unit_fn_fixable.rs:62:5 | LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -98,7 +98,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | help: try: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:64:5 + --> tests/ui/result_map_unit_fn_fixable.rs:64:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -106,7 +106,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | help: try: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:69:5 + --> tests/ui/result_map_unit_fn_fixable.rs:69:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -114,7 +114,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | help: try: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:71:5 + --> tests/ui/result_map_unit_fn_fixable.rs:71:5 | LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -122,7 +122,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | help: try: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:73:5 + --> tests/ui/result_map_unit_fn_fixable.rs:73:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -130,7 +130,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | help: try: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:76:5 + --> tests/ui/result_map_unit_fn_fixable.rs:76:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -138,7 +138,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | help: try: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:78:5 + --> tests/ui/result_map_unit_fn_fixable.rs:78:5 | LL | x.field.map(|value| println!("{:?}", value)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- diff --git a/tests/ui/result_map_unit_fn_unfixable.stderr b/tests/ui/result_map_unit_fn_unfixable.stderr index ccf9bfb947c70..fa2ac7a1b37e8 100644 --- a/tests/ui/result_map_unit_fn_unfixable.stderr +++ b/tests/ui/result_map_unit_fn_unfixable.stderr @@ -1,5 +1,5 @@ error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:23:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:23:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -10,7 +10,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); = help: to override `-D warnings` add `#[allow(clippy::result_map_unit_fn)]` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:27:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:27:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -18,7 +18,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) | help: try: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:32:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:32:5 | LL | // x.field.map(|value| { LL | || @@ -30,7 +30,7 @@ LL | || }); | error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:37:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:37:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -38,7 +38,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | help: try: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:42:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:42:5 | LL | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -46,7 +46,7 @@ LL | "12".parse::().map(diverge); | help: try: `if let Ok(a) = "12".parse::() { diverge(a) }` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:49:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:49:5 | LL | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- diff --git a/tests/ui/result_unit_error.stderr b/tests/ui/result_unit_error.stderr index 72208f5391647..e869a31597752 100644 --- a/tests/ui/result_unit_error.stderr +++ b/tests/ui/result_unit_error.stderr @@ -1,5 +1,5 @@ error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:3:1 + --> tests/ui/result_unit_error.rs:3:1 | LL | pub fn returns_unit_error() -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | pub fn returns_unit_error() -> Result { = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:13:5 + --> tests/ui/result_unit_error.rs:13:5 | LL | fn get_that_error(&self) -> Result; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn get_that_error(&self) -> Result; = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:16:5 + --> tests/ui/result_unit_error.rs:16:5 | LL | fn get_this_one_too(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn get_this_one_too(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:35:5 + --> tests/ui/result_unit_error.rs:35:5 | LL | pub fn unit_error(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | pub fn unit_error(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:45:5 + --> tests/ui/result_unit_error.rs:45:5 | LL | pub fn should_lint() -> ResInv<(), usize> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/return_self_not_must_use.stderr b/tests/ui/return_self_not_must_use.stderr index b3e41470d7b12..01f826b94a803 100644 --- a/tests/ui/return_self_not_must_use.stderr +++ b/tests/ui/return_self_not_must_use.stderr @@ -1,5 +1,5 @@ error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:8:5 + --> tests/ui/return_self_not_must_use.rs:8:5 | LL | fn what(&self) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | fn what(&self) -> Self; = help: to override `-D warnings` add `#[allow(clippy::return_self_not_must_use)]` error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:19:5 + --> tests/ui/return_self_not_must_use.rs:19:5 | LL | / pub fn foo(&self) -> Self { LL | | @@ -20,7 +20,7 @@ LL | | } = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:23:5 + --> tests/ui/return_self_not_must_use.rs:23:5 | LL | / pub fn bar(self) -> Self { LL | | diff --git a/tests/ui/reversed_empty_ranges_fixable.stderr b/tests/ui/reversed_empty_ranges_fixable.stderr index 92fbac8e30c9e..3747eb9deebc4 100644 --- a/tests/ui/reversed_empty_ranges_fixable.stderr +++ b/tests/ui/reversed_empty_ranges_fixable.stderr @@ -1,5 +1,5 @@ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_fixable.rs:9:5 + --> tests/ui/reversed_empty_ranges_fixable.rs:9:5 | LL | (42..=21).for_each(|x| println!("{}", x)); | ^^^^^^^^^ @@ -12,7 +12,7 @@ LL | (21..=42).rev().for_each(|x| println!("{}", x)); | ~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_fixable.rs:10:13 + --> tests/ui/reversed_empty_ranges_fixable.rs:10:13 | LL | let _ = (ANSWER..21).filter(|x| x % 2 == 0).take(10).collect::>(); | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = (21..ANSWER).rev().filter(|x| x % 2 == 0).take(10).collect:: $DIR/reversed_empty_ranges_fixable.rs:12:14 + --> tests/ui/reversed_empty_ranges_fixable.rs:12:14 | LL | for _ in -21..=-42 {} | ^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for _ in (-42..=-21).rev() {} | ~~~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_fixable.rs:13:14 + --> tests/ui/reversed_empty_ranges_fixable.rs:13:14 | LL | for _ in 42u32..21u32 {} | ^^^^^^^^^^^^ diff --git a/tests/ui/reversed_empty_ranges_loops_fixable.stderr b/tests/ui/reversed_empty_ranges_loops_fixable.stderr index 843d6a36d9be5..d5df34c42f4f0 100644 --- a/tests/ui/reversed_empty_ranges_loops_fixable.stderr +++ b/tests/ui/reversed_empty_ranges_loops_fixable.stderr @@ -1,5 +1,5 @@ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:7:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:7:14 | LL | for i in 10..0 { | ^^^^^ @@ -12,7 +12,7 @@ LL | for i in (0..10).rev() { | ~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:11:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:11:14 | LL | for i in 10..=0 { | ^^^^^^ @@ -23,7 +23,7 @@ LL | for i in (0..=10).rev() { | ~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:15:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:15:14 | LL | for i in MAX_LEN..0 { | ^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for i in (0..MAX_LEN).rev() { | ~~~~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:34:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:34:14 | LL | for i in (10..0).map(|x| x * 2) { | ^^^^^^^ @@ -45,7 +45,7 @@ LL | for i in (0..10).rev().map(|x| x * 2) { | ~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:39:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:39:14 | LL | for i in 10..5 + 4 { | ^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for i in (5 + 4..10).rev() { | ~~~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:43:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:43:14 | LL | for i in (5 + 2)..(3 - 1) { | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/reversed_empty_ranges_loops_unfixable.stderr b/tests/ui/reversed_empty_ranges_loops_unfixable.stderr index 73165e091cb16..b9e6fa04a34c6 100644 --- a/tests/ui/reversed_empty_ranges_loops_unfixable.stderr +++ b/tests/ui/reversed_empty_ranges_loops_unfixable.stderr @@ -1,5 +1,5 @@ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_unfixable.rs:5:14 + --> tests/ui/reversed_empty_ranges_loops_unfixable.rs:5:14 | LL | for i in 5..5 { | ^^^^ @@ -8,7 +8,7 @@ LL | for i in 5..5 { = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_unfixable.rs:11:14 + --> tests/ui/reversed_empty_ranges_loops_unfixable.rs:11:14 | LL | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/reversed_empty_ranges_unfixable.stderr b/tests/ui/reversed_empty_ranges_unfixable.stderr index e3dc96dfb9c4e..bc2b9576c41d3 100644 --- a/tests/ui/reversed_empty_ranges_unfixable.stderr +++ b/tests/ui/reversed_empty_ranges_unfixable.stderr @@ -1,5 +1,5 @@ error: this range is reversed and using it to index a slice will panic at run-time - --> $DIR/reversed_empty_ranges_unfixable.rs:8:18 + --> tests/ui/reversed_empty_ranges_unfixable.rs:8:18 | LL | let _ = &arr[3usize..=1usize]; | ^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | let _ = &arr[3usize..=1usize]; = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` error: this range is reversed and using it to index a slice will panic at run-time - --> $DIR/reversed_empty_ranges_unfixable.rs:11:18 + --> tests/ui/reversed_empty_ranges_unfixable.rs:11:18 | LL | let _ = &arr[SOME_NUM..1]; | ^^^^^^^^^^^ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_unfixable.rs:14:14 + --> tests/ui/reversed_empty_ranges_unfixable.rs:14:14 | LL | for _ in ANSWER..ANSWER {} | ^^^^^^^^^^^^^^ diff --git a/tests/ui/same_functions_in_if_condition.stderr b/tests/ui/same_functions_in_if_condition.stderr index 199e6769ff767..6cd4f96c13e32 100644 --- a/tests/ui/same_functions_in_if_condition.stderr +++ b/tests/ui/same_functions_in_if_condition.stderr @@ -1,76 +1,76 @@ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:39:15 + --> tests/ui/same_functions_in_if_condition.rs:39:15 | LL | } else if function() { | ^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:38:8 + --> tests/ui/same_functions_in_if_condition.rs:38:8 | LL | if function() { | ^^^^^^^^^^ note: the lint level is defined here - --> $DIR/same_functions_in_if_condition.rs:2:9 + --> tests/ui/same_functions_in_if_condition.rs:2:9 | LL | #![deny(clippy::same_functions_in_if_condition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:44:15 + --> tests/ui/same_functions_in_if_condition.rs:44:15 | LL | } else if fn_arg(a) { | ^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:43:8 + --> tests/ui/same_functions_in_if_condition.rs:43:8 | LL | if fn_arg(a) { | ^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:49:15 + --> tests/ui/same_functions_in_if_condition.rs:49:15 | LL | } else if obj.method() { | ^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:48:8 + --> tests/ui/same_functions_in_if_condition.rs:48:8 | LL | if obj.method() { | ^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:54:15 + --> tests/ui/same_functions_in_if_condition.rs:54:15 | LL | } else if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:53:8 + --> tests/ui/same_functions_in_if_condition.rs:53:8 | LL | if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:60:15 + --> tests/ui/same_functions_in_if_condition.rs:60:15 | LL | } else if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:59:8 + --> tests/ui/same_functions_in_if_condition.rs:59:8 | LL | if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:65:15 + --> tests/ui/same_functions_in_if_condition.rs:65:15 | LL | } else if v.len() == 42 { | ^^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:64:8 + --> tests/ui/same_functions_in_if_condition.rs:64:8 | LL | if v.len() == 42 { | ^^^^^^^^^^^^^ diff --git a/tests/ui/same_item_push.stderr b/tests/ui/same_item_push.stderr index f569aab64900a..eb296ed4ce4ae 100644 --- a/tests/ui/same_item_push.stderr +++ b/tests/ui/same_item_push.stderr @@ -1,5 +1,5 @@ error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:23:9 + --> tests/ui/same_item_push.rs:23:9 | LL | vec.push(item); | ^^^ @@ -9,7 +9,7 @@ LL | vec.push(item); = help: to override `-D warnings` add `#[allow(clippy::same_item_push)]` error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:30:9 + --> tests/ui/same_item_push.rs:30:9 | LL | vec.push(item); | ^^^ @@ -17,7 +17,7 @@ LL | vec.push(item); = help: consider using vec![item;SIZE] or vec.resize(NEW_SIZE, item) error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:36:9 + --> tests/ui/same_item_push.rs:36:9 | LL | vec.push(13); | ^^^ @@ -25,7 +25,7 @@ LL | vec.push(13); = help: consider using vec![13;SIZE] or vec.resize(NEW_SIZE, 13) error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:42:9 + --> tests/ui/same_item_push.rs:42:9 | LL | vec.push(VALUE); | ^^^ @@ -33,7 +33,7 @@ LL | vec.push(VALUE); = help: consider using vec![VALUE;SIZE] or vec.resize(NEW_SIZE, VALUE) error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:49:9 + --> tests/ui/same_item_push.rs:49:9 | LL | vec.push(item); | ^^^ diff --git a/tests/ui/same_name_method.stderr b/tests/ui/same_name_method.stderr index 82f5ef6a9e827..6c87a64b50514 100644 --- a/tests/ui/same_name_method.stderr +++ b/tests/ui/same_name_method.stderr @@ -1,11 +1,11 @@ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:21:13 + --> tests/ui/same_name_method.rs:21:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:26:13 + --> tests/ui/same_name_method.rs:26:13 | LL | fn foo() {} | ^^^^^^^^^^^ @@ -13,62 +13,62 @@ LL | fn foo() {} = help: to override `-D warnings` add `#[allow(clippy::same_name_method)]` error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:36:13 + --> tests/ui/same_name_method.rs:36:13 | LL | fn clone() {} | ^^^^^^^^^^^^^ | note: existing `clone` defined here - --> $DIR/same_name_method.rs:32:18 + --> tests/ui/same_name_method.rs:32:18 | LL | #[derive(Clone)] | ^^^^^ = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:47:13 + --> tests/ui/same_name_method.rs:47:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:52:13 + --> tests/ui/same_name_method.rs:52:13 | LL | fn foo() {} | ^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:62:13 + --> tests/ui/same_name_method.rs:62:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:66:9 + --> tests/ui/same_name_method.rs:66:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:75:13 + --> tests/ui/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:80:9 + --> tests/ui/same_name_method.rs:80:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:75:13 + --> tests/ui/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:82:9 + --> tests/ui/same_name_method.rs:82:9 | LL | impl T2 for S {} | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/search_is_some.stderr b/tests/ui/search_is_some.stderr index 9dec8c9caf274..b5f84d23284ac 100644 --- a/tests/ui/search_is_some.stderr +++ b/tests/ui/search_is_some.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:15:13 + --> tests/ui/search_is_some.rs:15:13 | LL | let _ = v.iter().find(|&x| { | _____________^ @@ -13,7 +13,7 @@ LL | | ).is_some(); = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: called `is_some()` after searching an `Iterator` with `position` - --> $DIR/search_is_some.rs:21:13 + --> tests/ui/search_is_some.rs:21:13 | LL | let _ = v.iter().position(|&x| { | _____________^ @@ -25,7 +25,7 @@ LL | | ).is_some(); = help: this is more succinctly expressed by calling `any()` error: called `is_some()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some.rs:27:13 + --> tests/ui/search_is_some.rs:27:13 | LL | let _ = v.iter().rposition(|&x| { | _____________^ @@ -37,13 +37,13 @@ LL | | ).is_some(); = help: this is more succinctly expressed by calling `any()` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:42:20 + --> tests/ui/search_is_some.rs:42:20 | LL | let _ = (0..1).find(some_closure).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(some_closure)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:52:13 + --> tests/ui/search_is_some.rs:52:13 | LL | let _ = v.iter().find(|&x| { | _____________^ @@ -55,7 +55,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `position` - --> $DIR/search_is_some.rs:58:13 + --> tests/ui/search_is_some.rs:58:13 | LL | let _ = v.iter().position(|&x| { | _____________^ @@ -67,7 +67,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some.rs:64:13 + --> tests/ui/search_is_some.rs:64:13 | LL | let _ = v.iter().rposition(|&x| { | _____________^ @@ -79,7 +79,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:79:13 + --> tests/ui/search_is_some.rs:79:13 | LL | let _ = (0..1).find(some_closure).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(some_closure)` diff --git a/tests/ui/search_is_some_fixable_none.stderr b/tests/ui/search_is_some_fixable_none.stderr index 107f59a97d2f3..4ad1e2508c480 100644 --- a/tests/ui/search_is_some_fixable_none.stderr +++ b/tests/ui/search_is_some_fixable_none.stderr @@ -1,5 +1,5 @@ error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:9:13 + --> tests/ui/search_is_some_fixable_none.rs:9:13 | LL | let _ = v.iter().find(|&x| *x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x < 0)` @@ -8,49 +8,49 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_none(); = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:10:13 + --> tests/ui/search_is_some_fixable_none.rs:10:13 | LL | let _ = (0..1).find(|x| **y == *x).is_none(); // one dereference less | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(|x| **y == x)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:11:13 + --> tests/ui/search_is_some_fixable_none.rs:11:13 | LL | let _ = (0..1).find(|x| *x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(|x| x == 0)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:12:13 + --> tests/ui/search_is_some_fixable_none.rs:12:13 | LL | let _ = v.iter().find(|x| **x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x == 0)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:13:13 + --> tests/ui/search_is_some_fixable_none.rs:13:13 | LL | let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(4..5).any(|x| x == 1 || x == 3 || x == 5)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:14:13 + --> tests/ui/search_is_some_fixable_none.rs:14:13 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(1..3).any(|x| [1, 2, 3].contains(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:15:13 + --> tests/ui/search_is_some_fixable_none.rs:15:13 | LL | let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(1..3).any(|x| x == 0 || [1, 2, 3].contains(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:16:13 + --> tests/ui/search_is_some_fixable_none.rs:16:13 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:17:13 + --> tests/ui/search_is_some_fixable_none.rs:17:13 | LL | let _ = (1..3) | _____________^ @@ -59,91 +59,91 @@ LL | | .is_none(); | |__________________^ help: consider using: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)` error: called `is_none()` after searching an `Iterator` with `position` - --> $DIR/search_is_some_fixable_none.rs:22:13 + --> tests/ui/search_is_some_fixable_none.rs:22:13 | LL | let _ = v.iter().position(|&x| x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|&x| x < 0)` error: called `is_none()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some_fixable_none.rs:25:13 + --> tests/ui/search_is_some_fixable_none.rs:25:13 | LL | let _ = v.iter().rposition(|&x| x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|&x| x < 0)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:31:13 + --> tests/ui/search_is_some_fixable_none.rs:31:13 | LL | let _ = "hello world".find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!"hello world".contains("world")` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:32:13 + --> tests/ui/search_is_some_fixable_none.rs:32:13 | LL | let _ = "hello world".find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!"hello world".contains(&s2)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:33:13 + --> tests/ui/search_is_some_fixable_none.rs:33:13 | LL | let _ = "hello world".find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!"hello world".contains(&s2[2..])` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:35:13 + --> tests/ui/search_is_some_fixable_none.rs:35:13 | LL | let _ = s1.find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1.contains("world")` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:36:13 + --> tests/ui/search_is_some_fixable_none.rs:36:13 | LL | let _ = s1.find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1.contains(&s2)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:37:13 + --> tests/ui/search_is_some_fixable_none.rs:37:13 | LL | let _ = s1.find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1.contains(&s2[2..])` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:39:13 + --> tests/ui/search_is_some_fixable_none.rs:39:13 | LL | let _ = s1[2..].find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1[2..].contains("world")` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:40:13 + --> tests/ui/search_is_some_fixable_none.rs:40:13 | LL | let _ = s1[2..].find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1[2..].contains(&s2)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:41:13 + --> tests/ui/search_is_some_fixable_none.rs:41:13 | LL | let _ = s1[2..].find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1[2..].contains(&s2[2..])` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:57:25 + --> tests/ui/search_is_some_fixable_none.rs:57:25 | LL | .filter(|c| filter_hand.iter().find(|cc| c == cc).is_none()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!filter_hand.iter().any(|cc| c == &cc)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:73:30 + --> tests/ui/search_is_some_fixable_none.rs:73:30 | LL | .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_none()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!filter_hand.iter().any(|cc| c == cc)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:84:17 + --> tests/ui/search_is_some_fixable_none.rs:84:17 | LL | let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|v| v.foo == 1 && v.bar == 2)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:87:17 + --> tests/ui/search_is_some_fixable_none.rs:87:17 | LL | let _ = vfoo | _________________^ @@ -159,55 +159,55 @@ LL ~ .iter().any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2); | error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:95:17 + --> tests/ui/search_is_some_fixable_none.rs:95:17 | LL | let _ = vfoo.iter().find(|a| a[0] == 42).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|a| a[0] == 42)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:101:17 + --> tests/ui/search_is_some_fixable_none.rs:101:17 | LL | let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|sub| sub[1..4].len() == 3)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:119:17 + --> tests/ui/search_is_some_fixable_none.rs:119:17 | LL | let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![ppx].iter().any(|ppp_x: &&u32| please(ppp_x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:120:17 + --> tests/ui/search_is_some_fixable_none.rs:120:17 | LL | let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![String::from("Hey hey")].iter().any(|s| s.len() == 2)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:123:17 + --> tests/ui/search_is_some_fixable_none.rs:123:17 | LL | let _ = v.iter().find(|x| deref_enough(**x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| deref_enough(*x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:124:17 + --> tests/ui/search_is_some_fixable_none.rs:124:17 | LL | let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x: &u32| deref_enough(*x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:127:17 + --> tests/ui/search_is_some_fixable_none.rs:127:17 | LL | let _ = v.iter().find(|x| arg_no_deref(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| arg_no_deref(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:129:17 + --> tests/ui/search_is_some_fixable_none.rs:129:17 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x: &u32| arg_no_deref(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:149:17 + --> tests/ui/search_is_some_fixable_none.rs:149:17 | LL | let _ = vfoo | _________________^ @@ -223,61 +223,61 @@ LL ~ .iter().any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] | error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:165:17 + --> tests/ui/search_is_some_fixable_none.rs:165:17 | LL | let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|v| v.inner[0].bar == 2)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:170:17 + --> tests/ui/search_is_some_fixable_none.rs:170:17 | LL | let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|x| (**x)[0] == 9)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:183:17 + --> tests/ui/search_is_some_fixable_none.rs:183:17 | LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|v| v.by_ref(&v.bar))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:187:17 + --> tests/ui/search_is_some_fixable_none.rs:187:17 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:188:17 + --> tests/ui/search_is_some_fixable_none.rs:188:17 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:207:17 + --> tests/ui/search_is_some_fixable_none.rs:207:17 | LL | let _ = v.iter().find(|s| s[0].is_empty()).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|s| s[0].is_empty())` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:208:17 + --> tests/ui/search_is_some_fixable_none.rs:208:17 | LL | let _ = v.iter().find(|s| test_string_1(&s[0])).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|s| test_string_1(&s[0]))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:217:17 + --> tests/ui/search_is_some_fixable_none.rs:217:17 | LL | let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| fp.field.is_power_of_two())` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:218:17 + --> tests/ui/search_is_some_fixable_none.rs:218:17 | LL | let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| test_u32_1(fp.field))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:219:17 + --> tests/ui/search_is_some_fixable_none.rs:219:17 | LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| test_u32_2(*fp.field))` diff --git a/tests/ui/search_is_some_fixable_some.stderr b/tests/ui/search_is_some_fixable_some.stderr index e706ce646923d..af1de7f82f80c 100644 --- a/tests/ui/search_is_some_fixable_some.stderr +++ b/tests/ui/search_is_some_fixable_some.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:9:22 + --> tests/ui/search_is_some_fixable_some.rs:9:22 | LL | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| *x < 0)` @@ -8,49 +8,49 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some(); = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:10:20 + --> tests/ui/search_is_some_fixable_some.rs:10:20 | LL | let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| **y == x)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:11:20 + --> tests/ui/search_is_some_fixable_some.rs:11:20 | LL | let _ = (0..1).find(|x| *x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| x == 0)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:12:22 + --> tests/ui/search_is_some_fixable_some.rs:12:22 | LL | let _ = v.iter().find(|x| **x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| *x == 0)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:13:20 + --> tests/ui/search_is_some_fixable_some.rs:13:20 | LL | let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| x == 1 || x == 3 || x == 5)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:14:20 + --> tests/ui/search_is_some_fixable_some.rs:14:20 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| [1, 2, 3].contains(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:15:20 + --> tests/ui/search_is_some_fixable_some.rs:15:20 | LL | let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| x == 0 || [1, 2, 3].contains(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:16:20 + --> tests/ui/search_is_some_fixable_some.rs:16:20 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| [1, 2, 3].contains(&x) || x == 0)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:18:10 + --> tests/ui/search_is_some_fixable_some.rs:18:10 | LL | .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1) | __________^ @@ -58,91 +58,91 @@ LL | | .is_some(); | |__________________^ help: consider using: `any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)` error: called `is_some()` after searching an `Iterator` with `position` - --> $DIR/search_is_some_fixable_some.rs:22:22 + --> tests/ui/search_is_some_fixable_some.rs:22:22 | LL | let _ = v.iter().position(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|&x| x < 0)` error: called `is_some()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some_fixable_some.rs:25:22 + --> tests/ui/search_is_some_fixable_some.rs:25:22 | LL | let _ = v.iter().rposition(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|&x| x < 0)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:30:27 + --> tests/ui/search_is_some_fixable_some.rs:30:27 | LL | let _ = "hello world".find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains("world")` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:31:27 + --> tests/ui/search_is_some_fixable_some.rs:31:27 | LL | let _ = "hello world".find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:32:27 + --> tests/ui/search_is_some_fixable_some.rs:32:27 | LL | let _ = "hello world".find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2[2..])` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:34:16 + --> tests/ui/search_is_some_fixable_some.rs:34:16 | LL | let _ = s1.find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains("world")` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:35:16 + --> tests/ui/search_is_some_fixable_some.rs:35:16 | LL | let _ = s1.find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:36:16 + --> tests/ui/search_is_some_fixable_some.rs:36:16 | LL | let _ = s1.find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2[2..])` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:38:21 + --> tests/ui/search_is_some_fixable_some.rs:38:21 | LL | let _ = s1[2..].find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains("world")` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:39:21 + --> tests/ui/search_is_some_fixable_some.rs:39:21 | LL | let _ = s1[2..].find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:40:21 + --> tests/ui/search_is_some_fixable_some.rs:40:21 | LL | let _ = s1[2..].find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2[2..])` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:56:44 + --> tests/ui/search_is_some_fixable_some.rs:56:44 | LL | .filter(|c| filter_hand.iter().find(|cc| c == cc).is_some()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|cc| c == &cc)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:72:49 + --> tests/ui/search_is_some_fixable_some.rs:72:49 | LL | .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_some()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|cc| c == cc)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:83:29 + --> tests/ui/search_is_some_fixable_some.rs:83:29 | LL | let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| v.foo == 1 && v.bar == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:88:14 + --> tests/ui/search_is_some_fixable_some.rs:88:14 | LL | .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2) | ______________^ @@ -150,55 +150,55 @@ LL | | .is_some(); | |______________________^ help: consider using: `any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:94:29 + --> tests/ui/search_is_some_fixable_some.rs:94:29 | LL | let _ = vfoo.iter().find(|a| a[0] == 42).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|a| a[0] == 42)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:100:29 + --> tests/ui/search_is_some_fixable_some.rs:100:29 | LL | let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|sub| sub[1..4].len() == 3)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:118:30 + --> tests/ui/search_is_some_fixable_some.rs:118:30 | LL | let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|ppp_x: &&u32| please(ppp_x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:119:50 + --> tests/ui/search_is_some_fixable_some.rs:119:50 | LL | let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|s| s.len() == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:122:26 + --> tests/ui/search_is_some_fixable_some.rs:122:26 | LL | let _ = v.iter().find(|x| deref_enough(**x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| deref_enough(*x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:123:26 + --> tests/ui/search_is_some_fixable_some.rs:123:26 | LL | let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| deref_enough(*x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:126:26 + --> tests/ui/search_is_some_fixable_some.rs:126:26 | LL | let _ = v.iter().find(|x| arg_no_deref(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| arg_no_deref(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:128:26 + --> tests/ui/search_is_some_fixable_some.rs:128:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:150:14 + --> tests/ui/search_is_some_fixable_some.rs:150:14 | LL | .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2) | ______________^ @@ -206,85 +206,85 @@ LL | | .is_some(); | |______________________^ help: consider using: `any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:164:29 + --> tests/ui/search_is_some_fixable_some.rs:164:29 | LL | let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| v.inner[0].bar == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:169:29 + --> tests/ui/search_is_some_fixable_some.rs:169:29 | LL | let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| (**x)[0] == 9)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:182:29 + --> tests/ui/search_is_some_fixable_some.rs:182:29 | LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| v.by_ref(&v.bar))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:186:55 + --> tests/ui/search_is_some_fixable_some.rs:186:55 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|(&x, y)| x == *y)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:187:55 + --> tests/ui/search_is_some_fixable_some.rs:187:55 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|(&x, y)| x == *y)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:206:26 + --> tests/ui/search_is_some_fixable_some.rs:206:26 | LL | let _ = v.iter().find(|s| s[0].is_empty()).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|s| s[0].is_empty())` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:207:26 + --> tests/ui/search_is_some_fixable_some.rs:207:26 | LL | let _ = v.iter().find(|s| test_string_1(&s[0])).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|s| test_string_1(&s[0]))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:216:26 + --> tests/ui/search_is_some_fixable_some.rs:216:26 | LL | let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|fp| fp.field.is_power_of_two())` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:217:26 + --> tests/ui/search_is_some_fixable_some.rs:217:26 | LL | let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|fp| test_u32_1(fp.field))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:218:26 + --> tests/ui/search_is_some_fixable_some.rs:218:26 | LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|fp| test_u32_2(*fp.field))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:233:18 + --> tests/ui/search_is_some_fixable_some.rs:233:18 | LL | v.iter().find(|x: &&u32| func(x)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| func(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:242:26 + --> tests/ui/search_is_some_fixable_some.rs:242:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_impl(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref_impl(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:245:26 + --> tests/ui/search_is_some_fixable_some.rs:245:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_dyn(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref_dyn(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:248:26 + --> tests/ui/search_is_some_fixable_some.rs:248:26 | LL | let _ = v.iter().find(|x: &&u32| (*arg_no_deref_dyn)(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| (*arg_no_deref_dyn)(&x))` diff --git a/tests/ui/seek_from_current.stderr b/tests/ui/seek_from_current.stderr index 4858cb82e7eb0..23ba9968bfffa 100644 --- a/tests/ui/seek_from_current.stderr +++ b/tests/ui/seek_from_current.stderr @@ -1,5 +1,5 @@ error: using `SeekFrom::Current` to start from current position - --> $DIR/seek_from_current.rs:19:5 + --> tests/ui/seek_from_current.rs:19:5 | LL | f.seek(SeekFrom::Current(0))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `f.stream_position()` diff --git a/tests/ui/seek_to_start_instead_of_rewind.stderr b/tests/ui/seek_to_start_instead_of_rewind.stderr index b6b0d2effa815..2c3c45820e107 100644 --- a/tests/ui/seek_to_start_instead_of_rewind.stderr +++ b/tests/ui/seek_to_start_instead_of_rewind.stderr @@ -1,5 +1,5 @@ error: used `seek` to go to the start of the stream - --> $DIR/seek_to_start_instead_of_rewind.rs:52:7 + --> tests/ui/seek_to_start_instead_of_rewind.rs:52:7 | LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` @@ -8,13 +8,13 @@ LL | t.seek(SeekFrom::Start(0)); = help: to override `-D warnings` add `#[allow(clippy::seek_to_start_instead_of_rewind)]` error: used `seek` to go to the start of the stream - --> $DIR/seek_to_start_instead_of_rewind.rs:57:7 + --> tests/ui/seek_to_start_instead_of_rewind.rs:57:7 | LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` error: used `seek` to go to the start of the stream - --> $DIR/seek_to_start_instead_of_rewind.rs:136:7 + --> tests/ui/seek_to_start_instead_of_rewind.rs:136:7 | LL | f.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` diff --git a/tests/ui/self_assignment.stderr b/tests/ui/self_assignment.stderr index 4612f8f824481..e92414163d4c4 100644 --- a/tests/ui/self_assignment.stderr +++ b/tests/ui/self_assignment.stderr @@ -1,5 +1,5 @@ error: self-assignment of `a` to `a` - --> $DIR/self_assignment.rs:13:5 + --> tests/ui/self_assignment.rs:13:5 | LL | a = a; | ^^^^^ @@ -8,61 +8,61 @@ LL | a = a; = help: to override `-D warnings` add `#[allow(clippy::self_assignment)]` error: self-assignment of `*b` to `*b` - --> $DIR/self_assignment.rs:16:5 + --> tests/ui/self_assignment.rs:16:5 | LL | *b = *b; | ^^^^^^^ error: self-assignment of `s` to `s` - --> $DIR/self_assignment.rs:18:5 + --> tests/ui/self_assignment.rs:18:5 | LL | s = s; | ^^^^^ error: self-assignment of `s.a` to `s.a` - --> $DIR/self_assignment.rs:20:5 + --> tests/ui/self_assignment.rs:20:5 | LL | s.a = s.a; | ^^^^^^^^^ error: self-assignment of `s.b[5 + 4]` to `s.b[9]` - --> $DIR/self_assignment.rs:22:5 + --> tests/ui/self_assignment.rs:22:5 | LL | s.b[9] = s.b[5 + 4]; | ^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.c[0][1]` to `s.c[0][1]` - --> $DIR/self_assignment.rs:24:5 + --> tests/ui/self_assignment.rs:24:5 | LL | s.c[0][1] = s.c[0][1]; | ^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.b[a]` to `s.b[a]` - --> $DIR/self_assignment.rs:26:5 + --> tests/ui/self_assignment.rs:26:5 | LL | s.b[a] = s.b[a]; | ^^^^^^^^^^^^^^^ error: self-assignment of `*s.e` to `*s.e` - --> $DIR/self_assignment.rs:28:5 + --> tests/ui/self_assignment.rs:28:5 | LL | *s.e = *s.e; | ^^^^^^^^^^^ error: self-assignment of `s.b[10 + a]` to `s.b[a + 10]` - --> $DIR/self_assignment.rs:30:5 + --> tests/ui/self_assignment.rs:30:5 | LL | s.b[a + 10] = s.b[10 + a]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `t.1` to `t.1` - --> $DIR/self_assignment.rs:34:5 + --> tests/ui/self_assignment.rs:34:5 | LL | t.1 = t.1; | ^^^^^^^^^ error: self-assignment of `(t.0)` to `t.0` - --> $DIR/self_assignment.rs:36:5 + --> tests/ui/self_assignment.rs:36:5 | LL | t.0 = (t.0); | ^^^^^^^^^^^ diff --git a/tests/ui/self_named_constructors.stderr b/tests/ui/self_named_constructors.stderr index 8083ff9651579..1d8b44f6bc2bd 100644 --- a/tests/ui/self_named_constructors.stderr +++ b/tests/ui/self_named_constructors.stderr @@ -1,5 +1,5 @@ error: constructor `should_spawn` has the same name as the type - --> $DIR/self_named_constructors.rs:7:5 + --> tests/ui/self_named_constructors.rs:7:5 | LL | / pub fn should_spawn() -> ShouldSpawn { LL | | diff --git a/tests/ui/semicolon_if_nothing_returned.stderr b/tests/ui/semicolon_if_nothing_returned.stderr index 09c4d12f216c5..286cf512ed0b2 100644 --- a/tests/ui/semicolon_if_nothing_returned.stderr +++ b/tests/ui/semicolon_if_nothing_returned.stderr @@ -1,5 +1,5 @@ error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:13:5 + --> tests/ui/semicolon_if_nothing_returned.rs:13:5 | LL | println!("Hello") | ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");` @@ -8,25 +8,25 @@ LL | println!("Hello") = help: to override `-D warnings` add `#[allow(clippy::semicolon_if_nothing_returned)]` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:17:5 + --> tests/ui/semicolon_if_nothing_returned.rs:17:5 | LL | get_unit() | ^^^^^^^^^^ help: add a `;` here: `get_unit();` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:22:5 + --> tests/ui/semicolon_if_nothing_returned.rs:22:5 | LL | y = x + 1 | ^^^^^^^^^ help: add a `;` here: `y = x + 1;` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:28:9 + --> tests/ui/semicolon_if_nothing_returned.rs:28:9 | LL | hello() | ^^^^^^^ help: add a `;` here: `hello();` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:39:9 + --> tests/ui/semicolon_if_nothing_returned.rs:39:9 | LL | ptr::drop_in_place(s.as_mut_ptr()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` diff --git a/tests/ui/semicolon_inside_block.stderr b/tests/ui/semicolon_inside_block.stderr index 1bfc1f24c436a..d32fb681d3b99 100644 --- a/tests/ui/semicolon_inside_block.stderr +++ b/tests/ui/semicolon_inside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:38:5 + --> tests/ui/semicolon_inside_block.rs:38:5 | LL | { unit_fn_block() }; | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block(); } | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:39:5 + --> tests/ui/semicolon_inside_block.rs:39:5 | LL | unsafe { unit_fn_block() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block(); } | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:47:5 + --> tests/ui/semicolon_inside_block.rs:47:5 | LL | / { LL | | unit_fn_block(); @@ -40,7 +40,7 @@ LL ~ } | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:60:5 + --> tests/ui/semicolon_inside_block.rs:60:5 | LL | { m!(()) }; | ^^^^^^^^^^^ diff --git a/tests/ui/semicolon_outside_block.stderr b/tests/ui/semicolon_outside_block.stderr index 427271fca64da..68b44c8f980f2 100644 --- a/tests/ui/semicolon_outside_block.stderr +++ b/tests/ui/semicolon_outside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:41:5 + --> tests/ui/semicolon_outside_block.rs:41:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:42:5 + --> tests/ui/semicolon_outside_block.rs:42:5 | LL | unsafe { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:51:5 + --> tests/ui/semicolon_outside_block.rs:51:5 | LL | / { LL | | unit_fn_block(); @@ -40,7 +40,7 @@ LL ~ }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:61:5 + --> tests/ui/semicolon_outside_block.rs:61:5 | LL | { m!(()); } | ^^^^^^^^^^^ diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index 079ba42bd2bc5..f71d41d58aae1 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -1,5 +1,5 @@ error: you should not implement `visit_string` without also implementing `visit_str` - --> $DIR/serde.rs:39:5 + --> tests/ui/serde.rs:39:5 | LL | / fn visit_string(self, _v: String) -> Result LL | | diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index 26ace287b1f4a..fdd149a2216f2 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,11 +1,11 @@ error: `x` is shadowed by itself in `x` - --> $DIR/shadow.rs:24:9 + --> tests/ui/shadow.rs:24:9 | LL | let x = x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:23:9 + --> tests/ui/shadow.rs:23:9 | LL | let x = 1; | ^ @@ -13,49 +13,49 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::shadow_same)]` error: `mut x` is shadowed by itself in `&x` - --> $DIR/shadow.rs:25:13 + --> tests/ui/shadow.rs:25:13 | LL | let mut x = &x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:24:9 + --> tests/ui/shadow.rs:24:9 | LL | let x = x; | ^ error: `x` is shadowed by itself in `&mut x` - --> $DIR/shadow.rs:26:9 + --> tests/ui/shadow.rs:26:9 | LL | let x = &mut x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:25:9 + --> tests/ui/shadow.rs:25:9 | LL | let mut x = &x; | ^^^^^ error: `x` is shadowed by itself in `*x` - --> $DIR/shadow.rs:27:9 + --> tests/ui/shadow.rs:27:9 | LL | let x = *x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:26:9 + --> tests/ui/shadow.rs:26:9 | LL | let x = &mut x; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:32:9 + --> tests/ui/shadow.rs:32:9 | LL | let x = x.0; | ^ | note: previous binding is here - --> $DIR/shadow.rs:31:9 + --> tests/ui/shadow.rs:31:9 | LL | let x = ([[0]], ()); | ^ @@ -63,97 +63,97 @@ LL | let x = ([[0]], ()); = help: to override `-D warnings` add `#[allow(clippy::shadow_reuse)]` error: `x` is shadowed - --> $DIR/shadow.rs:33:9 + --> tests/ui/shadow.rs:33:9 | LL | let x = x[0]; | ^ | note: previous binding is here - --> $DIR/shadow.rs:32:9 + --> tests/ui/shadow.rs:32:9 | LL | let x = x.0; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:34:10 + --> tests/ui/shadow.rs:34:10 | LL | let [x] = x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:33:9 + --> tests/ui/shadow.rs:33:9 | LL | let x = x[0]; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:35:9 + --> tests/ui/shadow.rs:35:9 | LL | let x = Some(x); | ^ | note: previous binding is here - --> $DIR/shadow.rs:34:10 + --> tests/ui/shadow.rs:34:10 | LL | let [x] = x; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:36:9 + --> tests/ui/shadow.rs:36:9 | LL | let x = foo(x); | ^ | note: previous binding is here - --> $DIR/shadow.rs:35:9 + --> tests/ui/shadow.rs:35:9 | LL | let x = Some(x); | ^ error: `x` is shadowed - --> $DIR/shadow.rs:37:9 + --> tests/ui/shadow.rs:37:9 | LL | let x = || x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:36:9 + --> tests/ui/shadow.rs:36:9 | LL | let x = foo(x); | ^ error: `x` is shadowed - --> $DIR/shadow.rs:38:9 + --> tests/ui/shadow.rs:38:9 | LL | let x = Some(1).map(|_| x)?; | ^ | note: previous binding is here - --> $DIR/shadow.rs:37:9 + --> tests/ui/shadow.rs:37:9 | LL | let x = || x; | ^ error: `y` is shadowed - --> $DIR/shadow.rs:40:9 + --> tests/ui/shadow.rs:40:9 | LL | let y = match y { | ^ | note: previous binding is here - --> $DIR/shadow.rs:39:9 + --> tests/ui/shadow.rs:39:9 | LL | let y = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:55:9 + --> tests/ui/shadow.rs:55:9 | LL | let x = 2; | ^ | note: previous binding is here - --> $DIR/shadow.rs:54:9 + --> tests/ui/shadow.rs:54:9 | LL | let x = 1; | ^ @@ -161,121 +161,121 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::shadow_unrelated)]` error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:60:13 + --> tests/ui/shadow.rs:60:13 | LL | let x = 1; | ^ | note: previous binding is here - --> $DIR/shadow.rs:59:10 + --> tests/ui/shadow.rs:59:10 | LL | fn f(x: u32) { | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:65:14 + --> tests/ui/shadow.rs:65:14 | LL | Some(x) => { | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:66:17 + --> tests/ui/shadow.rs:66:17 | LL | let x = 1; | ^ | note: previous binding is here - --> $DIR/shadow.rs:65:14 + --> tests/ui/shadow.rs:65:14 | LL | Some(x) => { | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:70:17 + --> tests/ui/shadow.rs:70:17 | LL | if let Some(x) = Some(1) {} | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:71:20 + --> tests/ui/shadow.rs:71:20 | LL | while let Some(x) = Some(1) {} | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:72:15 + --> tests/ui/shadow.rs:72:15 | LL | let _ = |[x]: [u32; 1]| { | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:73:13 + --> tests/ui/shadow.rs:73:13 | LL | let x = 1; | ^ | note: previous binding is here - --> $DIR/shadow.rs:72:15 + --> tests/ui/shadow.rs:72:15 | LL | let _ = |[x]: [u32; 1]| { | ^ error: `y` is shadowed - --> $DIR/shadow.rs:76:17 + --> tests/ui/shadow.rs:76:17 | LL | if let Some(y) = y {} | ^ | note: previous binding is here - --> $DIR/shadow.rs:75:9 + --> tests/ui/shadow.rs:75:9 | LL | let y = Some(1); | ^ error: `_b` shadows a previous, unrelated binding - --> $DIR/shadow.rs:112:9 + --> tests/ui/shadow.rs:112:9 | LL | let _b = _a; | ^^ | note: previous binding is here - --> $DIR/shadow.rs:111:28 + --> tests/ui/shadow.rs:111:28 | LL | pub async fn foo2(_a: i32, _b: i64) { | ^^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:118:21 + --> tests/ui/shadow.rs:118:21 | LL | if let Some(x) = Some(1) { x } else { 1 } | ^ | note: previous binding is here - --> $DIR/shadow.rs:117:13 + --> tests/ui/shadow.rs:117:13 | LL | let x = 1; | ^ diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index dbdf44dfcbd98..e7a8f2ca60ca1 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -1,5 +1,5 @@ error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:5:5 + --> tests/ui/short_circuit_statement.rs:5:5 | LL | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` @@ -8,13 +8,13 @@ LL | f() && g(); = help: to override `-D warnings` add `#[allow(clippy::short_circuit_statement)]` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:6:5 + --> tests/ui/short_circuit_statement.rs:6:5 | LL | f() || g(); | ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:7:5 + --> tests/ui/short_circuit_statement.rs:7:5 | LL | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if 1 != 2 { g(); }` diff --git a/tests/ui/should_impl_trait/method_list_1.stderr b/tests/ui/should_impl_trait/method_list_1.stderr index 46df34c3432ad..dfa55ace40f0a 100644 --- a/tests/ui/should_impl_trait/method_list_1.stderr +++ b/tests/ui/should_impl_trait/method_list_1.stderr @@ -1,5 +1,5 @@ error: method `add` can be confused for the standard trait method `std::ops::Add::add` - --> $DIR/should_impl_trait/method_list_1.rs:25:5 + --> tests/ui/should_impl_trait/method_list_1.rs:25:5 | LL | / pub fn add(self, other: T) -> T { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]` error: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` - --> $DIR/should_impl_trait/method_list_1.rs:30:5 + --> tests/ui/should_impl_trait/method_list_1.rs:30:5 | LL | / pub fn as_mut(&mut self) -> &mut T { LL | | @@ -23,7 +23,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsMut` or choosing a less ambiguous method name error: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` - --> $DIR/should_impl_trait/method_list_1.rs:35:5 + --> tests/ui/should_impl_trait/method_list_1.rs:35:5 | LL | / pub fn as_ref(&self) -> &T { LL | | @@ -34,7 +34,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsRef` or choosing a less ambiguous method name error: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` - --> $DIR/should_impl_trait/method_list_1.rs:40:5 + --> tests/ui/should_impl_trait/method_list_1.rs:40:5 | LL | / pub fn bitand(self, rhs: T) -> T { LL | | @@ -45,7 +45,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitAnd` or choosing a less ambiguous method name error: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` - --> $DIR/should_impl_trait/method_list_1.rs:45:5 + --> tests/ui/should_impl_trait/method_list_1.rs:45:5 | LL | / pub fn bitor(self, rhs: Self) -> Self { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitOr` or choosing a less ambiguous method name error: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` - --> $DIR/should_impl_trait/method_list_1.rs:50:5 + --> tests/ui/should_impl_trait/method_list_1.rs:50:5 | LL | / pub fn bitxor(self, rhs: Self) -> Self { LL | | @@ -67,7 +67,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitXor` or choosing a less ambiguous method name error: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` - --> $DIR/should_impl_trait/method_list_1.rs:55:5 + --> tests/ui/should_impl_trait/method_list_1.rs:55:5 | LL | / pub fn borrow(&self) -> &str { LL | | @@ -78,7 +78,7 @@ LL | | } = help: consider implementing the trait `std::borrow::Borrow` or choosing a less ambiguous method name error: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` - --> $DIR/should_impl_trait/method_list_1.rs:60:5 + --> tests/ui/should_impl_trait/method_list_1.rs:60:5 | LL | / pub fn borrow_mut(&mut self) -> &mut str { LL | | @@ -89,7 +89,7 @@ LL | | } = help: consider implementing the trait `std::borrow::BorrowMut` or choosing a less ambiguous method name error: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` - --> $DIR/should_impl_trait/method_list_1.rs:65:5 + --> tests/ui/should_impl_trait/method_list_1.rs:65:5 | LL | / pub fn clone(&self) -> Self { LL | | @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::clone::Clone` or choosing a less ambiguous method name error: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` - --> $DIR/should_impl_trait/method_list_1.rs:70:5 + --> tests/ui/should_impl_trait/method_list_1.rs:70:5 | LL | / pub fn cmp(&self, other: &Self) -> Self { LL | | @@ -111,7 +111,7 @@ LL | | } = help: consider implementing the trait `std::cmp::Ord` or choosing a less ambiguous method name error: method `default` can be confused for the standard trait method `std::default::Default::default` - --> $DIR/should_impl_trait/method_list_1.rs:75:5 + --> tests/ui/should_impl_trait/method_list_1.rs:75:5 | LL | / pub fn default() -> Self { LL | | @@ -122,7 +122,7 @@ LL | | } = help: consider implementing the trait `std::default::Default` or choosing a less ambiguous method name error: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` - --> $DIR/should_impl_trait/method_list_1.rs:80:5 + --> tests/ui/should_impl_trait/method_list_1.rs:80:5 | LL | / pub fn deref(&self) -> &Self { LL | | @@ -133,7 +133,7 @@ LL | | } = help: consider implementing the trait `std::ops::Deref` or choosing a less ambiguous method name error: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` - --> $DIR/should_impl_trait/method_list_1.rs:85:5 + --> tests/ui/should_impl_trait/method_list_1.rs:85:5 | LL | / pub fn deref_mut(&mut self) -> &mut Self { LL | | @@ -144,7 +144,7 @@ LL | | } = help: consider implementing the trait `std::ops::DerefMut` or choosing a less ambiguous method name error: method `div` can be confused for the standard trait method `std::ops::Div::div` - --> $DIR/should_impl_trait/method_list_1.rs:90:5 + --> tests/ui/should_impl_trait/method_list_1.rs:90:5 | LL | / pub fn div(self, rhs: Self) -> Self { LL | | @@ -155,7 +155,7 @@ LL | | } = help: consider implementing the trait `std::ops::Div` or choosing a less ambiguous method name error: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` - --> $DIR/should_impl_trait/method_list_1.rs:95:5 + --> tests/ui/should_impl_trait/method_list_1.rs:95:5 | LL | / pub fn drop(&mut self) { LL | | diff --git a/tests/ui/should_impl_trait/method_list_2.stderr b/tests/ui/should_impl_trait/method_list_2.stderr index 1f452c7003443..b1e5bbbfa4c5f 100644 --- a/tests/ui/should_impl_trait/method_list_2.stderr +++ b/tests/ui/should_impl_trait/method_list_2.stderr @@ -1,5 +1,5 @@ error: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` - --> $DIR/should_impl_trait/method_list_2.rs:26:5 + --> tests/ui/should_impl_trait/method_list_2.rs:26:5 | LL | / pub fn eq(&self, other: &Self) -> bool { LL | | @@ -12,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]` error: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` - --> $DIR/should_impl_trait/method_list_2.rs:31:5 + --> tests/ui/should_impl_trait/method_list_2.rs:31:5 | LL | / pub fn from_iter(iter: T) -> Self { LL | | @@ -23,7 +23,7 @@ LL | | } = help: consider implementing the trait `std::iter::FromIterator` or choosing a less ambiguous method name error: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` - --> $DIR/should_impl_trait/method_list_2.rs:36:5 + --> tests/ui/should_impl_trait/method_list_2.rs:36:5 | LL | / pub fn from_str(s: &str) -> Result { LL | | @@ -34,7 +34,7 @@ LL | | } = help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name error: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` - --> $DIR/should_impl_trait/method_list_2.rs:41:5 + --> tests/ui/should_impl_trait/method_list_2.rs:41:5 | LL | / pub fn hash(&self, state: &mut T) { LL | | @@ -45,7 +45,7 @@ LL | | } = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name error: method `index` can be confused for the standard trait method `std::ops::Index::index` - --> $DIR/should_impl_trait/method_list_2.rs:46:5 + --> tests/ui/should_impl_trait/method_list_2.rs:46:5 | LL | / pub fn index(&self, index: usize) -> &Self { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` - --> $DIR/should_impl_trait/method_list_2.rs:51:5 + --> tests/ui/should_impl_trait/method_list_2.rs:51:5 | LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { LL | | @@ -67,7 +67,7 @@ LL | | } = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` - --> $DIR/should_impl_trait/method_list_2.rs:56:5 + --> tests/ui/should_impl_trait/method_list_2.rs:56:5 | LL | / pub fn into_iter(self) -> Self { LL | | @@ -78,7 +78,7 @@ LL | | } = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` - --> $DIR/should_impl_trait/method_list_2.rs:61:5 + --> tests/ui/should_impl_trait/method_list_2.rs:61:5 | LL | / pub fn mul(self, rhs: Self) -> Self { LL | | @@ -89,7 +89,7 @@ LL | | } = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` - --> $DIR/should_impl_trait/method_list_2.rs:66:5 + --> tests/ui/should_impl_trait/method_list_2.rs:66:5 | LL | / pub fn neg(self) -> Self { LL | | @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` - --> $DIR/should_impl_trait/method_list_2.rs:71:5 + --> tests/ui/should_impl_trait/method_list_2.rs:71:5 | LL | / pub fn next(&mut self) -> Option { LL | | @@ -111,7 +111,7 @@ LL | | } = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name error: method `not` can be confused for the standard trait method `std::ops::Not::not` - --> $DIR/should_impl_trait/method_list_2.rs:76:5 + --> tests/ui/should_impl_trait/method_list_2.rs:76:5 | LL | / pub fn not(self) -> Self { LL | | @@ -122,7 +122,7 @@ LL | | } = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` - --> $DIR/should_impl_trait/method_list_2.rs:81:5 + --> tests/ui/should_impl_trait/method_list_2.rs:81:5 | LL | / pub fn rem(self, rhs: Self) -> Self { LL | | @@ -133,7 +133,7 @@ LL | | } = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` - --> $DIR/should_impl_trait/method_list_2.rs:86:5 + --> tests/ui/should_impl_trait/method_list_2.rs:86:5 | LL | / pub fn shl(self, rhs: Self) -> Self { LL | | @@ -144,7 +144,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` - --> $DIR/should_impl_trait/method_list_2.rs:91:5 + --> tests/ui/should_impl_trait/method_list_2.rs:91:5 | LL | / pub fn shr(self, rhs: Self) -> Self { LL | | @@ -155,7 +155,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` - --> $DIR/should_impl_trait/method_list_2.rs:96:5 + --> tests/ui/should_impl_trait/method_list_2.rs:96:5 | LL | / pub fn sub(self, rhs: Self) -> Self { LL | | diff --git a/tests/ui/should_panic_without_expect.stderr b/tests/ui/should_panic_without_expect.stderr index b13db83bd5c71..0b841b23848e7 100644 --- a/tests/ui/should_panic_without_expect.stderr +++ b/tests/ui/should_panic_without_expect.stderr @@ -1,11 +1,11 @@ error: #[should_panic] attribute without a reason - --> $DIR/should_panic_without_expect.rs:5:1 + --> tests/ui/should_panic_without_expect.rs:5:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ help: consider specifying the expected panic: `#[should_panic(expected = /* panic message */)]` | note: the lint level is defined here - --> $DIR/should_panic_without_expect.rs:2:9 + --> tests/ui/should_panic_without_expect.rs:2:9 | LL | #![deny(clippy::should_panic_without_expect)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/significant_drop_in_scrutinee.stderr b/tests/ui/significant_drop_in_scrutinee.stderr index 05bfda5475d8b..7d5b1acc7f00a 100644 --- a/tests/ui/significant_drop_in_scrutinee.stderr +++ b/tests/ui/significant_drop_in_scrutinee.stderr @@ -1,5 +1,5 @@ error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:55:11 + --> tests/ui/significant_drop_in_scrutinee.rs:55:11 | LL | match mutex.lock().unwrap().foo() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:143:11 + --> tests/ui/significant_drop_in_scrutinee.rs:143:11 | LL | match s.lock_m().get_the_value() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:166:11 + --> tests/ui/significant_drop_in_scrutinee.rs:166:11 | LL | match s.lock_m_m().get_the_value() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:216:11 + --> tests/ui/significant_drop_in_scrutinee.rs:216:11 | LL | match counter.temp_increment().len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:241:16 + --> tests/ui/significant_drop_in_scrutinee.rs:241:16 | LL | match (mutex1.lock().unwrap().s.len(), true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL ~ match (value, true) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:252:22 + --> tests/ui/significant_drop_in_scrutinee.rs:252:22 | LL | match (true, mutex1.lock().unwrap().s.len(), true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL ~ match (true, value, true) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:264:16 + --> tests/ui/significant_drop_in_scrutinee.rs:264:16 | LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL ~ match (value, true, mutex2.lock().unwrap().s.len()) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:264:54 + --> tests/ui/significant_drop_in_scrutinee.rs:264:54 | LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL ~ match (mutex1.lock().unwrap().s.len(), true, value) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:279:15 + --> tests/ui/significant_drop_in_scrutinee.rs:279:15 | LL | match mutex3.lock().unwrap().s.as_str() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -170,7 +170,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:291:22 + --> tests/ui/significant_drop_in_scrutinee.rs:291:22 | LL | match (true, mutex3.lock().unwrap().s.as_str()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -186,7 +186,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:312:11 + --> tests/ui/significant_drop_in_scrutinee.rs:312:11 | LL | match mutex.lock().unwrap().s.len() > 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:321:11 + --> tests/ui/significant_drop_in_scrutinee.rs:321:11 | LL | match 1 < mutex.lock().unwrap().s.len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -224,7 +224,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:341:11 + --> tests/ui/significant_drop_in_scrutinee.rs:341:11 | LL | match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -245,7 +245,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:354:11 + --> tests/ui/significant_drop_in_scrutinee.rs:354:11 | LL | match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -266,7 +266,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:391:11 + --> tests/ui/significant_drop_in_scrutinee.rs:391:11 | LL | match get_mutex_guard().s.len() > 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -285,7 +285,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:410:11 + --> tests/ui/significant_drop_in_scrutinee.rs:410:11 | LL | match match i { | ___________^ @@ -319,7 +319,7 @@ LL ~ match value | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:438:11 + --> tests/ui/significant_drop_in_scrutinee.rs:438:11 | LL | match if i > 1 { | ___________^ @@ -354,7 +354,7 @@ LL ~ match value | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:494:11 + --> tests/ui/significant_drop_in_scrutinee.rs:494:11 | LL | match s.lock().deref().deref() { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -372,7 +372,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:524:11 + --> tests/ui/significant_drop_in_scrutinee.rs:524:11 | LL | match s.lock().deref().deref() { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -386,7 +386,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:545:11 + --> tests/ui/significant_drop_in_scrutinee.rs:545:11 | LL | match mutex.lock().unwrap().i = i { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:553:11 + --> tests/ui/significant_drop_in_scrutinee.rs:553:11 | LL | match i = mutex.lock().unwrap().i { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -424,7 +424,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:561:11 + --> tests/ui/significant_drop_in_scrutinee.rs:561:11 | LL | match mutex.lock().unwrap().i += 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -443,7 +443,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:569:11 + --> tests/ui/significant_drop_in_scrutinee.rs:569:11 | LL | match i += mutex.lock().unwrap().i { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -462,7 +462,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:634:11 + --> tests/ui/significant_drop_in_scrutinee.rs:634:11 | LL | match rwlock.read().unwrap().to_number() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -473,7 +473,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression - --> $DIR/significant_drop_in_scrutinee.rs:646:14 + --> tests/ui/significant_drop_in_scrutinee.rs:646:14 | LL | for s in rwlock.read().unwrap().iter() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -484,7 +484,7 @@ LL | } = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:663:11 + --> tests/ui/significant_drop_in_scrutinee.rs:663:11 | LL | match mutex.lock().unwrap().foo() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/significant_drop_tightening.stderr b/tests/ui/significant_drop_tightening.stderr index 6572d99693170..f818a14cbe68b 100644 --- a/tests/ui/significant_drop_tightening.stderr +++ b/tests/ui/significant_drop_tightening.stderr @@ -1,5 +1,5 @@ error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:10:9 + --> tests/ui/significant_drop_tightening.rs:10:9 | LL | pub fn complex_return_triggers_the_lint() -> i32 { | __________________________________________________- @@ -24,7 +24,7 @@ LL + drop(lock); | error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:104:13 + --> tests/ui/significant_drop_tightening.rs:104:13 | LL | / { LL | | let mutex = Mutex::new(1i32); @@ -44,7 +44,7 @@ LL + drop(lock); | error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:125:13 + --> tests/ui/significant_drop_tightening.rs:125:13 | LL | / { LL | | let mutex = Mutex::new(1i32); @@ -68,7 +68,7 @@ LL + | error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:131:17 + --> tests/ui/significant_drop_tightening.rs:131:17 | LL | / { LL | | let mutex = Mutex::new(vec![1i32]); diff --git a/tests/ui/similar_names.stderr b/tests/ui/similar_names.stderr index 0cadb44ecf159..8d722fb8b564e 100644 --- a/tests/ui/similar_names.stderr +++ b/tests/ui/similar_names.stderr @@ -1,11 +1,11 @@ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:47:9 + --> tests/ui/similar_names.rs:47:9 | LL | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:46:9 + --> tests/ui/similar_names.rs:46:9 | LL | let blubx: i32; | ^^^^^ @@ -13,49 +13,49 @@ LL | let blubx: i32; = help: to override `-D warnings` add `#[allow(clippy::similar_names)]` error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:52:9 + --> tests/ui/similar_names.rs:52:9 | LL | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:50:9 + --> tests/ui/similar_names.rs:50:9 | LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:71:9 + --> tests/ui/similar_names.rs:71:9 | LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:69:9 + --> tests/ui/similar_names.rs:69:9 | LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:76:9 + --> tests/ui/similar_names.rs:76:9 | LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:74:9 + --> tests/ui/similar_names.rs:74:9 | LL | let parser: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:98:16 + --> tests/ui/similar_names.rs:98:16 | LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:97:16 + --> tests/ui/similar_names.rs:97:16 | LL | apple: spring, | ^^^^^^ diff --git a/tests/ui/single_call_fn.stderr b/tests/ui/single_call_fn.stderr index d5cd707754c2f..f48b78c94e9a4 100644 --- a/tests/ui/single_call_fn.stderr +++ b/tests/ui/single_call_fn.stderr @@ -1,5 +1,5 @@ error: this function is only used once - --> $DIR/single_call_fn.rs:34:1 + --> tests/ui/single_call_fn.rs:34:1 | LL | / fn c() { LL | | println!("really"); @@ -9,7 +9,7 @@ LL | | } | |_^ | help: used here - --> $DIR/single_call_fn.rs:41:5 + --> tests/ui/single_call_fn.rs:41:5 | LL | c(); | ^ @@ -17,37 +17,37 @@ LL | c(); = help: to override `-D warnings` add `#[allow(clippy::single_call_fn)]` error: this function is only used once - --> $DIR/single_call_fn.rs:13:1 + --> tests/ui/single_call_fn.rs:13:1 | LL | fn i() {} | ^^^^^^^^^ | help: used here - --> $DIR/single_call_fn.rs:18:13 + --> tests/ui/single_call_fn.rs:18:13 | LL | let a = i; | ^ error: this function is only used once - --> $DIR/single_call_fn.rs:44:1 + --> tests/ui/single_call_fn.rs:44:1 | LL | fn a() {} | ^^^^^^^^^ | help: used here - --> $DIR/single_call_fn.rs:47:5 + --> tests/ui/single_call_fn.rs:47:5 | LL | a(); | ^ error: this function is only used once - --> $DIR/single_call_fn.rs:14:1 + --> tests/ui/single_call_fn.rs:14:1 | LL | fn j() {} | ^^^^^^^^^ | help: used here - --> $DIR/single_call_fn.rs:25:9 + --> tests/ui/single_call_fn.rs:25:9 | LL | j(); | ^ diff --git a/tests/ui/single_char_add_str.stderr b/tests/ui/single_char_add_str.stderr index a6f2b3e037b4a..89d75f20f55a7 100644 --- a/tests/ui/single_char_add_str.stderr +++ b/tests/ui/single_char_add_str.stderr @@ -1,5 +1,5 @@ error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:14:5 + --> tests/ui/single_char_add_str.rs:14:5 | LL | string.push_str("R"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('R')` @@ -8,85 +8,85 @@ LL | string.push_str("R"); = help: to override `-D warnings` add `#[allow(clippy::single_char_add_str)]` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:15:5 + --> tests/ui/single_char_add_str.rs:15:5 | LL | string.push_str("'"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\'')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:20:5 + --> tests/ui/single_char_add_str.rs:20:5 | LL | string.push_str("\x52"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\x52')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:21:5 + --> tests/ui/single_char_add_str.rs:21:5 | LL | string.push_str("\u{0052}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\u{0052}')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:22:5 + --> tests/ui/single_char_add_str.rs:22:5 | LL | string.push_str(r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('a')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:24:5 + --> tests/ui/single_char_add_str.rs:24:5 | LL | get_string!().push_str("ö"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `get_string!().push('ö')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:29:5 + --> tests/ui/single_char_add_str.rs:29:5 | LL | string.insert_str(0, "R"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, 'R')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:30:5 + --> tests/ui/single_char_add_str.rs:30:5 | LL | string.insert_str(1, "'"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(1, '\'')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:35:5 + --> tests/ui/single_char_add_str.rs:35:5 | LL | string.insert_str(0, "\x52"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '\x52')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:36:5 + --> tests/ui/single_char_add_str.rs:36:5 | LL | string.insert_str(0, "\u{0052}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '\u{0052}')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:38:5 + --> tests/ui/single_char_add_str.rs:38:5 | LL | string.insert_str(x, r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(x, 'a')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:40:5 + --> tests/ui/single_char_add_str.rs:40:5 | LL | string.insert_str(Y, r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, 'a')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:41:5 + --> tests/ui/single_char_add_str.rs:41:5 | LL | string.insert_str(Y, r##"""##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '"')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:42:5 + --> tests/ui/single_char_add_str.rs:42:5 | LL | string.insert_str(Y, r##"'"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '\'')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:44:5 + --> tests/ui/single_char_add_str.rs:44:5 | LL | get_string!().insert_str(1, "?"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `get_string!().insert(1, '?')` diff --git a/tests/ui/single_char_lifetime_names.stderr b/tests/ui/single_char_lifetime_names.stderr index 2cdfd61358e75..005c897b19bac 100644 --- a/tests/ui/single_char_lifetime_names.stderr +++ b/tests/ui/single_char_lifetime_names.stderr @@ -1,5 +1,5 @@ error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:5:22 + --> tests/ui/single_char_lifetime_names.rs:5:22 | LL | struct DiagnosticCtx<'a, 'b> | ^^ @@ -9,7 +9,7 @@ LL | struct DiagnosticCtx<'a, 'b> = help: to override `-D warnings` add `#[allow(clippy::single_char_lifetime_names)]` error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:5:26 + --> tests/ui/single_char_lifetime_names.rs:5:26 | LL | struct DiagnosticCtx<'a, 'b> | ^^ @@ -17,7 +17,7 @@ LL | struct DiagnosticCtx<'a, 'b> = help: use a more informative name error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:16:6 + --> tests/ui/single_char_lifetime_names.rs:16:6 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | ^^ @@ -25,7 +25,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { = help: use a more informative name error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:16:10 + --> tests/ui/single_char_lifetime_names.rs:16:10 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | ^^ @@ -33,7 +33,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { = help: use a more informative name error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:38:15 + --> tests/ui/single_char_lifetime_names.rs:38:15 | LL | fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a str>) { | ^^ diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index 664d6b5a1e9b0..5a2ec6c764b18 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,5 +1,5 @@ error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:7:13 + --> tests/ui/single_char_pattern.rs:7:13 | LL | x.split("x"); | ^^^ help: consider using a `char`: `'x'` @@ -8,235 +8,235 @@ LL | x.split("x"); = help: to override `-D warnings` add `#[allow(clippy::single_char_pattern)]` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:13:13 + --> tests/ui/single_char_pattern.rs:13:13 | LL | x.split("ß"); | ^^^ help: consider using a `char`: `'ß'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:14:13 + --> tests/ui/single_char_pattern.rs:14:13 | LL | x.split("ℝ"); | ^^^ help: consider using a `char`: `'ℝ'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:15:13 + --> tests/ui/single_char_pattern.rs:15:13 | LL | x.split("💣"); | ^^^^ help: consider using a `char`: `'💣'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:18:23 + --> tests/ui/single_char_pattern.rs:18:23 | LL | x.split_inclusive("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:19:16 + --> tests/ui/single_char_pattern.rs:19:16 | LL | x.contains("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:20:19 + --> tests/ui/single_char_pattern.rs:20:19 | LL | x.starts_with("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:21:17 + --> tests/ui/single_char_pattern.rs:21:17 | LL | x.ends_with("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:22:12 + --> tests/ui/single_char_pattern.rs:22:12 | LL | x.find("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:23:13 + --> tests/ui/single_char_pattern.rs:23:13 | LL | x.rfind("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:24:14 + --> tests/ui/single_char_pattern.rs:24:14 | LL | x.rsplit("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:25:24 + --> tests/ui/single_char_pattern.rs:25:24 | LL | x.split_terminator("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:26:25 + --> tests/ui/single_char_pattern.rs:26:25 | LL | x.rsplit_terminator("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:27:17 + --> tests/ui/single_char_pattern.rs:27:17 | LL | x.splitn(2, "x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:28:18 + --> tests/ui/single_char_pattern.rs:28:18 | LL | x.rsplitn(2, "x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:29:18 + --> tests/ui/single_char_pattern.rs:29:18 | LL | x.split_once("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:30:19 + --> tests/ui/single_char_pattern.rs:30:19 | LL | x.rsplit_once("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:31:15 + --> tests/ui/single_char_pattern.rs:31:15 | LL | x.matches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:32:16 + --> tests/ui/single_char_pattern.rs:32:16 | LL | x.rmatches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:33:21 + --> tests/ui/single_char_pattern.rs:33:21 | LL | x.match_indices("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:34:22 + --> tests/ui/single_char_pattern.rs:34:22 | LL | x.rmatch_indices("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:35:26 + --> tests/ui/single_char_pattern.rs:35:26 | LL | x.trim_start_matches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:36:24 + --> tests/ui/single_char_pattern.rs:36:24 | LL | x.trim_end_matches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:37:20 + --> tests/ui/single_char_pattern.rs:37:20 | LL | x.strip_prefix("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:38:20 + --> tests/ui/single_char_pattern.rs:38:20 | LL | x.strip_suffix("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:39:15 + --> tests/ui/single_char_pattern.rs:39:15 | LL | x.replace("x", "y"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:40:16 + --> tests/ui/single_char_pattern.rs:40:16 | LL | x.replacen("x", "y", 3); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:42:13 + --> tests/ui/single_char_pattern.rs:42:13 | LL | x.split("\n"); | ^^^^ help: consider using a `char`: `'\n'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:43:13 + --> tests/ui/single_char_pattern.rs:43:13 | LL | x.split("'"); | ^^^ help: consider using a `char`: `'\''` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:44:13 + --> tests/ui/single_char_pattern.rs:44:13 | LL | x.split("\'"); | ^^^^ help: consider using a `char`: `'\''` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:46:13 + --> tests/ui/single_char_pattern.rs:46:13 | LL | x.split("\""); | ^^^^ help: consider using a `char`: `'"'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:51:31 + --> tests/ui/single_char_pattern.rs:51:31 | LL | x.replace(';', ",").split(","); // issue #2978 | ^^^ help: consider using a `char`: `','` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:52:19 + --> tests/ui/single_char_pattern.rs:52:19 | LL | x.starts_with("\x03"); // issue #2996 | ^^^^^^ help: consider using a `char`: `'\x03'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:59:13 + --> tests/ui/single_char_pattern.rs:59:13 | LL | x.split(r"a"); | ^^^^ help: consider using a `char`: `'a'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:60:13 + --> tests/ui/single_char_pattern.rs:60:13 | LL | x.split(r#"a"#); | ^^^^^^ help: consider using a `char`: `'a'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:61:13 + --> tests/ui/single_char_pattern.rs:61:13 | LL | x.split(r###"a"###); | ^^^^^^^^^^ help: consider using a `char`: `'a'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:62:13 + --> tests/ui/single_char_pattern.rs:62:13 | LL | x.split(r###"'"###); | ^^^^^^^^^^ help: consider using a `char`: `'\''` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:63:13 + --> tests/ui/single_char_pattern.rs:63:13 | LL | x.split(r###"#"###); | ^^^^^^^^^^ help: consider using a `char`: `'#'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:65:13 + --> tests/ui/single_char_pattern.rs:65:13 | LL | x.split(r#"\"#); | ^^^^^^ help: consider using a `char`: `'\\'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:66:13 + --> tests/ui/single_char_pattern.rs:66:13 | LL | x.split(r"\"); | ^^^^ help: consider using a `char`: `'\\'` diff --git a/tests/ui/single_component_path_imports.stderr b/tests/ui/single_component_path_imports.stderr index 440d34002d7ff..95d7e4d85b7c3 100644 --- a/tests/ui/single_component_path_imports.stderr +++ b/tests/ui/single_component_path_imports.stderr @@ -1,5 +1,5 @@ error: this import is redundant - --> $DIR/single_component_path_imports.rs:6:1 + --> tests/ui/single_component_path_imports.rs:6:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely @@ -8,7 +8,7 @@ LL | use regex; = help: to override `-D warnings` add `#[allow(clippy::single_component_path_imports)]` error: this import is redundant - --> $DIR/single_component_path_imports.rs:32:5 + --> tests/ui/single_component_path_imports.rs:32:5 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely diff --git a/tests/ui/single_component_path_imports_nested_first.stderr b/tests/ui/single_component_path_imports_nested_first.stderr index d65ab5620db77..8eec877860e7e 100644 --- a/tests/ui/single_component_path_imports_nested_first.stderr +++ b/tests/ui/single_component_path_imports_nested_first.stderr @@ -1,5 +1,5 @@ error: this import is redundant - --> $DIR/single_component_path_imports_nested_first.rs:4:1 + --> tests/ui/single_component_path_imports_nested_first.rs:4:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely @@ -8,7 +8,7 @@ LL | use regex; = help: to override `-D warnings` add `#[allow(clippy::single_component_path_imports)]` error: this import is redundant - --> $DIR/single_component_path_imports_nested_first.rs:17:10 + --> tests/ui/single_component_path_imports_nested_first.rs:17:10 | LL | use {regex, serde}; | ^^^^^ @@ -16,7 +16,7 @@ LL | use {regex, serde}; = help: remove this import error: this import is redundant - --> $DIR/single_component_path_imports_nested_first.rs:17:17 + --> tests/ui/single_component_path_imports_nested_first.rs:17:17 | LL | use {regex, serde}; | ^^^^^ diff --git a/tests/ui/single_element_loop.stderr b/tests/ui/single_element_loop.stderr index 952d704143a5b..dfae5605b5715 100644 --- a/tests/ui/single_element_loop.stderr +++ b/tests/ui/single_element_loop.stderr @@ -1,5 +1,5 @@ error: for loop over a single element - --> $DIR/single_element_loop.rs:8:5 + --> tests/ui/single_element_loop.rs:8:5 | LL | / for item in &[item1] { LL | | dbg!(item); @@ -17,7 +17,7 @@ LL + } | error: for loop over a single element - --> $DIR/single_element_loop.rs:12:5 + --> tests/ui/single_element_loop.rs:12:5 | LL | / for item in [item1].iter() { LL | | dbg!(item); @@ -33,31 +33,31 @@ LL + } | error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:16:17 + --> tests/ui/single_element_loop.rs:16:17 | LL | for item in &[0..5] { | ^^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:20:17 + --> tests/ui/single_element_loop.rs:20:17 | LL | for item in [0..5].iter_mut() { | ^^^^^^^^^^^^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:24:17 + --> tests/ui/single_element_loop.rs:24:17 | LL | for item in [0..5] { | ^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:28:17 + --> tests/ui/single_element_loop.rs:28:17 | LL | for item in [0..5].into_iter() { | ^^^^^^^^^^^^^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: for loop over a single element - --> $DIR/single_element_loop.rs:47:5 + --> tests/ui/single_element_loop.rs:47:5 | LL | / for _ in [42] { LL | | let _f = |n: u32| { diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index d4b8659952139..40af38879aeb2 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:14:5 + --> tests/ui/single_match.rs:14:5 | LL | / match x { LL | | Some(y) => { @@ -19,7 +19,7 @@ LL ~ }; | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:22:5 + --> tests/ui/single_match.rs:22:5 | LL | / match x { LL | | // Note the missing block braces. @@ -31,7 +31,7 @@ LL | | } | |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:31:5 + --> tests/ui/single_match.rs:31:5 | LL | / match z { LL | | (2..=3, 7..=9) => dummy(), @@ -40,7 +40,7 @@ LL | | }; | |_____^ help: try: `if let (2..=3, 7..=9) = z { dummy() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:60:5 + --> tests/ui/single_match.rs:60:5 | LL | / match x { LL | | Some(y) => dummy(), @@ -49,7 +49,7 @@ LL | | }; | |_____^ help: try: `if let Some(y) = x { dummy() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:65:5 + --> tests/ui/single_match.rs:65:5 | LL | / match y { LL | | Ok(y) => dummy(), @@ -58,7 +58,7 @@ LL | | }; | |_____^ help: try: `if let Ok(y) = y { dummy() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:72:5 + --> tests/ui/single_match.rs:72:5 | LL | / match c { LL | | Cow::Borrowed(..) => dummy(), @@ -67,7 +67,7 @@ LL | | }; | |_____^ help: try: `if let Cow::Borrowed(..) = c { dummy() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:93:5 + --> tests/ui/single_match.rs:93:5 | LL | / match x { LL | | "test" => println!(), @@ -76,7 +76,7 @@ LL | | } | |_____^ help: try: `if x == "test" { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:106:5 + --> tests/ui/single_match.rs:106:5 | LL | / match x { LL | | Foo::A => println!(), @@ -85,7 +85,7 @@ LL | | } | |_____^ help: try: `if x == Foo::A { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:112:5 + --> tests/ui/single_match.rs:112:5 | LL | / match x { LL | | FOO_C => println!(), @@ -94,7 +94,7 @@ LL | | } | |_____^ help: try: `if x == FOO_C { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:117:5 + --> tests/ui/single_match.rs:117:5 | LL | / match &&x { LL | | Foo::A => println!(), @@ -103,7 +103,7 @@ LL | | } | |_____^ help: try: `if x == Foo::A { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:123:5 + --> tests/ui/single_match.rs:123:5 | LL | / match &x { LL | | Foo::A => println!(), @@ -112,7 +112,7 @@ LL | | } | |_____^ help: try: `if x == &Foo::A { println!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:140:5 + --> tests/ui/single_match.rs:140:5 | LL | / match x { LL | | Bar::A => println!(), @@ -121,7 +121,7 @@ LL | | } | |_____^ help: try: `if let Bar::A = x { println!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:148:5 + --> tests/ui/single_match.rs:148:5 | LL | / match x { LL | | None => println!(), @@ -130,7 +130,7 @@ LL | | }; | |_____^ help: try: `if let None = x { println!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:170:5 + --> tests/ui/single_match.rs:170:5 | LL | / match x { LL | | (Some(_), _) => {}, @@ -139,7 +139,7 @@ LL | | } | |_____^ help: try: `if let (Some(_), _) = x {}` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:176:5 + --> tests/ui/single_match.rs:176:5 | LL | / match x { LL | | (Some(E::V), _) => todo!(), @@ -148,7 +148,7 @@ LL | | } | |_____^ help: try: `if let (Some(E::V), _) = x { todo!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:182:5 + --> tests/ui/single_match.rs:182:5 | LL | / match (Some(42), Some(E::V), Some(42)) { LL | | (.., Some(E::V), _) => {}, @@ -157,7 +157,7 @@ LL | | } | |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:254:5 + --> tests/ui/single_match.rs:254:5 | LL | / match bar { LL | | Some(v) => unsafe { @@ -177,7 +177,7 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:262:5 + --> tests/ui/single_match.rs:262:5 | LL | / match bar { LL | | #[rustfmt::skip] diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 3b4b1332c403a..63c733e9a7a03 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:16:13 + --> tests/ui/single_match_else.rs:16:13 | LL | let _ = match ExprNode::Butterflies { | _____________^ @@ -22,7 +22,7 @@ LL ~ }; | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:81:5 + --> tests/ui/single_match_else.rs:81:5 | LL | / match Some(1) { LL | | Some(a) => println!("${:?}", a), @@ -42,7 +42,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:90:5 + --> tests/ui/single_match_else.rs:90:5 | LL | / match Some(1) { LL | | Some(a) => println!("${:?}", a), @@ -62,7 +62,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:100:5 + --> tests/ui/single_match_else.rs:100:5 | LL | / match Result::::Ok(1) { LL | | Ok(a) => println!("${:?}", a), @@ -82,7 +82,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:109:5 + --> tests/ui/single_match_else.rs:109:5 | LL | / match Cow::from("moo") { LL | | Cow::Owned(a) => println!("${:?}", a), @@ -102,7 +102,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:119:5 + --> tests/ui/single_match_else.rs:119:5 | LL | / match bar { LL | | Some(v) => unsafe { @@ -125,7 +125,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:130:5 + --> tests/ui/single_match_else.rs:130:5 | LL | / match bar { LL | | Some(v) => { @@ -149,7 +149,7 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:142:5 + --> tests/ui/single_match_else.rs:142:5 | LL | / match bar { LL | | Some(v) => unsafe { @@ -173,7 +173,7 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:154:5 + --> tests/ui/single_match_else.rs:154:5 | LL | / match bar { LL | | #[rustfmt::skip] diff --git a/tests/ui/single_range_in_vec_init.stderr b/tests/ui/single_range_in_vec_init.stderr index e83e49af676cc..9c125adb51a73 100644 --- a/tests/ui/single_range_in_vec_init.stderr +++ b/tests/ui/single_range_in_vec_init.stderr @@ -1,5 +1,5 @@ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:26:5 + --> tests/ui/single_range_in_vec_init.rs:26:5 | LL | [0..200]; | ^^^^^^^^ @@ -16,7 +16,7 @@ LL | [0; 200]; | ~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:27:5 + --> tests/ui/single_range_in_vec_init.rs:27:5 | LL | vec![0..200]; | ^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | vec![0; 200]; | ~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:28:5 + --> tests/ui/single_range_in_vec_init.rs:28:5 | LL | [0u8..200]; | ^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | [0u8; 200]; | ~~~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:29:5 + --> tests/ui/single_range_in_vec_init.rs:29:5 | LL | [0usize..200]; | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | [0usize; 200]; | ~~~~~~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:30:5 + --> tests/ui/single_range_in_vec_init.rs:30:5 | LL | [0..200usize]; | ^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | [0; 200usize]; | ~~~~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:31:5 + --> tests/ui/single_range_in_vec_init.rs:31:5 | LL | vec![0u8..200]; | ^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | vec![0u8; 200]; | ~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:32:5 + --> tests/ui/single_range_in_vec_init.rs:32:5 | LL | vec![0usize..200]; | ^^^^^^^^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | vec![0usize; 200]; | ~~~~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:33:5 + --> tests/ui/single_range_in_vec_init.rs:33:5 | LL | vec![0..200usize]; | ^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | vec![0; 200usize]; | ~~~~~~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:35:5 + --> tests/ui/single_range_in_vec_init.rs:35:5 | LL | [0..200isize]; | ^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ LL | (0..200isize).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:36:5 + --> tests/ui/single_range_in_vec_init.rs:36:5 | LL | vec![0..200isize]; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/size_of_in_element_count/expressions.stderr b/tests/ui/size_of_in_element_count/expressions.stderr index ea8dc92ff1826..6396afd7f3955 100644 --- a/tests/ui/size_of_in_element_count/expressions.stderr +++ b/tests/ui/size_of_in_element_count/expressions.stderr @@ -1,5 +1,5 @@ error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/expressions.rs:15:62 + --> tests/ui/size_of_in_element_count/expressions.rs:15:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::( = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/expressions.rs:19:62 + --> tests/ui/size_of_in_element_count/expressions.rs:19:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * si = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/expressions.rs:23:47 + --> tests/ui/size_of_in_element_count/expressions.rs:23:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() / 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/expressions.rs:33:47 + --> tests/ui/size_of_in_element_count/expressions.rs:33:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::())) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/size_of_in_element_count/functions.stderr b/tests/ui/size_of_in_element_count/functions.stderr index ad1174e5e7bc0..abde7dc7cd2d3 100644 --- a/tests/ui/size_of_in_element_count/functions.stderr +++ b/tests/ui/size_of_in_element_count/functions.stderr @@ -1,5 +1,5 @@ error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:18:68 + --> tests/ui/size_of_in_element_count/functions.rs:18:68 | LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of: = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:20:62 + --> tests/ui/size_of_in_element_count/functions.rs:20:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:23:49 + --> tests/ui/size_of_in_element_count/functions.rs:23:49 | LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:25:64 + --> tests/ui/size_of_in_element_count/functions.rs:25:64 | LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of:: $DIR/size_of_in_element_count/functions.rs:27:51 + --> tests/ui/size_of_in_element_count/functions.rs:27:51 | LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:29:66 + --> tests/ui/size_of_in_element_count/functions.rs:29:66 | LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::< = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:32:47 + --> tests/ui/size_of_in_element_count/functions.rs:32:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:34:47 + --> tests/ui/size_of_in_element_count/functions.rs:34:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:37:46 + --> tests/ui/size_of_in_element_count/functions.rs:37:46 | LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:39:47 + --> tests/ui/size_of_in_element_count/functions.rs:39:47 | LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:42:66 + --> tests/ui/size_of_in_element_count/functions.rs:42:66 | LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::< = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:45:46 + --> tests/ui/size_of_in_element_count/functions.rs:45:46 | LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:47:38 + --> tests/ui/size_of_in_element_count/functions.rs:47:38 | LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:50:49 + --> tests/ui/size_of_in_element_count/functions.rs:50:49 | LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:52:41 + --> tests/ui/size_of_in_element_count/functions.rs:52:41 | LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:55:33 + --> tests/ui/size_of_in_element_count/functions.rs:55:33 | LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:57:29 + --> tests/ui/size_of_in_element_count/functions.rs:57:29 | LL | y.as_ptr().wrapping_sub(size_of::()); | ^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | y.as_ptr().wrapping_sub(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:59:29 + --> tests/ui/size_of_in_element_count/functions.rs:59:29 | LL | unsafe { y.as_ptr().add(size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | unsafe { y.as_ptr().add(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:61:33 + --> tests/ui/size_of_in_element_count/functions.rs:61:33 | LL | y.as_mut_ptr().wrapping_add(size_of::()); | ^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ LL | y.as_mut_ptr().wrapping_add(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:63:32 + --> tests/ui/size_of_in_element_count/functions.rs:63:32 | LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -161,7 +161,7 @@ LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/size_of_in_element_count/functions.rs:65:36 + --> tests/ui/size_of_in_element_count/functions.rs:65:36 | LL | y.as_mut_ptr().wrapping_offset(size_of::() as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/size_of_ref.stderr b/tests/ui/size_of_ref.stderr index e239c5810c92e..bb8f08de531cf 100644 --- a/tests/ui/size_of_ref.stderr +++ b/tests/ui/size_of_ref.stderr @@ -1,5 +1,5 @@ error: argument to `std::mem::size_of_val()` is a reference to a reference - --> $DIR/size_of_ref.rs:13:5 + --> tests/ui/size_of_ref.rs:13:5 | LL | size_of_val(&&x); | ^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | size_of_val(&&x); = help: to override `-D warnings` add `#[allow(clippy::size_of_ref)]` error: argument to `std::mem::size_of_val()` is a reference to a reference - --> $DIR/size_of_ref.rs:15:5 + --> tests/ui/size_of_ref.rs:15:5 | LL | size_of_val(&y); | ^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | size_of_val(&y); = help: dereference the argument to `std::mem::size_of_val()` to get the size of the value instead of the size of the reference-type error: argument to `std::mem::size_of_val()` is a reference to a reference - --> $DIR/size_of_ref.rs:27:9 + --> tests/ui/size_of_ref.rs:27:9 | LL | std::mem::size_of_val(&self) + (std::mem::size_of::() * self.data.capacity()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/skip_while_next.stderr b/tests/ui/skip_while_next.stderr index 3c33af3a16080..2c1b9eeba3b6e 100644 --- a/tests/ui/skip_while_next.stderr +++ b/tests/ui/skip_while_next.stderr @@ -1,5 +1,5 @@ error: called `skip_while(

).next()` on an `Iterator` - --> $DIR/skip_while_next.rs:14:13 + --> tests/ui/skip_while_next.rs:14:13 | LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); = help: to override `-D warnings` add `#[allow(clippy::skip_while_next)]` error: called `skip_while(

).next()` on an `Iterator` - --> $DIR/skip_while_next.rs:17:13 + --> tests/ui/skip_while_next.rs:17:13 | LL | let _ = v.iter().skip_while(|&x| { | _____________^ diff --git a/tests/ui/slow_vector_initialization.stderr b/tests/ui/slow_vector_initialization.stderr index 16a7057653c10..353c677097be7 100644 --- a/tests/ui/slow_vector_initialization.stderr +++ b/tests/ui/slow_vector_initialization.stderr @@ -1,5 +1,5 @@ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:14:5 + --> tests/ui/slow_vector_initialization.rs:14:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -10,7 +10,7 @@ LL | vec1.extend(repeat(0).take(len)); = help: to override `-D warnings` add `#[allow(clippy::slow_vector_initialization)]` error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:20:5 + --> tests/ui/slow_vector_initialization.rs:20:5 | LL | let mut vec2 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replacing this with: `vec![0; len - 10]` @@ -18,7 +18,7 @@ LL | vec2.extend(repeat(0).take(len - 10)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:28:5 + --> tests/ui/slow_vector_initialization.rs:28:5 | LL | let mut vec4 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -26,7 +26,7 @@ LL | vec4.extend(repeat(0).take(vec4.capacity())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:39:5 + --> tests/ui/slow_vector_initialization.rs:39:5 | LL | let mut resized_vec = Vec::with_capacity(30); | ---------------------- help: consider replacing this with: `vec![0; 30]` @@ -34,7 +34,7 @@ LL | resized_vec.resize(30, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:43:5 + --> tests/ui/slow_vector_initialization.rs:43:5 | LL | let mut extend_vec = Vec::with_capacity(30); | ---------------------- help: consider replacing this with: `vec![0; 30]` @@ -42,7 +42,7 @@ LL | extend_vec.extend(repeat(0).take(30)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:51:5 + --> tests/ui/slow_vector_initialization.rs:51:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -50,7 +50,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:60:5 + --> tests/ui/slow_vector_initialization.rs:60:5 | LL | let mut vec3 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replacing this with: `vec![0; len - 10]` @@ -58,7 +58,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:64:5 + --> tests/ui/slow_vector_initialization.rs:64:5 | LL | let mut vec4 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -66,7 +66,7 @@ LL | vec4.resize(vec4.capacity(), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:69:5 + --> tests/ui/slow_vector_initialization.rs:69:5 | LL | vec1 = Vec::with_capacity(10); | ---------------------- help: consider replacing this with: `vec![0; 10]` @@ -74,7 +74,7 @@ LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:77:5 + --> tests/ui/slow_vector_initialization.rs:77:5 | LL | let mut vec1 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; len]` @@ -82,7 +82,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:82:5 + --> tests/ui/slow_vector_initialization.rs:82:5 | LL | let mut vec3 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; len - 10]` @@ -90,7 +90,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:87:5 + --> tests/ui/slow_vector_initialization.rs:87:5 | LL | vec1 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; 10]` @@ -98,7 +98,7 @@ LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:91:5 + --> tests/ui/slow_vector_initialization.rs:91:5 | LL | vec1 = vec![]; | ------ help: consider replacing this with: `vec![0; 10]` diff --git a/tests/ui/stable_sort_primitive.stderr b/tests/ui/stable_sort_primitive.stderr index b665033283348..66bd4c79bb286 100644 --- a/tests/ui/stable_sort_primitive.stderr +++ b/tests/ui/stable_sort_primitive.stderr @@ -1,5 +1,5 @@ error: used `sort` on primitive type `i32` - --> $DIR/stable_sort_primitive.rs:7:5 + --> tests/ui/stable_sort_primitive.rs:7:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -9,7 +9,7 @@ LL | vec.sort(); = help: to override `-D warnings` add `#[allow(clippy::stable_sort_primitive)]` error: used `sort` on primitive type `bool` - --> $DIR/stable_sort_primitive.rs:9:5 + --> tests/ui/stable_sort_primitive.rs:9:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -17,7 +17,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `char` - --> $DIR/stable_sort_primitive.rs:11:5 + --> tests/ui/stable_sort_primitive.rs:11:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -25,7 +25,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `str` - --> $DIR/stable_sort_primitive.rs:13:5 + --> tests/ui/stable_sort_primitive.rs:13:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -33,7 +33,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `tuple` - --> $DIR/stable_sort_primitive.rs:15:5 + --> tests/ui/stable_sort_primitive.rs:15:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -41,7 +41,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `array` - --> $DIR/stable_sort_primitive.rs:17:5 + --> tests/ui/stable_sort_primitive.rs:17:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -49,7 +49,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `i32` - --> $DIR/stable_sort_primitive.rs:19:5 + --> tests/ui/stable_sort_primitive.rs:19:5 | LL | arr.sort(); | ^^^^^^^^^^ help: try: `arr.sort_unstable()` diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index c4c547949a364..cee31f1e4cdd3 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,5 +1,5 @@ error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:7:5 + --> tests/ui/starts_ends_with.rs:7:5 | LL | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` @@ -8,31 +8,31 @@ LL | "".chars().next() == Some(' '); = help: to override `-D warnings` add `#[allow(clippy::chars_next_cmp)]` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:8:5 + --> tests/ui/starts_ends_with.rs:8:5 | LL | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:11:5 + --> tests/ui/starts_ends_with.rs:11:5 | LL | "".chars().next() == Some('\n'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with('\n')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:12:5 + --> tests/ui/starts_ends_with.rs:12:5 | LL | Some('\n') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with('\n')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:17:8 + --> tests/ui/starts_ends_with.rs:17:8 | LL | if s.chars().next().unwrap() == 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:21:8 + --> tests/ui/starts_ends_with.rs:21:8 | LL | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` @@ -41,61 +41,61 @@ LL | if s.chars().next_back().unwrap() == 'o' { = help: to override `-D warnings` add `#[allow(clippy::chars_last_cmp)]` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:25:8 + --> tests/ui/starts_ends_with.rs:25:8 | LL | if s.chars().last().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:29:8 + --> tests/ui/starts_ends_with.rs:29:8 | LL | if s.chars().next().unwrap() != 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:33:8 + --> tests/ui/starts_ends_with.rs:33:8 | LL | if s.chars().next_back().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:37:8 + --> tests/ui/starts_ends_with.rs:37:8 | LL | if s.chars().last().unwrap() != '\n' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('\n')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:45:5 + --> tests/ui/starts_ends_with.rs:45:5 | LL | "".chars().last() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:46:5 + --> tests/ui/starts_ends_with.rs:46:5 | LL | Some(' ') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:47:5 + --> tests/ui/starts_ends_with.rs:47:5 | LL | "".chars().next_back() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:48:5 + --> tests/ui/starts_ends_with.rs:48:5 | LL | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:51:5 + --> tests/ui/starts_ends_with.rs:51:5 | LL | "".chars().last() == Some('\n'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with('\n')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:52:5 + --> tests/ui/starts_ends_with.rs:52:5 | LL | Some('\n') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with('\n')` diff --git a/tests/ui/std_instead_of_core.stderr b/tests/ui/std_instead_of_core.stderr index 4f7bdc4045e77..30dd49dc2688d 100644 --- a/tests/ui/std_instead_of_core.stderr +++ b/tests/ui/std_instead_of_core.stderr @@ -1,5 +1,5 @@ error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:13:9 + --> tests/ui/std_instead_of_core.rs:13:9 | LL | use std::hash::Hasher; | ^^^ help: consider importing the item from `core`: `core` @@ -8,49 +8,49 @@ LL | use std::hash::Hasher; = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_core)]` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:16:11 + --> tests/ui/std_instead_of_core.rs:16:11 | LL | use ::std::hash::Hash; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:22:9 + --> tests/ui/std_instead_of_core.rs:22:9 | LL | use std::fmt::{Debug, Result}; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:26:15 + --> tests/ui/std_instead_of_core.rs:26:15 | LL | let ptr = std::ptr::null::(); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:28:21 + --> tests/ui/std_instead_of_core.rs:28:21 | LL | let ptr_mut = ::std::ptr::null_mut::(); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:32:16 + --> tests/ui/std_instead_of_core.rs:32:16 | LL | let cell = std::cell::Cell::new(8u32); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:34:27 + --> tests/ui/std_instead_of_core.rs:34:27 | LL | let cell_absolute = ::std::cell::Cell::new(8u32); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:43:9 + --> tests/ui/std_instead_of_core.rs:43:9 | LL | use std::iter::Iterator; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `alloc` - --> $DIR/std_instead_of_core.rs:50:9 + --> tests/ui/std_instead_of_core.rs:50:9 | LL | use std::vec; | ^^^ help: consider importing the item from `alloc`: `alloc` @@ -59,13 +59,13 @@ LL | use std::vec; = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]` error: used import from `std` instead of `alloc` - --> $DIR/std_instead_of_core.rs:52:9 + --> tests/ui/std_instead_of_core.rs:52:9 | LL | use std::vec::Vec; | ^^^ help: consider importing the item from `alloc`: `alloc` error: used import from `alloc` instead of `core` - --> $DIR/std_instead_of_core.rs:58:9 + --> tests/ui/std_instead_of_core.rs:58:9 | LL | use alloc::slice::from_ref; | ^^^^^ help: consider importing the item from `core`: `core` diff --git a/tests/ui/str_split.stderr b/tests/ui/str_split.stderr index ee0a9653711a1..ebe0d4ef4d301 100644 --- a/tests/ui/str_split.stderr +++ b/tests/ui/str_split.stderr @@ -1,5 +1,5 @@ error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:59:13 + --> tests/ui/str_split.rs:59:13 | LL | let _ = s1.trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()` @@ -8,55 +8,55 @@ LL | let _ = s1.trim().split('\n'); = help: to override `-D warnings` add `#[allow(clippy::str_split_at_newline)]` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:61:13 + --> tests/ui/str_split.rs:61:13 | LL | let _ = s1.trim().split("\n"); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:62:13 + --> tests/ui/str_split.rs:62:13 | LL | let _ = s1.trim().split("\r\n"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:65:13 + --> tests/ui/str_split.rs:65:13 | LL | let _ = s2.trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:67:13 + --> tests/ui/str_split.rs:67:13 | LL | let _ = s2.trim().split("\n"); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:68:13 + --> tests/ui/str_split.rs:68:13 | LL | let _ = s2.trim().split("\r\n"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:72:13 + --> tests/ui/str_split.rs:72:13 | LL | let _ = s3.trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:74:13 + --> tests/ui/str_split.rs:74:13 | LL | let _ = s3.trim().split("\n"); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:75:13 + --> tests/ui/str_split.rs:75:13 | LL | let _ = s3.trim().split("\r\n"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:78:13 + --> tests/ui/str_split.rs:78:13 | LL | let _ = make_str!(s1).trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `make_str!(s1).lines()` diff --git a/tests/ui/str_to_string.stderr b/tests/ui/str_to_string.stderr index 203805eca5a64..13b73622d6982 100644 --- a/tests/ui/str_to_string.stderr +++ b/tests/ui/str_to_string.stderr @@ -1,5 +1,5 @@ error: `to_string()` called on a `&str` - --> $DIR/str_to_string.rs:4:17 + --> tests/ui/str_to_string.rs:4:17 | LL | let hello = "hello world".to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let hello = "hello world".to_string(); = help: to override `-D warnings` add `#[allow(clippy::str_to_string)]` error: `to_string()` called on a `&str` - --> $DIR/str_to_string.rs:7:5 + --> tests/ui/str_to_string.rs:7:5 | LL | msg.to_string(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/string_add.stderr b/tests/ui/string_add.stderr index 892753b9034e9..fe6849b894b53 100644 --- a/tests/ui/string_add.stderr +++ b/tests/ui/string_add.stderr @@ -1,5 +1,5 @@ error: manual implementation of an assign operation - --> $DIR/string_add.rs:13:9 + --> tests/ui/string_add.rs:13:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` @@ -8,7 +8,7 @@ LL | x = x + "."; = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/string_add.rs:13:13 + --> tests/ui/string_add.rs:13:13 | LL | x = x + "."; | ^^^^^^^ @@ -17,13 +17,13 @@ LL | x = x + "."; = help: to override `-D warnings` add `#[allow(clippy::string_add)]` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/string_add.rs:17:13 + --> tests/ui/string_add.rs:17:13 | LL | let z = y + "..."; | ^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/string_add.rs:22:5 + --> tests/ui/string_add.rs:22:5 | LL | x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` diff --git a/tests/ui/string_add_assign.stderr b/tests/ui/string_add_assign.stderr index 7d37c98a8f930..50f970084e6b2 100644 --- a/tests/ui/string_add_assign.stderr +++ b/tests/ui/string_add_assign.stderr @@ -1,5 +1,5 @@ error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/string_add_assign.rs:8:9 + --> tests/ui/string_add_assign.rs:8:9 | LL | x = x + "."; | ^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | x = x + "."; = help: to override `-D warnings` add `#[allow(clippy::string_add_assign)]` error: manual implementation of an assign operation - --> $DIR/string_add_assign.rs:8:9 + --> tests/ui/string_add_assign.rs:8:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` @@ -17,7 +17,7 @@ LL | x = x + "."; = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: manual implementation of an assign operation - --> $DIR/string_add_assign.rs:17:5 + --> tests/ui/string_add_assign.rs:17:5 | LL | x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index e063d87e37d3e..fadda786aacb6 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -1,5 +1,5 @@ error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:16:5 + --> tests/ui/string_extend.rs:16:5 | LL | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(abc)` @@ -8,19 +8,19 @@ LL | s.extend(abc.chars()); = help: to override `-D warnings` add `#[allow(clippy::string_extend_chars)]` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:19:5 + --> tests/ui/string_extend.rs:19:5 | LL | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str("abc")` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:22:5 + --> tests/ui/string_extend.rs:22:5 | LL | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(&def)` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:32:5 + --> tests/ui/string_extend.rs:32:5 | LL | s.extend(abc[0..2].chars()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(&abc[0..2])` diff --git a/tests/ui/string_from_utf8_as_bytes.stderr b/tests/ui/string_from_utf8_as_bytes.stderr index 4738bef3ae9ea..99c8d8ae4eabc 100644 --- a/tests/ui/string_from_utf8_as_bytes.stderr +++ b/tests/ui/string_from_utf8_as_bytes.stderr @@ -1,5 +1,5 @@ error: calling a slice of `as_bytes()` with `from_utf8` should be not necessary - --> $DIR/string_from_utf8_as_bytes.rs:4:13 + --> tests/ui/string_from_utf8_as_bytes.rs:4:13 | LL | let _ = std::str::from_utf8(&"Hello World!".as_bytes()[6..11]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(&"Hello World!"[6..11])` diff --git a/tests/ui/string_lit_as_bytes.stderr b/tests/ui/string_lit_as_bytes.stderr index 1c12cb8e56d28..66b3e6f9462db 100644 --- a/tests/ui/string_lit_as_bytes.stderr +++ b/tests/ui/string_lit_as_bytes.stderr @@ -1,5 +1,5 @@ error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:16:14 + --> tests/ui/string_lit_as_bytes.rs:16:14 | LL | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` @@ -8,25 +8,25 @@ LL | let bs = "hello there".as_bytes(); = help: to override `-D warnings` add `#[allow(clippy::string_lit_as_bytes)]` error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:18:14 + --> tests/ui/string_lit_as_bytes.rs:18:14 | LL | let bs = r###"raw string with 3# plus " ""###.as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `br###"raw string with 3# plus " ""###` error: calling `into_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:20:14 + --> tests/ui/string_lit_as_bytes.rs:20:14 | LL | let bs = "lit to string".to_string().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to string".to_vec()` error: calling `into_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:21:14 + --> tests/ui/string_lit_as_bytes.rs:21:14 | LL | let bs = "lit to owned".to_owned().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to owned".to_vec()` error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:11:26 + --> tests/ui/string_lit_as_bytes.rs:11:26 | LL | const B: &[u8] = $b.as_bytes(); | ^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"warning"` @@ -37,13 +37,13 @@ LL | b!("warning"); = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) error: calling `as_bytes()` on `include_str!(..)` - --> $DIR/string_lit_as_bytes.rs:38:22 + --> tests/ui/string_lit_as_bytes.rs:38:22 | LL | let includestr = include_str!("string_lit_as_bytes.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("string_lit_as_bytes.rs")` error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:40:13 + --> tests/ui/string_lit_as_bytes.rs:40:13 | LL | let _ = "string with newline\t\n".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"string with newline\t\n"` diff --git a/tests/ui/string_lit_chars_any.stderr b/tests/ui/string_lit_chars_any.stderr index 09c4f02eb062c..4d3ca98e62371 100644 --- a/tests/ui/string_lit_chars_any.stderr +++ b/tests/ui/string_lit_chars_any.stderr @@ -1,5 +1,5 @@ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:18:5 + --> tests/ui/string_lit_chars_any.rs:18:5 | LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:19:5 + --> tests/ui/string_lit_chars_any.rs:19:5 | LL | r#"\.+*?()|[]{}^$#&-~"#.chars().any(|x| x == c); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:20:5 + --> tests/ui/string_lit_chars_any.rs:20:5 | LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| c == x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:21:5 + --> tests/ui/string_lit_chars_any.rs:21:5 | LL | r#"\.+*?()|[]{}^$#&-~"#.chars().any(|x| c == x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:23:5 + --> tests/ui/string_lit_chars_any.rs:23:5 | LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| { x == c }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/string_slice.stderr b/tests/ui/string_slice.stderr index e9e773aaf3ae3..7a4596b5f2d25 100644 --- a/tests/ui/string_slice.stderr +++ b/tests/ui/string_slice.stderr @@ -1,5 +1,5 @@ error: indexing into a string may panic if the index is within a UTF-8 character - --> $DIR/string_slice.rs:5:6 + --> tests/ui/string_slice.rs:5:6 | LL | &"Ölkanne"[1..]; | ^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | &"Ölkanne"[1..]; = help: to override `-D warnings` add `#[allow(clippy::string_slice)]` error: indexing into a string may panic if the index is within a UTF-8 character - --> $DIR/string_slice.rs:9:6 + --> tests/ui/string_slice.rs:9:6 | LL | &m[2..5]; | ^^^^^^^ error: indexing into a string may panic if the index is within a UTF-8 character - --> $DIR/string_slice.rs:12:6 + --> tests/ui/string_slice.rs:12:6 | LL | &s[0..2]; | ^^^^^^^ diff --git a/tests/ui/string_to_string.stderr b/tests/ui/string_to_string.stderr index f1f8e176bc57d..ae80597d1f841 100644 --- a/tests/ui/string_to_string.stderr +++ b/tests/ui/string_to_string.stderr @@ -1,5 +1,5 @@ error: `to_string()` called on a `String` - --> $DIR/string_to_string.rs:6:17 + --> tests/ui/string_to_string.rs:6:17 | LL | let mut v = message.to_string(); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/strlen_on_c_strings.stderr b/tests/ui/strlen_on_c_strings.stderr index 6d8ad3981c04b..8c2a7692659c4 100644 --- a/tests/ui/strlen_on_c_strings.stderr +++ b/tests/ui/strlen_on_c_strings.stderr @@ -1,5 +1,5 @@ error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:13:13 + --> tests/ui/strlen_on_c_strings.rs:13:13 | LL | let _ = unsafe { libc::strlen(cstring.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstring.as_bytes().len()` @@ -8,37 +8,37 @@ LL | let _ = unsafe { libc::strlen(cstring.as_ptr()) }; = help: to override `-D warnings` add `#[allow(clippy::strlen_on_c_strings)]` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:17:13 + --> tests/ui/strlen_on_c_strings.rs:17:13 | LL | let _ = unsafe { libc::strlen(cstr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstr.to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:19:13 + --> tests/ui/strlen_on_c_strings.rs:19:13 | LL | let _ = unsafe { strlen(cstr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstr.to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:22:22 + --> tests/ui/strlen_on_c_strings.rs:22:22 | LL | let _ = unsafe { strlen((*pcstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*pcstr).to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:27:22 + --> tests/ui/strlen_on_c_strings.rs:27:22 | LL | let _ = unsafe { strlen(unsafe_identity(cstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unsafe_identity(cstr).to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:28:13 + --> tests/ui/strlen_on_c_strings.rs:28:13 | LL | let _ = unsafe { strlen(unsafe { unsafe_identity(cstr) }.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unsafe { unsafe_identity(cstr) }.to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:31:22 + --> tests/ui/strlen_on_c_strings.rs:31:22 | LL | let _ = unsafe { strlen(f(cstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `f(cstr).to_bytes().len()` diff --git a/tests/ui/struct_excessive_bools.stderr b/tests/ui/struct_excessive_bools.stderr index 5284949c2d2aa..bdf6f0b7a1dae 100644 --- a/tests/ui/struct_excessive_bools.stderr +++ b/tests/ui/struct_excessive_bools.stderr @@ -1,5 +1,5 @@ error: more than 3 bools in a struct - --> $DIR/struct_excessive_bools.rs:22:1 + --> tests/ui/struct_excessive_bools.rs:22:1 | LL | / struct BadFoo { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::struct_excessive_bools)]` error: more than 3 bools in a struct - --> $DIR/struct_excessive_bools.rs:39:5 + --> tests/ui/struct_excessive_bools.rs:39:5 | LL | / struct FooFoo { LL | | diff --git a/tests/ui/struct_fields.stderr b/tests/ui/struct_fields.stderr index d2bdbd17d5cc5..3358c20f74d47 100644 --- a/tests/ui/struct_fields.stderr +++ b/tests/ui/struct_fields.stderr @@ -1,5 +1,5 @@ error: field name ends with the struct's name - --> $DIR/struct_fields.rs:10:5 + --> tests/ui/struct_fields.rs:10:5 | LL | field_data1: u8, | ^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | field_data1: u8, = help: to override `-D warnings` add `#[allow(clippy::struct_field_names)]` error: field name starts with the struct's name - --> $DIR/struct_fields.rs:20:5 + --> tests/ui/struct_fields.rs:20:5 | LL | data2_field: u8, | ^^^^^^^^^^^^^^^ error: all fields have the same postfix: `data` - --> $DIR/struct_fields.rs:25:1 + --> tests/ui/struct_fields.rs:25:1 | LL | / struct StructData { LL | | @@ -27,7 +27,7 @@ LL | | } = help: remove the postfixes error: all fields have the same prefix: `data` - --> $DIR/struct_fields.rs:32:1 + --> tests/ui/struct_fields.rs:32:1 | LL | / struct DataStruct { LL | | @@ -40,7 +40,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `some_data` - --> $DIR/struct_fields.rs:39:1 + --> tests/ui/struct_fields.rs:39:1 | LL | / struct DoublePrefix { LL | | @@ -53,7 +53,7 @@ LL | | } = help: remove the prefixes error: all fields have the same postfix: `some_data` - --> $DIR/struct_fields.rs:46:1 + --> tests/ui/struct_fields.rs:46:1 | LL | / struct DoublePostfix { LL | | @@ -66,7 +66,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `someData` - --> $DIR/struct_fields.rs:54:1 + --> tests/ui/struct_fields.rs:54:1 | LL | / struct NotSnakeCase { LL | | @@ -79,7 +79,7 @@ LL | | } = help: remove the postfixes error: all fields have the same prefix: `someData` - --> $DIR/struct_fields.rs:61:1 + --> tests/ui/struct_fields.rs:61:1 | LL | / struct NotSnakeCase2 { LL | | @@ -92,7 +92,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `prefix` - --> $DIR/struct_fields.rs:74:1 + --> tests/ui/struct_fields.rs:74:1 | LL | / struct NonCaps { LL | | @@ -105,7 +105,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `_type` - --> $DIR/struct_fields.rs:124:5 + --> tests/ui/struct_fields.rs:124:5 | LL | / struct DoLint { LL | | @@ -119,7 +119,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `__type` - --> $DIR/struct_fields.rs:132:5 + --> tests/ui/struct_fields.rs:132:5 | LL | / struct DoLint2 { LL | | @@ -133,7 +133,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `___type` - --> $DIR/struct_fields.rs:140:5 + --> tests/ui/struct_fields.rs:140:5 | LL | / struct DoLint3 { LL | | @@ -147,7 +147,7 @@ LL | | } = help: remove the prefixes error: all fields have the same postfix: `_` - --> $DIR/struct_fields.rs:148:5 + --> tests/ui/struct_fields.rs:148:5 | LL | / struct DoLint4 { LL | | @@ -161,7 +161,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `__` - --> $DIR/struct_fields.rs:156:5 + --> tests/ui/struct_fields.rs:156:5 | LL | / struct DoLint5 { LL | | @@ -175,7 +175,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `___` - --> $DIR/struct_fields.rs:164:5 + --> tests/ui/struct_fields.rs:164:5 | LL | / struct DoLint6 { LL | | @@ -189,7 +189,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `type` - --> $DIR/struct_fields.rs:172:5 + --> tests/ui/struct_fields.rs:172:5 | LL | / struct DoLintToo { LL | | @@ -202,13 +202,13 @@ LL | | } = help: remove the postfixes error: field name starts with the struct's name - --> $DIR/struct_fields.rs:210:5 + --> tests/ui/struct_fields.rs:210:5 | LL | proxy: i32, | ^^^^^^^^^^ error: all fields have the same prefix: `some` - --> $DIR/struct_fields.rs:226:13 + --> tests/ui/struct_fields.rs:226:13 | LL | / struct MacroStruct { LL | | some_a: i32, @@ -224,7 +224,7 @@ LL | mk_struct!(); = note: this error originates in the macro `mk_struct` (in Nightly builds, run with -Z macro-backtrace for more info) error: field name starts with the struct's name - --> $DIR/struct_fields.rs:239:17 + --> tests/ui/struct_fields.rs:239:17 | LL | macrobaz_a: i32, | ^^^^^^^^^^^^^^^ @@ -235,7 +235,7 @@ LL | mk_struct2!(); = note: this error originates in the macro `mk_struct2` (in Nightly builds, run with -Z macro-backtrace for more info) error: field name starts with the struct's name - --> $DIR/struct_fields.rs:251:17 + --> tests/ui/struct_fields.rs:251:17 | LL | $field: i32, | ^^^^^^^^^^^ @@ -246,7 +246,7 @@ LL | mk_struct_with_names!(Foo, foo); = note: this error originates in the macro `mk_struct_with_names` (in Nightly builds, run with -Z macro-backtrace for more info) error: all fields have the same prefix: `some` - --> $DIR/struct_fields.rs:291:13 + --> tests/ui/struct_fields.rs:291:13 | LL | / struct $struct_name { LL | | $field1: i32, @@ -262,19 +262,19 @@ LL | mk_struct_full_def!(PrefixData, some_data, some_meta, some_other); = note: this error originates in the macro `mk_struct_full_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: field name starts with the struct's name - --> $DIR/struct_fields.rs:339:5 + --> tests/ui/struct_fields.rs:339:5 | LL | use_foo: bool, | ^^^^^^^^^^^^^ error: field name starts with the struct's name - --> $DIR/struct_fields.rs:341:5 + --> tests/ui/struct_fields.rs:341:5 | LL | use_bar: bool, | ^^^^^^^^^^^^^ error: field name starts with the struct's name - --> $DIR/struct_fields.rs:342:5 + --> tests/ui/struct_fields.rs:342:5 | LL | use_baz: bool, | ^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 3995c6eb5c4ee..193cd64149b1f 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,5 +1,5 @@ error: suspicious use of `-` in `Add` impl - --> $DIR/suspicious_arithmetic_impl.rs:13:20 + --> tests/ui/suspicious_arithmetic_impl.rs:13:20 | LL | Foo(self.0 - other.0) | ^ @@ -8,7 +8,7 @@ LL | Foo(self.0 - other.0) = help: to override `-D warnings` add `#[allow(clippy::suspicious_arithmetic_impl)]` error: suspicious use of `-` in `AddAssign` impl - --> $DIR/suspicious_arithmetic_impl.rs:21:23 + --> tests/ui/suspicious_arithmetic_impl.rs:21:23 | LL | *self = *self - other; | ^ @@ -17,43 +17,43 @@ LL | *self = *self - other; = help: to override `-D warnings` add `#[allow(clippy::suspicious_op_assign_impl)]` error: suspicious use of `/` in `MulAssign` impl - --> $DIR/suspicious_arithmetic_impl.rs:36:16 + --> tests/ui/suspicious_arithmetic_impl.rs:36:16 | LL | self.0 /= other.0; | ^^ error: suspicious use of `/` in `Rem` impl - --> $DIR/suspicious_arithmetic_impl.rs:75:20 + --> tests/ui/suspicious_arithmetic_impl.rs:75:20 | LL | Foo(self.0 / other.0) | ^ error: suspicious use of `|` in `BitAnd` impl - --> $DIR/suspicious_arithmetic_impl.rs:84:20 + --> tests/ui/suspicious_arithmetic_impl.rs:84:20 | LL | Foo(self.0 | other.0) | ^ error: suspicious use of `^` in `BitOr` impl - --> $DIR/suspicious_arithmetic_impl.rs:93:20 + --> tests/ui/suspicious_arithmetic_impl.rs:93:20 | LL | Foo(self.0 ^ other.0) | ^ error: suspicious use of `&` in `BitXor` impl - --> $DIR/suspicious_arithmetic_impl.rs:102:20 + --> tests/ui/suspicious_arithmetic_impl.rs:102:20 | LL | Foo(self.0 & other.0) | ^ error: suspicious use of `>>` in `Shl` impl - --> $DIR/suspicious_arithmetic_impl.rs:111:20 + --> tests/ui/suspicious_arithmetic_impl.rs:111:20 | LL | Foo(self.0 >> other.0) | ^^ error: suspicious use of `<<` in `Shr` impl - --> $DIR/suspicious_arithmetic_impl.rs:120:20 + --> tests/ui/suspicious_arithmetic_impl.rs:120:20 | LL | Foo(self.0 << other.0) | ^^ diff --git a/tests/ui/suspicious_command_arg_space.stderr b/tests/ui/suspicious_command_arg_space.stderr index 9bf3128cb8e26..d2517b66b5661 100644 --- a/tests/ui/suspicious_command_arg_space.stderr +++ b/tests/ui/suspicious_command_arg_space.stderr @@ -1,5 +1,5 @@ error: single argument that looks like it should be multiple arguments - --> $DIR/suspicious_command_arg_space.rs:3:44 + --> tests/ui/suspicious_command_arg_space.rs:3:44 | LL | std::process::Command::new("echo").arg("-n hello").spawn().unwrap(); | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap | ~~~~ ~~~~~~~~~~~~~~~ error: single argument that looks like it should be multiple arguments - --> $DIR/suspicious_command_arg_space.rs:6:43 + --> tests/ui/suspicious_command_arg_space.rs:6:43 | LL | std::process::Command::new("cat").arg("--number file").spawn().unwrap(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_doc_comments.stderr b/tests/ui/suspicious_doc_comments.stderr index 1b238f501e13a..b54309b44d5d8 100644 --- a/tests/ui/suspicious_doc_comments.stderr +++ b/tests/ui/suspicious_doc_comments.stderr @@ -1,5 +1,5 @@ error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:5:1 + --> tests/ui/suspicious_doc_comments.rs:5:1 | LL | ///! Fake module documentation. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | //! Fake module documentation. | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:9:5 + --> tests/ui/suspicious_doc_comments.rs:9:5 | LL | ///! This module contains useful functions. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | //! This module contains useful functions. | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:21:5 + --> tests/ui/suspicious_doc_comments.rs:21:5 | LL | / /**! This module contains useful functions. LL | | */ @@ -36,7 +36,7 @@ LL + */ | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:35:5 + --> tests/ui/suspicious_doc_comments.rs:35:5 | LL | / ///! This module LL | | ///! contains @@ -51,7 +51,7 @@ LL ~ //! useful functions. | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:43:5 + --> tests/ui/suspicious_doc_comments.rs:43:5 | LL | / ///! a LL | | ///! b @@ -64,7 +64,7 @@ LL ~ //! b | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:51:5 + --> tests/ui/suspicious_doc_comments.rs:51:5 | LL | ///! a | ^^^^^^ @@ -75,7 +75,7 @@ LL | //! a | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:57:5 + --> tests/ui/suspicious_doc_comments.rs:57:5 | LL | / ///! a LL | | @@ -90,7 +90,7 @@ LL ~ //! b | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:69:5 + --> tests/ui/suspicious_doc_comments.rs:69:5 | LL | ///! Very cool macro | ^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | //! Very cool macro | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:76:5 + --> tests/ui/suspicious_doc_comments.rs:76:5 | LL | ///! Huh. | ^^^^^^^^^ diff --git a/tests/ui/suspicious_doc_comments_unfixable.stderr b/tests/ui/suspicious_doc_comments_unfixable.stderr index ae92c334f6092..d15f16f7c5032 100644 --- a/tests/ui/suspicious_doc_comments_unfixable.stderr +++ b/tests/ui/suspicious_doc_comments_unfixable.stderr @@ -1,5 +1,5 @@ error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments_unfixable.rs:4:1 + --> tests/ui/suspicious_doc_comments_unfixable.rs:4:1 | LL | / ///! a LL | | @@ -22,7 +22,7 @@ LL + //! d | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments_unfixable.rs:12:1 + --> tests/ui/suspicious_doc_comments_unfixable.rs:12:1 | LL | / ///! a LL | | diff --git a/tests/ui/suspicious_else_formatting.stderr b/tests/ui/suspicious_else_formatting.stderr index 95047cb95ee13..28c5a2d904ce2 100644 --- a/tests/ui/suspicious_else_formatting.stderr +++ b/tests/ui/suspicious_else_formatting.stderr @@ -1,5 +1,5 @@ error: this looks like an `else {..}` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:22:6 + --> tests/ui/suspicious_else_formatting.rs:22:6 | LL | } { | ^ @@ -9,7 +9,7 @@ LL | } { = help: to override `-D warnings` add `#[allow(clippy::suspicious_else_formatting)]` error: this looks like an `else if` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:26:6 + --> tests/ui/suspicious_else_formatting.rs:26:6 | LL | } if foo() { | ^ @@ -17,7 +17,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:33:10 + --> tests/ui/suspicious_else_formatting.rs:33:10 | LL | } if foo() { | ^ @@ -25,7 +25,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:41:10 + --> tests/ui/suspicious_else_formatting.rs:41:10 | LL | } if foo() { | ^ @@ -33,7 +33,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:50:6 + --> tests/ui/suspicious_else_formatting.rs:50:6 | LL | } else | ______^ @@ -43,7 +43,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else if` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:62:6 + --> tests/ui/suspicious_else_formatting.rs:62:6 | LL | } else | ______^ @@ -53,7 +53,7 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else if` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:67:6 + --> tests/ui/suspicious_else_formatting.rs:67:6 | LL | } | ______^ @@ -64,7 +64,7 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:94:6 + --> tests/ui/suspicious_else_formatting.rs:94:6 | LL | } | ______^ @@ -76,7 +76,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:102:6 + --> tests/ui/suspicious_else_formatting.rs:102:6 | LL | } | ______^ diff --git a/tests/ui/suspicious_map.stderr b/tests/ui/suspicious_map.stderr index 9c065e05ca6f6..2a5e2bf2a3467 100644 --- a/tests/ui/suspicious_map.stderr +++ b/tests/ui/suspicious_map.stderr @@ -1,5 +1,5 @@ error: this call to `map()` won't have an effect on the call to `count()` - --> $DIR/suspicious_map.rs:4:13 + --> tests/ui/suspicious_map.rs:4:13 | LL | let _ = (0..3).map(|x| x + 2).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = (0..3).map(|x| x + 2).count(); = help: to override `-D warnings` add `#[allow(clippy::suspicious_map)]` error: this call to `map()` won't have an effect on the call to `count()` - --> $DIR/suspicious_map.rs:8:13 + --> tests/ui/suspicious_map.rs:8:13 | LL | let _ = (0..3).map(f).count(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_operation_groupings.stderr b/tests/ui/suspicious_operation_groupings.stderr index 0784da06e5f58..9d1d8a1f34f55 100644 --- a/tests/ui/suspicious_operation_groupings.stderr +++ b/tests/ui/suspicious_operation_groupings.stderr @@ -1,5 +1,5 @@ error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:15:9 + --> tests/ui/suspicious_operation_groupings.rs:15:9 | LL | self.x == other.y && self.y == other.y && self.z == other.z | ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x` @@ -8,151 +8,151 @@ LL | self.x == other.y && self.y == other.y && self.z == other.z = help: to override `-D warnings` add `#[allow(clippy::suspicious_operation_groupings)]` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:28:20 + --> tests/ui/suspicious_operation_groupings.rs:28:20 | LL | s1.a < s2.a && s1.a < s2.b | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:76:33 + --> tests/ui/suspicious_operation_groupings.rs:76:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:81:19 + --> tests/ui/suspicious_operation_groupings.rs:81:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:81:19 + --> tests/ui/suspicious_operation_groupings.rs:81:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:86:19 + --> tests/ui/suspicious_operation_groupings.rs:86:19 | LL | s1.a * s2.a + s2.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:91:19 + --> tests/ui/suspicious_operation_groupings.rs:91:19 | LL | s1.a * s2.a + s1.b * s1.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:96:5 + --> tests/ui/suspicious_operation_groupings.rs:96:5 | LL | s1.a * s1.a + s1.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.a * s2.a` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:101:33 + --> tests/ui/suspicious_operation_groupings.rs:101:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s1.c | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:114:20 + --> tests/ui/suspicious_operation_groupings.rs:114:20 | LL | (s1.a * s2.a + s1.b * s1.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:119:34 + --> tests/ui/suspicious_operation_groupings.rs:119:34 | LL | (s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:124:38 + --> tests/ui/suspicious_operation_groupings.rs:124:38 | LL | (s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:129:39 + --> tests/ui/suspicious_operation_groupings.rs:129:39 | LL | ((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:134:42 + --> tests/ui/suspicious_operation_groupings.rs:134:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:134:42 + --> tests/ui/suspicious_operation_groupings.rs:134:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:139:40 + --> tests/ui/suspicious_operation_groupings.rs:139:40 | LL | (((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b)) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:144:40 + --> tests/ui/suspicious_operation_groupings.rs:144:40 | LL | ((s1.a * s2.a) + ((s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:149:20 + --> tests/ui/suspicious_operation_groupings.rs:149:20 | LL | (s1.a * s2.a + s2.b * s2.b) / 2 | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:154:35 + --> tests/ui/suspicious_operation_groupings.rs:154:35 | LL | i32::swap_bytes(s1.a * s2.a + s2.b * s2.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:159:29 + --> tests/ui/suspicious_operation_groupings.rs:159:29 | LL | s1.a > 0 && s1.b > 0 && s1.d == s2.c && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:164:17 + --> tests/ui/suspicious_operation_groupings.rs:164:17 | LL | s1.a > 0 && s1.d == s2.c && s1.b > 0 && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:173:77 + --> tests/ui/suspicious_operation_groupings.rs:173:77 | LL | (n1.inner.0).0 == (n2.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.1).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `(n1.inner.2).0 == (n2.inner.2).0` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:187:25 + --> tests/ui/suspicious_operation_groupings.rs:187:25 | LL | s1.a <= s2.a && s1.a <= s2.b | ^^^^^^^^^^^^ help: did you mean: `s1.b <= s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:193:23 + --> tests/ui/suspicious_operation_groupings.rs:193:23 | LL | if s1.a < s2.a && s1.a < s2.b { | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:200:48 + --> tests/ui/suspicious_operation_groupings.rs:200:48 | LL | -(-(-s1.a * -s2.a) + (-(-s1.b * -s2.b) + -(-s1.c * -s2.b) + -(-s1.d * -s2.d))) | ^^^^^^^^^^^^^ help: did you mean: `-s1.c * -s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:205:27 + --> tests/ui/suspicious_operation_groupings.rs:205:27 | LL | -(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a }) | ^^^^^^^^^^^^^ help: did you mean: `-s1.b < -s2.b` diff --git a/tests/ui/suspicious_splitn.stderr b/tests/ui/suspicious_splitn.stderr index 4513beac8b2de..6e05bc28d130e 100644 --- a/tests/ui/suspicious_splitn.stderr +++ b/tests/ui/suspicious_splitn.stderr @@ -1,5 +1,5 @@ error: `splitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:10:13 + --> tests/ui/suspicious_splitn.rs:10:13 | LL | let _ = "a,b".splitn(0, ','); | ^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = "a,b".splitn(0, ','); = help: to override `-D warnings` add `#[allow(clippy::suspicious_splitn)]` error: `rsplitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:13:13 + --> tests/ui/suspicious_splitn.rs:13:13 | LL | let _ = "a,b".rsplitn(0, ','); | ^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = "a,b".rsplitn(0, ','); = note: the resulting iterator will always return `None` error: `splitn` called with `1` split - --> $DIR/suspicious_splitn.rs:16:13 + --> tests/ui/suspicious_splitn.rs:16:13 | LL | let _ = "a,b".splitn(1, ','); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = "a,b".splitn(1, ','); = note: the resulting iterator will always return the entire string followed by `None` error: `splitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:19:13 + --> tests/ui/suspicious_splitn.rs:19:13 | LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); = note: the resulting iterator will always return `None` error: `splitn_mut` called with `0` splits - --> $DIR/suspicious_splitn.rs:22:13 + --> tests/ui/suspicious_splitn.rs:22:13 | LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); = note: the resulting iterator will always return `None` error: `splitn` called with `1` split - --> $DIR/suspicious_splitn.rs:25:13 + --> tests/ui/suspicious_splitn.rs:25:13 | LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); = note: the resulting iterator will always return the entire slice followed by `None` error: `rsplitn_mut` called with `1` split - --> $DIR/suspicious_splitn.rs:28:13 + --> tests/ui/suspicious_splitn.rs:28:13 | LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); = note: the resulting iterator will always return the entire slice followed by `None` error: `splitn` called with `1` split - --> $DIR/suspicious_splitn.rs:33:13 + --> tests/ui/suspicious_splitn.rs:33:13 | LL | let _ = "a,b".splitn(X + 1, ','); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = "a,b".splitn(X + 1, ','); = note: the resulting iterator will always return the entire string followed by `None` error: `splitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:36:13 + --> tests/ui/suspicious_splitn.rs:36:13 | LL | let _ = "a,b".splitn(X, ','); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_to_owned.stderr b/tests/ui/suspicious_to_owned.stderr index eb967a714d949..255f211e65509 100644 --- a/tests/ui/suspicious_to_owned.stderr +++ b/tests/ui/suspicious_to_owned.stderr @@ -1,5 +1,5 @@ error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned - --> $DIR/suspicious_to_owned.rs:17:13 + --> tests/ui/suspicious_to_owned.rs:17:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, [char; 3]> itself and does not cause the Cow<'_, [char; 3]> contents to become owned - --> $DIR/suspicious_to_owned.rs:29:13 + --> tests/ui/suspicious_to_owned.rs:29:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, Vec> itself and does not cause the Cow<'_, Vec> contents to become owned - --> $DIR/suspicious_to_owned.rs:40:13 + --> tests/ui/suspicious_to_owned.rs:40:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned - --> $DIR/suspicious_to_owned.rs:51:13 + --> tests/ui/suspicious_to_owned.rs:51:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type - --> $DIR/suspicious_to_owned.rs:66:13 + --> tests/ui/suspicious_to_owned.rs:66:13 | LL | let _ = String::from(moo).to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::from(moo).clone()` @@ -70,7 +70,7 @@ LL | let _ = String::from(moo).to_owned(); = help: to override `-D warnings` add `#[allow(clippy::implicit_clone)]` error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type - --> $DIR/suspicious_to_owned.rs:69:13 + --> tests/ui/suspicious_to_owned.rs:69:13 | LL | let _ = moos_vec.to_owned(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `moos_vec.clone()` diff --git a/tests/ui/suspicious_unary_op_formatting.stderr b/tests/ui/suspicious_unary_op_formatting.stderr index 3cddde4eca7b9..379fb17266a96 100644 --- a/tests/ui/suspicious_unary_op_formatting.stderr +++ b/tests/ui/suspicious_unary_op_formatting.stderr @@ -1,5 +1,5 @@ error: by not having a space between `>` and `-` it looks like `>-` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:9:9 + --> tests/ui/suspicious_unary_op_formatting.rs:9:9 | LL | if a >- 30 {} | ^^^^ @@ -9,7 +9,7 @@ LL | if a >- 30 {} = help: to override `-D warnings` add `#[allow(clippy::suspicious_unary_op_formatting)]` error: by not having a space between `>=` and `-` it looks like `>=-` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:11:9 + --> tests/ui/suspicious_unary_op_formatting.rs:11:9 | LL | if a >=- 30 {} | ^^^^^ @@ -17,7 +17,7 @@ LL | if a >=- 30 {} = help: put a space between `>=` and `-` and remove the space after `-` error: by not having a space between `&&` and `!` it looks like `&&!` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:17:9 + --> tests/ui/suspicious_unary_op_formatting.rs:17:9 | LL | if b &&! c {} | ^^^^^ @@ -25,7 +25,7 @@ LL | if b &&! c {} = help: put a space between `&&` and `!` and remove the space after `!` error: by not having a space between `>` and `-` it looks like `>-` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:20:9 + --> tests/ui/suspicious_unary_op_formatting.rs:20:9 | LL | if a >- 30 {} | ^^^^^^ diff --git a/tests/ui/suspicious_xor_used_as_pow.stderr b/tests/ui/suspicious_xor_used_as_pow.stderr index 29e9fa771019e..4faf0237c17ad 100644 --- a/tests/ui/suspicious_xor_used_as_pow.stderr +++ b/tests/ui/suspicious_xor_used_as_pow.stderr @@ -1,5 +1,5 @@ error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:19:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:19:13 | LL | let _ = 2 ^ 5; | ^^^^^ help: did you mean to write: `2.pow(5)` @@ -8,37 +8,37 @@ LL | let _ = 2 ^ 5; = help: to override `-D warnings` add `#[allow(clippy::suspicious_xor_used_as_pow)]` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:22:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:22:13 | LL | let _ = 2i32 ^ 9i32; | ^^^^^^^^^^^ help: did you mean to write: `2i32.pow(9i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:24:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:24:13 | LL | let _ = 2i32 ^ 2i32; | ^^^^^^^^^^^ help: did you mean to write: `2i32.pow(2i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:26:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:26:13 | LL | let _ = 50i32 ^ 3i32; | ^^^^^^^^^^^^ help: did you mean to write: `50i32.pow(3i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:28:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:28:13 | LL | let _ = 5i32 ^ 8i32; | ^^^^^^^^^^^ help: did you mean to write: `5i32.pow(8i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:30:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:30:13 | LL | let _ = 2i32 ^ 32i32; | ^^^^^^^^^^^^ help: did you mean to write: `2i32.pow(32i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:13:9 + --> tests/ui/suspicious_xor_used_as_pow.rs:13:9 | LL | 1 ^ 2 // should warn even if inside macro | ^^^^^ help: did you mean to write: `1.pow(2)` diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index e69ad02b08fe1..fad356782479b 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are swapping `bar.a` and `bar.b` manually - --> $DIR/swap.rs:28:5 + --> tests/ui/swap.rs:28:5 | LL | / let temp = bar.a; LL | | bar.a = bar.b; @@ -11,7 +11,7 @@ LL | | bar.b = temp; = help: to override `-D warnings` add `#[allow(clippy::manual_swap)]` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:40:5 + --> tests/ui/swap.rs:40:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -19,7 +19,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:49:5 + --> tests/ui/swap.rs:49:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -27,7 +27,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:68:5 + --> tests/ui/swap.rs:68:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -35,7 +35,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:79:5 + --> tests/ui/swap.rs:79:5 | LL | / a ^= b; LL | | b ^= a; @@ -43,7 +43,7 @@ LL | | a ^= b; | |___________^ help: try: `std::mem::swap(&mut a, &mut b);` error: this looks like you are swapping `bar.a` and `bar.b` manually - --> $DIR/swap.rs:87:5 + --> tests/ui/swap.rs:87:5 | LL | / bar.a ^= bar.b; LL | | bar.b ^= bar.a; @@ -51,7 +51,7 @@ LL | | bar.a ^= bar.b; | |___________________^ help: try: `std::mem::swap(&mut bar.a, &mut bar.b);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:95:5 + --> tests/ui/swap.rs:95:5 | LL | / foo[0] ^= foo[1]; LL | | foo[1] ^= foo[0]; @@ -59,7 +59,7 @@ LL | | foo[0] ^= foo[1]; | |_____________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping `foo[0][1]` and `bar[1][0]` manually - --> $DIR/swap.rs:124:5 + --> tests/ui/swap.rs:124:5 | LL | / let temp = foo[0][1]; LL | | foo[0][1] = bar[1][0]; @@ -69,7 +69,7 @@ LL | | bar[1][0] = temp; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:138:7 + --> tests/ui/swap.rs:138:7 | LL | ; let t = a; | _______^ @@ -80,7 +80,7 @@ LL | | b = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:147:7 + --> tests/ui/swap.rs:147:7 | LL | ; let t = c.0; | _______^ @@ -91,7 +91,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `b` and `a` manually - --> $DIR/swap.rs:173:5 + --> tests/ui/swap.rs:173:5 | LL | / let t = b; LL | | b = a; @@ -101,7 +101,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:135:5 + --> tests/ui/swap.rs:135:5 | LL | / a = b; LL | | b = a; @@ -112,7 +112,7 @@ LL | | b = a; = help: to override `-D warnings` add `#[allow(clippy::almost_swapped)]` error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:144:5 + --> tests/ui/swap.rs:144:5 | LL | / c.0 = a; LL | | a = c.0; @@ -121,7 +121,7 @@ LL | | a = c.0; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:151:5 + --> tests/ui/swap.rs:151:5 | LL | / let a = b; LL | | let b = a; @@ -130,7 +130,7 @@ LL | | let b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `d` and `c` - --> $DIR/swap.rs:156:5 + --> tests/ui/swap.rs:156:5 | LL | / d = c; LL | | c = d; @@ -139,7 +139,7 @@ LL | | c = d; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:160:5 + --> tests/ui/swap.rs:160:5 | LL | / let a = b; LL | | b = a; @@ -148,7 +148,7 @@ LL | | b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `s.0.x` and `s.0.y` manually - --> $DIR/swap.rs:208:5 + --> tests/ui/swap.rs:208:5 | LL | / let t = s.0.x; LL | | s.0.x = s.0.y; diff --git a/tests/ui/swap_ptr_to_ref.stderr b/tests/ui/swap_ptr_to_ref.stderr index 42455f4926e89..019c2f91f0e9e 100644 --- a/tests/ui/swap_ptr_to_ref.stderr +++ b/tests/ui/swap_ptr_to_ref.stderr @@ -1,5 +1,5 @@ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:11:9 + --> tests/ui/swap_ptr_to_ref.rs:11:9 | LL | core::mem::swap(&mut *y, &mut *z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, z)` @@ -8,19 +8,19 @@ LL | core::mem::swap(&mut *y, &mut *z); = help: to override `-D warnings` add `#[allow(clippy::swap_ptr_to_ref)]` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:12:9 + --> tests/ui/swap_ptr_to_ref.rs:12:9 | LL | core::mem::swap(&mut *y, &mut x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, &mut x)` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:13:9 + --> tests/ui/swap_ptr_to_ref.rs:13:9 | LL | core::mem::swap(&mut x, &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(&mut x, y)` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:14:9 + --> tests/ui/swap_ptr_to_ref.rs:14:9 | LL | core::mem::swap(&mut *addr_of_mut!(x), &mut *addr_of_mut!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(addr_of_mut!(x), addr_of_mut!(x))` diff --git a/tests/ui/swap_ptr_to_ref_unfixable.stderr b/tests/ui/swap_ptr_to_ref_unfixable.stderr index ce1d7814250a7..8a0352049483e 100644 --- a/tests/ui/swap_ptr_to_ref_unfixable.stderr +++ b/tests/ui/swap_ptr_to_ref_unfixable.stderr @@ -1,5 +1,5 @@ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref_unfixable.rs:14:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:14:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); = help: to override `-D warnings` add `#[allow(clippy::swap_ptr_to_ref)]` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref_unfixable.rs:17:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:17:9 | LL | core::mem::swap(&mut *y, addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref_unfixable.rs:19:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:19:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/tabs_in_doc_comments.stderr b/tests/ui/tabs_in_doc_comments.stderr index 69ce214ae565b..23d5dcd3a8dab 100644 --- a/tests/ui/tabs_in_doc_comments.stderr +++ b/tests/ui/tabs_in_doc_comments.stderr @@ -1,5 +1,5 @@ error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:10:9 + --> tests/ui/tabs_in_doc_comments.rs:10:9 | LL | /// - First String: | ^^^^ help: consider using four spaces per tab @@ -8,43 +8,43 @@ LL | /// - First String: = help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]` error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:11:9 + --> tests/ui/tabs_in_doc_comments.rs:11:9 | LL | /// - needs to be inside here | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:14:9 + --> tests/ui/tabs_in_doc_comments.rs:14:9 | LL | /// - Second String: | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:15:9 + --> tests/ui/tabs_in_doc_comments.rs:15:9 | LL | /// - needs to be inside here | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:6:5 + --> tests/ui/tabs_in_doc_comments.rs:6:5 | LL | /// - first one | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:6:13 + --> tests/ui/tabs_in_doc_comments.rs:6:13 | LL | /// - first one | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:7:5 + --> tests/ui/tabs_in_doc_comments.rs:7:5 | LL | /// - second one | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:7:14 + --> tests/ui/tabs_in_doc_comments.rs:7:14 | LL | /// - second one | ^^^^ help: consider using four spaces per tab diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 9331841596b3a..1b6007f0b9878 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -1,5 +1,5 @@ error: assignment to temporary - --> $DIR/temporary_assignment.rs:47:5 + --> tests/ui/temporary_assignment.rs:47:5 | LL | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | Struct { field: 0 }.field = 1; = help: to override `-D warnings` add `#[allow(clippy::temporary_assignment)]` error: assignment to temporary - --> $DIR/temporary_assignment.rs:50:5 + --> tests/ui/temporary_assignment.rs:50:5 | LL | / MultiStruct { LL | | @@ -19,13 +19,13 @@ LL | | .field = 1; | |______________^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:56:5 + --> tests/ui/temporary_assignment.rs:56:5 | LL | ArrayStruct { array: [0] }.array[0] = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:58:5 + --> tests/ui/temporary_assignment.rs:58:5 | LL | (0, 0).0 = 1; | ^^^^^^^^^^^^ diff --git a/tests/ui/test_attr_in_doctest.stderr b/tests/ui/test_attr_in_doctest.stderr index 605259f3bfb4c..f950455f2908d 100644 --- a/tests/ui/test_attr_in_doctest.stderr +++ b/tests/ui/test_attr_in_doctest.stderr @@ -1,5 +1,5 @@ error: unit tests in doctest are not executed - --> $DIR/test_attr_in_doctest.rs:6:5 + --> tests/ui/test_attr_in_doctest.rs:6:5 | LL | /// #[test] | _____^ @@ -10,7 +10,7 @@ LL | | /// fn should_be_linted() { = help: to override `-D warnings` add `#[allow(clippy::test_attr_in_doctest)]` error: unit tests in doctest are not executed - --> $DIR/test_attr_in_doctest.rs:16:5 + --> tests/ui/test_attr_in_doctest.rs:16:5 | LL | /// #[test] | _____^ @@ -18,7 +18,7 @@ LL | | /// fn should_also_be_linted() { | |____________________________^ error: unit tests in doctest are not executed - --> $DIR/test_attr_in_doctest.rs:22:5 + --> tests/ui/test_attr_in_doctest.rs:22:5 | LL | /// #[test] | _____^ diff --git a/tests/ui/tests_outside_test_module.stderr b/tests/ui/tests_outside_test_module.stderr index ec0cdea83d657..09feae6bf2aa7 100644 --- a/tests/ui/tests_outside_test_module.stderr +++ b/tests/ui/tests_outside_test_module.stderr @@ -1,5 +1,5 @@ error: this function marked with #[test] is outside a #[cfg(test)] module - --> $DIR/tests_outside_test_module.rs:10:1 + --> tests/ui/tests_outside_test_module.rs:10:1 | LL | fn my_test() {} | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/thread_local_initializer_can_be_made_const.stderr b/tests/ui/thread_local_initializer_can_be_made_const.stderr index b35bd306b5230..9ee52fbbb319e 100644 --- a/tests/ui/thread_local_initializer_can_be_made_const.stderr +++ b/tests/ui/thread_local_initializer_can_be_made_const.stderr @@ -1,5 +1,5 @@ error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:8:41 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:8:41 | LL | static BUF_1: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` @@ -8,19 +8,19 @@ LL | static BUF_1: RefCell = RefCell::new(String::new()); = help: to override `-D warnings` add `#[allow(clippy::thread_local_initializer_can_be_made_const)]` error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:18:29 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:18:29 | LL | static SIMPLE:i32 = 1; | ^ help: replace with: `const { 1 }` error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:24:59 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:24:59 | LL | static BUF_3_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:26:59 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:26:59 | LL | static BUF_4_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` diff --git a/tests/ui/to_digit_is_some.stderr b/tests/ui/to_digit_is_some.stderr index 5067ad7fb6dff..e44106b2e188b 100644 --- a/tests/ui/to_digit_is_some.stderr +++ b/tests/ui/to_digit_is_some.stderr @@ -1,5 +1,5 @@ error: use of `.to_digit(..).is_some()` - --> $DIR/to_digit_is_some.rs:7:13 + --> tests/ui/to_digit_is_some.rs:7:13 | LL | let _ = d.to_digit(8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d.is_digit(8)` @@ -8,7 +8,7 @@ LL | let _ = d.to_digit(8).is_some(); = help: to override `-D warnings` add `#[allow(clippy::to_digit_is_some)]` error: use of `.to_digit(..).is_some()` - --> $DIR/to_digit_is_some.rs:8:13 + --> tests/ui/to_digit_is_some.rs:8:13 | LL | let _ = char::to_digit(c, 8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `char::is_digit(c, 8)` diff --git a/tests/ui/to_string_in_format_args_incremental.stderr b/tests/ui/to_string_in_format_args_incremental.stderr index 8d327ea8f571c..535dd21ea5888 100644 --- a/tests/ui/to_string_in_format_args_incremental.stderr +++ b/tests/ui/to_string_in_format_args_incremental.stderr @@ -1,5 +1,5 @@ error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/to_string_in_format_args_incremental.rs:7:21 + --> tests/ui/to_string_in_format_args_incremental.rs:7:21 | LL | println!("{}", s.to_string()); | ^^^^^^^^^^^^ help: remove this diff --git a/tests/ui/to_string_trait_impl.stderr b/tests/ui/to_string_trait_impl.stderr index 0051ea25ae00a..304c9a5e1fb71 100644 --- a/tests/ui/to_string_trait_impl.stderr +++ b/tests/ui/to_string_trait_impl.stderr @@ -1,5 +1,5 @@ error: direct implementation of `ToString` - --> $DIR/to_string_trait_impl.rs:11:1 + --> tests/ui/to_string_trait_impl.rs:11:1 | LL | / impl ToString for Point { LL | | fn to_string(&self) -> String { @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::to_string_trait_impl)]` error: direct implementation of `ToString` - --> $DIR/to_string_trait_impl.rs:56:5 + --> tests/ui/to_string_trait_impl.rs:56:5 | LL | / impl ToString for S { LL | | fn to_string(&self) -> String { diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 2c27a3c8e9189..61f0fd4a6cd20 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,5 +1,5 @@ error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:14:9 + --> tests/ui/toplevel_ref_arg.rs:14:9 | LL | let ref _x = 1; | ----^^^^^^----- help: try: `let _x = &1;` @@ -8,31 +8,31 @@ LL | let ref _x = 1; = help: to override `-D warnings` add `#[allow(clippy::toplevel_ref_arg)]` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:16:9 + --> tests/ui/toplevel_ref_arg.rs:16:9 | LL | let ref _y: (&_, u8) = (&1, 2); | ----^^^^^^--------------------- help: try: `let _y: &(&_, u8) = &(&1, 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:18:9 + --> tests/ui/toplevel_ref_arg.rs:18:9 | LL | let ref _z = 1 + 2; | ----^^^^^^--------- help: try: `let _z = &(1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:20:9 + --> tests/ui/toplevel_ref_arg.rs:20:9 | LL | let ref mut _z = 1 + 2; | ----^^^^^^^^^^--------- help: try: `let _z = &mut (1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:25:9 + --> tests/ui/toplevel_ref_arg.rs:25:9 | LL | let ref _x = vec![1, 2, 3]; | ----^^^^^^----------------- help: try: `let _x = &vec![1, 2, 3];` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:35:17 + --> tests/ui/toplevel_ref_arg.rs:35:17 | LL | inline!(let ref _y = 42;); | ----^^^^^^------ help: try: `let _y = &42;` diff --git a/tests/ui/toplevel_ref_arg_non_rustfix.stderr b/tests/ui/toplevel_ref_arg_non_rustfix.stderr index 45123dd5ec0bd..fb8fb1a009012 100644 --- a/tests/ui/toplevel_ref_arg_non_rustfix.stderr +++ b/tests/ui/toplevel_ref_arg_non_rustfix.stderr @@ -1,5 +1,5 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead - --> $DIR/toplevel_ref_arg_non_rustfix.rs:9:15 + --> tests/ui/toplevel_ref_arg_non_rustfix.rs:9:15 | LL | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn the_answer(ref mut x: u8) { = help: to override `-D warnings` add `#[allow(clippy::toplevel_ref_arg)]` error: `ref` directly on a function argument is ignored. Consider using a reference type instead - --> $DIR/toplevel_ref_arg_non_rustfix.rs:20:24 + --> tests/ui/toplevel_ref_arg_non_rustfix.rs:20:24 | LL | fn fun_example(ref _x: usize) {} | ^^^^^^ diff --git a/tests/ui/track-diagnostics.stderr b/tests/ui/track-diagnostics.stderr index 131adfd588c25..410e80f25280a 100644 --- a/tests/ui/track-diagnostics.stderr +++ b/tests/ui/track-diagnostics.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:LL:CC + --> tests/ui/track-diagnostics.rs:LL:CC | LL | const S: A = B; | ^ expected `A`, found `B` diff --git a/tests/ui/trailing_empty_array.stderr b/tests/ui/trailing_empty_array.stderr index ef7fc24c374fa..756381478f2b7 100644 --- a/tests/ui/trailing_empty_array.stderr +++ b/tests/ui/trailing_empty_array.stderr @@ -1,5 +1,5 @@ error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:5:1 + --> tests/ui/trailing_empty_array.rs:5:1 | LL | / struct RarelyUseful { LL | | @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::trailing_empty_array)]` error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:11:1 + --> tests/ui/trailing_empty_array.rs:11:1 | LL | / struct OnlyField { LL | | @@ -24,7 +24,7 @@ LL | | } = help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:16:1 + --> tests/ui/trailing_empty_array.rs:16:1 | LL | / struct GenericArrayType { LL | | @@ -36,7 +36,7 @@ LL | | } = help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:23:1 + --> tests/ui/trailing_empty_array.rs:23:1 | LL | / struct OnlyAnotherAttribute { LL | | @@ -48,7 +48,7 @@ LL | | } = help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:30:1 + --> tests/ui/trailing_empty_array.rs:30:1 | LL | / struct OnlyADeriveAttribute { LL | | @@ -60,7 +60,7 @@ LL | | } = help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:37:1 + --> tests/ui/trailing_empty_array.rs:37:1 | LL | / struct ZeroSizedWithConst { LL | | @@ -72,7 +72,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:47:1 + --> tests/ui/trailing_empty_array.rs:47:1 | LL | / struct ZeroSizedWithConstFunction { LL | | @@ -84,7 +84,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:56:1 + --> tests/ui/trailing_empty_array.rs:56:1 | LL | / struct ZeroSizedWithConstFunction2 { LL | | @@ -96,7 +96,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:62:1 + --> tests/ui/trailing_empty_array.rs:62:1 | LL | struct ZeroSizedArrayWrapper([usize; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | struct ZeroSizedArrayWrapper([usize; 0]); = help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:65:1 + --> tests/ui/trailing_empty_array.rs:65:1 | LL | struct TupleStruct(i32, [usize; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | struct TupleStruct(i32, [usize; 0]); = help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:68:1 + --> tests/ui/trailing_empty_array.rs:68:1 | LL | / struct LotsOfFields { LL | | diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 10924ad124712..6f3e7aa1d762e 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,5 +1,5 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:6:13 + --> tests/ui/trailing_zeros.rs:6:13 | LL | let _ = (x & 0b1111 == 0); | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` @@ -8,7 +8,7 @@ LL | let _ = (x & 0b1111 == 0); = help: to override `-D warnings` add `#[allow(clippy::verbose_bit_mask)]` error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:9:13 + --> tests/ui/trailing_zeros.rs:9:13 | LL | let _ = x & 0b1_1111 == 0; | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` diff --git a/tests/ui/trait_duplication_in_bounds.stderr b/tests/ui/trait_duplication_in_bounds.stderr index 61a45538b65c1..78861fc16e817 100644 --- a/tests/ui/trait_duplication_in_bounds.stderr +++ b/tests/ui/trait_duplication_in_bounds.stderr @@ -1,59 +1,59 @@ error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:6:15 + --> tests/ui/trait_duplication_in_bounds.rs:6:15 | LL | fn bad_foo(arg0: T, argo1: U) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` | note: the lint level is defined here - --> $DIR/trait_duplication_in_bounds.rs:1:9 + --> tests/ui/trait_duplication_in_bounds.rs:1:9 | LL | #![deny(clippy::trait_duplication_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: these where clauses contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:12:8 + --> tests/ui/trait_duplication_in_bounds.rs:12:8 | LL | T: Clone + Clone + Clone + Copy, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:40:26 + --> tests/ui/trait_duplication_in_bounds.rs:40:26 | LL | trait BadSelfTraitBound: Clone + Clone + Clone { | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone` error: these where clauses contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:47:15 + --> tests/ui/trait_duplication_in_bounds.rs:47:15 | LL | Self: Clone + Clone + Clone; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:61:24 + --> tests/ui/trait_duplication_in_bounds.rs:61:24 | LL | trait BadTraitBound { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` error: these where clauses contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:68:12 + --> tests/ui/trait_duplication_in_bounds.rs:68:12 | LL | T: Clone + Clone + Clone + Copy, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:101:19 + --> tests/ui/trait_duplication_in_bounds.rs:101:19 | LL | fn bad_generic + GenericTrait + GenericTrait>(arg0: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait + GenericTrait` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:109:22 + --> tests/ui/trait_duplication_in_bounds.rs:109:22 | LL | fn qualified_path(arg0: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::clone::Clone + foo::Clone` error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds.rs:117:33 + --> tests/ui/trait_duplication_in_bounds.rs:117:33 | LL | fn bad_trait_object(arg0: &(dyn Any + Send + Send)) { | ^^^^^^^^^^^^^^^^^ help: try: `Any + Send` diff --git a/tests/ui/trait_duplication_in_bounds_unfixable.stderr b/tests/ui/trait_duplication_in_bounds_unfixable.stderr index 80dc7d8b6c32d..1d87e50e8a56c 100644 --- a/tests/ui/trait_duplication_in_bounds_unfixable.stderr +++ b/tests/ui/trait_duplication_in_bounds_unfixable.stderr @@ -1,18 +1,18 @@ error: this trait bound is already specified in the where clause - --> $DIR/trait_duplication_in_bounds_unfixable.rs:6:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:6:15 | LL | fn bad_foo(arg0: T, arg1: Z) | ^^^^^ | = help: consider removing this trait bound note: the lint level is defined here - --> $DIR/trait_duplication_in_bounds_unfixable.rs:1:9 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:1:9 | LL | #![deny(clippy::trait_duplication_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this trait bound is already specified in the where clause - --> $DIR/trait_duplication_in_bounds_unfixable.rs:6:23 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:6:23 | LL | fn bad_foo(arg0: T, arg1: Z) | ^^^^^^^ @@ -20,7 +20,7 @@ LL | fn bad_foo(arg0: T, arg1: Z) = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:37:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:37:15 | LL | Self: Default; | ^^^^^^^ @@ -28,7 +28,7 @@ LL | Self: Default; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:52:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:52:15 | LL | Self: Default + Clone; | ^^^^^^^ @@ -36,7 +36,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:59:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:59:15 | LL | Self: Default + Clone; | ^^^^^^^ @@ -44,7 +44,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:59:25 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:59:25 | LL | Self: Default + Clone; | ^^^^^ @@ -52,7 +52,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:64:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:64:15 | LL | Self: Default; | ^^^^^^^ @@ -60,7 +60,7 @@ LL | Self: Default; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:100:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:100:15 | LL | Self: Iterator, | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index df32d478cbf40..3ed6cb2b3f974 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,5 +1,5 @@ error: transmute from a reference to a pointer - --> $DIR/transmute.rs:24:23 + --> tests/ui/transmute.rs:24:23 | LL | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` @@ -8,61 +8,61 @@ LL | let _: *const T = core::intrinsics::transmute(t); = help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:28:21 + --> tests/ui/transmute.rs:28:21 | LL | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:31:23 + --> tests/ui/transmute.rs:31:23 | LL | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:38:27 + --> tests/ui/transmute.rs:38:27 | LL | let _: Vec = core::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:41:27 + --> tests/ui/transmute.rs:41:27 | LL | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:44:27 + --> tests/ui/transmute.rs:44:27 | LL | let _: Vec = std::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:47:27 + --> tests/ui/transmute.rs:47:27 | LL | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:50:27 + --> tests/ui/transmute.rs:50:27 | LL | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer - --> $DIR/transmute.rs:53:31 + --> tests/ui/transmute.rs:53:31 | LL | let _: *const usize = std::mem::transmute(5_isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` error: transmute from an integer to a pointer - --> $DIR/transmute.rs:58:31 + --> tests/ui/transmute.rs:58:31 | LL | let _: *const usize = std::mem::transmute(1 + 1usize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:90:24 + --> tests/ui/transmute.rs:90:24 | LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,25 +71,25 @@ LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); = help: to override `-D warnings` add `#[allow(clippy::crosspointer_transmute)]` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:94:24 + --> tests/ui/transmute.rs:94:24 | LL | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> $DIR/transmute.rs:97:31 + --> tests/ui/transmute.rs:97:31 | LL | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> $DIR/transmute.rs:100:29 + --> tests/ui/transmute.rs:100:29 | LL | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u8` to a `bool` - --> $DIR/transmute.rs:107:28 + --> tests/ui/transmute.rs:107:28 | LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` @@ -98,7 +98,7 @@ LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]` error: transmute from a `u32` to a `f32` - --> $DIR/transmute.rs:115:31 + --> tests/ui/transmute.rs:115:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` @@ -107,25 +107,25 @@ LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]` error: transmute from a `i32` to a `f32` - --> $DIR/transmute.rs:118:31 + --> tests/ui/transmute.rs:118:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` error: transmute from a `u64` to a `f64` - --> $DIR/transmute.rs:120:31 + --> tests/ui/transmute.rs:120:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)` error: transmute from a `i64` to a `f64` - --> $DIR/transmute.rs:122:31 + --> tests/ui/transmute.rs:122:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)` error: transmute from a `u8` to a `[u8; 1]` - --> $DIR/transmute.rs:143:30 + --> tests/ui/transmute.rs:143:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` @@ -134,85 +134,85 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8); = help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]` error: transmute from a `u32` to a `[u8; 4]` - --> $DIR/transmute.rs:146:30 + --> tests/ui/transmute.rs:146:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` error: transmute from a `u128` to a `[u8; 16]` - --> $DIR/transmute.rs:148:31 + --> tests/ui/transmute.rs:148:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` error: transmute from a `i8` to a `[u8; 1]` - --> $DIR/transmute.rs:150:30 + --> tests/ui/transmute.rs:150:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` error: transmute from a `i32` to a `[u8; 4]` - --> $DIR/transmute.rs:152:30 + --> tests/ui/transmute.rs:152:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` error: transmute from a `i128` to a `[u8; 16]` - --> $DIR/transmute.rs:154:31 + --> tests/ui/transmute.rs:154:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` error: transmute from a `f32` to a `[u8; 4]` - --> $DIR/transmute.rs:156:30 + --> tests/ui/transmute.rs:156:30 | LL | let _: [u8; 4] = std::mem::transmute(0.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()` error: transmute from a `f64` to a `[u8; 8]` - --> $DIR/transmute.rs:158:30 + --> tests/ui/transmute.rs:158:30 | LL | let _: [u8; 8] = std::mem::transmute(0.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()` error: transmute from a `u8` to a `[u8; 1]` - --> $DIR/transmute.rs:164:30 + --> tests/ui/transmute.rs:164:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` error: transmute from a `u32` to a `[u8; 4]` - --> $DIR/transmute.rs:166:30 + --> tests/ui/transmute.rs:166:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` error: transmute from a `u128` to a `[u8; 16]` - --> $DIR/transmute.rs:168:31 + --> tests/ui/transmute.rs:168:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` error: transmute from a `i8` to a `[u8; 1]` - --> $DIR/transmute.rs:170:30 + --> tests/ui/transmute.rs:170:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` error: transmute from a `i32` to a `[u8; 4]` - --> $DIR/transmute.rs:172:30 + --> tests/ui/transmute.rs:172:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` error: transmute from a `i128` to a `[u8; 16]` - --> $DIR/transmute.rs:174:31 + --> tests/ui/transmute.rs:174:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:185:28 + --> tests/ui/transmute.rs:185:28 | LL | let _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()` @@ -221,13 +221,13 @@ LL | let _: &str = unsafe { std::mem::transmute(B) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]` error: transmute from a `&mut [u8]` to a `&mut str` - --> $DIR/transmute.rs:188:32 + --> tests/ui/transmute.rs:188:32 | LL | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:190:30 + --> tests/ui/transmute.rs:190:30 | LL | const _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)` diff --git a/tests/ui/transmute_32bit.stderr b/tests/ui/transmute_32bit.stderr index baa819e30fded..2f16d124670e7 100644 --- a/tests/ui/transmute_32bit.stderr +++ b/tests/ui/transmute_32bit.stderr @@ -1,5 +1,5 @@ error: transmute from a `f32` to a pointer - --> $DIR/transmute_32bit.rs:6:31 + --> tests/ui/transmute_32bit.rs:6:31 | LL | let _: *const usize = std::mem::transmute(6.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | let _: *const usize = std::mem::transmute(6.0f32); = help: to override `-D warnings` add `#[allow(clippy::wrong_transmute)]` error: transmute from a `f32` to a pointer - --> $DIR/transmute_32bit.rs:8:29 + --> tests/ui/transmute_32bit.rs:8:29 | LL | let _: *mut usize = std::mem::transmute(6.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `char` to a pointer - --> $DIR/transmute_32bit.rs:10:31 + --> tests/ui/transmute_32bit.rs:10:31 | LL | let _: *const usize = std::mem::transmute('x'); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `char` to a pointer - --> $DIR/transmute_32bit.rs:12:29 + --> tests/ui/transmute_32bit.rs:12:29 | LL | let _: *mut usize = std::mem::transmute('x'); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index a30480eb7df0a..65fff17f59fa9 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,5 +1,5 @@ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:6:31 + --> tests/ui/transmute_64bit.rs:6:31 | LL | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _: *const usize = std::mem::transmute(6.0f64); = help: to override `-D warnings` add `#[allow(clippy::wrong_transmute)]` error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:10:29 + --> tests/ui/transmute_64bit.rs:10:29 | LL | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute_collection.stderr b/tests/ui/transmute_collection.stderr index 2163142eef2e8..f71fba6315ca7 100644 --- a/tests/ui/transmute_collection.stderr +++ b/tests/ui/transmute_collection.stderr @@ -1,5 +1,5 @@ error: transmute from `std::vec::Vec` to `std::vec::Vec` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:9:17 + --> tests/ui/transmute_collection.rs:9:17 | LL | let _ = transmute::<_, Vec>(vec![0u8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,103 +8,103 @@ LL | let _ = transmute::<_, Vec>(vec![0u8]); = help: to override `-D warnings` add `#[allow(clippy::unsound_collection_transmute)]` error: transmute from `std::vec::Vec` to `std::vec::Vec<[u8; 4]>` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:13:17 + --> tests/ui/transmute_collection.rs:13:17 | LL | let _ = transmute::<_, Vec<[u8; 4]>>(vec![1234u32]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::VecDeque` to `std::collections::VecDeque` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:17:17 + --> tests/ui/transmute_collection.rs:17:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::VecDeque<[u8; 4]>` to `std::collections::VecDeque` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:20:17 + --> tests/ui/transmute_collection.rs:20:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BinaryHeap` to `std::collections::BinaryHeap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:24:17 + --> tests/ui/transmute_collection.rs:24:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BinaryHeap<[u8; 4]>` to `std::collections::BinaryHeap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:27:17 + --> tests/ui/transmute_collection.rs:27:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeSet` to `std::collections::BTreeSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:31:17 + --> tests/ui/transmute_collection.rs:31:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeSet<[u8; 4]>` to `std::collections::BTreeSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:34:17 + --> tests/ui/transmute_collection.rs:34:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashSet` to `std::collections::HashSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:38:17 + --> tests/ui/transmute_collection.rs:38:17 | LL | let _ = transmute::<_, HashSet>(HashSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashSet<[u8; 4]>` to `std::collections::HashSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:41:17 + --> tests/ui/transmute_collection.rs:41:17 | LL | let _ = transmute::<_, HashSet>(HashSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:45:17 + --> tests/ui/transmute_collection.rs:45:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:47:17 + --> tests/ui/transmute_collection.rs:47:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:50:17 + --> tests/ui/transmute_collection.rs:50:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap<[u8; 4], u32>` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:52:17 + --> tests/ui/transmute_collection.rs:52:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:56:17 + --> tests/ui/transmute_collection.rs:56:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:58:17 + --> tests/ui/transmute_collection.rs:58:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:61:17 + --> tests/ui/transmute_collection.rs:61:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap<[u8; 4], u32>` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:63:17 + --> tests/ui/transmute_collection.rs:63:17 | LL | let _ = transmute::<_, HashMap>(HashMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute_float_to_int.stderr b/tests/ui/transmute_float_to_int.stderr index 1895120c0c99c..e89258d9102ac 100644 --- a/tests/ui/transmute_float_to_int.stderr +++ b/tests/ui/transmute_float_to_int.stderr @@ -1,5 +1,5 @@ error: transmute from a `f32` to a `u32` - --> $DIR/transmute_float_to_int.rs:4:27 + --> tests/ui/transmute_float_to_int.rs:4:27 | LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits()` @@ -8,31 +8,31 @@ LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_float_to_int)]` error: transmute from a `f32` to a `i32` - --> $DIR/transmute_float_to_int.rs:7:27 + --> tests/ui/transmute_float_to_int.rs:7:27 | LL | let _: i32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits() as i32` error: transmute from a `f64` to a `u64` - --> $DIR/transmute_float_to_int.rs:9:27 + --> tests/ui/transmute_float_to_int.rs:9:27 | LL | let _: u64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits()` error: transmute from a `f64` to a `i64` - --> $DIR/transmute_float_to_int.rs:11:27 + --> tests/ui/transmute_float_to_int.rs:11:27 | LL | let _: i64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits() as i64` error: transmute from a `f64` to a `u64` - --> $DIR/transmute_float_to_int.rs:13:27 + --> tests/ui/transmute_float_to_int.rs:13:27 | LL | let _: u64 = unsafe { std::mem::transmute(1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.0f64.to_bits()` error: transmute from a `f64` to a `u64` - --> $DIR/transmute_float_to_int.rs:15:27 + --> tests/ui/transmute_float_to_int.rs:15:27 | LL | let _: u64 = unsafe { std::mem::transmute(-1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-1.0f64).to_bits()` diff --git a/tests/ui/transmute_int_to_char.stderr b/tests/ui/transmute_int_to_char.stderr index 2297f5b4f8bf2..8444afbd21ef2 100644 --- a/tests/ui/transmute_int_to_char.stderr +++ b/tests/ui/transmute_int_to_char.stderr @@ -1,5 +1,5 @@ error: transmute from a `u32` to a `char` - --> $DIR/transmute_int_to_char.rs:4:28 + --> tests/ui/transmute_int_to_char.rs:4:28 | LL | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` @@ -8,7 +8,7 @@ LL | let _: char = unsafe { std::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` - --> $DIR/transmute_int_to_char.rs:7:28 + --> tests/ui/transmute_int_to_char.rs:7:28 | LL | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` diff --git a/tests/ui/transmute_int_to_char_no_std.stderr b/tests/ui/transmute_int_to_char_no_std.stderr index aace6968696da..d2c3842b684e4 100644 --- a/tests/ui/transmute_int_to_char_no_std.stderr +++ b/tests/ui/transmute_int_to_char_no_std.stderr @@ -1,5 +1,5 @@ error: transmute from a `u32` to a `char` - --> $DIR/transmute_int_to_char_no_std.rs:16:28 + --> tests/ui/transmute_int_to_char_no_std.rs:16:28 | LL | let _: char = unsafe { core::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::char::from_u32(0_u32).unwrap()` @@ -8,7 +8,7 @@ LL | let _: char = unsafe { core::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` - --> $DIR/transmute_int_to_char_no_std.rs:19:28 + --> tests/ui/transmute_int_to_char_no_std.rs:19:28 | LL | let _: char = unsafe { core::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::char::from_u32(0_i32 as u32).unwrap()` diff --git a/tests/ui/transmute_int_to_non_zero.stderr b/tests/ui/transmute_int_to_non_zero.stderr index b79a80c326d8d..dd37bd2105585 100644 --- a/tests/ui/transmute_int_to_non_zero.stderr +++ b/tests/ui/transmute_int_to_non_zero.stderr @@ -1,5 +1,5 @@ error: transmute from a `u8` to a `NonZeroU8` - --> $DIR/transmute_int_to_non_zero.rs:18:33 + --> tests/ui/transmute_int_to_non_zero.rs:18:33 | LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU8::new_unchecked(int_u8)` @@ -8,55 +8,55 @@ LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_non_zero)]` error: transmute from a `u16` to a `NonZeroU16` - --> $DIR/transmute_int_to_non_zero.rs:21:34 + --> tests/ui/transmute_int_to_non_zero.rs:21:34 | LL | let _: NonZeroU16 = unsafe { std::mem::transmute(int_u16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU16::new_unchecked(int_u16)` error: transmute from a `u32` to a `NonZeroU32` - --> $DIR/transmute_int_to_non_zero.rs:23:34 + --> tests/ui/transmute_int_to_non_zero.rs:23:34 | LL | let _: NonZeroU32 = unsafe { std::mem::transmute(int_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU32::new_unchecked(int_u32)` error: transmute from a `u64` to a `NonZeroU64` - --> $DIR/transmute_int_to_non_zero.rs:25:34 + --> tests/ui/transmute_int_to_non_zero.rs:25:34 | LL | let _: NonZeroU64 = unsafe { std::mem::transmute(int_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU64::new_unchecked(int_u64)` error: transmute from a `u128` to a `NonZeroU128` - --> $DIR/transmute_int_to_non_zero.rs:27:35 + --> tests/ui/transmute_int_to_non_zero.rs:27:35 | LL | let _: NonZeroU128 = unsafe { std::mem::transmute(int_u128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU128::new_unchecked(int_u128)` error: transmute from a `i8` to a `NonZeroI8` - --> $DIR/transmute_int_to_non_zero.rs:30:33 + --> tests/ui/transmute_int_to_non_zero.rs:30:33 | LL | let _: NonZeroI8 = unsafe { std::mem::transmute(int_i8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI8::new_unchecked(int_i8)` error: transmute from a `i16` to a `NonZeroI16` - --> $DIR/transmute_int_to_non_zero.rs:32:34 + --> tests/ui/transmute_int_to_non_zero.rs:32:34 | LL | let _: NonZeroI16 = unsafe { std::mem::transmute(int_i16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI16::new_unchecked(int_i16)` error: transmute from a `i32` to a `NonZeroI32` - --> $DIR/transmute_int_to_non_zero.rs:34:34 + --> tests/ui/transmute_int_to_non_zero.rs:34:34 | LL | let _: NonZeroI32 = unsafe { std::mem::transmute(int_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI32::new_unchecked(int_i32)` error: transmute from a `i64` to a `NonZeroI64` - --> $DIR/transmute_int_to_non_zero.rs:36:34 + --> tests/ui/transmute_int_to_non_zero.rs:36:34 | LL | let _: NonZeroI64 = unsafe { std::mem::transmute(int_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI64::new_unchecked(int_i64)` error: transmute from a `i128` to a `NonZeroI128` - --> $DIR/transmute_int_to_non_zero.rs:38:35 + --> tests/ui/transmute_int_to_non_zero.rs:38:35 | LL | let _: NonZeroI128 = unsafe { std::mem::transmute(int_i128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI128::new_unchecked(int_i128)` diff --git a/tests/ui/transmute_null_to_fn.stderr b/tests/ui/transmute_null_to_fn.stderr index 9073080cbf3c6..cea7b42cb801c 100644 --- a/tests/ui/transmute_null_to_fn.stderr +++ b/tests/ui/transmute_null_to_fn.stderr @@ -1,5 +1,5 @@ error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:8:23 + --> tests/ui/transmute_null_to_fn.rs:8:23 | LL | let _: fn() = std::mem::transmute(0 as *const ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -9,7 +9,7 @@ LL | let _: fn() = std::mem::transmute(0 as *const ()); = help: to override `-D warnings` add `#[allow(clippy::transmute_null_to_fn)]` error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:10:23 + --> tests/ui/transmute_null_to_fn.rs:10:23 | LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -17,7 +17,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:21:23 + --> tests/ui/transmute_null_to_fn.rs:21:23 | LL | let _: fn() = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -25,7 +25,7 @@ LL | let _: fn() = std::mem::transmute(ZPTR); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:30:23 + --> tests/ui/transmute_null_to_fn.rs:30:23 | LL | let _: fn() = std::mem::transmute(0 as *const u8 as *const ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -33,7 +33,7 @@ LL | let _: fn() = std::mem::transmute(0 as *const u8 as *const ()); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:32:23 + --> tests/ui/transmute_null_to_fn.rs:32:23 | LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -41,7 +41,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:34:23 + --> tests/ui/transmute_null_to_fn.rs:34:23 | LL | let _: fn() = std::mem::transmute(ZPTR as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr index 9f8599921ec7d..5896bfa9546c6 100644 --- a/tests/ui/transmute_ptr_to_ptr.stderr +++ b/tests/ui/transmute_ptr_to_ptr.stderr @@ -1,5 +1,5 @@ error: transmute from a pointer to a pointer - --> $DIR/transmute_ptr_to_ptr.rs:30:29 + --> tests/ui/transmute_ptr_to_ptr.rs:30:29 | LL | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` @@ -8,37 +8,37 @@ LL | let _: *const f32 = std::mem::transmute(ptr); = help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ptr)]` error: transmute from a pointer to a pointer - --> $DIR/transmute_ptr_to_ptr.rs:33:27 + --> tests/ui/transmute_ptr_to_ptr.rs:33:27 | LL | let _: *mut f32 = std::mem::transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:36:23 + --> tests/ui/transmute_ptr_to_ptr.rs:36:23 | LL | let _: &f32 = std::mem::transmute(&1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:38:23 + --> tests/ui/transmute_ptr_to_ptr.rs:38:23 | LL | let _: &f64 = std::mem::transmute(&1f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:42:27 + --> tests/ui/transmute_ptr_to_ptr.rs:42:27 | LL | let _: &mut f32 = std::mem::transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:44:37 + --> tests/ui/transmute_ptr_to_ptr.rs:44:37 | LL | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:47:38 + --> tests/ui/transmute_ptr_to_ptr.rs:47:38 | LL | let u64_ref: &u64 = unsafe { std::mem::transmute(u8_ref) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u8_ref as *const u8 as *const u64)` diff --git a/tests/ui/transmute_ptr_to_ref.stderr b/tests/ui/transmute_ptr_to_ref.stderr index 9d1b22a795b3d..d7d180398e1c6 100644 --- a/tests/ui/transmute_ptr_to_ref.stderr +++ b/tests/ui/transmute_ptr_to_ref.stderr @@ -1,5 +1,5 @@ error: transmute from a pointer type (`*const T`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:5:17 + --> tests/ui/transmute_ptr_to_ref.rs:5:17 | LL | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` @@ -8,127 +8,127 @@ LL | let _: &T = std::mem::transmute(p); = help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ref)]` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute_ptr_to_ref.rs:8:21 + --> tests/ui/transmute_ptr_to_ref.rs:8:21 | LL | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:11:17 + --> tests/ui/transmute_ptr_to_ref.rs:11:17 | LL | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute_ptr_to_ref.rs:14:21 + --> tests/ui/transmute_ptr_to_ref.rs:14:21 | LL | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:17:17 + --> tests/ui/transmute_ptr_to_ref.rs:17:17 | LL | let _: &T = std::mem::transmute(o); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - --> $DIR/transmute_ptr_to_ref.rs:20:21 + --> tests/ui/transmute_ptr_to_ref.rs:20:21 | LL | let _: &mut T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:23:17 + --> tests/ui/transmute_ptr_to_ref.rs:23:17 | LL | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, u8>`) - --> $DIR/transmute_ptr_to_ref.rs:33:32 + --> tests/ui/transmute_ptr_to_ref.rs:33:32 | LL | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::>()` error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, &u8>`) - --> $DIR/transmute_ptr_to_ref.rs:35:33 + --> tests/ui/transmute_ptr_to_ref.rs:35:33 | LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::>()` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) - --> $DIR/transmute_ptr_to_ref.rs:39:14 + --> tests/ui/transmute_ptr_to_ref.rs:39:14 | LL | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:44:14 + --> tests/ui/transmute_ptr_to_ref.rs:44:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:45:14 + --> tests/ui/transmute_ptr_to_ref.rs:45:14 | LL | 1 => std::mem::transmute(y), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:46:14 + --> tests/ui/transmute_ptr_to_ref.rs:46:14 | LL | 2 => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:47:14 + --> tests/ui/transmute_ptr_to_ref.rs:47:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(y), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&'b u32>()` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:55:19 + --> tests/ui/transmute_ptr_to_ref.rs:55:19 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:56:19 + --> tests/ui/transmute_ptr_to_ref.rs:56:19 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a.cast::()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:58:14 + --> tests/ui/transmute_ptr_to_ref.rs:58:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:59:14 + --> tests/ui/transmute_ptr_to_ref.rs:59:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:67:19 + --> tests/ui/transmute_ptr_to_ref.rs:67:19 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:68:19 + --> tests/ui/transmute_ptr_to_ref.rs:68:19 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const u32)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:70:14 + --> tests/ui/transmute_ptr_to_ref.rs:70:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &u32)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:71:14 + --> tests/ui/transmute_ptr_to_ref.rs:71:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &'b u32)` diff --git a/tests/ui/transmute_ref_to_ref.stderr b/tests/ui/transmute_ref_to_ref.stderr index 4238bc637ad04..e2d04cea8959f 100644 --- a/tests/ui/transmute_ref_to_ref.stderr +++ b/tests/ui/transmute_ref_to_ref.stderr @@ -1,23 +1,23 @@ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref.rs:9:39 + --> tests/ui/transmute_ref_to_ref.rs:9:39 | LL | let bools: &[bool] = unsafe { std::mem::transmute(single_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(single_u64 as *const [u64] as *const [bool])` | note: the lint level is defined here - --> $DIR/transmute_ref_to_ref.rs:3:9 + --> tests/ui/transmute_ref_to_ref.rs:3:9 | LL | #![deny(clippy::transmute_ptr_to_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref.rs:12:33 + --> tests/ui/transmute_ref_to_ref.rs:12:33 | LL | let b: &[u8] = unsafe { std::mem::transmute(a) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const [u32] as *const [u8])` error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref.rs:15:42 + --> tests/ui/transmute_ref_to_ref.rs:15:42 | LL | let alt_slice: &[u32] = unsafe { std::mem::transmute(bytes) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(bytes as *const [u8] as *const [u32])` diff --git a/tests/ui/transmute_ref_to_ref_no_std.stderr b/tests/ui/transmute_ref_to_ref_no_std.stderr index ca7966ffa9e88..6a76d6729d05b 100644 --- a/tests/ui/transmute_ref_to_ref_no_std.stderr +++ b/tests/ui/transmute_ref_to_ref_no_std.stderr @@ -1,23 +1,23 @@ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref_no_std.rs:21:39 + --> tests/ui/transmute_ref_to_ref_no_std.rs:21:39 | LL | let bools: &[bool] = unsafe { core::mem::transmute(single_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(single_u64 as *const [u64] as *const [bool])` | note: the lint level is defined here - --> $DIR/transmute_ref_to_ref_no_std.rs:3:9 + --> tests/ui/transmute_ref_to_ref_no_std.rs:3:9 | LL | #![deny(clippy::transmute_ptr_to_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref_no_std.rs:24:33 + --> tests/ui/transmute_ref_to_ref_no_std.rs:24:33 | LL | let b: &[u8] = unsafe { core::mem::transmute(a) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const [u32] as *const [u8])` error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref_no_std.rs:27:42 + --> tests/ui/transmute_ref_to_ref_no_std.rs:27:42 | LL | let alt_slice: &[u32] = unsafe { core::mem::transmute(bytes) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(bytes as *const [u8] as *const [u32])` diff --git a/tests/ui/transmute_undefined_repr.stderr b/tests/ui/transmute_undefined_repr.stderr index f87b1ece96472..5504fbe16e416 100644 --- a/tests/ui/transmute_undefined_repr.stderr +++ b/tests/ui/transmute_undefined_repr.stderr @@ -1,5 +1,5 @@ error: transmute from `Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:29:33 + --> tests/ui/transmute_undefined_repr.rs:29:33 | LL | let _: Ty2C = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | let _: Ty2C = transmute(value::>()); = help: to override `-D warnings` add `#[allow(clippy::transmute_undefined_repr)]` error: transmute into `Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:33:32 + --> tests/ui/transmute_undefined_repr.rs:33:32 | LL | let _: Ty2 = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `Ty>` to `Ty2`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:42:32 + --> tests/ui/transmute_undefined_repr.rs:42:32 | LL | let _: Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | let _: Ty2 = transmute(value::>>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `Ty2` to `Ty>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:46:36 + --> tests/ui/transmute_undefined_repr.rs:46:36 | LL | let _: Ty> = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | let _: Ty> = transmute(value::>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `Ty<&Ty2>` to `&Ty2`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:54:33 + --> tests/ui/transmute_undefined_repr.rs:54:33 | LL | let _: &Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | let _: &Ty2 = transmute(value::>>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `&Ty2` to `Ty<&Ty2>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:58:37 + --> tests/ui/transmute_undefined_repr.rs:58:37 | LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `std::boxed::Box>` to `&mut Ty2`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:88:45 + --> tests/ui/transmute_undefined_repr.rs:88:45 | LL | let _: &'static mut Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,7 +54,7 @@ LL | let _: &'static mut Ty2 = transmute(value::` to `std::boxed::Box>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:92:37 + --> tests/ui/transmute_undefined_repr.rs:92:37 | LL | let _: Box> = transmute(value::<&'static mut Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +62,7 @@ LL | let _: Box> = transmute(value::<&'static mut Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:189:39 + --> tests/ui/transmute_undefined_repr.rs:189:39 | LL | let _: *const Ty2 = transmute(value::<*const Ty2C>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | let _: *const Ty2 = transmute(value::<*const Ty2C` has an undefined layout error: transmute from `*const Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:193:50 + --> tests/ui/transmute_undefined_repr.rs:193:50 | LL | let _: *const Ty2C> = transmute(value::<*const Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _: *const Ty2C> = transmute(value::<*const T = note: the contained type `Ty2` has an undefined layout error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:240:35 + --> tests/ui/transmute_undefined_repr.rs:240:35 | LL | let _: Vec> = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | let _: Vec> = transmute(value::>>()); = note: two instances of the same generic type (`Vec`) may have different layouts error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:244:35 + --> tests/ui/transmute_undefined_repr.rs:244:35 | LL | let _: Vec> = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmutes_expressible_as_ptr_casts.stderr b/tests/ui/transmutes_expressible_as_ptr_casts.stderr index a7988dc4b39b2..2ca44485826d7 100644 --- a/tests/ui/transmutes_expressible_as_ptr_casts.stderr +++ b/tests/ui/transmutes_expressible_as_ptr_casts.stderr @@ -1,5 +1,5 @@ error: transmute from an integer to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:17:39 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:17:39 | LL | let _ptr_i32_transmute = unsafe { transmute::(usize::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32` @@ -8,7 +8,7 @@ LL | let _ptr_i32_transmute = unsafe { transmute::(usize: = help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]` error: transmute from a pointer to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:21:38 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:21:38 | LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as *const i8` @@ -17,13 +17,13 @@ LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr = help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ptr)]` error: transmute from a pointer to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:27:46 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:27:46 | LL | let _ptr_to_unsized_transmute = unsafe { transmute::<*const [i32], *const [u32]>(slice_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice_ptr as *const [u32]` error: transmute from `*const i32` to `usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:33:50 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:33:50 | LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, usize>(ptr_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as usize` @@ -32,37 +32,37 @@ LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, us = help: to override `-D warnings` add `#[allow(clippy::transmutes_expressible_as_ptr_casts)]` error: transmute from a reference to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:39:41 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:39:41 | LL | let _array_ptr_transmute = unsafe { transmute::<&[i32; 4], *const [i32; 4]>(array_ref) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array_ref as *const [i32; 4]` error: transmute from `fn(usize) -> u8` to `*const usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:47:41 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:47:41 | LL | let _usize_ptr_transmute = unsafe { transmute:: u8, *const usize>(foo) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as *const usize` error: transmute from `fn(usize) -> u8` to `usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:51:49 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:51:49 | LL | let _usize_from_fn_ptr_transmute = unsafe { transmute:: u8, usize>(foo) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as usize` error: transmute from `*const u32` to `usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:54:36 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:54:36 | LL | let _usize_from_ref = unsafe { transmute::<*const u32, usize>(&1u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&1u32 as *const u32 as usize` error: transmute from a reference to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:65:14 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:65:14 | LL | unsafe { transmute::<&[i32; 1], *const u8>(in_param) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `in_param as *const [i32; 1] as *const u8` error: transmute from `fn()` to `*const u8` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:83:28 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:83:28 | LL | let _x: u8 = unsafe { *std::mem::transmute::(f) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(f as *const u8)` diff --git a/tests/ui/transmuting_null.stderr b/tests/ui/transmuting_null.stderr index 402de38fe9e2f..84e6e374d5253 100644 --- a/tests/ui/transmuting_null.stderr +++ b/tests/ui/transmuting_null.stderr @@ -1,5 +1,5 @@ error: transmuting a known null pointer into a reference - --> $DIR/transmuting_null.rs:10:23 + --> tests/ui/transmuting_null.rs:10:23 | LL | let _: &u64 = std::mem::transmute(0 as *const u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | let _: &u64 = std::mem::transmute(0 as *const u64); = help: to override `-D warnings` add `#[allow(clippy::transmuting_null)]` error: transmuting a known null pointer into a reference - --> $DIR/transmuting_null.rs:13:23 + --> tests/ui/transmuting_null.rs:13:23 | LL | let _: &u64 = std::mem::transmute(std::ptr::null::()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmuting a known null pointer into a reference - --> $DIR/transmuting_null.rs:24:23 + --> tests/ui/transmuting_null.rs:24:23 | LL | let _: &u64 = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/trim_split_whitespace.stderr b/tests/ui/trim_split_whitespace.stderr index a1c66eea0d14c..6119d21a8e9ae 100644 --- a/tests/ui/trim_split_whitespace.stderr +++ b/tests/ui/trim_split_whitespace.stderr @@ -1,5 +1,5 @@ error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:61:23 + --> tests/ui/trim_split_whitespace.rs:61:23 | LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` @@ -8,43 +8,43 @@ LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint = help: to override `-D warnings` add `#[allow(clippy::trim_split_whitespace)]` error: found call to `str::trim_start` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:62:23 + --> tests/ui/trim_split_whitespace.rs:62:23 | LL | let _ = " A B C ".trim_start().split_whitespace(); // should trigger lint | ^^^^^^^^^^^^^ help: remove `trim_start()` error: found call to `str::trim_end` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:63:23 + --> tests/ui/trim_split_whitespace.rs:63:23 | LL | let _ = " A B C ".trim_end().split_whitespace(); // should trigger lint | ^^^^^^^^^^^ help: remove `trim_end()` error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:66:37 + --> tests/ui/trim_split_whitespace.rs:66:37 | LL | let _ = (" A B C ").to_string().trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` error: found call to `str::trim_start` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:67:37 + --> tests/ui/trim_split_whitespace.rs:67:37 | LL | let _ = (" A B C ").to_string().trim_start().split_whitespace(); // should trigger lint | ^^^^^^^^^^^^^ help: remove `trim_start()` error: found call to `str::trim_end` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:68:37 + --> tests/ui/trim_split_whitespace.rs:68:37 | LL | let _ = (" A B C ").to_string().trim_end().split_whitespace(); // should trigger lint | ^^^^^^^^^^^ help: remove `trim_end()` error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:75:15 + --> tests/ui/trim_split_whitespace.rs:75:15 | LL | let _ = s.trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:83:15 + --> tests/ui/trim_split_whitespace.rs:83:15 | LL | let _ = s.trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index c9585e519883c..4887fb00e7425 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,113 +1,113 @@ error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:52:11 + --> tests/ui/trivially_copy_pass_by_ref.rs:52:11 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` | note: the lint level is defined here - --> $DIR/trivially_copy_pass_by_ref.rs:3:9 + --> tests/ui/trivially_copy_pass_by_ref.rs:3:9 | LL | #![deny(clippy::trivially_copy_pass_by_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:52:20 + --> tests/ui/trivially_copy_pass_by_ref.rs:52:20 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:52:29 + --> tests/ui/trivially_copy_pass_by_ref.rs:52:29 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:12 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:12 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:22 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:22 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:31 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:31 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:40 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:40 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:67:16 + --> tests/ui/trivially_copy_pass_by_ref.rs:67:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:67:25 + --> tests/ui/trivially_copy_pass_by_ref.rs:67:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:67:34 + --> tests/ui/trivially_copy_pass_by_ref.rs:67:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:72:35 + --> tests/ui/trivially_copy_pass_by_ref.rs:72:35 | LL | fn bad_issue7518(self, other: &Self) {} | ^^^^^ help: consider passing by value instead: `Self` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:85:16 + --> tests/ui/trivially_copy_pass_by_ref.rs:85:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:85:25 + --> tests/ui/trivially_copy_pass_by_ref.rs:85:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:85:34 + --> tests/ui/trivially_copy_pass_by_ref.rs:85:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:92:34 + --> tests/ui/trivially_copy_pass_by_ref.rs:92:34 | LL | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:125:21 + --> tests/ui/trivially_copy_pass_by_ref.rs:125:21 | LL | fn foo_never(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:131:15 + --> tests/ui/trivially_copy_pass_by_ref.rs:131:15 | LL | fn foo(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:159:37 + --> tests/ui/trivially_copy_pass_by_ref.rs:159:37 | LL | fn _unrelated_lifetimes<'a, 'b>(_x: &'a u32, y: &'b u32) -> &'b u32 { | ^^^^^^^ help: consider passing by value instead: `u32` diff --git a/tests/ui/try_err.stderr b/tests/ui/try_err.stderr index 887889ffd111d..fb563d4078660 100644 --- a/tests/ui/try_err.stderr +++ b/tests/ui/try_err.stderr @@ -1,35 +1,35 @@ error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:22:9 + --> tests/ui/try_err.rs:22:9 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err)` | note: the lint level is defined here - --> $DIR/try_err.rs:3:9 + --> tests/ui/try_err.rs:3:9 | LL | #![deny(clippy::try_err)] | ^^^^^^^^^^^^^^^ error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:32:9 + --> tests/ui/try_err.rs:32:9 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err.into())` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:52:17 + --> tests/ui/try_err.rs:52:17 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err)` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:71:17 + --> tests/ui/try_err.rs:71:17 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err.into())` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:91:23 + --> tests/ui/try_err.rs:91:23 | LL | Err(_) => Err(1)?, | ^^^^^^^ help: try: `return Err(1)` @@ -37,7 +37,7 @@ LL | Err(_) => Err(1)?, = note: this error originates in the macro `__inline_mac_fn_calling_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:98:23 + --> tests/ui/try_err.rs:98:23 | LL | Err(_) => Err(inline!(1))?, | ^^^^^^^^^^^^^^^^ help: try: `return Err(inline!(1))` @@ -45,31 +45,31 @@ LL | Err(_) => Err(inline!(1))?, = note: this error originates in the macro `__inline_mac_fn_calling_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:125:9 + --> tests/ui/try_err.rs:125:9 | LL | Err(inline!(inline!(String::from("aasdfasdfasdfa"))))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Err(inline!(inline!(String::from("aasdfasdfasdfa"))))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:132:9 + --> tests/ui/try_err.rs:132:9 | LL | Err(io::ErrorKind::WriteZero)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Poll::Ready(Err(io::ErrorKind::WriteZero.into()))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:134:9 + --> tests/ui/try_err.rs:134:9 | LL | Err(io::Error::new(io::ErrorKind::InvalidInput, "error"))? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Poll::Ready(Err(io::Error::new(io::ErrorKind::InvalidInput, "error")))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:142:9 + --> tests/ui/try_err.rs:142:9 | LL | Err(io::ErrorKind::NotFound)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Poll::Ready(Some(Err(io::ErrorKind::NotFound.into())))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:151:16 + --> tests/ui/try_err.rs:151:16 | LL | return Err(42)?; | ^^^^^^^^ help: try: `Err(42)` diff --git a/tests/ui/tuple_array_conversions.stderr b/tests/ui/tuple_array_conversions.stderr index f8f5b3e75871d..9e022b3cfb254 100644 --- a/tests/ui/tuple_array_conversions.stderr +++ b/tests/ui/tuple_array_conversions.stderr @@ -1,5 +1,5 @@ error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:10:13 + --> tests/ui/tuple_array_conversions.rs:10:13 | LL | let x = (x[0], x[1]); | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let x = (x[0], x[1]); = help: to override `-D warnings` add `#[allow(clippy::tuple_array_conversions)]` error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:11:13 + --> tests/ui/tuple_array_conversions.rs:11:13 | LL | let x = [x.0, x.1]; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let x = [x.0, x.1]; = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:16:53 + --> tests/ui/tuple_array_conversions.rs:16:53 | LL | let v1: Vec<[u32; 2]> = t1.iter().map(|&(a, b)| [a, b]).collect(); | ^^^^^^ @@ -25,7 +25,7 @@ LL | let v1: Vec<[u32; 2]> = t1.iter().map(|&(a, b)| [a, b]).collect(); = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:17:38 + --> tests/ui/tuple_array_conversions.rs:17:38 | LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); | ^^^^^^ @@ -33,7 +33,7 @@ LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:18:55 + --> tests/ui/tuple_array_conversions.rs:18:55 | LL | let t2: Vec<(u32, u32)> = v1.iter().map(|&[a, b]| (a, b)).collect(); | ^^^^^^ @@ -41,7 +41,7 @@ LL | let t2: Vec<(u32, u32)> = v1.iter().map(|&[a, b]| (a, b)).collect(); = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:19:38 + --> tests/ui/tuple_array_conversions.rs:19:38 | LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); | ^^^^^^ @@ -49,7 +49,7 @@ LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:57:22 + --> tests/ui/tuple_array_conversions.rs:57:22 | LL | let _: &[f64] = &[a, b]; | ^^^^^^ @@ -57,7 +57,7 @@ LL | let _: &[f64] = &[a, b]; = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:60:5 + --> tests/ui/tuple_array_conversions.rs:60:5 | LL | (src, dest); | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | (src, dest); = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:104:13 + --> tests/ui/tuple_array_conversions.rs:104:13 | LL | let x = (x[0], x[1]); | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let x = (x[0], x[1]); = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:105:13 + --> tests/ui/tuple_array_conversions.rs:105:13 | LL | let x = [x.0, x.1]; | ^^^^^^^^^^ diff --git a/tests/ui/type_complexity.stderr b/tests/ui/type_complexity.stderr index a3cf6ffe97516..9e27899e4f904 100644 --- a/tests/ui/type_complexity.stderr +++ b/tests/ui/type_complexity.stderr @@ -1,5 +1,5 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:7:12 + --> tests/ui/type_complexity.rs:7:12 | LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,85 +8,85 @@ LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); = help: to override `-D warnings` add `#[allow(clippy::type_complexity)]` error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:10:12 + --> tests/ui/type_complexity.rs:10:12 | LL | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:14:8 + --> tests/ui/type_complexity.rs:14:8 | LL | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:18:11 + --> tests/ui/type_complexity.rs:18:11 | LL | struct Ts(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:22:11 + --> tests/ui/type_complexity.rs:22:11 | LL | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:24:17 + --> tests/ui/type_complexity.rs:24:17 | LL | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:29:14 + --> tests/ui/type_complexity.rs:29:14 | LL | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:31:30 + --> tests/ui/type_complexity.rs:31:30 | LL | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:36:14 + --> tests/ui/type_complexity.rs:36:14 | LL | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:38:14 + --> tests/ui/type_complexity.rs:38:14 | LL | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:40:25 + --> tests/ui/type_complexity.rs:40:25 | LL | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:42:29 + --> tests/ui/type_complexity.rs:42:29 | LL | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:55:15 + --> tests/ui/type_complexity.rs:55:15 | LL | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:60:14 + --> tests/ui/type_complexity.rs:60:14 | LL | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:64:13 + --> tests/ui/type_complexity.rs:64:13 | LL | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type_id_on_box.stderr b/tests/ui/type_id_on_box.stderr index 844dae158b8d8..0fce6a37c0044 100644 --- a/tests/ui/type_id_on_box.stderr +++ b/tests/ui/type_id_on_box.stderr @@ -1,5 +1,5 @@ error: calling `.type_id()` on a `Box` - --> $DIR/type_id_on_box.rs:24:13 + --> tests/ui/type_id_on_box.rs:24:13 | LL | let _ = any_box.type_id(); | -------^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | let _ = any_box.type_id(); = help: to override `-D warnings` add `#[allow(clippy::type_id_on_box)]` error: calling `.type_id()` on a `Box` - --> $DIR/type_id_on_box.rs:28:13 + --> tests/ui/type_id_on_box.rs:28:13 | LL | let _ = any_box.type_id(); // 2 derefs are needed here to get to the `dyn Any` | -------^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = any_box.type_id(); // 2 derefs are needed here to get to the `d = note: if this is intentional, use `TypeId::of::>()` instead, which makes it more clear error: calling `.type_id()` on a `Box` - --> $DIR/type_id_on_box.rs:34:13 + --> tests/ui/type_id_on_box.rs:34:13 | LL | let _ = b.type_id(); | -^^^^^^^^^^ diff --git a/tests/ui/type_repetition_in_bounds.stderr b/tests/ui/type_repetition_in_bounds.stderr index 607cd1fbf6a7b..e9c6b41aaa8ec 100644 --- a/tests/ui/type_repetition_in_bounds.stderr +++ b/tests/ui/type_repetition_in_bounds.stderr @@ -1,18 +1,18 @@ error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:10:5 + --> tests/ui/type_repetition_in_bounds.rs:10:5 | LL | T: Clone, | ^^^^^^^^ | = help: consider combining the bounds: `T: Copy + Clone` note: the lint level is defined here - --> $DIR/type_repetition_in_bounds.rs:1:9 + --> tests/ui/type_repetition_in_bounds.rs:1:9 | LL | #![deny(clippy::type_repetition_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:28:5 + --> tests/ui/type_repetition_in_bounds.rs:28:5 | LL | Self: Copy + Default + Ord, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | Self: Copy + Default + Ord, = help: consider combining the bounds: `Self: Clone + Copy + Default + Ord` error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:103:5 + --> tests/ui/type_repetition_in_bounds.rs:103:5 | LL | T: Clone, | ^^^^^^^^ @@ -28,7 +28,7 @@ LL | T: Clone, = help: consider combining the bounds: `T: ?Sized + Clone` error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:109:5 + --> tests/ui/type_repetition_in_bounds.rs:109:5 | LL | T: ?Sized, | ^^^^^^^^^ @@ -36,7 +36,7 @@ LL | T: ?Sized, = help: consider combining the bounds: `T: Clone + ?Sized` error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:135:9 + --> tests/ui/type_repetition_in_bounds.rs:135:9 | LL | T: Trait, Box<[String]>, bool> + 'static, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index f7473e1c5c52d..02e75018129f4 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,5 +1,5 @@ error: casting `i32` to `i64` may become silently lossy if you later change the type - --> $DIR/types.rs:12:22 + --> tests/ui/types.rs:12:22 | LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` diff --git a/tests/ui/unchecked_duration_subtraction.stderr b/tests/ui/unchecked_duration_subtraction.stderr index 2b62bc9640392..b5e9bab86b478 100644 --- a/tests/ui/unchecked_duration_subtraction.stderr +++ b/tests/ui/unchecked_duration_subtraction.stderr @@ -1,5 +1,5 @@ error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:9:13 + --> tests/ui/unchecked_duration_subtraction.rs:9:13 | LL | let _ = _first - second; | ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap()` @@ -8,19 +8,19 @@ LL | let _ = _first - second; = help: to override `-D warnings` add `#[allow(clippy::unchecked_duration_subtraction)]` error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:11:13 + --> tests/ui/unchecked_duration_subtraction.rs:11:13 | LL | let _ = Instant::now() - Duration::from_secs(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap()` error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:13:13 + --> tests/ui/unchecked_duration_subtraction.rs:13:13 | LL | let _ = _first - Duration::from_secs(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap()` error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:15:13 + --> tests/ui/unchecked_duration_subtraction.rs:15:13 | LL | let _ = Instant::now() - second; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap()` diff --git a/tests/ui/unconditional_recursion.stderr b/tests/ui/unconditional_recursion.stderr index 93a5eac91d8e3..8535472595ed0 100644 --- a/tests/ui/unconditional_recursion.stderr +++ b/tests/ui/unconditional_recursion.stderr @@ -1,5 +1,5 @@ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:42:5 + --> tests/ui/unconditional_recursion.rs:42:5 | LL | fn ne(&self, other: &Self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -12,7 +12,7 @@ LL | self.ne(other) = help: to override `-D warnings` add `#[allow(unconditional_recursion)]` error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:46:5 + --> tests/ui/unconditional_recursion.rs:46:5 | LL | fn eq(&self, other: &Self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -23,7 +23,7 @@ LL | self.eq(other) = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:211:5 + --> tests/ui/unconditional_recursion.rs:211:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -34,7 +34,7 @@ LL | self.to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:221:5 + --> tests/ui/unconditional_recursion.rs:221:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -45,7 +45,7 @@ LL | x.to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:232:5 + --> tests/ui/unconditional_recursion.rs:232:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -56,7 +56,7 @@ LL | (self as &Self).to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:12:5 + --> tests/ui/unconditional_recursion.rs:12:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -65,7 +65,7 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:14:9 + --> tests/ui/unconditional_recursion.rs:14:9 | LL | self != other | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | self != other = help: to override `-D warnings` add `#[allow(clippy::unconditional_recursion)]` error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:16:5 + --> tests/ui/unconditional_recursion.rs:16:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -82,13 +82,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:18:9 + --> tests/ui/unconditional_recursion.rs:18:9 | LL | self == other | ^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:28:5 + --> tests/ui/unconditional_recursion.rs:28:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | self != &Foo2::B // no error here @@ -96,13 +96,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:29:9 + --> tests/ui/unconditional_recursion.rs:29:9 | LL | self != &Foo2::B // no error here | ^^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:31:5 + --> tests/ui/unconditional_recursion.rs:31:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | self == &Foo2::B // no error here @@ -110,13 +110,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:32:9 + --> tests/ui/unconditional_recursion.rs:32:9 | LL | self == &Foo2::B // no error here | ^^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:42:5 + --> tests/ui/unconditional_recursion.rs:42:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -125,19 +125,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:44:9 + --> tests/ui/unconditional_recursion.rs:44:9 | LL | self.ne(other) | ^^^^^^^^^^^^^^ error: parameter is only used in recursion - --> $DIR/unconditional_recursion.rs:42:18 + --> tests/ui/unconditional_recursion.rs:42:18 | LL | fn ne(&self, other: &Self) -> bool { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_other` | note: parameter used here - --> $DIR/unconditional_recursion.rs:44:17 + --> tests/ui/unconditional_recursion.rs:44:17 | LL | self.ne(other) | ^^^^^ @@ -145,7 +145,7 @@ LL | self.ne(other) = help: to override `-D warnings` add `#[allow(clippy::only_used_in_recursion)]` error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:46:5 + --> tests/ui/unconditional_recursion.rs:46:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -154,25 +154,25 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:48:9 + --> tests/ui/unconditional_recursion.rs:48:9 | LL | self.eq(other) | ^^^^^^^^^^^^^^ error: parameter is only used in recursion - --> $DIR/unconditional_recursion.rs:46:18 + --> tests/ui/unconditional_recursion.rs:46:18 | LL | fn eq(&self, other: &Self) -> bool { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_other` | note: parameter used here - --> $DIR/unconditional_recursion.rs:48:17 + --> tests/ui/unconditional_recursion.rs:48:17 | LL | self.eq(other) | ^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:90:5 + --> tests/ui/unconditional_recursion.rs:90:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -181,13 +181,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:92:9 + --> tests/ui/unconditional_recursion.rs:92:9 | LL | other != self | ^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:94:5 + --> tests/ui/unconditional_recursion.rs:94:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -196,13 +196,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:96:9 + --> tests/ui/unconditional_recursion.rs:96:9 | LL | other == self | ^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:104:5 + --> tests/ui/unconditional_recursion.rs:104:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -211,13 +211,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:106:9 + --> tests/ui/unconditional_recursion.rs:106:9 | LL | other != other | ^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/unconditional_recursion.rs:106:9 + --> tests/ui/unconditional_recursion.rs:106:9 | LL | other != other | ^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | other != other = note: `#[deny(clippy::eq_op)]` on by default error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:108:5 + --> tests/ui/unconditional_recursion.rs:108:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -234,19 +234,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:110:9 + --> tests/ui/unconditional_recursion.rs:110:9 | LL | other == other | ^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/unconditional_recursion.rs:110:9 + --> tests/ui/unconditional_recursion.rs:110:9 | LL | other == other | ^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:117:5 + --> tests/ui/unconditional_recursion.rs:117:5 | LL | / fn ne(&self, _other: &Self) -> bool { LL | | @@ -255,19 +255,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:119:9 + --> tests/ui/unconditional_recursion.rs:119:9 | LL | self != self | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/unconditional_recursion.rs:119:9 + --> tests/ui/unconditional_recursion.rs:119:9 | LL | self != self | ^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:121:5 + --> tests/ui/unconditional_recursion.rs:121:5 | LL | / fn eq(&self, _other: &Self) -> bool { LL | | @@ -276,19 +276,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:123:9 + --> tests/ui/unconditional_recursion.rs:123:9 | LL | self == self | ^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/unconditional_recursion.rs:123:9 + --> tests/ui/unconditional_recursion.rs:123:9 | LL | self == self | ^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:149:13 + --> tests/ui/unconditional_recursion.rs:149:13 | LL | / fn eq(&self, other: &Self) -> bool { LL | | self == other @@ -299,7 +299,7 @@ LL | impl_partial_eq!(S5); | -------------------- in this macro invocation | note: recursive call site - --> $DIR/unconditional_recursion.rs:150:17 + --> tests/ui/unconditional_recursion.rs:150:17 | LL | self == other | ^^^^^^^^^^^^^ @@ -309,7 +309,7 @@ LL | impl_partial_eq!(S5); = note: this error originates in the macro `impl_partial_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:178:5 + --> tests/ui/unconditional_recursion.rs:178:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -320,13 +320,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:182:9 + --> tests/ui/unconditional_recursion.rs:182:9 | LL | mine == theirs | ^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:247:5 + --> tests/ui/unconditional_recursion.rs:247:5 | LL | / fn new() -> Self { LL | | @@ -335,13 +335,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:249:9 + --> tests/ui/unconditional_recursion.rs:249:9 | LL | Self::default() | ^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:286:5 + --> tests/ui/unconditional_recursion.rs:286:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -352,7 +352,7 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:290:9 + --> tests/ui/unconditional_recursion.rs:290:9 | LL | mine.eq(theirs) | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 0b6e20664e34c..9c365e1097dbc 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -1,5 +1,5 @@ error: invisible character detected - --> $DIR/unicode.rs:5:12 + --> tests/ui/unicode.rs:5:12 | LL | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{200B}< is a ZWS, and \u{200B}another"` @@ -8,19 +8,19 @@ LL | print!("Here >​< is a ZWS, and ​another"); = help: to override `-D warnings` add `#[allow(clippy::invisible_characters)]` error: invisible character detected - --> $DIR/unicode.rs:7:12 + --> tests/ui/unicode.rs:7:12 | LL | print!("Here >­< is a SHY, and ­another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{AD}< is a SHY, and \u{AD}another"` error: invisible character detected - --> $DIR/unicode.rs:9:12 + --> tests/ui/unicode.rs:9:12 | LL | print!("Here >⁠< is a WJ, and ⁠another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{2060}< is a WJ, and \u{2060}another"` error: non-NFC Unicode sequence detected - --> $DIR/unicode.rs:15:12 + --> tests/ui/unicode.rs:15:12 | LL | print!("̀àh?"); | ^^^^^ help: consider replacing the string with: `"̀àh?"` @@ -29,37 +29,37 @@ LL | print!("̀àh?"); = help: to override `-D warnings` add `#[allow(clippy::unicode_not_nfc)]` error: literal non-ASCII character detected - --> $DIR/unicode.rs:23:16 + --> tests/ui/unicode.rs:23:16 | LL | print!("Üben!"); | ^^^^^^^ help: consider replacing the string with: `"\u{dc}ben!"` | note: the lint level is defined here - --> $DIR/unicode.rs:20:13 + --> tests/ui/unicode.rs:20:13 | LL | #![deny(clippy::non_ascii_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: literal non-ASCII character detected - --> $DIR/unicode.rs:29:36 + --> tests/ui/unicode.rs:29:36 | LL | const _EMPTY_BLOCK: char = '▱'; | ^^^ help: consider replacing the string with: `'\u{25b1}'` error: literal non-ASCII character detected - --> $DIR/unicode.rs:30:35 + --> tests/ui/unicode.rs:30:35 | LL | const _FULL_BLOCK: char = '▰'; | ^^^ help: consider replacing the string with: `'\u{25b0}'` error: literal non-ASCII character detected - --> $DIR/unicode.rs:50:21 + --> tests/ui/unicode.rs:50:21 | LL | let _ = "悲しいかな、ここに日本語を書くことはできない。"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"\u{60b2}\u{3057}\u{3044}\u{304b}\u{306a}\u{3001}\u{3053}\u{3053}\u{306b}\u{65e5}\u{672c}\u{8a9e}\u{3092}\u{66f8}\u{304f}\u{3053}\u{3068}\u{306f}\u{3067}\u{304d}\u{306a}\u{3044}\u{3002}"` | note: the lint level is defined here - --> $DIR/unicode.rs:39:17 + --> tests/ui/unicode.rs:39:17 | LL | #![deny(clippy::non_ascii_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninhabited_references.stderr b/tests/ui/uninhabited_references.stderr index 2cdf320b8092f..446d4e7555703 100644 --- a/tests/ui/uninhabited_references.stderr +++ b/tests/ui/uninhabited_references.stderr @@ -1,5 +1,5 @@ error: dereferencing a reference to an uninhabited type would be undefined behavior - --> $DIR/uninhabited_references.rs:4:23 + --> tests/ui/uninhabited_references.rs:4:23 | LL | fn ret_uninh_ref() -> &'static std::convert::Infallible { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn ret_uninh_ref() -> &'static std::convert::Infallible { = help: to override `-D warnings` add `#[allow(clippy::uninhabited_references)]` error: dereferencing a reference to an uninhabited type would be undefined behavior - --> $DIR/uninhabited_references.rs:10:30 + --> tests/ui/uninhabited_references.rs:10:30 | LL | fn $name(x: &$ty) -> &$ty { | ^^^^ @@ -19,7 +19,7 @@ LL | ret_something!(id_never, !); = note: this error originates in the macro `ret_something` (in Nightly builds, run with -Z macro-backtrace for more info) error: dereferencing a reference to an uninhabited type is undefined behavior - --> $DIR/uninhabited_references.rs:11:14 + --> tests/ui/uninhabited_references.rs:11:14 | LL | &*x | ^^ @@ -30,7 +30,7 @@ LL | ret_something!(id_never, !); = note: this error originates in the macro `ret_something` (in Nightly builds, run with -Z macro-backtrace for more info) error: dereferencing a reference to an uninhabited type is undefined behavior - --> $DIR/uninhabited_references.rs:21:13 + --> tests/ui/uninhabited_references.rs:21:13 | LL | let _ = *x; | ^^ diff --git a/tests/ui/uninit.stderr b/tests/ui/uninit.stderr index 1cc27ffe70d5d..81577fe3fd477 100644 --- a/tests/ui/uninit.stderr +++ b/tests/ui/uninit.stderr @@ -1,5 +1,5 @@ error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:12:29 + --> tests/ui/uninit.rs:12:29 | LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; = note: `#[deny(clippy::uninit_assumed_init)]` on by default error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:35:29 + --> tests/ui/uninit.rs:35:29 | LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:44:29 + --> tests/ui/uninit.rs:44:29 | LL | let _: T = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninit_vec.stderr b/tests/ui/uninit_vec.stderr index d39f05839ed90..8e93466c2cc84 100644 --- a/tests/ui/uninit_vec.stderr +++ b/tests/ui/uninit_vec.stderr @@ -1,5 +1,5 @@ error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:17:5 + --> tests/ui/uninit_vec.rs:17:5 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | vec.set_len(200); = help: to override `-D warnings` add `#[allow(clippy::uninit_vec)]` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:24:5 + --> tests/ui/uninit_vec.rs:24:5 | LL | vec.reserve(1000); | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` on empty `Vec` creates out-of-bound values - --> $DIR/uninit_vec.rs:31:5 + --> tests/ui/uninit_vec.rs:31:5 | LL | let mut vec: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ error: calling `set_len()` on empty `Vec` creates out-of-bound values - --> $DIR/uninit_vec.rs:38:5 + --> tests/ui/uninit_vec.rs:38:5 | LL | let mut vec: Vec = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ error: calling `set_len()` on empty `Vec` creates out-of-bound values - --> $DIR/uninit_vec.rs:44:5 + --> tests/ui/uninit_vec.rs:44:5 | LL | let mut vec: Vec = Vec::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:61:5 + --> tests/ui/uninit_vec.rs:61:5 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:71:5 + --> tests/ui/uninit_vec.rs:71:5 | LL | my_vec.vec.reserve(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | my_vec.vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:77:5 + --> tests/ui/uninit_vec.rs:77:5 | LL | my_vec.vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | my_vec.vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:52:9 + --> tests/ui/uninit_vec.rs:52:9 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:56:9 + --> tests/ui/uninit_vec.rs:56:9 | LL | vec.reserve(1000); | ^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:132:9 + --> tests/ui/uninit_vec.rs:132:9 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninlined_format_args.stderr b/tests/ui/uninlined_format_args.stderr index 829d646b86692..5a7ff3bc4f5aa 100644 --- a/tests/ui/uninlined_format_args.stderr +++ b/tests/ui/uninlined_format_args.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:45:5 + --> tests/ui/uninlined_format_args.rs:45:5 | LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:46:5 + --> tests/ui/uninlined_format_args.rs:46:5 | LL | println!("val='{ }'", local_i32); // 3 spaces | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("val='{local_i32}'"); // 3 spaces | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:47:5 + --> tests/ui/uninlined_format_args.rs:47:5 | LL | println!("val='{ }'", local_i32); // tab | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("val='{local_i32}'"); // tab | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:48:5 + --> tests/ui/uninlined_format_args.rs:48:5 | LL | println!("val='{ }'", local_i32); // space+tab | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("val='{local_i32}'"); // space+tab | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:49:5 + --> tests/ui/uninlined_format_args.rs:49:5 | LL | println!("val='{ }'", local_i32); // tab+space | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!("val='{local_i32}'"); // tab+space | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:50:5 + --> tests/ui/uninlined_format_args.rs:50:5 | LL | / println!( LL | | "val='{ @@ -71,7 +71,7 @@ LL | | ); | |_____^ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:55:5 + --> tests/ui/uninlined_format_args.rs:55:5 | LL | println!("{}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL + println!("{local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:56:5 + --> tests/ui/uninlined_format_args.rs:56:5 | LL | println!("{}", fn_arg); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL + println!("{fn_arg}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:57:5 + --> tests/ui/uninlined_format_args.rs:57:5 | LL | println!("{:?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -107,7 +107,7 @@ LL + println!("{local_i32:?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:58:5 + --> tests/ui/uninlined_format_args.rs:58:5 | LL | println!("{:#?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL + println!("{local_i32:#?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:59:5 + --> tests/ui/uninlined_format_args.rs:59:5 | LL | println!("{:4}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL + println!("{local_i32:4}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:60:5 + --> tests/ui/uninlined_format_args.rs:60:5 | LL | println!("{:04}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -143,7 +143,7 @@ LL + println!("{local_i32:04}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:61:5 + --> tests/ui/uninlined_format_args.rs:61:5 | LL | println!("{:<3}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + println!("{local_i32:<3}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:62:5 + --> tests/ui/uninlined_format_args.rs:62:5 | LL | println!("{:#010x}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL + println!("{local_i32:#010x}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:63:5 + --> tests/ui/uninlined_format_args.rs:63:5 | LL | println!("{:.1}", local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL + println!("{local_f64:.1}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:67:5 + --> tests/ui/uninlined_format_args.rs:67:5 | LL | println!("{} {}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -191,7 +191,7 @@ LL + println!("{local_i32} {local_f64}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:69:5 + --> tests/ui/uninlined_format_args.rs:69:5 | LL | println!("{}", val); | ^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL + println!("{val}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:70:5 + --> tests/ui/uninlined_format_args.rs:70:5 | LL | println!("{}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -215,7 +215,7 @@ LL + println!("{val}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:72:5 + --> tests/ui/uninlined_format_args.rs:72:5 | LL | println!("val='{\t }'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -227,7 +227,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:73:5 + --> tests/ui/uninlined_format_args.rs:73:5 | LL | println!("val='{\n }'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -239,7 +239,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:74:5 + --> tests/ui/uninlined_format_args.rs:74:5 | LL | println!("val='{local_i32}'", local_i32 = local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -251,7 +251,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:75:5 + --> tests/ui/uninlined_format_args.rs:75:5 | LL | println!("val='{local_i32}'", local_i32 = fn_arg); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL + println!("val='{fn_arg}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:76:5 + --> tests/ui/uninlined_format_args.rs:76:5 | LL | println!("{0}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,7 +275,7 @@ LL + println!("{local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:77:5 + --> tests/ui/uninlined_format_args.rs:77:5 | LL | println!("{0:?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -287,7 +287,7 @@ LL + println!("{local_i32:?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:78:5 + --> tests/ui/uninlined_format_args.rs:78:5 | LL | println!("{0:#?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -299,7 +299,7 @@ LL + println!("{local_i32:#?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:79:5 + --> tests/ui/uninlined_format_args.rs:79:5 | LL | println!("{0:04}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -311,7 +311,7 @@ LL + println!("{local_i32:04}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:80:5 + --> tests/ui/uninlined_format_args.rs:80:5 | LL | println!("{0:<3}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -323,7 +323,7 @@ LL + println!("{local_i32:<3}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:81:5 + --> tests/ui/uninlined_format_args.rs:81:5 | LL | println!("{0:#010x}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -335,7 +335,7 @@ LL + println!("{local_i32:#010x}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:82:5 + --> tests/ui/uninlined_format_args.rs:82:5 | LL | println!("{0:.1}", local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -347,7 +347,7 @@ LL + println!("{local_f64:.1}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:83:5 + --> tests/ui/uninlined_format_args.rs:83:5 | LL | println!("{0} {0}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -359,7 +359,7 @@ LL + println!("{local_i32} {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:84:5 + --> tests/ui/uninlined_format_args.rs:84:5 | LL | println!("{1} {} {0} {}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL + println!("{local_f64} {local_i32} {local_i32} {local_f64}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:85:5 + --> tests/ui/uninlined_format_args.rs:85:5 | LL | println!("{0} {1}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -383,7 +383,7 @@ LL + println!("{local_i32} {local_f64}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:86:5 + --> tests/ui/uninlined_format_args.rs:86:5 | LL | println!("{1} {0}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -395,7 +395,7 @@ LL + println!("{local_f64} {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:87:5 + --> tests/ui/uninlined_format_args.rs:87:5 | LL | println!("{1} {0} {1} {0}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -407,7 +407,7 @@ LL + println!("{local_f64} {local_i32} {local_f64} {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:89:5 + --> tests/ui/uninlined_format_args.rs:89:5 | LL | println!("{v}", v = local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -419,7 +419,7 @@ LL + println!("{local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:90:5 + --> tests/ui/uninlined_format_args.rs:90:5 | LL | println!("{local_i32:0$}", width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -431,7 +431,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:91:5 + --> tests/ui/uninlined_format_args.rs:91:5 | LL | println!("{local_i32:w$}", w = width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -443,7 +443,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:92:5 + --> tests/ui/uninlined_format_args.rs:92:5 | LL | println!("{local_i32:.0$}", prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:93:5 + --> tests/ui/uninlined_format_args.rs:93:5 | LL | println!("{local_i32:.p$}", p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -467,7 +467,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:94:5 + --> tests/ui/uninlined_format_args.rs:94:5 | LL | println!("{:0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -479,7 +479,7 @@ LL + println!("{val:val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:95:5 + --> tests/ui/uninlined_format_args.rs:95:5 | LL | println!("{0:0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -491,7 +491,7 @@ LL + println!("{val:val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:96:5 + --> tests/ui/uninlined_format_args.rs:96:5 | LL | println!("{:0$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -503,7 +503,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:97:5 + --> tests/ui/uninlined_format_args.rs:97:5 | LL | println!("{0:0$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -515,7 +515,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:98:5 + --> tests/ui/uninlined_format_args.rs:98:5 | LL | println!("{0:0$.v$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -527,7 +527,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:99:5 + --> tests/ui/uninlined_format_args.rs:99:5 | LL | println!("{0:v$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -539,7 +539,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:100:5 + --> tests/ui/uninlined_format_args.rs:100:5 | LL | println!("{v:0$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -551,7 +551,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:101:5 + --> tests/ui/uninlined_format_args.rs:101:5 | LL | println!("{v:v$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -563,7 +563,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:102:5 + --> tests/ui/uninlined_format_args.rs:102:5 | LL | println!("{v:0$.v$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -575,7 +575,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:103:5 + --> tests/ui/uninlined_format_args.rs:103:5 | LL | println!("{v:v$.v$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -587,7 +587,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:104:5 + --> tests/ui/uninlined_format_args.rs:104:5 | LL | println!("{:0$}", width); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -599,7 +599,7 @@ LL + println!("{width:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:105:5 + --> tests/ui/uninlined_format_args.rs:105:5 | LL | println!("{:1$}", local_i32, width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -611,7 +611,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:106:5 + --> tests/ui/uninlined_format_args.rs:106:5 | LL | println!("{:w$}", w = width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -623,7 +623,7 @@ LL + println!("{width:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:107:5 + --> tests/ui/uninlined_format_args.rs:107:5 | LL | println!("{:w$}", local_i32, w = width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -635,7 +635,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:108:5 + --> tests/ui/uninlined_format_args.rs:108:5 | LL | println!("{:.0$}", prec); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -647,7 +647,7 @@ LL + println!("{prec:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:109:5 + --> tests/ui/uninlined_format_args.rs:109:5 | LL | println!("{:.1$}", local_i32, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -659,7 +659,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:110:5 + --> tests/ui/uninlined_format_args.rs:110:5 | LL | println!("{:.p$}", p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -671,7 +671,7 @@ LL + println!("{prec:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:111:5 + --> tests/ui/uninlined_format_args.rs:111:5 | LL | println!("{:.p$}", local_i32, p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -683,7 +683,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:112:5 + --> tests/ui/uninlined_format_args.rs:112:5 | LL | println!("{:0$.1$}", width, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -695,7 +695,7 @@ LL + println!("{width:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:113:5 + --> tests/ui/uninlined_format_args.rs:113:5 | LL | println!("{:0$.w$}", width, w = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -707,7 +707,7 @@ LL + println!("{width:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:114:5 + --> tests/ui/uninlined_format_args.rs:114:5 | LL | println!("{:1$.2$}", local_f64, width, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -719,7 +719,7 @@ LL + println!("{local_f64:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:115:5 + --> tests/ui/uninlined_format_args.rs:115:5 | LL | println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -731,7 +731,7 @@ LL + println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:116:5 + --> tests/ui/uninlined_format_args.rs:116:5 | LL | / println!( LL | | "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$}", @@ -740,7 +740,7 @@ LL | | ); | |_____^ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:127:5 + --> tests/ui/uninlined_format_args.rs:127:5 | LL | println!("Width = {}, value with width = {:0$}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -752,7 +752,7 @@ LL + println!("Width = {local_i32}, value with width = {local_f64:local_i32$ | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:128:5 + --> tests/ui/uninlined_format_args.rs:128:5 | LL | println!("{:w$.p$}", local_i32, w = width, p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -764,7 +764,7 @@ LL + println!("{local_i32:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:129:5 + --> tests/ui/uninlined_format_args.rs:129:5 | LL | println!("{:w$.p$}", w = width, p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -776,7 +776,7 @@ LL + println!("{width:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:148:5 + --> tests/ui/uninlined_format_args.rs:148:5 | LL | / println!( LL | | "{}", @@ -786,7 +786,7 @@ LL | | ); | |_____^ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:153:5 + --> tests/ui/uninlined_format_args.rs:153:5 | LL | println!("{}", /* comment with a comma , in it */ val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -798,7 +798,7 @@ LL + println!("{val}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:159:9 + --> tests/ui/uninlined_format_args.rs:159:9 | LL | panic!("p1 {}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -810,7 +810,7 @@ LL + panic!("p1 {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:162:9 + --> tests/ui/uninlined_format_args.rs:162:9 | LL | panic!("p2 {0}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -822,7 +822,7 @@ LL + panic!("p2 {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:165:9 + --> tests/ui/uninlined_format_args.rs:165:9 | LL | panic!("p3 {local_i32}", local_i32 = local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -834,7 +834,7 @@ LL + panic!("p3 {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:185:5 + --> tests/ui/uninlined_format_args.rs:185:5 | LL | println!("expand='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninlined_format_args_panic.edition2018.stderr b/tests/ui/uninlined_format_args_panic.edition2018.stderr index 736a68ab1c7e3..0541dd9a7d7bc 100644 --- a/tests/ui/uninlined_format_args_panic.edition2018.stderr +++ b/tests/ui/uninlined_format_args_panic.edition2018.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:10:5 + --> tests/ui/uninlined_format_args_panic.rs:10:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninlined_format_args_panic.edition2021.stderr b/tests/ui/uninlined_format_args_panic.edition2021.stderr index ec1e3a1cf1178..3615eaa9dee37 100644 --- a/tests/ui/uninlined_format_args_panic.edition2021.stderr +++ b/tests/ui/uninlined_format_args_panic.edition2021.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:10:5 + --> tests/ui/uninlined_format_args_panic.rs:10:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("val='{var}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:13:9 + --> tests/ui/uninlined_format_args_panic.rs:13:9 | LL | panic!("p1 {}", var); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + panic!("p1 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:16:9 + --> tests/ui/uninlined_format_args_panic.rs:16:9 | LL | panic!("p2 {0}", var); | ^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + panic!("p2 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:19:9 + --> tests/ui/uninlined_format_args_panic.rs:19:9 | LL | panic!("p3 {var}", var = var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + panic!("p3 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:29:5 + --> tests/ui/uninlined_format_args_panic.rs:29:5 | LL | assert!(var == 1, "p5 {}", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + assert!(var == 1, "p5 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:30:5 + --> tests/ui/uninlined_format_args_panic.rs:30:5 | LL | debug_assert!(var == 1, "p6 {}", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index 8656c8fddabc3..41ad1a2d3834f 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,5 +1,5 @@ error: passing a unit value to a function - --> $DIR/unit_arg.rs:63:5 + --> tests/ui/unit_arg.rs:63:5 | LL | / foo({ LL | | 1; @@ -21,7 +21,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:66:5 + --> tests/ui/unit_arg.rs:66:5 | LL | foo(foo(1)); | ^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:67:5 + --> tests/ui/unit_arg.rs:67:5 | LL | / foo({ LL | | foo(1); @@ -55,7 +55,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:72:5 + --> tests/ui/unit_arg.rs:72:5 | LL | / b.bar({ LL | | 1; @@ -75,7 +75,7 @@ LL ~ b.bar(()); | error: passing unit values to a function - --> $DIR/unit_arg.rs:75:5 + --> tests/ui/unit_arg.rs:75:5 | LL | taking_multiple_units(foo(0), foo(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL ~ taking_multiple_units((), ()); | error: passing unit values to a function - --> $DIR/unit_arg.rs:76:5 + --> tests/ui/unit_arg.rs:76:5 | LL | / taking_multiple_units(foo(0), { LL | | foo(1); @@ -111,7 +111,7 @@ LL ~ taking_multiple_units((), ()); | error: passing unit values to a function - --> $DIR/unit_arg.rs:80:5 + --> tests/ui/unit_arg.rs:80:5 | LL | / taking_multiple_units( LL | | { @@ -147,7 +147,7 @@ LL ~ ); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:91:13 + --> tests/ui/unit_arg.rs:91:13 | LL | None.or(Some(foo(2))); | ^^^^^^^^^^^^ @@ -161,7 +161,7 @@ LL ~ }); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:94:5 + --> tests/ui/unit_arg.rs:94:5 | LL | foo(foo(())); | ^^^^^^^^^^^^ @@ -173,7 +173,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:131:5 + --> tests/ui/unit_arg.rs:131:5 | LL | Some(foo(1)) | ^^^^^^^^^^^^ diff --git a/tests/ui/unit_arg_empty_blocks.stderr b/tests/ui/unit_arg_empty_blocks.stderr index b207acb5927d5..d971195dda265 100644 --- a/tests/ui/unit_arg_empty_blocks.stderr +++ b/tests/ui/unit_arg_empty_blocks.stderr @@ -1,5 +1,5 @@ error: passing a unit value to a function - --> $DIR/unit_arg_empty_blocks.rs:16:5 + --> tests/ui/unit_arg_empty_blocks.rs:16:5 | LL | foo({}); | ^^^^--^ @@ -10,7 +10,7 @@ LL | foo({}); = help: to override `-D warnings` add `#[allow(clippy::unit_arg)]` error: passing a unit value to a function - --> $DIR/unit_arg_empty_blocks.rs:17:5 + --> tests/ui/unit_arg_empty_blocks.rs:17:5 | LL | foo3({}, 2, 2); | ^^^^^--^^^^^^^ @@ -18,7 +18,7 @@ LL | foo3({}, 2, 2); | help: use a unit literal instead: `()` error: passing unit values to a function - --> $DIR/unit_arg_empty_blocks.rs:18:5 + --> tests/ui/unit_arg_empty_blocks.rs:18:5 | LL | taking_two_units({}, foo(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL ~ taking_two_units((), ()); | error: passing unit values to a function - --> $DIR/unit_arg_empty_blocks.rs:19:5 + --> tests/ui/unit_arg_empty_blocks.rs:19:5 | LL | taking_three_units({}, foo(0), foo(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 17355e2379785..f9473d3be2627 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,5 +1,5 @@ error: ==-comparison of unit values detected. This will always be true - --> $DIR/unit_cmp.rs:17:8 + --> tests/ui/unit_cmp.rs:17:8 | LL | if { | ________^ @@ -15,7 +15,7 @@ LL | | } {} = help: to override `-D warnings` add `#[allow(clippy::unit_cmp)]` error: >-comparison of unit values detected. This will always be false - --> $DIR/unit_cmp.rs:25:8 + --> tests/ui/unit_cmp.rs:25:8 | LL | if { | ________^ @@ -27,7 +27,7 @@ LL | | } {} | |_____^ error: `assert_eq` of unit values detected. This will always succeed - --> $DIR/unit_cmp.rs:32:5 + --> tests/ui/unit_cmp.rs:32:5 | LL | / assert_eq!( LL | | @@ -39,7 +39,7 @@ LL | | ); | |_____^ error: `debug_assert_eq` of unit values detected. This will always succeed - --> $DIR/unit_cmp.rs:41:5 + --> tests/ui/unit_cmp.rs:41:5 | LL | / debug_assert_eq!( LL | | @@ -51,7 +51,7 @@ LL | | ); | |_____^ error: `assert_ne` of unit values detected. This will always fail - --> $DIR/unit_cmp.rs:51:5 + --> tests/ui/unit_cmp.rs:51:5 | LL | / assert_ne!( LL | | @@ -63,7 +63,7 @@ LL | | ); | |_____^ error: `debug_assert_ne` of unit values detected. This will always fail - --> $DIR/unit_cmp.rs:60:5 + --> tests/ui/unit_cmp.rs:60:5 | LL | / debug_assert_ne!( LL | | diff --git a/tests/ui/unit_hash.stderr b/tests/ui/unit_hash.stderr index a26fd734413c1..b48f3a543b763 100644 --- a/tests/ui/unit_hash.stderr +++ b/tests/ui/unit_hash.stderr @@ -1,5 +1,5 @@ error: this call to `hash` on the unit type will do nothing - --> $DIR/unit_hash.rs:19:23 + --> tests/ui/unit_hash.rs:19:23 | LL | Foo::Empty => ().hash(&mut state), | ^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` @@ -9,7 +9,7 @@ LL | Foo::Empty => ().hash(&mut state), = help: to override `-D warnings` add `#[allow(clippy::unit_hash)]` error: this call to `hash` on the unit type will do nothing - --> $DIR/unit_hash.rs:26:5 + --> tests/ui/unit_hash.rs:26:5 | LL | res.hash(&mut state); | ^^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` @@ -17,7 +17,7 @@ LL | res.hash(&mut state); = note: the implementation of `Hash` for `()` is a no-op error: this call to `hash` on the unit type will do nothing - --> $DIR/unit_hash.rs:31:5 + --> tests/ui/unit_hash.rs:31:5 | LL | do_nothing().hash(&mut state); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` diff --git a/tests/ui/unit_return_expecting_ord.stderr b/tests/ui/unit_return_expecting_ord.stderr index 9220fb89e901e..b2fc885701582 100644 --- a/tests/ui/unit_return_expecting_ord.stderr +++ b/tests/ui/unit_return_expecting_ord.stderr @@ -1,11 +1,11 @@ error: this closure returns the unit type which also implements Ord - --> $DIR/unit_return_expecting_ord.rs:19:25 + --> tests/ui/unit_return_expecting_ord.rs:19:25 | LL | structs.sort_by_key(|s| { | ^^^ | help: probably caused by this trailing semicolon - --> $DIR/unit_return_expecting_ord.rs:21:24 + --> tests/ui/unit_return_expecting_ord.rs:21:24 | LL | double(s.field); | ^ @@ -13,25 +13,25 @@ LL | double(s.field); = help: to override `-D warnings` add `#[allow(clippy::unit_return_expecting_ord)]` error: this closure returns the unit type which also implements PartialOrd - --> $DIR/unit_return_expecting_ord.rs:24:30 + --> tests/ui/unit_return_expecting_ord.rs:24:30 | LL | structs.is_sorted_by_key(|s| { | ^^^ | help: probably caused by this trailing semicolon - --> $DIR/unit_return_expecting_ord.rs:26:24 + --> tests/ui/unit_return_expecting_ord.rs:26:24 | LL | double(s.field); | ^ error: this closure returns the unit type which also implements PartialOrd - --> $DIR/unit_return_expecting_ord.rs:28:30 + --> tests/ui/unit_return_expecting_ord.rs:28:30 | LL | structs.is_sorted_by_key(|s| { | ^^^ error: this closure returns the unit type which also implements Ord - --> $DIR/unit_return_expecting_ord.rs:39:25 + --> tests/ui/unit_return_expecting_ord.rs:39:25 | LL | structs.sort_by_key(|s| unit(s.field)); | ^^^ diff --git a/tests/ui/unknown_attribute.stderr b/tests/ui/unknown_attribute.stderr index edad35d1591be..d1f8eeb51aeac 100644 --- a/tests/ui/unknown_attribute.stderr +++ b/tests/ui/unknown_attribute.stderr @@ -1,5 +1,5 @@ error: usage of unknown attribute - --> $DIR/unknown_attribute.rs:1:11 + --> tests/ui/unknown_attribute.rs:1:11 | LL | #[clippy::unknown] | ^^^^^^^ diff --git a/tests/ui/unknown_clippy_lints.stderr b/tests/ui/unknown_clippy_lints.stderr index 432c7f72e32ed..aa2c2f3c0e202 100644 --- a/tests/ui/unknown_clippy_lints.stderr +++ b/tests/ui/unknown_clippy_lints.stderr @@ -1,5 +1,5 @@ error: unknown lint: `clippy::All` - --> $DIR/unknown_clippy_lints.rs:3:10 + --> tests/ui/unknown_clippy_lints.rs:3:10 | LL | #![allow(clippy::All)] | ^^^^^^^^^^^ help: did you mean: `clippy::all` @@ -8,31 +8,31 @@ LL | #![allow(clippy::All)] = help: to override `-D warnings` add `#[allow(unknown_lints)]` error: unknown lint: `clippy::CMP_OWNED` - --> $DIR/unknown_clippy_lints.rs:4:9 + --> tests/ui/unknown_clippy_lints.rs:4:9 | LL | #![warn(clippy::CMP_OWNED)] | ^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::cmp_owned` error: unknown lint: `clippy::if_not_els` - --> $DIR/unknown_clippy_lints.rs:7:8 + --> tests/ui/unknown_clippy_lints.rs:7:8 | LL | #[warn(clippy::if_not_els)] | ^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::if_not_else` error: unknown lint: `clippy::UNNecsaRy_cAst` - --> $DIR/unknown_clippy_lints.rs:8:8 + --> tests/ui/unknown_clippy_lints.rs:8:8 | LL | #[warn(clippy::UNNecsaRy_cAst)] | ^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unnecessary_cast` error: unknown lint: `clippy::useles_transute` - --> $DIR/unknown_clippy_lints.rs:9:8 + --> tests/ui/unknown_clippy_lints.rs:9:8 | LL | #[warn(clippy::useles_transute)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::useless_transmute` error: unknown lint: `clippy::dead_cod` - --> $DIR/unknown_clippy_lints.rs:11:8 + --> tests/ui/unknown_clippy_lints.rs:11:8 | LL | #[warn(clippy::dead_cod)] | ^^^^^^^^^^^^^^^^ @@ -43,19 +43,19 @@ LL | #[warn(dead_code)] | ~~~~~~~~~ error: unknown lint: `clippy::unused_colle` - --> $DIR/unknown_clippy_lints.rs:13:8 + --> tests/ui/unknown_clippy_lints.rs:13:8 | LL | #[warn(clippy::unused_colle)] | ^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unused_self` error: unknown lint: `clippy::const_static_lifetim` - --> $DIR/unknown_clippy_lints.rs:15:8 + --> tests/ui/unknown_clippy_lints.rs:15:8 | LL | #[warn(clippy::const_static_lifetim)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::redundant_static_lifetimes` error: unknown lint: `clippy::missing_docs` - --> $DIR/unknown_clippy_lints.rs:17:8 + --> tests/ui/unknown_clippy_lints.rs:17:8 | LL | #[warn(clippy::missing_docs)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_box_returns.stderr b/tests/ui/unnecessary_box_returns.stderr index 944e911fa944e..cb88ba1b0016d 100644 --- a/tests/ui/unnecessary_box_returns.stderr +++ b/tests/ui/unnecessary_box_returns.stderr @@ -1,5 +1,5 @@ error: boxed return of the sized type `usize` - --> $DIR/unnecessary_box_returns.rs:5:22 + --> tests/ui/unnecessary_box_returns.rs:5:22 | LL | fn baz(&self) -> Box; | ^^^^^^^^^^ help: try: `usize` @@ -9,7 +9,7 @@ LL | fn baz(&self) -> Box; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_box_returns)]` error: boxed return of the sized type `usize` - --> $DIR/unnecessary_box_returns.rs:19:22 + --> tests/ui/unnecessary_box_returns.rs:19:22 | LL | fn baz(&self) -> Box { | ^^^^^^^^^^ help: try: `usize` @@ -17,7 +17,7 @@ LL | fn baz(&self) -> Box { = help: changing this also requires a change to the return expressions in this function error: boxed return of the sized type `usize` - --> $DIR/unnecessary_box_returns.rs:27:20 + --> tests/ui/unnecessary_box_returns.rs:27:20 | LL | fn bxed_usize() -> Box { | ^^^^^^^^^^ help: try: `usize` @@ -25,7 +25,7 @@ LL | fn bxed_usize() -> Box { = help: changing this also requires a change to the return expressions in this function error: boxed return of the sized type `Foo` - --> $DIR/unnecessary_box_returns.rs:33:19 + --> tests/ui/unnecessary_box_returns.rs:33:19 | LL | fn _bxed_foo() -> Box { | ^^^^^^^^ help: try: `Foo` diff --git a/tests/ui/unnecessary_cast.stderr b/tests/ui/unnecessary_cast.stderr index d4786f66e4476..9456c5acde39f 100644 --- a/tests/ui/unnecessary_cast.stderr +++ b/tests/ui/unnecessary_cast.stderr @@ -1,5 +1,5 @@ error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) - --> $DIR/unnecessary_cast.rs:18:5 + --> tests/ui/unnecessary_cast.rs:18:5 | LL | ptr as *const T | ^^^^^^^^^^^^^^^ help: try: `ptr` @@ -8,235 +8,235 @@ LL | ptr as *const T = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:53:5 + --> tests/ui/unnecessary_cast.rs:53:5 | LL | 1i32 as i32; | ^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:54:5 + --> tests/ui/unnecessary_cast.rs:54:5 | LL | 1f32 as f32; | ^^^^^^^^^^^ help: try: `1_f32` error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/unnecessary_cast.rs:55:5 + --> tests/ui/unnecessary_cast.rs:55:5 | LL | false as bool; | ^^^^^^^^^^^^^ help: try: `false` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:58:5 + --> tests/ui/unnecessary_cast.rs:58:5 | LL | -1_i32 as i32; | ^^^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:59:5 + --> tests/ui/unnecessary_cast.rs:59:5 | LL | - 1_i32 as i32; | ^^^^^^^^^^^^^^ help: try: `- 1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:60:5 + --> tests/ui/unnecessary_cast.rs:60:5 | LL | -1f32 as f32; | ^^^^^^^^^^^^ help: try: `-1_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:61:5 + --> tests/ui/unnecessary_cast.rs:61:5 | LL | 1_i32 as i32; | ^^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:62:5 + --> tests/ui/unnecessary_cast.rs:62:5 | LL | 1_f32 as f32; | ^^^^^^^^^^^^ help: try: `1_f32` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:64:22 + --> tests/ui/unnecessary_cast.rs:64:22 | LL | let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:66:5 + --> tests/ui/unnecessary_cast.rs:66:5 | LL | [1u8, 2].as_ptr() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`) - --> $DIR/unnecessary_cast.rs:68:5 + --> tests/ui/unnecessary_cast.rs:68:5 | LL | [1u8, 2].as_mut_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) - --> $DIR/unnecessary_cast.rs:79:5 + --> tests/ui/unnecessary_cast.rs:79:5 | LL | owo::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `owo::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:80:5 + --> tests/ui/unnecessary_cast.rs:80:5 | LL | uwu::([1u32].as_ptr()) as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) - --> $DIR/unnecessary_cast.rs:82:5 + --> tests/ui/unnecessary_cast.rs:82:5 | LL | uwu::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting to the same type is unnecessary (`u32` -> `u32`) - --> $DIR/unnecessary_cast.rs:117:5 + --> tests/ui/unnecessary_cast.rs:117:5 | LL | aaa() as u32; | ^^^^^^^^^^^^ help: try: `aaa()` error: casting to the same type is unnecessary (`u32` -> `u32`) - --> $DIR/unnecessary_cast.rs:119:5 + --> tests/ui/unnecessary_cast.rs:119:5 | LL | aaa() as u32; | ^^^^^^^^^^^^ help: try: `aaa()` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:155:9 + --> tests/ui/unnecessary_cast.rs:155:9 | LL | 100 as f32; | ^^^^^^^^^^ help: try: `100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:156:9 + --> tests/ui/unnecessary_cast.rs:156:9 | LL | 100 as f64; | ^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:157:9 + --> tests/ui/unnecessary_cast.rs:157:9 | LL | 100_i32 as f64; | ^^^^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:158:17 + --> tests/ui/unnecessary_cast.rs:158:17 | LL | let _ = -100 as f32; | ^^^^^^^^^^^ help: try: `-100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:159:17 + --> tests/ui/unnecessary_cast.rs:159:17 | LL | let _ = -100 as f64; | ^^^^^^^^^^^ help: try: `-100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:160:17 + --> tests/ui/unnecessary_cast.rs:160:17 | LL | let _ = -100_i32 as f64; | ^^^^^^^^^^^^^^^ help: try: `-100_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:161:9 + --> tests/ui/unnecessary_cast.rs:161:9 | LL | 100. as f32; | ^^^^^^^^^^^ help: try: `100_f32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:162:9 + --> tests/ui/unnecessary_cast.rs:162:9 | LL | 100. as f64; | ^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:174:9 + --> tests/ui/unnecessary_cast.rs:174:9 | LL | 1 as u32; | ^^^^^^^^ help: try: `1_u32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:175:9 + --> tests/ui/unnecessary_cast.rs:175:9 | LL | 0x10 as i32; | ^^^^^^^^^^^ help: try: `0x10_i32` error: casting integer literal to `usize` is unnecessary - --> $DIR/unnecessary_cast.rs:176:9 + --> tests/ui/unnecessary_cast.rs:176:9 | LL | 0b10 as usize; | ^^^^^^^^^^^^^ help: try: `0b10_usize` error: casting integer literal to `u16` is unnecessary - --> $DIR/unnecessary_cast.rs:177:9 + --> tests/ui/unnecessary_cast.rs:177:9 | LL | 0o73 as u16; | ^^^^^^^^^^^ help: try: `0o73_u16` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:178:9 + --> tests/ui/unnecessary_cast.rs:178:9 | LL | 1_000_000_000 as u32; | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:180:9 + --> tests/ui/unnecessary_cast.rs:180:9 | LL | 1.0 as f64; | ^^^^^^^^^^ help: try: `1.0_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:181:9 + --> tests/ui/unnecessary_cast.rs:181:9 | LL | 0.5 as f32; | ^^^^^^^^^^ help: try: `0.5_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:185:17 + --> tests/ui/unnecessary_cast.rs:185:17 | LL | let _ = -1 as i32; | ^^^^^^^^^ help: try: `-1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:186:17 + --> tests/ui/unnecessary_cast.rs:186:17 | LL | let _ = -1.0 as f32; | ^^^^^^^^^^^ help: try: `-1.0_f32` error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/unnecessary_cast.rs:192:18 + --> tests/ui/unnecessary_cast.rs:192:18 | LL | let _ = &(x as i32); | ^^^^^^^^^^ help: try: `{ x }` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:198:22 + --> tests/ui/unnecessary_cast.rs:198:22 | LL | let _: i32 = -(1) as i32; | ^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i64` is unnecessary - --> $DIR/unnecessary_cast.rs:200:22 + --> tests/ui/unnecessary_cast.rs:200:22 | LL | let _: i64 = -(1) as i64; | ^^^^^^^^^^^ help: try: `-1_i64` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:207:22 + --> tests/ui/unnecessary_cast.rs:207:22 | LL | let _: f64 = (-8.0 as f64).exp(); | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:209:23 + --> tests/ui/unnecessary_cast.rs:209:23 | LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior | ^^^^^^^^^^^^ help: try: `8.0_f64` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/unnecessary_cast.rs:217:20 + --> tests/ui/unnecessary_cast.rs:217:20 | LL | let _num = foo() as f32; | ^^^^^^^^^^^^ help: try: `foo()` diff --git a/tests/ui/unnecessary_cast_unfixable.stderr b/tests/ui/unnecessary_cast_unfixable.stderr index 2d38a2a7709ca..cafaffeae6c36 100644 --- a/tests/ui/unnecessary_cast_unfixable.stderr +++ b/tests/ui/unnecessary_cast_unfixable.stderr @@ -1,5 +1,5 @@ error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast_unfixable.rs:4:13 + --> tests/ui/unnecessary_cast_unfixable.rs:4:13 | LL | let _ = std::ptr::null() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null()` @@ -8,7 +8,7 @@ LL | let _ = std::ptr::null() as *const u8; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting raw pointers to the same type and constness is unnecessary (`*mut issue11113::Vtbl` -> `*mut issue11113::Vtbl`) - --> $DIR/unnecessary_cast_unfixable.rs:21:16 + --> tests/ui/unnecessary_cast_unfixable.rs:21:16 | LL | ((*(*(self.object as *mut *mut _) as *mut Vtbl)).query)() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `*(self.object as *mut *mut _)` diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index eab5f04231656..e34a387c77e2e 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,5 +1,5 @@ error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:23:5 + --> tests/ui/unnecessary_clone.rs:23:5 | LL | rc.clone(); | ^^^^^^^^^^ help: try: `Rc::::clone(&rc)` @@ -8,31 +8,31 @@ LL | rc.clone(); = help: to override `-D warnings` add `#[allow(clippy::clone_on_ref_ptr)]` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:28:5 + --> tests/ui/unnecessary_clone.rs:28:5 | LL | arc.clone(); | ^^^^^^^^^^^ help: try: `Arc::::clone(&arc)` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:32:5 + --> tests/ui/unnecessary_clone.rs:32:5 | LL | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try: `Weak::::clone(&rcweak)` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:36:5 + --> tests/ui/unnecessary_clone.rs:36:5 | LL | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try: `Weak::::clone(&arc_weak)` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:41:33 + --> tests/ui/unnecessary_clone.rs:41:33 | LL | let _: Arc = x.clone(); | ^^^^^^^^^ help: try: `Arc::::clone(&x)` error: using `clone` on type `T` which implements the `Copy` trait - --> $DIR/unnecessary_clone.rs:46:5 + --> tests/ui/unnecessary_clone.rs:46:5 | LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` @@ -41,19 +41,19 @@ LL | t.clone(); = help: to override `-D warnings` add `#[allow(clippy::clone_on_copy)]` error: using `clone` on type `Option` which implements the `Copy` trait - --> $DIR/unnecessary_clone.rs:50:5 + --> tests/ui/unnecessary_clone.rs:50:5 | LL | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on type `E` which implements the `Copy` trait - --> $DIR/unnecessary_clone.rs:85:20 + --> tests/ui/unnecessary_clone.rs:85:20 | LL | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:105:14 + --> tests/ui/unnecessary_clone.rs:105:14 | LL | Some(try_opt!(Some(rc)).clone()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc::::clone(&try_opt!(Some(rc)))` diff --git a/tests/ui/unnecessary_fallible_conversions.stderr b/tests/ui/unnecessary_fallible_conversions.stderr index 598f4ba91b3c0..ade3aada92897 100644 --- a/tests/ui/unnecessary_fallible_conversions.stderr +++ b/tests/ui/unnecessary_fallible_conversions.stderr @@ -1,5 +1,5 @@ error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:6:23 + --> tests/ui/unnecessary_fallible_conversions.rs:6:23 | LL | let _: i64 = 0i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL + let _: i64 = 0i32.into(); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:9:23 + --> tests/ui/unnecessary_fallible_conversions.rs:9:23 | LL | let _: i64 = 0i32.try_into().expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL + let _: i64 = 0i32.into(); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:14:13 + --> tests/ui/unnecessary_fallible_conversions.rs:14:13 | LL | let _ = i64::try_from(0i32).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL + let _ = i64::from(0i32); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:17:13 + --> tests/ui/unnecessary_fallible_conversions.rs:17:13 | LL | let _ = i64::try_from(0i32).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL + let _ = i64::from(0i32); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:22:18 + --> tests/ui/unnecessary_fallible_conversions.rs:22:18 | LL | let _: i64 = i32::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL + let _: i64 = i32::into(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:25:18 + --> tests/ui/unnecessary_fallible_conversions.rs:25:18 | LL | let _: i64 = i32::try_into(0i32).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL + let _: i64 = i32::into(0i32); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:30:13 + --> tests/ui/unnecessary_fallible_conversions.rs:30:13 | LL | let _ = >::try_from(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:33:13 + --> tests/ui/unnecessary_fallible_conversions.rs:33:13 | LL | let _ = >::try_from(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:38:18 + --> tests/ui/unnecessary_fallible_conversions.rs:38:18 | LL | let _: i64 = >::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL + let _: i64 = >::into(0); | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:41:18 + --> tests/ui/unnecessary_fallible_conversions.rs:41:18 | LL | let _: i64 = >::try_into(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_fallible_conversions_unfixable.stderr b/tests/ui/unnecessary_fallible_conversions_unfixable.stderr index 033de0e925082..43d0cde9399f0 100644 --- a/tests/ui/unnecessary_fallible_conversions_unfixable.stderr +++ b/tests/ui/unnecessary_fallible_conversions_unfixable.stderr @@ -1,5 +1,5 @@ error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:27:34 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:27:34 | LL | let _: Result = 0i64.try_into(); | ^^^^^^^^ help: use: `into` @@ -9,7 +9,7 @@ LL | let _: Result = 0i64.try_into(); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fallible_conversions)]` error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:29:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:29:29 | LL | let _: Result = i64::try_into(0i64); | ^^^^^^^^^^^^^ help: use: `Into::into` @@ -17,7 +17,7 @@ LL | let _: Result = i64::try_into(0i64); = note: converting `i64` to `Foo` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:31:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:31:29 | LL | let _: Result = Foo::try_from(0i64); | ^^^^^^^^^^^^^ help: use: `From::from` @@ -25,7 +25,7 @@ LL | let _: Result = Foo::try_from(0i64); = note: converting `i64` to `Foo` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:34:34 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:34:34 | LL | let _: Result = 0i32.try_into(); | ^^^^^^^^ help: use: `into` @@ -33,7 +33,7 @@ LL | let _: Result = 0i32.try_into(); = note: converting `i32` to `i64` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:36:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:36:29 | LL | let _: Result = i32::try_into(0i32); | ^^^^^^^^^^^^^ help: use: `Into::into` @@ -41,7 +41,7 @@ LL | let _: Result = i32::try_into(0i32); = note: converting `i32` to `i64` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:38:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:38:29 | LL | let _: Result = <_>::try_from(0i32); | ^^^^^^^^^^^^^ help: use: `From::from` diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 0dd65f6527248..f32d444ba9e09 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -1,5 +1,5 @@ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:4:13 + --> tests/ui/unnecessary_filter_map.rs:4:13 | LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_filter_map)]` error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:7:13 + --> tests/ui/unnecessary_filter_map.rs:7:13 | LL | let _ = (0..4).filter_map(|x| { | _____________^ @@ -21,7 +21,7 @@ LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:14:13 + --> tests/ui/unnecessary_filter_map.rs:14:13 | LL | let _ = (0..4).filter_map(|x| match x { | _____________^ @@ -32,13 +32,13 @@ LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.map` - --> $DIR/unnecessary_filter_map.rs:20:13 + --> tests/ui/unnecessary_filter_map.rs:20:13 | LL | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:160:14 + --> tests/ui/unnecessary_filter_map.rs:160:14 | LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_find_map.stderr b/tests/ui/unnecessary_find_map.stderr index 662623fb61790..bb939a9921467 100644 --- a/tests/ui/unnecessary_find_map.stderr +++ b/tests/ui/unnecessary_find_map.stderr @@ -1,5 +1,5 @@ error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:4:13 + --> tests/ui/unnecessary_find_map.rs:4:13 | LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_find_map)]` error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:7:13 + --> tests/ui/unnecessary_find_map.rs:7:13 | LL | let _ = (0..4).find_map(|x| { | _____________^ @@ -21,7 +21,7 @@ LL | | }); | |______^ error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:14:13 + --> tests/ui/unnecessary_find_map.rs:14:13 | LL | let _ = (0..4).find_map(|x| match x { | _____________^ @@ -32,13 +32,13 @@ LL | | }); | |______^ error: this `.find_map` can be written more simply using `.map(..).next()` - --> $DIR/unnecessary_find_map.rs:20:13 + --> tests/ui/unnecessary_find_map.rs:20:13 | LL | let _ = (0..4).find_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:32:14 + --> tests/ui/unnecessary_find_map.rs:32:14 | LL | let _x = std::iter::once(1).find_map(|n| (n > 1).then_some(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index 123d4a3be7557..31abab62f4c60 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,5 +1,5 @@ error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:10:20 + --> tests/ui/unnecessary_fold.rs:10:20 | LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` @@ -8,7 +8,7 @@ LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fold)]` error: redundant closure - --> $DIR/unnecessary_fold.rs:12:32 + --> tests/ui/unnecessary_fold.rs:12:32 | LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `is_any` @@ -17,85 +17,85 @@ LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:14:20 + --> tests/ui/unnecessary_fold.rs:14:20 | LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:16:25 + --> tests/ui/unnecessary_fold.rs:16:25 | LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:18:25 + --> tests/ui/unnecessary_fold.rs:18:25 | LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:23:41 + --> tests/ui/unnecessary_fold.rs:23:41 | LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:53:10 + --> tests/ui/unnecessary_fold.rs:53:10 | LL | .fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:64:33 + --> tests/ui/unnecessary_fold.rs:64:33 | LL | assert_eq!(map.values().fold(0, |x, y| x + y), 0); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:67:30 + --> tests/ui/unnecessary_fold.rs:67:30 | LL | let _ = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:68:30 + --> tests/ui/unnecessary_fold.rs:68:30 | LL | let _ = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:69:35 + --> tests/ui/unnecessary_fold.rs:69:35 | LL | let _: i32 = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:70:35 + --> tests/ui/unnecessary_fold.rs:70:35 | LL | let _: i32 = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:71:31 + --> tests/ui/unnecessary_fold.rs:71:31 | LL | anything(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:72:31 + --> tests/ui/unnecessary_fold.rs:72:31 | LL | anything(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:73:26 + --> tests/ui/unnecessary_fold.rs:73:26 | LL | num(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:74:26 + --> tests/ui/unnecessary_fold.rs:74:26 | LL | num(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` diff --git a/tests/ui/unnecessary_iter_cloned.stderr b/tests/ui/unnecessary_iter_cloned.stderr index ba40c6c14db21..9d3591e0dbfc8 100644 --- a/tests/ui/unnecessary_iter_cloned.stderr +++ b/tests/ui/unnecessary_iter_cloned.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `copied` - --> $DIR/unnecessary_iter_cloned.rs:29:22 + --> tests/ui/unnecessary_iter_cloned.rs:29:22 | LL | for (t, path) in files.iter().copied() { | ^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + let other = match get_file_path(t) { | error: unnecessary use of `copied` - --> $DIR/unnecessary_iter_cloned.rs:44:22 + --> tests/ui/unnecessary_iter_cloned.rs:44:22 | LL | for (t, path) in files.iter().copied() { | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_join.stderr b/tests/ui/unnecessary_join.stderr index 205a714b694ae..a06a1059033b7 100644 --- a/tests/ui/unnecessary_join.stderr +++ b/tests/ui/unnecessary_join.stderr @@ -1,5 +1,5 @@ error: called `.collect::>().join("")` on an iterator - --> $DIR/unnecessary_join.rs:10:10 + --> tests/ui/unnecessary_join.rs:10:10 | LL | .collect::>() | __________^ @@ -10,7 +10,7 @@ LL | | .join(""); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_join)]` error: called `.collect::>().join("")` on an iterator - --> $DIR/unnecessary_join.rs:19:10 + --> tests/ui/unnecessary_join.rs:19:10 | LL | .collect::>() | __________^ diff --git a/tests/ui/unnecessary_lazy_eval.stderr b/tests/ui/unnecessary_lazy_eval.stderr index 6ff2691a46167..fcd60f48bccdd 100644 --- a/tests/ui/unnecessary_lazy_eval.stderr +++ b/tests/ui/unnecessary_lazy_eval.stderr @@ -1,5 +1,5 @@ error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:83:13 + --> tests/ui/unnecessary_lazy_eval.rs:83:13 | LL | let _ = opt.unwrap_or_else(|| 2); | ^^^^-------------------- @@ -10,7 +10,7 @@ LL | let _ = opt.unwrap_or_else(|| 2); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_lazy_evaluations)]` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:84:13 + --> tests/ui/unnecessary_lazy_eval.rs:84:13 | LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | ^^^^--------------------------------- @@ -18,7 +18,7 @@ LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:85:13 + --> tests/ui/unnecessary_lazy_eval.rs:85:13 | LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | ^^^^------------------------------------- @@ -26,7 +26,7 @@ LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:87:13 + --> tests/ui/unnecessary_lazy_eval.rs:87:13 | LL | let _ = opt.and_then(|_| ext_opt); | ^^^^--------------------- @@ -34,7 +34,7 @@ LL | let _ = opt.and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:88:13 + --> tests/ui/unnecessary_lazy_eval.rs:88:13 | LL | let _ = opt.or_else(|| ext_opt); | ^^^^------------------- @@ -42,7 +42,7 @@ LL | let _ = opt.or_else(|| ext_opt); | help: use `or(..)` instead: `or(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:89:13 + --> tests/ui/unnecessary_lazy_eval.rs:89:13 | LL | let _ = opt.or_else(|| None); | ^^^^---------------- @@ -50,7 +50,7 @@ LL | let _ = opt.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:90:13 + --> tests/ui/unnecessary_lazy_eval.rs:90:13 | LL | let _ = opt.get_or_insert_with(|| 2); | ^^^^------------------------ @@ -58,7 +58,7 @@ LL | let _ = opt.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:91:13 + --> tests/ui/unnecessary_lazy_eval.rs:91:13 | LL | let _ = opt.ok_or_else(|| 2); | ^^^^---------------- @@ -66,7 +66,7 @@ LL | let _ = opt.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:92:13 + --> tests/ui/unnecessary_lazy_eval.rs:92:13 | LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | ^^^^^^^^^^^^^^^^^------------------------------- @@ -74,7 +74,7 @@ LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | help: use `unwrap_or(..)` instead: `unwrap_or(Some((1, 2)))` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:93:13 + --> tests/ui/unnecessary_lazy_eval.rs:93:13 | LL | let _ = cond.then(|| astronomers_pi); | ^^^^^----------------------- @@ -82,7 +82,7 @@ LL | let _ = cond.then(|| astronomers_pi); | help: use `then_some(..)` instead: `then_some(astronomers_pi)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:94:13 + --> tests/ui/unnecessary_lazy_eval.rs:94:13 | LL | let _ = true.then(|| -> _ {}); | ^^^^^---------------- @@ -90,7 +90,7 @@ LL | let _ = true.then(|| -> _ {}); | help: use `then_some(..)` instead: `then_some({})` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:95:13 + --> tests/ui/unnecessary_lazy_eval.rs:95:13 | LL | let _ = true.then(|| {}); | ^^^^^----------- @@ -98,7 +98,7 @@ LL | let _ = true.then(|| {}); | help: use `then_some(..)` instead: `then_some({})` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:99:13 + --> tests/ui/unnecessary_lazy_eval.rs:99:13 | LL | let _ = Some(1).unwrap_or_else(|| *r); | ^^^^^^^^--------------------- @@ -106,7 +106,7 @@ LL | let _ = Some(1).unwrap_or_else(|| *r); | help: use `unwrap_or(..)` instead: `unwrap_or(*r)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:101:13 + --> tests/ui/unnecessary_lazy_eval.rs:101:13 | LL | let _ = Some(1).unwrap_or_else(|| *b); | ^^^^^^^^--------------------- @@ -114,7 +114,7 @@ LL | let _ = Some(1).unwrap_or_else(|| *b); | help: use `unwrap_or(..)` instead: `unwrap_or(*b)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:103:13 + --> tests/ui/unnecessary_lazy_eval.rs:103:13 | LL | let _ = Some(1).as_ref().unwrap_or_else(|| &r); | ^^^^^^^^^^^^^^^^^--------------------- @@ -122,7 +122,7 @@ LL | let _ = Some(1).as_ref().unwrap_or_else(|| &r); | help: use `unwrap_or(..)` instead: `unwrap_or(&r)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:104:13 + --> tests/ui/unnecessary_lazy_eval.rs:104:13 | LL | let _ = Some(1).as_ref().unwrap_or_else(|| &b); | ^^^^^^^^^^^^^^^^^--------------------- @@ -130,7 +130,7 @@ LL | let _ = Some(1).as_ref().unwrap_or_else(|| &b); | help: use `unwrap_or(..)` instead: `unwrap_or(&b)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:107:13 + --> tests/ui/unnecessary_lazy_eval.rs:107:13 | LL | let _ = Some(10).unwrap_or_else(|| 2); | ^^^^^^^^^-------------------- @@ -138,7 +138,7 @@ LL | let _ = Some(10).unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:108:13 + --> tests/ui/unnecessary_lazy_eval.rs:108:13 | LL | let _ = Some(10).and_then(|_| ext_opt); | ^^^^^^^^^--------------------- @@ -146,7 +146,7 @@ LL | let _ = Some(10).and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:109:28 + --> tests/ui/unnecessary_lazy_eval.rs:109:28 | LL | let _: Option = None.or_else(|| ext_opt); | ^^^^^------------------- @@ -154,7 +154,7 @@ LL | let _: Option = None.or_else(|| ext_opt); | help: use `or(..)` instead: `or(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:110:13 + --> tests/ui/unnecessary_lazy_eval.rs:110:13 | LL | let _ = None.get_or_insert_with(|| 2); | ^^^^^------------------------ @@ -162,7 +162,7 @@ LL | let _ = None.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:111:35 + --> tests/ui/unnecessary_lazy_eval.rs:111:35 | LL | let _: Result = None.ok_or_else(|| 2); | ^^^^^---------------- @@ -170,7 +170,7 @@ LL | let _: Result = None.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:112:28 + --> tests/ui/unnecessary_lazy_eval.rs:112:28 | LL | let _: Option = None.or_else(|| None); | ^^^^^---------------- @@ -178,7 +178,7 @@ LL | let _: Option = None.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:115:13 + --> tests/ui/unnecessary_lazy_eval.rs:115:13 | LL | let _ = deep.0.unwrap_or_else(|| 2); | ^^^^^^^-------------------- @@ -186,7 +186,7 @@ LL | let _ = deep.0.unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:116:13 + --> tests/ui/unnecessary_lazy_eval.rs:116:13 | LL | let _ = deep.0.and_then(|_| ext_opt); | ^^^^^^^--------------------- @@ -194,7 +194,7 @@ LL | let _ = deep.0.and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:117:13 + --> tests/ui/unnecessary_lazy_eval.rs:117:13 | LL | let _ = deep.0.or_else(|| None); | ^^^^^^^---------------- @@ -202,7 +202,7 @@ LL | let _ = deep.0.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:118:13 + --> tests/ui/unnecessary_lazy_eval.rs:118:13 | LL | let _ = deep.0.get_or_insert_with(|| 2); | ^^^^^^^------------------------ @@ -210,7 +210,7 @@ LL | let _ = deep.0.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:119:13 + --> tests/ui/unnecessary_lazy_eval.rs:119:13 | LL | let _ = deep.0.ok_or_else(|| 2); | ^^^^^^^---------------- @@ -218,7 +218,7 @@ LL | let _ = deep.0.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:150:28 + --> tests/ui/unnecessary_lazy_eval.rs:150:28 | LL | let _: Option = None.or_else(|| Some(3)); | ^^^^^------------------- @@ -226,7 +226,7 @@ LL | let _: Option = None.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:151:13 + --> tests/ui/unnecessary_lazy_eval.rs:151:13 | LL | let _ = deep.0.or_else(|| Some(3)); | ^^^^^^^------------------- @@ -234,7 +234,7 @@ LL | let _ = deep.0.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:152:13 + --> tests/ui/unnecessary_lazy_eval.rs:152:13 | LL | let _ = opt.or_else(|| Some(3)); | ^^^^------------------- @@ -242,7 +242,7 @@ LL | let _ = opt.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:158:13 + --> tests/ui/unnecessary_lazy_eval.rs:158:13 | LL | let _ = res2.unwrap_or_else(|_| 2); | ^^^^^--------------------- @@ -250,7 +250,7 @@ LL | let _ = res2.unwrap_or_else(|_| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:159:13 + --> tests/ui/unnecessary_lazy_eval.rs:159:13 | LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | ^^^^^---------------------------------- @@ -258,7 +258,7 @@ LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:160:13 + --> tests/ui/unnecessary_lazy_eval.rs:160:13 | LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | ^^^^^-------------------------------------- @@ -266,7 +266,7 @@ LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:182:35 + --> tests/ui/unnecessary_lazy_eval.rs:182:35 | LL | let _: Result = res.and_then(|_| Err(2)); | ^^^^-------------------- @@ -274,7 +274,7 @@ LL | let _: Result = res.and_then(|_| Err(2)); | help: use `and(..)` instead: `and(Err(2))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:183:35 + --> tests/ui/unnecessary_lazy_eval.rs:183:35 | LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | ^^^^--------------------------------- @@ -282,7 +282,7 @@ LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | help: use `and(..)` instead: `and(Err(astronomers_pi))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:184:35 + --> tests/ui/unnecessary_lazy_eval.rs:184:35 | LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)); | ^^^^------------------------------------- @@ -290,7 +290,7 @@ LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)) | help: use `and(..)` instead: `and(Err(ext_str.some_field))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:186:35 + --> tests/ui/unnecessary_lazy_eval.rs:186:35 | LL | let _: Result = res.or_else(|_| Ok(2)); | ^^^^------------------ @@ -298,7 +298,7 @@ LL | let _: Result = res.or_else(|_| Ok(2)); | help: use `or(..)` instead: `or(Ok(2))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:187:35 + --> tests/ui/unnecessary_lazy_eval.rs:187:35 | LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | ^^^^------------------------------- @@ -306,7 +306,7 @@ LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | help: use `or(..)` instead: `or(Ok(astronomers_pi))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:188:35 + --> tests/ui/unnecessary_lazy_eval.rs:188:35 | LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | ^^^^----------------------------------- @@ -314,7 +314,7 @@ LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:189:35 + --> tests/ui/unnecessary_lazy_eval.rs:189:35 | LL | let _: Result = res. | ___________________________________^ @@ -329,7 +329,7 @@ LL | | or_else(|_| Ok(ext_str.some_field)); | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:219:14 + --> tests/ui/unnecessary_lazy_eval.rs:219:14 | LL | let _x = false.then(|| i32::MAX + 1); | ^^^^^^--------------------- @@ -337,7 +337,7 @@ LL | let _x = false.then(|| i32::MAX + 1); | help: use `then_some(..)` instead: `then_some(i32::MAX + 1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:221:14 + --> tests/ui/unnecessary_lazy_eval.rs:221:14 | LL | let _x = false.then(|| i32::MAX * 2); | ^^^^^^--------------------- @@ -345,7 +345,7 @@ LL | let _x = false.then(|| i32::MAX * 2); | help: use `then_some(..)` instead: `then_some(i32::MAX * 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:223:14 + --> tests/ui/unnecessary_lazy_eval.rs:223:14 | LL | let _x = false.then(|| i32::MAX - 1); | ^^^^^^--------------------- @@ -353,7 +353,7 @@ LL | let _x = false.then(|| i32::MAX - 1); | help: use `then_some(..)` instead: `then_some(i32::MAX - 1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:225:14 + --> tests/ui/unnecessary_lazy_eval.rs:225:14 | LL | let _x = false.then(|| i32::MIN - 1); | ^^^^^^--------------------- @@ -361,7 +361,7 @@ LL | let _x = false.then(|| i32::MIN - 1); | help: use `then_some(..)` instead: `then_some(i32::MIN - 1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:227:14 + --> tests/ui/unnecessary_lazy_eval.rs:227:14 | LL | let _x = false.then(|| (1 + 2 * 3 - 2 / 3 + 9) << 2); | ^^^^^^------------------------------------- @@ -369,7 +369,7 @@ LL | let _x = false.then(|| (1 + 2 * 3 - 2 / 3 + 9) << 2); | help: use `then_some(..)` instead: `then_some((1 + 2 * 3 - 2 / 3 + 9) << 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:229:14 + --> tests/ui/unnecessary_lazy_eval.rs:229:14 | LL | let _x = false.then(|| 255u8 << 7); | ^^^^^^------------------- @@ -377,7 +377,7 @@ LL | let _x = false.then(|| 255u8 << 7); | help: use `then_some(..)` instead: `then_some(255u8 << 7)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:231:14 + --> tests/ui/unnecessary_lazy_eval.rs:231:14 | LL | let _x = false.then(|| 255u8 << 8); | ^^^^^^------------------- @@ -385,7 +385,7 @@ LL | let _x = false.then(|| 255u8 << 8); | help: use `then_some(..)` instead: `then_some(255u8 << 8)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:233:14 + --> tests/ui/unnecessary_lazy_eval.rs:233:14 | LL | let _x = false.then(|| 255u8 >> 8); | ^^^^^^------------------- @@ -393,7 +393,7 @@ LL | let _x = false.then(|| 255u8 >> 8); | help: use `then_some(..)` instead: `then_some(255u8 >> 8)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:236:14 + --> tests/ui/unnecessary_lazy_eval.rs:236:14 | LL | let _x = false.then(|| i32::MAX + -1); | ^^^^^^---------------------- @@ -401,7 +401,7 @@ LL | let _x = false.then(|| i32::MAX + -1); | help: use `then_some(..)` instead: `then_some(i32::MAX + -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:238:14 + --> tests/ui/unnecessary_lazy_eval.rs:238:14 | LL | let _x = false.then(|| -i32::MAX); | ^^^^^^------------------ @@ -409,7 +409,7 @@ LL | let _x = false.then(|| -i32::MAX); | help: use `then_some(..)` instead: `then_some(-i32::MAX)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:240:14 + --> tests/ui/unnecessary_lazy_eval.rs:240:14 | LL | let _x = false.then(|| -i32::MIN); | ^^^^^^------------------ @@ -417,7 +417,7 @@ LL | let _x = false.then(|| -i32::MIN); | help: use `then_some(..)` instead: `then_some(-i32::MIN)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:243:14 + --> tests/ui/unnecessary_lazy_eval.rs:243:14 | LL | let _x = false.then(|| 255 >> -7); | ^^^^^^------------------ @@ -425,7 +425,7 @@ LL | let _x = false.then(|| 255 >> -7); | help: use `then_some(..)` instead: `then_some(255 >> -7)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:245:14 + --> tests/ui/unnecessary_lazy_eval.rs:245:14 | LL | let _x = false.then(|| 255 << -1); | ^^^^^^------------------ @@ -433,7 +433,7 @@ LL | let _x = false.then(|| 255 << -1); | help: use `then_some(..)` instead: `then_some(255 << -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:247:14 + --> tests/ui/unnecessary_lazy_eval.rs:247:14 | LL | let _x = false.then(|| 1 / 0); | ^^^^^^-------------- @@ -441,7 +441,7 @@ LL | let _x = false.then(|| 1 / 0); | help: use `then_some(..)` instead: `then_some(1 / 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:249:14 + --> tests/ui/unnecessary_lazy_eval.rs:249:14 | LL | let _x = false.then(|| x << -1); | ^^^^^^---------------- @@ -449,7 +449,7 @@ LL | let _x = false.then(|| x << -1); | help: use `then_some(..)` instead: `then_some(x << -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:251:14 + --> tests/ui/unnecessary_lazy_eval.rs:251:14 | LL | let _x = false.then(|| x << 2); | ^^^^^^--------------- @@ -457,7 +457,7 @@ LL | let _x = false.then(|| x << 2); | help: use `then_some(..)` instead: `then_some(x << 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:261:14 + --> tests/ui/unnecessary_lazy_eval.rs:261:14 | LL | let _x = false.then(|| x / 0); | ^^^^^^-------------- @@ -465,7 +465,7 @@ LL | let _x = false.then(|| x / 0); | help: use `then_some(..)` instead: `then_some(x / 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:263:14 + --> tests/ui/unnecessary_lazy_eval.rs:263:14 | LL | let _x = false.then(|| x % 0); | ^^^^^^-------------- @@ -473,7 +473,7 @@ LL | let _x = false.then(|| x % 0); | help: use `then_some(..)` instead: `then_some(x % 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:266:14 + --> tests/ui/unnecessary_lazy_eval.rs:266:14 | LL | let _x = false.then(|| 1 / -1); | ^^^^^^--------------- @@ -481,7 +481,7 @@ LL | let _x = false.then(|| 1 / -1); | help: use `then_some(..)` instead: `then_some(1 / -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:268:14 + --> tests/ui/unnecessary_lazy_eval.rs:268:14 | LL | let _x = false.then(|| i32::MIN / -1); | ^^^^^^---------------------- @@ -489,7 +489,7 @@ LL | let _x = false.then(|| i32::MIN / -1); | help: use `then_some(..)` instead: `then_some(i32::MIN / -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:271:14 + --> tests/ui/unnecessary_lazy_eval.rs:271:14 | LL | let _x = false.then(|| i32::MIN / 0); | ^^^^^^--------------------- @@ -497,7 +497,7 @@ LL | let _x = false.then(|| i32::MIN / 0); | help: use `then_some(..)` instead: `then_some(i32::MIN / 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:273:14 + --> tests/ui/unnecessary_lazy_eval.rs:273:14 | LL | let _x = false.then(|| 4 / 2); | ^^^^^^-------------- @@ -505,7 +505,7 @@ LL | let _x = false.then(|| 4 / 2); | help: use `then_some(..)` instead: `then_some(4 / 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:281:14 + --> tests/ui/unnecessary_lazy_eval.rs:281:14 | LL | let _x = false.then(|| f1 + f2); | ^^^^^^---------------- diff --git a/tests/ui/unnecessary_lazy_eval_unfixable.stderr b/tests/ui/unnecessary_lazy_eval_unfixable.stderr index 95b02be91ca8a..b566b119571cb 100644 --- a/tests/ui/unnecessary_lazy_eval_unfixable.stderr +++ b/tests/ui/unnecessary_lazy_eval_unfixable.stderr @@ -1,5 +1,5 @@ error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:13:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:13:13 | LL | let _ = Ok(1).unwrap_or_else(|()| 2); | ^^^^^^---------------------- @@ -10,7 +10,7 @@ LL | let _ = Ok(1).unwrap_or_else(|()| 2); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_lazy_evaluations)]` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:19:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:19:13 | LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); | ^^^^^^------------------------ @@ -18,7 +18,7 @@ LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:21:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:21:13 | LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); | ^^^^^^------------------------------------- @@ -26,7 +26,7 @@ LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:31:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:31:13 | LL | let _ = true.then(|| -> &[u8] { &[] }); | ^^^^^------------------------- diff --git a/tests/ui/unnecessary_literal_unwrap.stderr b/tests/ui/unnecessary_literal_unwrap.stderr index 4940091be60ae..15708090361ed 100644 --- a/tests/ui/unnecessary_literal_unwrap.stderr +++ b/tests/ui/unnecessary_literal_unwrap.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:11:16 + --> tests/ui/unnecessary_literal_unwrap.rs:11:16 | LL | let _val = Some(1).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + let _val = 1; | error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:12:16 + --> tests/ui/unnecessary_literal_unwrap.rs:12:16 | LL | let _val = Some(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + let _val = 1; | error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:14:5 + --> tests/ui/unnecessary_literal_unwrap.rs:14:5 | LL | Some(1).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + 1; | error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:15:5 + --> tests/ui/unnecessary_literal_unwrap.rs:15:5 | LL | Some(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,13 +49,13 @@ LL + 1; | error: used `unwrap()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:20:16 + --> tests/ui/unnecessary_literal_unwrap.rs:20:16 | LL | let _val = None::<()>.unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()` error: used `expect()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:21:16 + --> tests/ui/unnecessary_literal_unwrap.rs:21:16 | LL | let _val = None::<()>.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,13 +66,13 @@ LL | let _val = panic!("this always happens"); | ~~~~~~~ ~ error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:22:24 + --> tests/ui/unnecessary_literal_unwrap.rs:22:24 | LL | let _val: String = None.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `String::default()` error: used `unwrap_or()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:23:21 + --> tests/ui/unnecessary_literal_unwrap.rs:23:21 | LL | let _val: u16 = None.unwrap_or(234); | ^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL + let _val: u16 = 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:24:21 + --> tests/ui/unnecessary_literal_unwrap.rs:24:21 | LL | let _val: u16 = None.unwrap_or_else(|| 234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + let _val: u16 = 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:25:21 + --> tests/ui/unnecessary_literal_unwrap.rs:25:21 | LL | let _val: u16 = None.unwrap_or_else(|| { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + let _val: u16 = { 234 }; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:26:21 + --> tests/ui/unnecessary_literal_unwrap.rs:26:21 | LL | let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,13 +120,13 @@ LL + let _val: u16 = { 234 }; | error: used `unwrap()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:28:5 + --> tests/ui/unnecessary_literal_unwrap.rs:28:5 | LL | None::<()>.unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()` error: used `expect()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:29:5 + --> tests/ui/unnecessary_literal_unwrap.rs:29:5 | LL | None::<()>.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,13 +137,13 @@ LL | panic!("this always happens"); | ~~~~~~~ ~ error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:30:5 + --> tests/ui/unnecessary_literal_unwrap.rs:30:5 | LL | None::.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `String::default()` error: used `unwrap_or()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:31:5 + --> tests/ui/unnecessary_literal_unwrap.rs:31:5 | LL | None::.unwrap_or(234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:32:5 + --> tests/ui/unnecessary_literal_unwrap.rs:32:5 | LL | None::.unwrap_or_else(|| 234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL + 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:33:5 + --> tests/ui/unnecessary_literal_unwrap.rs:33:5 | LL | None::.unwrap_or_else(|| { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL + { 234 }; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:34:5 + --> tests/ui/unnecessary_literal_unwrap.rs:34:5 | LL | None::.unwrap_or_else(|| -> u16 { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -191,7 +191,7 @@ LL + { 234 }; | error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:38:16 + --> tests/ui/unnecessary_literal_unwrap.rs:38:16 | LL | let _val = Ok::<_, ()>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL + let _val = 1; | error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:39:16 + --> tests/ui/unnecessary_literal_unwrap.rs:39:16 | LL | let _val = Ok::<_, ()>(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -215,7 +215,7 @@ LL + let _val = 1; | error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:40:16 + --> tests/ui/unnecessary_literal_unwrap.rs:40:16 | LL | let _val = Ok::<_, ()>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -226,7 +226,7 @@ LL | let _val = panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:41:16 + --> tests/ui/unnecessary_literal_unwrap.rs:41:16 | LL | let _val = Ok::<_, ()>(1).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -237,7 +237,7 @@ LL | let _val = panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:43:5 + --> tests/ui/unnecessary_literal_unwrap.rs:43:5 | LL | Ok::<_, ()>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -249,7 +249,7 @@ LL + 1; | error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:44:5 + --> tests/ui/unnecessary_literal_unwrap.rs:44:5 | LL | Ok::<_, ()>(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -261,7 +261,7 @@ LL + 1; | error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:45:5 + --> tests/ui/unnecessary_literal_unwrap.rs:45:5 | LL | Ok::<_, ()>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -272,7 +272,7 @@ LL | panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:46:5 + --> tests/ui/unnecessary_literal_unwrap.rs:46:5 | LL | Ok::<_, ()>(1).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -283,7 +283,7 @@ LL | panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:50:16 + --> tests/ui/unnecessary_literal_unwrap.rs:50:16 | LL | let _val = Err::<(), _>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +295,7 @@ LL + let _val = 1; | error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:51:16 + --> tests/ui/unnecessary_literal_unwrap.rs:51:16 | LL | let _val = Err::<(), _>(1).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,7 @@ LL + let _val = 1; | error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:52:16 + --> tests/ui/unnecessary_literal_unwrap.rs:52:16 | LL | let _val = Err::<(), _>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,7 @@ LL | let _val = panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:53:16 + --> tests/ui/unnecessary_literal_unwrap.rs:53:16 | LL | let _val = Err::<(), _>(1).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | let _val = panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:55:5 + --> tests/ui/unnecessary_literal_unwrap.rs:55:5 | LL | Err::<(), _>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -341,7 +341,7 @@ LL + 1; | error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:56:5 + --> tests/ui/unnecessary_literal_unwrap.rs:56:5 | LL | Err::<(), _>(1).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -353,7 +353,7 @@ LL + 1; | error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:57:5 + --> tests/ui/unnecessary_literal_unwrap.rs:57:5 | LL | Err::<(), _>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -364,7 +364,7 @@ LL | panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:58:5 + --> tests/ui/unnecessary_literal_unwrap.rs:58:5 | LL | Err::<(), _>(1).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -375,7 +375,7 @@ LL | panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:62:16 + --> tests/ui/unnecessary_literal_unwrap.rs:62:16 | LL | let _val = Some(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^ @@ -387,7 +387,7 @@ LL + let _val = 1; | error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:63:16 + --> tests/ui/unnecessary_literal_unwrap.rs:63:16 | LL | let _val = Some(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -399,7 +399,7 @@ LL + let _val = 1; | error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:64:16 + --> tests/ui/unnecessary_literal_unwrap.rs:64:16 | LL | let _val = Some(1).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -411,7 +411,7 @@ LL + let _val = 1; | error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:66:5 + --> tests/ui/unnecessary_literal_unwrap.rs:66:5 | LL | Some(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^ @@ -423,7 +423,7 @@ LL + 1; | error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:67:5 + --> tests/ui/unnecessary_literal_unwrap.rs:67:5 | LL | Some(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ LL + 1; | error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:68:5 + --> tests/ui/unnecessary_literal_unwrap.rs:68:5 | LL | Some(1).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -447,7 +447,7 @@ LL + 1; | error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:72:16 + --> tests/ui/unnecessary_literal_unwrap.rs:72:16 | LL | let _val = Ok::<_, ()>(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL + let _val = 1; | error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:73:16 + --> tests/ui/unnecessary_literal_unwrap.rs:73:16 | LL | let _val = Ok::<_, ()>(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -471,7 +471,7 @@ LL + let _val = 1; | error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:74:16 + --> tests/ui/unnecessary_literal_unwrap.rs:74:16 | LL | let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +483,7 @@ LL + let _val = 1; | error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:76:5 + --> tests/ui/unnecessary_literal_unwrap.rs:76:5 | LL | Ok::<_, ()>(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -495,7 +495,7 @@ LL + 1; | error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:77:5 + --> tests/ui/unnecessary_literal_unwrap.rs:77:5 | LL | Ok::<_, ()>(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL + 1; | error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:78:5 + --> tests/ui/unnecessary_literal_unwrap.rs:78:5 | LL | Ok::<_, ()>(1).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -519,7 +519,7 @@ LL + 1; | error: used `unwrap_unchecked()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:92:22 + --> tests/ui/unnecessary_literal_unwrap.rs:92:22 | LL | let _ = unsafe { Some(1).unwrap_unchecked() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -531,7 +531,7 @@ LL + let _ = 1; | error: used `unwrap_unchecked()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:93:22 + --> tests/ui/unnecessary_literal_unwrap.rs:93:22 | LL | let _ = unsafe { Some(1).unwrap_unchecked() + *(&1 as *const i32) }; // needs to keep the unsafe block | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ LL + let _ = unsafe { 1 + *(&1 as *const i32) }; // needs to keep the unsafe | error: used `unwrap_unchecked()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:94:22 + --> tests/ui/unnecessary_literal_unwrap.rs:94:22 | LL | let _ = unsafe { Some(1).unwrap_unchecked() } + 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL + let _ = 1 + 1; | error: used `unwrap_unchecked()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:95:22 + --> tests/ui/unnecessary_literal_unwrap.rs:95:22 | LL | let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -567,7 +567,7 @@ LL + let _ = 1; | error: used `unwrap_unchecked()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:96:22 + --> tests/ui/unnecessary_literal_unwrap.rs:96:22 | LL | let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() + *(&1 as *const i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -579,7 +579,7 @@ LL + let _ = unsafe { 1 + *(&1 as *const i32) }; | error: used `unwrap_unchecked()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:97:22 + --> tests/ui/unnecessary_literal_unwrap.rs:97:22 | LL | let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() } + 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -591,7 +591,7 @@ LL + let _ = 1 + 1; | error: used `unwrap_err_unchecked()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:98:22 + --> tests/ui/unnecessary_literal_unwrap.rs:98:22 | LL | let _ = unsafe { Err::<(), i32>(123).unwrap_err_unchecked() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr index c6ecd6de61ea1..b7dd7ae729fd9 100644 --- a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr +++ b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr @@ -1,11 +1,11 @@ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:7:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:6:15 | LL | let val = Some(1); | ^^^^^^^ @@ -13,601 +13,601 @@ LL | let val = Some(1); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_literal_unwrap)]` error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:9:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:9:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:6:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:14:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:14:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:14:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:14:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:16:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:16:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:16:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:16:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:20:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:20:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:19:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:19:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:22:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:22:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:19:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:19:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:28:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:28:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `None` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:27:15 | LL | let val = None::<()>; | ^^^^^^^^^^ error: used `expect()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:30:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:30:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `None` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:27:15 | LL | let val = None::<()>; | ^^^^^^^^^^ error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:32:21 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:32:21 | LL | let _val3: u8 = None.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `Default::default()` error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:34:5 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:34:5 | LL | None::<()>.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `Default::default()` error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:40:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:42:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:42:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:44:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:44:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:46:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:46:17 | LL | let _val2 = val.expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:51:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:51:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:51:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:51:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:53:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:53:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:53:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:53:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:55:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:55:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:55:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:55:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:57:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:57:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:61:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:63:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:63:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:65:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:65:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:67:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:67:17 | LL | let _val2 = val.expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:73:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:73:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:75:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:75:17 | LL | let _val2 = val.expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:77:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:77:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:79:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:79:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:84:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:84:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:84:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:84:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:86:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:86:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:86:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:86:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:88:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:88:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:88:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:88:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:90:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:90:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:96:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:96:17 | LL | let _val2 = val.expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:98:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:100:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:100:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:106:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:106:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:105:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:108:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:108:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:105:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:110:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:110:17 | LL | let _val2 = val.unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:105:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:115:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:115:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:115:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:115:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:117:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:117:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:117:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:117:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:119:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:119:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:119:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:119:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:123:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:123:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:122:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:122:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:125:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:125:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:122:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:122:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:127:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:127:17 | LL | let _val2 = val.unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:122:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:122:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:133:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:133:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:132:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:132:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:135:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:135:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:132:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:132:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:137:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:137:17 | LL | let _val2 = val.unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:132:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:132:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:142:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:142:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:142:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:142:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:144:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:144:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:144:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:144:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:146:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:146:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:146:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:146:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:150:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:150:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:149:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:149:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:152:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:152:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:149:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:149:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:154:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:154:17 | LL | let _val2 = val.unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:149:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:149:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_map_on_constructor.stderr b/tests/ui/unnecessary_map_on_constructor.stderr index d522b68d8726a..ecbf652441549 100644 --- a/tests/ui/unnecessary_map_on_constructor.stderr +++ b/tests/ui/unnecessary_map_on_constructor.stderr @@ -1,5 +1,5 @@ error: unnecessary map on constructor Some(_) - --> $DIR/unnecessary_map_on_constructor.rs:32:13 + --> tests/ui/unnecessary_map_on_constructor.rs:32:13 | LL | let a = Some(x).map(fun); | ^^^^^^^^^^^^^^^^ help: try: `Some(fun(x))` @@ -8,43 +8,43 @@ LL | let a = Some(x).map(fun); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_on_constructor)]` error: unnecessary map on constructor Ok(_) - --> $DIR/unnecessary_map_on_constructor.rs:33:27 + --> tests/ui/unnecessary_map_on_constructor.rs:33:27 | LL | let b: SimpleResult = Ok(x).map(fun); | ^^^^^^^^^^^^^^ help: try: `Ok(fun(x))` error: unnecessary map_err on constructor Err(_) - --> $DIR/unnecessary_map_on_constructor.rs:34:27 + --> tests/ui/unnecessary_map_on_constructor.rs:34:27 | LL | let c: SimpleResult = Err(err).map_err(notfun); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Err(notfun(err))` error: unnecessary map on constructor Option::Some(_) - --> $DIR/unnecessary_map_on_constructor.rs:36:13 + --> tests/ui/unnecessary_map_on_constructor.rs:36:13 | LL | let a = Option::Some(x).map(fun); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Option::Some(fun(x))` error: unnecessary map on constructor SimpleResult::Ok(_) - --> $DIR/unnecessary_map_on_constructor.rs:37:27 + --> tests/ui/unnecessary_map_on_constructor.rs:37:27 | LL | let b: SimpleResult = SimpleResult::Ok(x).map(fun); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `SimpleResult::Ok(fun(x))` error: unnecessary map_err on constructor SimpleResult::Err(_) - --> $DIR/unnecessary_map_on_constructor.rs:38:27 + --> tests/ui/unnecessary_map_on_constructor.rs:38:27 | LL | let c: SimpleResult = SimpleResult::Err(err).map_err(notfun); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `SimpleResult::Err(notfun(err))` error: unnecessary map on constructor Ok(_) - --> $DIR/unnecessary_map_on_constructor.rs:39:52 + --> tests/ui/unnecessary_map_on_constructor.rs:39:52 | LL | let b: std::result::Result = Ok(x).map(fun); | ^^^^^^^^^^^^^^ help: try: `Ok(fun(x))` error: unnecessary map_err on constructor Err(_) - --> $DIR/unnecessary_map_on_constructor.rs:40:52 + --> tests/ui/unnecessary_map_on_constructor.rs:40:52 | LL | let c: std::result::Result = Err(err).map_err(notfun); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Err(notfun(err))` diff --git a/tests/ui/unnecessary_operation.stderr b/tests/ui/unnecessary_operation.stderr index eeee9ad60068b..27be5e6f4b922 100644 --- a/tests/ui/unnecessary_operation.stderr +++ b/tests/ui/unnecessary_operation.stderr @@ -1,5 +1,5 @@ error: unnecessary operation - --> $DIR/unnecessary_operation.rs:70:5 + --> tests/ui/unnecessary_operation.rs:70:5 | LL | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` @@ -8,103 +8,103 @@ LL | Tuple(get_number()); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_operation)]` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:71:5 + --> tests/ui/unnecessary_operation.rs:71:5 | LL | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:72:5 + --> tests/ui/unnecessary_operation.rs:72:5 | LL | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:73:5 + --> tests/ui/unnecessary_operation.rs:73:5 | LL | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:74:5 + --> tests/ui/unnecessary_operation.rs:74:5 | LL | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:75:5 + --> tests/ui/unnecessary_operation.rs:75:5 | LL | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:76:5 + --> tests/ui/unnecessary_operation.rs:76:5 | LL | *&get_number(); | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:77:5 + --> tests/ui/unnecessary_operation.rs:77:5 | LL | &get_number(); | ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:78:5 + --> tests/ui/unnecessary_operation.rs:78:5 | LL | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:79:5 + --> tests/ui/unnecessary_operation.rs:79:5 | LL | get_number()..; | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:80:5 + --> tests/ui/unnecessary_operation.rs:80:5 | LL | ..get_number(); | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:81:5 + --> tests/ui/unnecessary_operation.rs:81:5 | LL | 5..get_number(); | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:82:5 + --> tests/ui/unnecessary_operation.rs:82:5 | LL | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:83:5 + --> tests/ui/unnecessary_operation.rs:83:5 | LL | [42, 55][get_usize()]; | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:84:5 + --> tests/ui/unnecessary_operation.rs:84:5 | LL | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:85:5 + --> tests/ui/unnecessary_operation.rs:85:5 | LL | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:86:5 + --> tests/ui/unnecessary_operation.rs:86:5 | LL | [42; 55][get_usize()]; | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:87:5 + --> tests/ui/unnecessary_operation.rs:87:5 | LL | / { LL | | get_number() @@ -112,7 +112,7 @@ LL | | }; | |______^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:90:5 + --> tests/ui/unnecessary_operation.rs:90:5 | LL | / FooString { LL | | s: String::from("blah"), diff --git a/tests/ui/unnecessary_owned_empty_strings.stderr b/tests/ui/unnecessary_owned_empty_strings.stderr index 58d925b1096d9..1820ea4ef5d85 100644 --- a/tests/ui/unnecessary_owned_empty_strings.stderr +++ b/tests/ui/unnecessary_owned_empty_strings.stderr @@ -1,5 +1,5 @@ error: usage of `&String::new()` for a function expecting a `&str` argument - --> $DIR/unnecessary_owned_empty_strings.rs:10:22 + --> tests/ui/unnecessary_owned_empty_strings.rs:10:22 | LL | ref_str_argument(&String::new()); | ^^^^^^^^^^^^^^ help: try: `""` @@ -8,7 +8,7 @@ LL | ref_str_argument(&String::new()); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_owned_empty_strings)]` error: usage of `&String::from("")` for a function expecting a `&str` argument - --> $DIR/unnecessary_owned_empty_strings.rs:14:22 + --> tests/ui/unnecessary_owned_empty_strings.rs:14:22 | LL | ref_str_argument(&String::from("")); | ^^^^^^^^^^^^^^^^^ help: try: `""` diff --git a/tests/ui/unnecessary_result_map_or_else.stderr b/tests/ui/unnecessary_result_map_or_else.stderr index 0f83be5d55661..e3a6dbf8ecd8b 100644 --- a/tests/ui/unnecessary_result_map_or_else.stderr +++ b/tests/ui/unnecessary_result_map_or_else.stderr @@ -1,5 +1,5 @@ error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:6:5 + --> tests/ui/unnecessary_result_map_or_else.rs:6:5 | LL | x.map_or_else(|err| err, |n| n); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` @@ -8,19 +8,19 @@ LL | x.map_or_else(|err| err, |n| n); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_result_map_or_else)]` error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:10:5 + --> tests/ui/unnecessary_result_map_or_else.rs:10:5 | LL | x.map_or_else(|err: ()| err, |n: ()| n); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err: ()| err)` error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:15:19 + --> tests/ui/unnecessary_result_map_or_else.rs:15:19 | LL | let y: &str = x.map_or_else(|err| err, |n| n); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:19:5 + --> tests/ui/unnecessary_result_map_or_else.rs:19:5 | LL | / x.map_or_else( LL | | diff --git a/tests/ui/unnecessary_safety_comment.stderr b/tests/ui/unnecessary_safety_comment.stderr index 6d4ef6c308db8..139ed769975b3 100644 --- a/tests/ui/unnecessary_safety_comment.stderr +++ b/tests/ui/unnecessary_safety_comment.stderr @@ -1,11 +1,11 @@ error: constant item has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:6:5 + --> tests/ui/unnecessary_safety_comment.rs:6:5 | LL | const CONST: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:5:5 + --> tests/ui/unnecessary_safety_comment.rs:5:5 | LL | // SAFETY: | ^^^^^^^^^^ @@ -13,55 +13,55 @@ LL | // SAFETY: = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: static item has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:9:5 + --> tests/ui/unnecessary_safety_comment.rs:9:5 | LL | static STATIC: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:8:5 + --> tests/ui/unnecessary_safety_comment.rs:8:5 | LL | // SAFETY: | ^^^^^^^^^^ error: struct has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:12:5 + --> tests/ui/unnecessary_safety_comment.rs:12:5 | LL | struct Struct; | ^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:11:5 + --> tests/ui/unnecessary_safety_comment.rs:11:5 | LL | // SAFETY: | ^^^^^^^^^^ error: enum has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:15:5 + --> tests/ui/unnecessary_safety_comment.rs:15:5 | LL | enum Enum {} | ^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:14:5 + --> tests/ui/unnecessary_safety_comment.rs:14:5 | LL | // SAFETY: | ^^^^^^^^^^ error: module has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:18:5 + --> tests/ui/unnecessary_safety_comment.rs:18:5 | LL | mod module {} | ^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:17:5 + --> tests/ui/unnecessary_safety_comment.rs:17:5 | LL | // SAFETY: | ^^^^^^^^^^ error: impl has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:38:13 + --> tests/ui/unnecessary_safety_comment.rs:38:13 | LL | impl T for $t {} | ^^^^^^^^^^^^^^^^ @@ -70,44 +70,44 @@ LL | with_safety_comment!(i32); | ------------------------- in this macro invocation | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:37:13 + --> tests/ui/unnecessary_safety_comment.rs:37:13 | LL | // Safety: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `with_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: expression has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:55:5 + --> tests/ui/unnecessary_safety_comment.rs:55:5 | LL | 24 | ^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:54:5 + --> tests/ui/unnecessary_safety_comment.rs:54:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ error: statement has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:47:5 + --> tests/ui/unnecessary_safety_comment.rs:47:5 | LL | let num = 42; | ^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:46:5 + --> tests/ui/unnecessary_safety_comment.rs:46:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ error: statement has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:51:5 + --> tests/ui/unnecessary_safety_comment.rs:51:5 | LL | if num > 24 {} | ^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:50:5 + --> tests/ui/unnecessary_safety_comment.rs:50:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_self_imports.stderr b/tests/ui/unnecessary_self_imports.stderr index 4e50aaececf95..9b143b48c9a6e 100644 --- a/tests/ui/unnecessary_self_imports.stderr +++ b/tests/ui/unnecessary_self_imports.stderr @@ -1,5 +1,5 @@ error: import ending with `::{self}` - --> $DIR/unnecessary_self_imports.rs:5:1 + --> tests/ui/unnecessary_self_imports.rs:5:1 | LL | use std::fs::{self as alias}; | ^^^^^^^^^-------------------- @@ -11,7 +11,7 @@ LL | use std::fs::{self as alias}; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_self_imports)]` error: import ending with `::{self}` - --> $DIR/unnecessary_self_imports.rs:7:1 + --> tests/ui/unnecessary_self_imports.rs:7:1 | LL | use std::rc::{self}; | ^^^^^^^^^----------- diff --git a/tests/ui/unnecessary_sort_by.stderr b/tests/ui/unnecessary_sort_by.stderr index f4409113a45fa..e2013a4e6f9d2 100644 --- a/tests/ui/unnecessary_sort_by.stderr +++ b/tests/ui/unnecessary_sort_by.stderr @@ -1,5 +1,5 @@ error: consider using `sort` - --> $DIR/unnecessary_sort_by.rs:12:5 + --> tests/ui/unnecessary_sort_by.rs:12:5 | LL | vec.sort_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()` @@ -8,67 +8,67 @@ LL | vec.sort_by(|a, b| a.cmp(b)); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_sort_by)]` error: consider using `sort` - --> $DIR/unnecessary_sort_by.rs:13:5 + --> tests/ui/unnecessary_sort_by.rs:13:5 | LL | vec.sort_unstable_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable()` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:14:5 + --> tests/ui/unnecessary_sort_by.rs:14:5 | LL | vec.sort_by(|a, b| (a + 5).abs().cmp(&(b + 5).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|a| (a + 5).abs())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:15:5 + --> tests/ui/unnecessary_sort_by.rs:15:5 | LL | vec.sort_unstable_by(|a, b| id(-a).cmp(&id(-b))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|a| id(-a))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:18:5 + --> tests/ui/unnecessary_sort_by.rs:18:5 | LL | vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|b| std::cmp::Reverse((b + 5).abs()))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:19:5 + --> tests/ui/unnecessary_sort_by.rs:19:5 | LL | vec.sort_unstable_by(|a, b| id(-b).cmp(&id(-a))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|b| std::cmp::Reverse(id(-b)))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:29:5 + --> tests/ui/unnecessary_sort_by.rs:29:5 | LL | vec.sort_by(|a, b| (***a).abs().cmp(&(***b).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|a| (***a).abs())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:30:5 + --> tests/ui/unnecessary_sort_by.rs:30:5 | LL | vec.sort_unstable_by(|a, b| (***a).abs().cmp(&(***b).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|a| (***a).abs())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:89:9 + --> tests/ui/unnecessary_sort_by.rs:89:9 | LL | args.sort_by(|a, b| a.name().cmp(&b.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|a| a.name())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:90:9 + --> tests/ui/unnecessary_sort_by.rs:90:9 | LL | args.sort_unstable_by(|a, b| a.name().cmp(&b.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_unstable_by_key(|a| a.name())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:92:9 + --> tests/ui/unnecessary_sort_by.rs:92:9 | LL | args.sort_by(|a, b| b.name().cmp(&a.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|b| std::cmp::Reverse(b.name()))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:93:9 + --> tests/ui/unnecessary_sort_by.rs:93:9 | LL | args.sort_unstable_by(|a, b| b.name().cmp(&a.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_unstable_by_key(|b| std::cmp::Reverse(b.name()))` diff --git a/tests/ui/unnecessary_struct_initialization.stderr b/tests/ui/unnecessary_struct_initialization.stderr index d8e0ce6ccaf27..8bc308c7567b5 100644 --- a/tests/ui/unnecessary_struct_initialization.stderr +++ b/tests/ui/unnecessary_struct_initialization.stderr @@ -1,5 +1,5 @@ error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:32:9 + --> tests/ui/unnecessary_struct_initialization.rs:32:9 | LL | Self { ..*self } | ^^^^^^^^^^^^^^^^ help: replace with: `*self` @@ -8,25 +8,25 @@ LL | Self { ..*self } = help: to override `-D warnings` add `#[allow(clippy::unnecessary_struct_initialization)]` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:39:17 + --> tests/ui/unnecessary_struct_initialization.rs:39:17 | LL | let mut b = S { ..a }; | ^^^^^^^^^ help: replace with: `a` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:42:18 + --> tests/ui/unnecessary_struct_initialization.rs:42:18 | LL | let c = &mut S { ..b }; | ^^^^^^^^^ help: replace with: `b` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:50:14 + --> tests/ui/unnecessary_struct_initialization.rs:50:14 | LL | let g = &S { ..f }; | ^^^^^^^^^ help: replace with: `f` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:53:18 + --> tests/ui/unnecessary_struct_initialization.rs:53:18 | LL | let h = &mut S { | __________________^ @@ -35,7 +35,7 @@ LL | | }; | |_____^ help: replace with: `*Box::new(S { f: String::from("foo") })` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:72:18 + --> tests/ui/unnecessary_struct_initialization.rs:72:18 | LL | let p = &mut T { | __________________^ diff --git a/tests/ui/unnecessary_to_owned.stderr b/tests/ui/unnecessary_to_owned.stderr index 95ff5f2ec2cff..d4199f8a30a70 100644 --- a/tests/ui/unnecessary_to_owned.stderr +++ b/tests/ui/unnecessary_to_owned.stderr @@ -1,11 +1,11 @@ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:155:64 + --> tests/ui/unnecessary_to_owned.rs:155:64 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:155:20 + --> tests/ui/unnecessary_to_owned.rs:155:20 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,55 +13,55 @@ LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()) = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone - --> $DIR/unnecessary_to_owned.rs:156:40 + --> tests/ui/unnecessary_to_owned.rs:156:40 | LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:156:21 + --> tests/ui/unnecessary_to_owned.rs:156:21 | LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:157:48 + --> tests/ui/unnecessary_to_owned.rs:157:48 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:157:19 + --> tests/ui/unnecessary_to_owned.rs:157:19 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:158:35 + --> tests/ui/unnecessary_to_owned.rs:158:35 | LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:158:18 + --> tests/ui/unnecessary_to_owned.rs:158:18 | LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:159:39 + --> tests/ui/unnecessary_to_owned.rs:159:39 | LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:159:20 + --> tests/ui/unnecessary_to_owned.rs:159:20 | LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^^^^^^^^^ error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:64:36 + --> tests/ui/unnecessary_to_owned.rs:64:36 | LL | require_c_str(&Cow::from(c_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this @@ -70,415 +70,415 @@ LL | require_c_str(&Cow::from(c_str).into_owned()); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:65:19 + --> tests/ui/unnecessary_to_owned.rs:65:19 | LL | require_c_str(&c_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_os_string` - --> $DIR/unnecessary_to_owned.rs:67:20 + --> tests/ui/unnecessary_to_owned.rs:67:20 | LL | require_os_str(&os_str.to_os_string()); | ^^^^^^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:68:38 + --> tests/ui/unnecessary_to_owned.rs:68:38 | LL | require_os_str(&Cow::from(os_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:69:20 + --> tests/ui/unnecessary_to_owned.rs:69:20 | LL | require_os_str(&os_str.to_owned()); | ^^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_path_buf` - --> $DIR/unnecessary_to_owned.rs:71:18 + --> tests/ui/unnecessary_to_owned.rs:71:18 | LL | require_path(&path.to_path_buf()); | ^^^^^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:72:34 + --> tests/ui/unnecessary_to_owned.rs:72:34 | LL | require_path(&Cow::from(path).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:73:18 + --> tests/ui/unnecessary_to_owned.rs:73:18 | LL | require_path(&path.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:75:17 + --> tests/ui/unnecessary_to_owned.rs:75:17 | LL | require_str(&s.to_string()); | ^^^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:76:30 + --> tests/ui/unnecessary_to_owned.rs:76:30 | LL | require_str(&Cow::from(s).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:77:17 + --> tests/ui/unnecessary_to_owned.rs:77:17 | LL | require_str(&s.to_owned()); | ^^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:78:17 + --> tests/ui/unnecessary_to_owned.rs:78:17 | LL | require_str(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref.as_ref()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:80:19 + --> tests/ui/unnecessary_to_owned.rs:80:19 | LL | require_slice(&slice.to_vec()); | ^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:81:36 + --> tests/ui/unnecessary_to_owned.rs:81:36 | LL | require_slice(&Cow::from(slice).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:82:19 + --> tests/ui/unnecessary_to_owned.rs:82:19 | LL | require_slice(&array.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `array.as_ref()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:83:19 + --> tests/ui/unnecessary_to_owned.rs:83:19 | LL | require_slice(&array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref.as_ref()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:84:19 + --> tests/ui/unnecessary_to_owned.rs:84:19 | LL | require_slice(&slice.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:87:42 + --> tests/ui/unnecessary_to_owned.rs:87:42 | LL | require_x(&Cow::::Owned(x.clone()).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:90:25 + --> tests/ui/unnecessary_to_owned.rs:90:25 | LL | require_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:91:26 + --> tests/ui/unnecessary_to_owned.rs:91:26 | LL | require_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:92:24 + --> tests/ui/unnecessary_to_owned.rs:92:24 | LL | require_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:93:23 + --> tests/ui/unnecessary_to_owned.rs:93:23 | LL | require_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:94:25 + --> tests/ui/unnecessary_to_owned.rs:94:25 | LL | require_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:96:30 + --> tests/ui/unnecessary_to_owned.rs:96:30 | LL | require_impl_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:97:31 + --> tests/ui/unnecessary_to_owned.rs:97:31 | LL | require_impl_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:98:29 + --> tests/ui/unnecessary_to_owned.rs:98:29 | LL | require_impl_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:99:28 + --> tests/ui/unnecessary_to_owned.rs:99:28 | LL | require_impl_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:100:30 + --> tests/ui/unnecessary_to_owned.rs:100:30 | LL | require_impl_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:102:29 + --> tests/ui/unnecessary_to_owned.rs:102:29 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:102:43 + --> tests/ui/unnecessary_to_owned.rs:102:43 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:103:29 + --> tests/ui/unnecessary_to_owned.rs:103:29 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:103:47 + --> tests/ui/unnecessary_to_owned.rs:103:47 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:105:26 + --> tests/ui/unnecessary_to_owned.rs:105:26 | LL | require_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:106:27 + --> tests/ui/unnecessary_to_owned.rs:106:27 | LL | require_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:107:25 + --> tests/ui/unnecessary_to_owned.rs:107:25 | LL | require_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:108:24 + --> tests/ui/unnecessary_to_owned.rs:108:24 | LL | require_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:109:24 + --> tests/ui/unnecessary_to_owned.rs:109:24 | LL | require_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:110:26 + --> tests/ui/unnecessary_to_owned.rs:110:26 | LL | require_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:111:26 + --> tests/ui/unnecessary_to_owned.rs:111:26 | LL | require_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:112:26 + --> tests/ui/unnecessary_to_owned.rs:112:26 | LL | require_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:114:31 + --> tests/ui/unnecessary_to_owned.rs:114:31 | LL | require_impl_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:115:32 + --> tests/ui/unnecessary_to_owned.rs:115:32 | LL | require_impl_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:116:30 + --> tests/ui/unnecessary_to_owned.rs:116:30 | LL | require_impl_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:117:29 + --> tests/ui/unnecessary_to_owned.rs:117:29 | LL | require_impl_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:118:29 + --> tests/ui/unnecessary_to_owned.rs:118:29 | LL | require_impl_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:119:31 + --> tests/ui/unnecessary_to_owned.rs:119:31 | LL | require_impl_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:120:31 + --> tests/ui/unnecessary_to_owned.rs:120:31 | LL | require_impl_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:121:31 + --> tests/ui/unnecessary_to_owned.rs:121:31 | LL | require_impl_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:123:30 + --> tests/ui/unnecessary_to_owned.rs:123:30 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:123:44 + --> tests/ui/unnecessary_to_owned.rs:123:44 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:124:30 + --> tests/ui/unnecessary_to_owned.rs:124:30 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:124:44 + --> tests/ui/unnecessary_to_owned.rs:124:44 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:125:30 + --> tests/ui/unnecessary_to_owned.rs:125:30 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:125:44 + --> tests/ui/unnecessary_to_owned.rs:125:44 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:126:30 + --> tests/ui/unnecessary_to_owned.rs:126:30 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:126:48 + --> tests/ui/unnecessary_to_owned.rs:126:48 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:127:30 + --> tests/ui/unnecessary_to_owned.rs:127:30 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:127:52 + --> tests/ui/unnecessary_to_owned.rs:127:52 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:128:30 + --> tests/ui/unnecessary_to_owned.rs:128:30 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:128:48 + --> tests/ui/unnecessary_to_owned.rs:128:48 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:130:20 + --> tests/ui/unnecessary_to_owned.rs:130:20 | LL | let _ = x.join(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:132:13 + --> tests/ui/unnecessary_to_owned.rs:132:13 | LL | let _ = slice.to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:133:13 + --> tests/ui/unnecessary_to_owned.rs:133:13 | LL | let _ = slice.to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:134:13 + --> tests/ui/unnecessary_to_owned.rs:134:13 | LL | let _ = [std::path::PathBuf::new()][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:135:13 + --> tests/ui/unnecessary_to_owned.rs:135:13 | LL | let _ = [std::path::PathBuf::new()][..].to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:137:13 + --> tests/ui/unnecessary_to_owned.rs:137:13 | LL | let _ = IntoIterator::into_iter(slice.to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:138:13 + --> tests/ui/unnecessary_to_owned.rs:138:13 | LL | let _ = IntoIterator::into_iter(slice.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:139:13 + --> tests/ui/unnecessary_to_owned.rs:139:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:140:13 + --> tests/ui/unnecessary_to_owned.rs:140:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:202:14 + --> tests/ui/unnecessary_to_owned.rs:202:14 | LL | for t in file_types.to_vec() { | ^^^^^^^^^^^^^^^^^^^ @@ -494,31 +494,31 @@ LL + let path = match get_file_path(t) { | error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:225:14 + --> tests/ui/unnecessary_to_owned.rs:225:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:230:14 + --> tests/ui/unnecessary_to_owned.rs:230:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:278:24 + --> tests/ui/unnecessary_to_owned.rs:278:24 | LL | Box::new(build(y.to_string())) | ^^^^^^^^^^^^^ help: use: `y` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:387:12 + --> tests/ui/unnecessary_to_owned.rs:387:12 | LL | id("abc".to_string()) | ^^^^^^^^^^^^^^^^^ help: use: `"abc"` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:530:37 + --> tests/ui/unnecessary_to_owned.rs:530:37 | LL | IntoFuture::into_future(foo([].to_vec(), &0)); | ^^^^^^^^^^^ help: use: `[]` diff --git a/tests/ui/unnecessary_to_owned_on_split.stderr b/tests/ui/unnecessary_to_owned_on_split.stderr index 9aea15b48bfbd..cf5c964bcf3cd 100644 --- a/tests/ui/unnecessary_to_owned_on_split.stderr +++ b/tests/ui/unnecessary_to_owned_on_split.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:19:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:19:13 | LL | let _ = "a".to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` @@ -8,49 +8,49 @@ LL | let _ = "a".to_string().split('a').next().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:21:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:21:13 | LL | let _ = "a".to_string().split("a").next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split("a")` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:23:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:23:13 | LL | let _ = "a".to_owned().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:25:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:25:13 | LL | let _ = "a".to_owned().split("a").next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split("a")` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:27:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:27:13 | LL | let _ = Issue12068.to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Issue12068.as_ref().split('a')` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned_on_split.rs:30:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:30:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned_on_split.rs:32:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:32:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:34:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:34:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:36:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:36:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` diff --git a/tests/ui/unnecessary_unsafety_doc.stderr b/tests/ui/unnecessary_unsafety_doc.stderr index 817eb3e26eed5..d8a9f0aa38c33 100644 --- a/tests/ui/unnecessary_unsafety_doc.stderr +++ b/tests/ui/unnecessary_unsafety_doc.stderr @@ -1,5 +1,5 @@ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:19:1 + --> tests/ui/unnecessary_unsafety_doc.rs:19:1 | LL | pub fn apocalypse(universe: &mut ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | pub fn apocalypse(universe: &mut ()) { = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_doc)]` error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:45:5 + --> tests/ui/unnecessary_unsafety_doc.rs:45:5 | LL | pub fn republished() { | ^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:58:5 + --> tests/ui/unnecessary_unsafety_doc.rs:58:5 | LL | fn documented(self); | ^^^^^^^^^^^^^^^^^^^^ error: docs for safe trait have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:68:1 + --> tests/ui/unnecessary_unsafety_doc.rs:68:1 | LL | pub trait DocumentedSafeTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:96:5 + --> tests/ui/unnecessary_unsafety_doc.rs:96:5 | LL | pub fn documented() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:123:9 + --> tests/ui/unnecessary_unsafety_doc.rs:123:9 | LL | pub fn drive() { | ^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | very_safe!(); = note: this error originates in the macro `very_safe` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for safe trait have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:151:1 + --> tests/ui/unnecessary_unsafety_doc.rs:151:1 | LL | pub trait DocumentedSafeTraitWithImplementationHeader { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_wraps.stderr b/tests/ui/unnecessary_wraps.stderr index 20d3e070e71c9..a55a23d449f57 100644 --- a/tests/ui/unnecessary_wraps.stderr +++ b/tests/ui/unnecessary_wraps.stderr @@ -1,5 +1,5 @@ error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:9:1 + --> tests/ui/unnecessary_wraps.rs:9:1 | LL | / fn func1(a: bool, b: bool) -> Option { LL | | @@ -28,7 +28,7 @@ LL ~ return 1337; | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:24:1 + --> tests/ui/unnecessary_wraps.rs:24:1 | LL | / fn func2(a: bool, b: bool) -> Option { LL | | @@ -51,7 +51,7 @@ LL ~ if a { 20 } else { 30 } | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:43:1 + --> tests/ui/unnecessary_wraps.rs:43:1 | LL | / fn func5() -> Option { LL | | @@ -69,7 +69,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Result` - --> $DIR/unnecessary_wraps.rs:54:1 + --> tests/ui/unnecessary_wraps.rs:54:1 | LL | / fn func7() -> Result { LL | | @@ -87,7 +87,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:83:5 + --> tests/ui/unnecessary_wraps.rs:83:5 | LL | / fn func12() -> Option { LL | | @@ -105,7 +105,7 @@ LL | 1 | error: this function's return value is unnecessary - --> $DIR/unnecessary_wraps.rs:111:1 + --> tests/ui/unnecessary_wraps.rs:111:1 | LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> { LL | | @@ -132,7 +132,7 @@ LL ~ return ; | error: this function's return value is unnecessary - --> $DIR/unnecessary_wraps.rs:125:1 + --> tests/ui/unnecessary_wraps.rs:125:1 | LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { LL | | diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 68b433df8aaac..4ea33a5db9e2f 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,5 +1,5 @@ error: you matched a field with a wildcard pattern, consider using `..` instead - --> $DIR/unneeded_field_pattern.rs:18:15 + --> tests/ui/unneeded_field_pattern.rs:18:15 | LL | Foo { a: _, b: 0, .. } => {}, | ^^^^ @@ -9,7 +9,7 @@ LL | Foo { a: _, b: 0, .. } => {}, = help: to override `-D warnings` add `#[allow(clippy::unneeded_field_pattern)]` error: all the struct fields are matched to a wildcard pattern, consider using `..` - --> $DIR/unneeded_field_pattern.rs:20:9 + --> tests/ui/unneeded_field_pattern.rs:20:9 | LL | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unneeded_wildcard_pattern.stderr b/tests/ui/unneeded_wildcard_pattern.stderr index f2880a8e68d38..ceb7d7fe9e09f 100644 --- a/tests/ui/unneeded_wildcard_pattern.stderr +++ b/tests/ui/unneeded_wildcard_pattern.stderr @@ -1,89 +1,89 @@ error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:12:18 + --> tests/ui/unneeded_wildcard_pattern.rs:12:18 | LL | if let (0, .., _) = t {}; | ^^^ help: remove it | note: the lint level is defined here - --> $DIR/unneeded_wildcard_pattern.rs:3:9 + --> tests/ui/unneeded_wildcard_pattern.rs:3:9 | LL | #![deny(clippy::unneeded_wildcard_pattern)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:13:16 + --> tests/ui/unneeded_wildcard_pattern.rs:13:16 | LL | if let (0, _, ..) = t {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:14:13 + --> tests/ui/unneeded_wildcard_pattern.rs:14:13 | LL | if let (_, .., 0) = t {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:15:15 + --> tests/ui/unneeded_wildcard_pattern.rs:15:15 | LL | if let (.., _, 0) = t {}; | ^^^ help: remove it error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:16:16 + --> tests/ui/unneeded_wildcard_pattern.rs:16:16 | LL | if let (0, _, _, ..) = t {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:17:18 + --> tests/ui/unneeded_wildcard_pattern.rs:17:18 | LL | if let (0, .., _, _) = t {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:26:22 + --> tests/ui/unneeded_wildcard_pattern.rs:26:22 | LL | if let (0, .., _, _,) = t {}; | ^^^^^^ help: remove them error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:33:19 + --> tests/ui/unneeded_wildcard_pattern.rs:33:19 | LL | if let S(0, .., _) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:34:17 + --> tests/ui/unneeded_wildcard_pattern.rs:34:17 | LL | if let S(0, _, ..) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:35:14 + --> tests/ui/unneeded_wildcard_pattern.rs:35:14 | LL | if let S(_, .., 0) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:36:16 + --> tests/ui/unneeded_wildcard_pattern.rs:36:16 | LL | if let S(.., _, 0) = s {}; | ^^^ help: remove it error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:37:17 + --> tests/ui/unneeded_wildcard_pattern.rs:37:17 | LL | if let S(0, _, _, ..) = s {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:38:19 + --> tests/ui/unneeded_wildcard_pattern.rs:38:19 | LL | if let S(0, .., _, _) = s {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:47:23 + --> tests/ui/unneeded_wildcard_pattern.rs:47:23 | LL | if let S(0, .., _, _,) = s {}; | ^^^^^^ help: remove them diff --git a/tests/ui/unnested_or_patterns.stderr b/tests/ui/unnested_or_patterns.stderr index 98ca7e3735678..bd15ef62368ea 100644 --- a/tests/ui/unnested_or_patterns.stderr +++ b/tests/ui/unnested_or_patterns.stderr @@ -1,5 +1,5 @@ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:16:12 + --> tests/ui/unnested_or_patterns.rs:16:12 | LL | if let box 0 | box 2 = Box::new(0) {} | ^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let box (0 | 2) = Box::new(0) {} | ~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:17:12 + --> tests/ui/unnested_or_patterns.rs:17:12 | LL | if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:19:12 + --> tests/ui/unnested_or_patterns.rs:19:12 | LL | if let Some(1) | C0 | Some(2) = None {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | if let Some(1 | 2) | C0 = None {} | ~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:20:12 + --> tests/ui/unnested_or_patterns.rs:20:12 | LL | if let &mut 0 | &mut 2 = &mut 0 {} | ^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | if let &mut (0 | 2) = &mut 0 {} | ~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:21:12 + --> tests/ui/unnested_or_patterns.rs:21:12 | LL | if let x @ 0 | x @ 2 = 0 {} | ^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | if let x @ (0 | 2) = 0 {} | ~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:22:12 + --> tests/ui/unnested_or_patterns.rs:22:12 | LL | if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | if let (0, 1 | 2 | 3) = (0, 0) {} | ~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:23:12 + --> tests/ui/unnested_or_patterns.rs:23:12 | LL | if let (1, 0) | (2, 0) | (3, 0) = (0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | if let (1 | 2 | 3, 0) = (0, 0) {} | ~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:24:12 + --> tests/ui/unnested_or_patterns.rs:24:12 | LL | if let (x, ..) | (x, 1) | (x, 2) = (0, 1) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | if let (x, ..) | (x, 1 | 2) = (0, 1) {} | ~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:25:12 + --> tests/ui/unnested_or_patterns.rs:25:12 | LL | if let [0] | [1] = [0] {} | ^^^^^^^^^ @@ -100,7 +100,7 @@ LL | if let [0 | 1] = [0] {} | ~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:26:12 + --> tests/ui/unnested_or_patterns.rs:26:12 | LL | if let [x, 0] | [x, 1] = [0, 1] {} | ^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | if let [x, 0 | 1] = [0, 1] {} | ~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:27:12 + --> tests/ui/unnested_or_patterns.rs:27:12 | LL | if let [x, 0] | [x, 1] | [x, 2] = [0, 1] {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | if let [x, 0 | 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:28:12 + --> tests/ui/unnested_or_patterns.rs:28:12 | LL | if let [x, ..] | [x, 1] | [x, 2] = [0, 1] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | if let [x, ..] | [x, 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:30:12 + --> tests/ui/unnested_or_patterns.rs:30:12 | LL | if let TS(0, x) | TS(1, x) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | if let TS(0 | 1, x) = TS(0, 0) {} | ~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:31:12 + --> tests/ui/unnested_or_patterns.rs:31:12 | LL | if let TS(1, 0) | TS(2, 0) | TS(3, 0) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | if let TS(1 | 2 | 3, 0) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:32:12 + --> tests/ui/unnested_or_patterns.rs:32:12 | LL | if let TS(x, ..) | TS(x, 1) | TS(x, 2) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | if let TS(x, ..) | TS(x, 1 | 2) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:37:12 + --> tests/ui/unnested_or_patterns.rs:37:12 | LL | if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {} | ~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:48:12 + --> tests/ui/unnested_or_patterns.rs:48:12 | LL | if let [1] | [53] = [0] {} | ^^^^^^^^^^ diff --git a/tests/ui/unnested_or_patterns2.stderr b/tests/ui/unnested_or_patterns2.stderr index 182ae00de2208..54f03937508a9 100644 --- a/tests/ui/unnested_or_patterns2.stderr +++ b/tests/ui/unnested_or_patterns2.stderr @@ -1,5 +1,5 @@ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:12:12 + --> tests/ui/unnested_or_patterns2.rs:12:12 | LL | if let Some(Some(0)) | Some(Some(1)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let Some(Some(0 | 1)) = None {} | ~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:13:12 + --> tests/ui/unnested_or_patterns2.rs:13:12 | LL | if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if let Some(Some(0 | 1 | 2)) = None {} | ~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:14:12 + --> tests/ui/unnested_or_patterns2.rs:14:12 | LL | if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:15:12 + --> tests/ui/unnested_or_patterns2.rs:15:12 | LL | if let Some(Some(0) | Some(1 | 2)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | if let Some(Some(0 | 1 | 2)) = None {} | ~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:16:12 + --> tests/ui/unnested_or_patterns2.rs:16:12 | LL | if let ((0,),) | ((1,) | (2,),) = ((0,),) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | if let ((0 | 1 | 2,),) = ((0,),) {} | ~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:17:12 + --> tests/ui/unnested_or_patterns2.rs:17:12 | LL | if let 0 | (1 | 2) = 0 {} | ^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | if let 0 | 1 | 2 = 0 {} | ~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:18:12 + --> tests/ui/unnested_or_patterns2.rs:18:12 | LL | if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:19:12 + --> tests/ui/unnested_or_patterns2.rs:19:12 | LL | if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index 37f91acf82b94..5e350d760643a 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -1,5 +1,5 @@ error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:17 + --> tests/ui/unreadable_literal.rs:31:17 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` @@ -8,55 +8,55 @@ LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); = help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:31 + --> tests/ui/unreadable_literal.rs:31:31 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^ help: consider: `0x1234_5678_usize` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:49 + --> tests/ui/unreadable_literal.rs:31:49 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:61 + --> tests/ui/unreadable_literal.rs:31:61 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:33:20 + --> tests/ui/unreadable_literal.rs:33:20 | LL | let _bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:35:18 + --> tests/ui/unreadable_literal.rs:35:18 | LL | let _fail1 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:36:23 + --> tests/ui/unreadable_literal.rs:36:23 | LL | let _fail2: u32 = 0xBAFEBAFE; | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:37:18 + --> tests/ui/unreadable_literal.rs:37:18 | LL | let _fail3 = 0xabcdeff; | ^^^^^^^^^ help: consider: `0x0abc_deff` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:38:24 + --> tests/ui/unreadable_literal.rs:38:24 | LL | let _fail4: i128 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:39:18 + --> tests/ui/unreadable_literal.rs:39:18 | LL | let _fail5 = 1.100300400; | ^^^^^^^^^^^ help: consider: `1.100_300_400` diff --git a/tests/ui/unsafe_derive_deserialize.stderr b/tests/ui/unsafe_derive_deserialize.stderr index d6fb82398d87a..f2d4429f707a5 100644 --- a/tests/ui/unsafe_derive_deserialize.stderr +++ b/tests/ui/unsafe_derive_deserialize.stderr @@ -1,5 +1,5 @@ error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` - --> $DIR/unsafe_derive_deserialize.rs:8:10 + --> tests/ui/unsafe_derive_deserialize.rs:8:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[derive(Deserialize)] = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` - --> $DIR/unsafe_derive_deserialize.rs:17:10 + --> tests/ui/unsafe_derive_deserialize.rs:17:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | #[derive(Deserialize)] = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` - --> $DIR/unsafe_derive_deserialize.rs:24:10 + --> tests/ui/unsafe_derive_deserialize.rs:24:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | #[derive(Deserialize)] = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` - --> $DIR/unsafe_derive_deserialize.rs:33:10 + --> tests/ui/unsafe_derive_deserialize.rs:33:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 261c7837a4c1f..998cdbb579f65 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -1,5 +1,5 @@ error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCell` - --> $DIR/unsafe_removed_from_name.rs:5:1 + --> tests/ui/unsafe_removed_from_name.rs:5:1 | LL | use std::cell::UnsafeCell as TotallySafeCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | use std::cell::UnsafeCell as TotallySafeCell; = help: to override `-D warnings` add `#[allow(clippy::unsafe_removed_from_name)]` error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCellAgain` - --> $DIR/unsafe_removed_from_name.rs:9:1 + --> tests/ui/unsafe_removed_from_name.rs:9:1 | LL | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `LieAboutModSafety` - --> $DIR/unsafe_removed_from_name.rs:28:1 + --> tests/ui/unsafe_removed_from_name.rs:28:1 | LL | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `A` - --> $DIR/unsafe_removed_from_name.rs:32:1 + --> tests/ui/unsafe_removed_from_name.rs:32:1 | LL | use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `B` - --> $DIR/unsafe_removed_from_name.rs:32:1 + --> tests/ui/unsafe_removed_from_name.rs:32:1 | LL | use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unseparated_prefix_literals.stderr b/tests/ui/unseparated_prefix_literals.stderr index d74e728750577..1c51f7ada91f1 100644 --- a/tests/ui/unseparated_prefix_literals.stderr +++ b/tests/ui/unseparated_prefix_literals.stderr @@ -1,5 +1,5 @@ error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:23:18 + --> tests/ui/unseparated_prefix_literals.rs:23:18 | LL | let _fail1 = 1234i32; | ^^^^^^^ help: add an underscore: `1234_i32` @@ -8,43 +8,43 @@ LL | let _fail1 = 1234i32; = help: to override `-D warnings` add `#[allow(clippy::unseparated_literal_suffix)]` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:24:18 + --> tests/ui/unseparated_prefix_literals.rs:24:18 | LL | let _fail2 = 1234u32; | ^^^^^^^ help: add an underscore: `1234_u32` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:25:18 + --> tests/ui/unseparated_prefix_literals.rs:25:18 | LL | let _fail3 = 1234isize; | ^^^^^^^^^ help: add an underscore: `1234_isize` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:26:18 + --> tests/ui/unseparated_prefix_literals.rs:26:18 | LL | let _fail4 = 1234usize; | ^^^^^^^^^ help: add an underscore: `1234_usize` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:27:18 + --> tests/ui/unseparated_prefix_literals.rs:27:18 | LL | let _fail5 = 0x123isize; | ^^^^^^^^^^ help: add an underscore: `0x123_isize` error: float type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:31:19 + --> tests/ui/unseparated_prefix_literals.rs:31:19 | LL | let _failf1 = 1.5f32; | ^^^^^^ help: add an underscore: `1.5_f32` error: float type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:32:19 + --> tests/ui/unseparated_prefix_literals.rs:32:19 | LL | let _failf2 = 1f32; | ^^^^ help: add an underscore: `1_f32` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:15:9 + --> tests/ui/unseparated_prefix_literals.rs:15:9 | LL | 42usize | ^^^^^^^ help: add an underscore: `42_usize` @@ -55,7 +55,7 @@ LL | let _ = lit_from_macro!(); = note: this error originates in the macro `lit_from_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:40:16 + --> tests/ui/unseparated_prefix_literals.rs:40:16 | LL | assert_eq!(4897u32, 32223); | ^^^^^^^ help: add an underscore: `4897_u32` diff --git a/tests/ui/unused_async.stderr b/tests/ui/unused_async.stderr index c97a76a55cbe1..337c650e029f8 100644 --- a/tests/ui/unused_async.stderr +++ b/tests/ui/unused_async.stderr @@ -1,5 +1,5 @@ error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:12:5 + --> tests/ui/unused_async.rs:12:5 | LL | / async fn async_block_await() { LL | | @@ -11,7 +11,7 @@ LL | | } | = help: consider removing the `async` from this function note: `await` used in an async block, which does not require the enclosing function to be `async` - --> $DIR/unused_async.rs:15:23 + --> tests/ui/unused_async.rs:15:23 | LL | ready(()).await; | ^^^^^ @@ -19,7 +19,7 @@ LL | ready(()).await; = help: to override `-D warnings` add `#[allow(clippy::unused_async)]` error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:45:5 + --> tests/ui/unused_async.rs:45:5 | LL | async fn f3() {} | ^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | async fn f3() {} = help: consider removing the `async` from this function error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:58:1 + --> tests/ui/unused_async.rs:58:1 | LL | / async fn foo() -> i32 { LL | | @@ -38,7 +38,7 @@ LL | | } = help: consider removing the `async` from this function error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:70:5 + --> tests/ui/unused_async.rs:70:5 | LL | / async fn unused(&self) -> i32 { LL | | diff --git a/tests/ui/unused_enumerate_index.stderr b/tests/ui/unused_enumerate_index.stderr index b575fbbc4e616..7bd7d29117e24 100644 --- a/tests/ui/unused_enumerate_index.stderr +++ b/tests/ui/unused_enumerate_index.stderr @@ -1,5 +1,5 @@ error: you seem to use `.enumerate()` and immediately discard the index - --> $DIR/unused_enumerate_index.rs:8:19 + --> tests/ui/unused_enumerate_index.rs:8:19 | LL | for (_, x) in v.iter().enumerate() { | ^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | for x in v.iter() { | ~ ~~~~~~~~ error: you seem to use `.enumerate()` and immediately discard the index - --> $DIR/unused_enumerate_index.rs:55:19 + --> tests/ui/unused_enumerate_index.rs:55:19 | LL | for (_, x) in dummy.enumerate() { | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unused_format_specs_unfixable.stderr b/tests/ui/unused_format_specs_unfixable.stderr index 183e80c853c66..d3b334c6092ed 100644 --- a/tests/ui/unused_format_specs_unfixable.stderr +++ b/tests/ui/unused_format_specs_unfixable.stderr @@ -1,5 +1,5 @@ error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:12:15 + --> tests/ui/unused_format_specs_unfixable.rs:12:15 | LL | println!("{:5}.", format_args!("")); | ^^^^ @@ -17,7 +17,7 @@ LL + println!("{}.", format_args!("")); | error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:16:15 + --> tests/ui/unused_format_specs_unfixable.rs:16:15 | LL | println!("{:.3}", format_args!("abcde")); | ^^^^^ @@ -33,7 +33,7 @@ LL + println!("{}", format_args!("abcde")); | error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:19:15 + --> tests/ui/unused_format_specs_unfixable.rs:19:15 | LL | println!("{:5}.", format_args_from_macro!()); | ^^^^ @@ -46,7 +46,7 @@ LL + println!("{}.", format_args_from_macro!()); | error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:23:15 + --> tests/ui/unused_format_specs_unfixable.rs:23:15 | LL | println!("{args:5}"); | ^^^^^^^^ diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 1aab56966a88c..771e463ca010a 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -1,5 +1,5 @@ error: written amount is not handled - --> $DIR/unused_io_amount.rs:10:5 + --> tests/ui/unused_io_amount.rs:10:5 | LL | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | s.write(b"test")?; = help: to override `-D warnings` add `#[allow(clippy::unused_io_amount)]` error: read amount is not handled - --> $DIR/unused_io_amount.rs:13:5 + --> tests/ui/unused_io_amount.rs:13:5 | LL | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | s.read(&mut buf)?; = help: use `Read::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:19:5 + --> tests/ui/unused_io_amount.rs:19:5 | LL | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | s.write(b"test").unwrap(); = help: use `Write::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:22:5 + --> tests/ui/unused_io_amount.rs:22:5 | LL | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,19 +33,19 @@ LL | s.read(&mut buf).unwrap(); = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:27:5 + --> tests/ui/unused_io_amount.rs:27:5 | LL | s.read_vectored(&mut [io::IoSliceMut::new(&mut [])])?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:29:5 + --> tests/ui/unused_io_amount.rs:29:5 | LL | s.write_vectored(&[io::IoSlice::new(&[])])?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:37:5 + --> tests/ui/unused_io_amount.rs:37:5 | LL | reader.read(&mut result).ok()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | reader.read(&mut result).ok()?; = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:47:5 + --> tests/ui/unused_io_amount.rs:47:5 | LL | reader.read(&mut result).or_else(|err| Err(err))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | reader.read(&mut result).or_else(|err| Err(err))?; = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:60:5 + --> tests/ui/unused_io_amount.rs:60:5 | LL | reader.read(&mut result).or(Err(Error::Kind))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | reader.read(&mut result).or(Err(Error::Kind))?; = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:68:5 + --> tests/ui/unused_io_amount.rs:68:5 | LL | / reader LL | | @@ -82,7 +82,7 @@ LL | | .expect("error"); = help: use `Read::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:78:5 + --> tests/ui/unused_io_amount.rs:78:5 | LL | s.write(b"ok").is_ok(); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | s.write(b"ok").is_ok(); = help: use `Write::write_all` instead, or handle partial writes error: written amount is not handled - --> $DIR/unused_io_amount.rs:80:5 + --> tests/ui/unused_io_amount.rs:80:5 | LL | s.write(b"err").is_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -98,7 +98,7 @@ LL | s.write(b"err").is_err(); = help: use `Write::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:83:5 + --> tests/ui/unused_io_amount.rs:83:5 | LL | s.read(&mut buf).is_ok(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | s.read(&mut buf).is_ok(); = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:85:5 + --> tests/ui/unused_io_amount.rs:85:5 | LL | s.read(&mut buf).is_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | s.read(&mut buf).is_err(); = help: use `Read::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:90:5 + --> tests/ui/unused_io_amount.rs:90:5 | LL | w.write(b"hello world").await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | w.write(b"hello world").await.unwrap(); = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:96:5 + --> tests/ui/unused_io_amount.rs:96:5 | LL | r.read(&mut buf[..]).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | r.read(&mut buf[..]).await.unwrap(); = help: use `AsyncReadExt::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:104:5 + --> tests/ui/unused_io_amount.rs:104:5 | LL | w.write(b"hello world"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL | w.write(b"hello world"); = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: written amount is not handled - --> $DIR/unused_io_amount.rs:110:9 + --> tests/ui/unused_io_amount.rs:110:9 | LL | w.write(b"hello world").await?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,7 +146,7 @@ LL | w.write(b"hello world").await?; = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:119:9 + --> tests/ui/unused_io_amount.rs:119:9 | LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?; = help: use `AsyncReadExt::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:128:5 + --> tests/ui/unused_io_amount.rs:128:5 | LL | w.write(b"hello world").await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -162,7 +162,7 @@ LL | w.write(b"hello world").await.unwrap(); = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:134:5 + --> tests/ui/unused_io_amount.rs:134:5 | LL | r.read(&mut buf[..]).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -170,92 +170,92 @@ LL | r.read(&mut buf[..]).await.unwrap(); = help: use `AsyncReadExt::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:147:11 + --> tests/ui/unused_io_amount.rs:147:11 | LL | match s.write(b"test") { | ^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:149:9 + --> tests/ui/unused_io_amount.rs:149:9 | LL | Ok(_) => todo!(), | ^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:155:11 + --> tests/ui/unused_io_amount.rs:155:11 | LL | match s.read(&mut buf) { | ^^^^^^^^^^^^^^^^ | = help: use `Read::read_exact` instead, or handle partial reads note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:157:9 + --> tests/ui/unused_io_amount.rs:157:9 | LL | Ok(_) => todo!(), | ^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:164:11 + --> tests/ui/unused_io_amount.rs:164:11 | LL | match s.read(&mut [0u8; 4]) { | ^^^^^^^^^^^^^^^^^^^^^ | = help: use `Read::read_exact` instead, or handle partial reads note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:166:9 + --> tests/ui/unused_io_amount.rs:166:9 | LL | Ok(_) => todo!(), | ^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:173:11 + --> tests/ui/unused_io_amount.rs:173:11 | LL | match s.write(b"test") { | ^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:175:9 + --> tests/ui/unused_io_amount.rs:175:9 | LL | Ok(_) => todo!(), | ^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:186:8 + --> tests/ui/unused_io_amount.rs:186:8 | LL | if let Ok(_) = s.read(&mut [0u8; 4]) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Read::read_exact` instead, or handle partial reads note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:186:12 + --> tests/ui/unused_io_amount.rs:186:12 | LL | if let Ok(_) = s.read(&mut [0u8; 4]) { | ^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:193:8 + --> tests/ui/unused_io_amount.rs:193:8 | LL | if let Ok(_) = s.write(b"test") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:193:12 + --> tests/ui/unused_io_amount.rs:193:12 | LL | if let Ok(_) = s.write(b"test") { | ^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:200:8 + --> tests/ui/unused_io_amount.rs:200:8 | LL | if let Ok(..) = s.write(b"test") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:200:12 + --> tests/ui/unused_io_amount.rs:200:12 | LL | if let Ok(..) = s.write(b"test") { | ^^^^^^ diff --git a/tests/ui/unused_peekable.stderr b/tests/ui/unused_peekable.stderr index 157d6fc15f2f7..00c6a52bab336 100644 --- a/tests/ui/unused_peekable.stderr +++ b/tests/ui/unused_peekable.stderr @@ -1,5 +1,5 @@ error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:13:9 + --> tests/ui/unused_peekable.rs:13:9 | LL | let peekable = std::iter::empty::().peekable(); | ^^^^^^^^ @@ -9,7 +9,7 @@ LL | let peekable = std::iter::empty::().peekable(); = help: to override `-D warnings` add `#[allow(clippy::unused_peekable)]` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:18:9 + --> tests/ui/unused_peekable.rs:18:9 | LL | let new_local = old_local; | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let new_local = old_local; = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:23:9 + --> tests/ui/unused_peekable.rs:23:9 | LL | let by_mut_ref = &mut by_mut_ref_test; | ^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let by_mut_ref = &mut by_mut_ref_test; = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:31:9 + --> tests/ui/unused_peekable.rs:31:9 | LL | let peekable_from_fn = returns_peekable(); | ^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let peekable_from_fn = returns_peekable(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:35:13 + --> tests/ui/unused_peekable.rs:35:13 | LL | let mut peekable_using_iterator_method = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let mut peekable_using_iterator_method = std::iter::empty::().peek = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:41:9 + --> tests/ui/unused_peekable.rs:41:9 | LL | let passed_along_ref = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let passed_along_ref = std::iter::empty::().peekable(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:47:9 + --> tests/ui/unused_peekable.rs:47:9 | LL | let _by_ref = by_ref_test.by_ref(); | ^^^^^^^ @@ -57,7 +57,7 @@ LL | let _by_ref = by_ref_test.by_ref(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:50:13 + --> tests/ui/unused_peekable.rs:50:13 | LL | let mut peekable_in_for_loop = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unused_rounding.stderr b/tests/ui/unused_rounding.stderr index d6ce27351353c..75ad895012b37 100644 --- a/tests/ui/unused_rounding.stderr +++ b/tests/ui/unused_rounding.stderr @@ -1,5 +1,5 @@ error: used the `ceil` method with a whole number float - --> $DIR/unused_rounding.rs:4:13 + --> tests/ui/unused_rounding.rs:4:13 | LL | let _ = 1f32.ceil(); | ^^^^^^^^^^^ help: remove the `ceil` method call: `1f32` @@ -8,25 +8,25 @@ LL | let _ = 1f32.ceil(); = help: to override `-D warnings` add `#[allow(clippy::unused_rounding)]` error: used the `floor` method with a whole number float - --> $DIR/unused_rounding.rs:5:13 + --> tests/ui/unused_rounding.rs:5:13 | LL | let _ = 1.0f64.floor(); | ^^^^^^^^^^^^^^ help: remove the `floor` method call: `1.0f64` error: used the `round` method with a whole number float - --> $DIR/unused_rounding.rs:6:13 + --> tests/ui/unused_rounding.rs:6:13 | LL | let _ = 1.00f32.round(); | ^^^^^^^^^^^^^^^ help: remove the `round` method call: `1.00f32` error: used the `round` method with a whole number float - --> $DIR/unused_rounding.rs:12:13 + --> tests/ui/unused_rounding.rs:12:13 | LL | let _ = 3.0_f32.round(); | ^^^^^^^^^^^^^^^ help: remove the `round` method call: `3.0_f32` error: used the `round` method with a whole number float - --> $DIR/unused_rounding.rs:14:13 + --> tests/ui/unused_rounding.rs:14:13 | LL | let _ = 3_3.0_0_f32.round(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `round` method call: `3_3.0_0_f32` diff --git a/tests/ui/unused_self.stderr b/tests/ui/unused_self.stderr index 3865095bbfeb6..5d5f1b643a4a1 100644 --- a/tests/ui/unused_self.stderr +++ b/tests/ui/unused_self.stderr @@ -1,5 +1,5 @@ error: unused `self` argument - --> $DIR/unused_self.rs:11:29 + --> tests/ui/unused_self.rs:11:29 | LL | fn unused_self_move(self) {} | ^^^^ @@ -9,7 +9,7 @@ LL | fn unused_self_move(self) {} = help: to override `-D warnings` add `#[allow(clippy::unused_self)]` error: unused `self` argument - --> $DIR/unused_self.rs:13:28 + --> tests/ui/unused_self.rs:13:28 | LL | fn unused_self_ref(&self) {} | ^^^^^ @@ -17,7 +17,7 @@ LL | fn unused_self_ref(&self) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:15:32 + --> tests/ui/unused_self.rs:15:32 | LL | fn unused_self_mut_ref(&mut self) {} | ^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn unused_self_mut_ref(&mut self) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:17:32 + --> tests/ui/unused_self.rs:17:32 | LL | fn unused_self_pin_ref(self: Pin<&Self>) {} | ^^^^ @@ -33,7 +33,7 @@ LL | fn unused_self_pin_ref(self: Pin<&Self>) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:19:36 + --> tests/ui/unused_self.rs:19:36 | LL | fn unused_self_pin_mut_ref(self: Pin<&mut Self>) {} | ^^^^ @@ -41,7 +41,7 @@ LL | fn unused_self_pin_mut_ref(self: Pin<&mut Self>) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:21:35 + --> tests/ui/unused_self.rs:21:35 | LL | fn unused_self_pin_nested(self: Pin>) {} | ^^^^ @@ -49,7 +49,7 @@ LL | fn unused_self_pin_nested(self: Pin>) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:23:28 + --> tests/ui/unused_self.rs:23:28 | LL | fn unused_self_box(self: Box) {} | ^^^^ @@ -57,7 +57,7 @@ LL | fn unused_self_box(self: Box) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:25:40 + --> tests/ui/unused_self.rs:25:40 | LL | fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { | ^^^^^ @@ -65,7 +65,7 @@ LL | fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:29:37 + --> tests/ui/unused_self.rs:29:37 | LL | fn unused_self_class_method(&self) { | ^^^^^ diff --git a/tests/ui/unused_unit.stderr b/tests/ui/unused_unit.stderr index ce06738cfe473..104159ad5fc63 100644 --- a/tests/ui/unused_unit.stderr +++ b/tests/ui/unused_unit.stderr @@ -1,119 +1,119 @@ error: unneeded unit return type - --> $DIR/unused_unit.rs:20:58 + --> tests/ui/unused_unit.rs:20:58 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` | note: the lint level is defined here - --> $DIR/unused_unit.rs:13:9 + --> tests/ui/unused_unit.rs:13:9 | LL | #![deny(clippy::unused_unit)] | ^^^^^^^^^^^^^^^^^^^ error: unneeded unit return type - --> $DIR/unused_unit.rs:20:28 + --> tests/ui/unused_unit.rs:20:28 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:21:18 + --> tests/ui/unused_unit.rs:21:18 | LL | where G: Fn() -> () { | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:22:26 + --> tests/ui/unused_unit.rs:22:26 | LL | let _y: &dyn Fn() -> () = &f; | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:29:18 + --> tests/ui/unused_unit.rs:29:18 | LL | fn into(self) -> () { | ^^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:30:9 + --> tests/ui/unused_unit.rs:30:9 | LL | () | ^^ help: remove the final `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:35:29 + --> tests/ui/unused_unit.rs:35:29 | LL | fn redundant (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:37:19 + --> tests/ui/unused_unit.rs:37:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:38:16 + --> tests/ui/unused_unit.rs:38:16 | LL | H: Fn() -> (); | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:42:29 + --> tests/ui/unused_unit.rs:42:29 | LL | fn redundant (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:44:19 + --> tests/ui/unused_unit.rs:44:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:45:16 + --> tests/ui/unused_unit.rs:45:16 | LL | H: Fn() -> () {} | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:48:17 + --> tests/ui/unused_unit.rs:48:17 | LL | fn return_unit() -> () { () } | ^^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:48:26 + --> tests/ui/unused_unit.rs:48:26 | LL | fn return_unit() -> () { () } | ^^ help: remove the final `()` error: unneeded `()` - --> $DIR/unused_unit.rs:58:14 + --> tests/ui/unused_unit.rs:58:14 | LL | break(); | ^^ help: remove the `()` error: unneeded `()` - --> $DIR/unused_unit.rs:60:11 + --> tests/ui/unused_unit.rs:60:11 | LL | return(); | ^^ help: remove the `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:77:10 + --> tests/ui/unused_unit.rs:77:10 | LL | fn test()->(){} | ^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:80:11 + --> tests/ui/unused_unit.rs:80:11 | LL | fn test2() ->(){} | ^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:83:11 + --> tests/ui/unused_unit.rs:83:11 | LL | fn test3()-> (){} | ^^^^^ help: remove the `-> ()` diff --git a/tests/ui/unwrap.stderr b/tests/ui/unwrap.stderr index 25911ded2fb3c..3c1b37bc3d9bf 100644 --- a/tests/ui/unwrap.stderr +++ b/tests/ui/unwrap.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on an `Option` value - --> $DIR/unwrap.rs:6:13 + --> tests/ui/unwrap.rs:6:13 | LL | let _ = opt.unwrap(); | ^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | let _ = opt.unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `unwrap()` on a `Result` value - --> $DIR/unwrap.rs:12:13 + --> tests/ui/unwrap.rs:12:13 | LL | let _ = res.unwrap(); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | let _ = res.unwrap(); = help: consider using `expect()` to provide a better panic message error: used `unwrap_err()` on a `Result` value - --> $DIR/unwrap.rs:14:13 + --> tests/ui/unwrap.rs:14:13 | LL | let _ = res.unwrap_err(); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unwrap_expect_used.stderr b/tests/ui/unwrap_expect_used.stderr index cbe6ea22e8997..9069522a4df1a 100644 --- a/tests/ui/unwrap_expect_used.stderr +++ b/tests/ui/unwrap_expect_used.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_expect_used.rs:27:5 + --> tests/ui/unwrap_expect_used.rs:27:5 | LL | Some(3).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(3).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `expect()` on an `Option` value - --> $DIR/unwrap_expect_used.rs:29:5 + --> tests/ui/unwrap_expect_used.rs:29:5 | LL | Some(3).expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | Some(3).expect("Hello world!"); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `unwrap()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:45:5 + --> tests/ui/unwrap_expect_used.rs:45:5 | LL | a.unwrap(); | ^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | a.unwrap(); = note: if this value is an `Err`, it will panic error: used `expect()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:47:5 + --> tests/ui/unwrap_expect_used.rs:47:5 | LL | a.expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | a.expect("Hello world!"); = note: if this value is an `Err`, it will panic error: used `unwrap_err()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:49:5 + --> tests/ui/unwrap_expect_used.rs:49:5 | LL | a.unwrap_err(); | ^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | a.unwrap_err(); = note: if this value is an `Ok`, it will panic error: used `expect_err()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:51:5 + --> tests/ui/unwrap_expect_used.rs:51:5 | LL | a.expect_err("Hello error!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unwrap_in_result.stderr b/tests/ui/unwrap_in_result.stderr index 9a0a32d471e33..29c7a9373aa7b 100644 --- a/tests/ui/unwrap_in_result.stderr +++ b/tests/ui/unwrap_in_result.stderr @@ -1,5 +1,5 @@ error: used unwrap or expect in a function that returns result or option - --> $DIR/unwrap_in_result.rs:22:5 + --> tests/ui/unwrap_in_result.rs:22:5 | LL | / fn bad_divisible_by_3(i_str: String) -> Result { LL | | @@ -12,7 +12,7 @@ LL | | } | = help: unwrap and expect should not be used in a function that returns result or option note: potential non-recoverable error(s) - --> $DIR/unwrap_in_result.rs:25:17 + --> tests/ui/unwrap_in_result.rs:25:17 | LL | let i = i_str.parse::().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | let i = i_str.parse::().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_in_result)]` error: used unwrap or expect in a function that returns result or option - --> $DIR/unwrap_in_result.rs:33:5 + --> tests/ui/unwrap_in_result.rs:33:5 | LL | / fn example_option_expect(i_str: String) -> Option { LL | | @@ -33,7 +33,7 @@ LL | | } | = help: unwrap and expect should not be used in a function that returns result or option note: potential non-recoverable error(s) - --> $DIR/unwrap_in_result.rs:35:17 + --> tests/ui/unwrap_in_result.rs:35:17 | LL | let i = i_str.parse::().expect("not a number"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index 3a32092f7be17..6aa0b9df29b94 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:5:47 + --> tests/ui/unwrap_or.rs:5:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| "Fail".to_string())` @@ -8,7 +8,7 @@ LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()) = help: to override `-D warnings` add `#[allow(clippy::or_fun_call)]` error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:11:47 + --> tests/ui/unwrap_or.rs:11:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| "Fail".to_string())` diff --git a/tests/ui/unwrap_or_else_default.stderr b/tests/ui/unwrap_or_else_default.stderr index 3119aba19e8fd..e4b4a0a1f6aa7 100644 --- a/tests/ui/unwrap_or_else_default.stderr +++ b/tests/ui/unwrap_or_else_default.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:46:14 + --> tests/ui/unwrap_or_else_default.rs:46:14 | LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` @@ -8,91 +8,91 @@ LL | with_new.unwrap_or_else(Vec::new); = help: to override `-D warnings` add `#[allow(clippy::unwrap_or_default)]` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:60:23 + --> tests/ui/unwrap_or_else_default.rs:60:23 | LL | with_real_default.unwrap_or_else(::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:63:24 + --> tests/ui/unwrap_or_else_default.rs:63:24 | LL | with_default_trait.unwrap_or_else(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:66:23 + --> tests/ui/unwrap_or_else_default.rs:66:23 | LL | with_default_type.unwrap_or_else(u64::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:69:23 + --> tests/ui/unwrap_or_else_default.rs:69:23 | LL | with_default_type.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:72:18 + --> tests/ui/unwrap_or_else_default.rs:72:18 | LL | empty_string.unwrap_or_else(|| "".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:76:12 + --> tests/ui/unwrap_or_else_default.rs:76:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:79:12 + --> tests/ui/unwrap_or_else_default.rs:79:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:82:12 + --> tests/ui/unwrap_or_else_default.rs:82:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:85:12 + --> tests/ui/unwrap_or_else_default.rs:85:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:88:12 + --> tests/ui/unwrap_or_else_default.rs:88:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:91:12 + --> tests/ui/unwrap_or_else_default.rs:91:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:94:12 + --> tests/ui/unwrap_or_else_default.rs:94:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:97:12 + --> tests/ui/unwrap_or_else_default.rs:97:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:113:12 + --> tests/ui/unwrap_or_else_default.rs:113:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/unwrap_or_else_default.rs:130:32 + --> tests/ui/unwrap_or_else_default.rs:130:32 | LL | let _ = inner_map.entry(0).or_insert_with(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` diff --git a/tests/ui/upper_case_acronyms.stderr b/tests/ui/upper_case_acronyms.stderr index 009c53c725b6f..1f8046c8e841f 100644 --- a/tests/ui/upper_case_acronyms.stderr +++ b/tests/ui/upper_case_acronyms.stderr @@ -1,5 +1,5 @@ error: name `CWR` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:9:5 + --> tests/ui/upper_case_acronyms.rs:9:5 | LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` @@ -8,67 +8,67 @@ LL | CWR, = help: to override `-D warnings` add `#[allow(clippy::upper_case_acronyms)]` error: name `ECE` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:12:5 + --> tests/ui/upper_case_acronyms.rs:12:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` error: name `URG` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:14:5 + --> tests/ui/upper_case_acronyms.rs:14:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` error: name `ACK` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:16:5 + --> tests/ui/upper_case_acronyms.rs:16:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` error: name `PSH` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:18:5 + --> tests/ui/upper_case_acronyms.rs:18:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` error: name `RST` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:20:5 + --> tests/ui/upper_case_acronyms.rs:20:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` error: name `SYN` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:22:5 + --> tests/ui/upper_case_acronyms.rs:22:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` error: name `FIN` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:24:5 + --> tests/ui/upper_case_acronyms.rs:24:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` error: name `WASD` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:45:5 + --> tests/ui/upper_case_acronyms.rs:45:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` error: name `JSON` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:52:8 + --> tests/ui/upper_case_acronyms.rs:52:8 | LL | struct JSON; | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Json` error: name `YAML` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:56:6 + --> tests/ui/upper_case_acronyms.rs:56:6 | LL | enum YAML { | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Yaml` error: name `DISALLOW` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:64:5 + --> tests/ui/upper_case_acronyms.rs:64:5 | LL | DISALLOW, | ^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `Disallow` diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index a1d4eac5dc09a..8d045f05ed286 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:21:21 + --> tests/ui/use_self.rs:21:21 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` @@ -8,247 +8,247 @@ LL | fn new() -> Foo { = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition - --> $DIR/use_self.rs:22:13 + --> tests/ui/use_self.rs:22:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:24:22 + --> tests/ui/use_self.rs:24:22 | LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:25:13 + --> tests/ui/use_self.rs:25:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:30:25 + --> tests/ui/use_self.rs:30:25 | LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:31:13 + --> tests/ui/use_self.rs:31:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:96:24 + --> tests/ui/use_self.rs:96:24 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:96:55 + --> tests/ui/use_self.rs:96:55 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:13 + --> tests/ui/use_self.rs:111:13 | LL | TS(0) | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:146:29 + --> tests/ui/use_self.rs:146:29 | LL | fn bar() -> Bar { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:147:21 + --> tests/ui/use_self.rs:147:21 | LL | Bar { foo: Foo {} } | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:158:21 + --> tests/ui/use_self.rs:158:21 | LL | fn baz() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:159:13 + --> tests/ui/use_self.rs:159:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:176:21 + --> tests/ui/use_self.rs:176:21 | LL | let _ = Enum::B(42); | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:177:21 + --> tests/ui/use_self.rs:177:21 | LL | let _ = Enum::C { field: true }; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:178:21 + --> tests/ui/use_self.rs:178:21 | LL | let _ = Enum::A; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:220:13 + --> tests/ui/use_self.rs:220:13 | LL | nested::A::fun_1(); | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:221:13 + --> tests/ui/use_self.rs:221:13 | LL | nested::A::A; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:223:13 + --> tests/ui/use_self.rs:223:13 | LL | nested::A {}; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:242:13 + --> tests/ui/use_self.rs:242:13 | LL | TestStruct::from_something() | ^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:256:25 + --> tests/ui/use_self.rs:256:25 | LL | async fn g() -> S { | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:257:13 + --> tests/ui/use_self.rs:257:13 | LL | S {} | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:261:16 + --> tests/ui/use_self.rs:261:16 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:261:22 + --> tests/ui/use_self.rs:261:22 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:284:29 + --> tests/ui/use_self.rs:284:29 | LL | fn foo(value: T) -> Foo { | ^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:285:13 + --> tests/ui/use_self.rs:285:13 | LL | Foo:: { value } | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:457:13 + --> tests/ui/use_self.rs:457:13 | LL | A::new::(submod::B {}) | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:494:13 + --> tests/ui/use_self.rs:494:13 | LL | S2::new() | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:531:17 + --> tests/ui/use_self.rs:531:17 | LL | Foo::Bar => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:532:17 + --> tests/ui/use_self.rs:532:17 | LL | Foo::Baz => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:538:20 + --> tests/ui/use_self.rs:538:20 | LL | if let Foo::Bar = self { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:562:17 + --> tests/ui/use_self.rs:562:17 | LL | Something::Num(n) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:563:17 + --> tests/ui/use_self.rs:563:17 | LL | Something::TupleNums(n, _m) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:564:17 + --> tests/ui/use_self.rs:564:17 | LL | Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:570:17 + --> tests/ui/use_self.rs:570:17 | LL | crate::issue8845::Something::Num(n) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:571:17 + --> tests/ui/use_self.rs:571:17 | LL | crate::issue8845::Something::TupleNums(n, _m) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:572:17 + --> tests/ui/use_self.rs:572:17 | LL | crate::issue8845::Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:588:17 + --> tests/ui/use_self.rs:588:17 | LL | let Foo(x) = self; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:593:17 + --> tests/ui/use_self.rs:593:17 | LL | let crate::issue8845::Foo(x) = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:600:17 + --> tests/ui/use_self.rs:600:17 | LL | let Bar { x, .. } = self; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:605:17 + --> tests/ui/use_self.rs:605:17 | LL | let crate::issue8845::Bar { x, .. } = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:644:17 + --> tests/ui/use_self.rs:644:17 | LL | E::A => {}, | ^ help: use the applicable keyword: `Self` diff --git a/tests/ui/use_self_trait.stderr b/tests/ui/use_self_trait.stderr index 71a227174eafc..9cbb728ebe667 100644 --- a/tests/ui/use_self_trait.stderr +++ b/tests/ui/use_self_trait.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:19:18 + --> tests/ui/use_self_trait.rs:19:18 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` @@ -8,91 +8,91 @@ LL | fn refs(p1: &Bad) -> &Bad { = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:19:27 + --> tests/ui/use_self_trait.rs:19:27 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:23:33 + --> tests/ui/use_self_trait.rs:23:33 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:23:49 + --> tests/ui/use_self_trait.rs:23:49 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:27:26 + --> tests/ui/use_self_trait.rs:27:26 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:27:39 + --> tests/ui/use_self_trait.rs:27:39 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:31:24 + --> tests/ui/use_self_trait.rs:31:24 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:31:42 + --> tests/ui/use_self_trait.rs:31:42 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:33:16 + --> tests/ui/use_self_trait.rs:33:16 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:33:24 + --> tests/ui/use_self_trait.rs:33:24 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:34:9 + --> tests/ui/use_self_trait.rs:34:9 | LL | Bad | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:39:19 + --> tests/ui/use_self_trait.rs:39:19 | LL | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:41:23 + --> tests/ui/use_self_trait.rs:41:23 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:41:31 + --> tests/ui/use_self_trait.rs:41:31 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:48:9 + --> tests/ui/use_self_trait.rs:48:9 | LL | Bad | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:145:13 + --> tests/ui/use_self_trait.rs:145:13 | LL | std::fmt::Error // Should lint | ^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 78d8279810c1f..556e1792b3e68 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,11 +1,11 @@ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:23:5 + --> tests/ui/used_underscore_binding.rs:23:5 | LL | _foo + 1 | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:22:22 + --> tests/ui/used_underscore_binding.rs:22:22 | LL | fn prefix_underscore(_foo: u32) -> u32 { | ^^^^ @@ -13,61 +13,61 @@ LL | fn prefix_underscore(_foo: u32) -> u32 { = help: to override `-D warnings` add `#[allow(clippy::used_underscore_binding)]` error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:28:20 + --> tests/ui/used_underscore_binding.rs:28:20 | LL | println!("{}", _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> tests/ui/used_underscore_binding.rs:27:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:29:16 + --> tests/ui/used_underscore_binding.rs:29:16 | LL | assert_eq!(_foo, _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> tests/ui/used_underscore_binding.rs:27:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:29:22 + --> tests/ui/used_underscore_binding.rs:29:22 | LL | assert_eq!(_foo, _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> tests/ui/used_underscore_binding.rs:27:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:42:5 + --> tests/ui/used_underscore_binding.rs:42:5 | LL | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ | note: `_underscore_field` is defined here - --> $DIR/used_underscore_binding.rs:36:5 + --> tests/ui/used_underscore_binding.rs:36:5 | LL | _underscore_field: u32, | ^^^^^^^^^^^^^^^^^^^^^^ error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:103:16 + --> tests/ui/used_underscore_binding.rs:103:16 | LL | uses_i(_i); | ^^ | note: `_i` is defined here - --> $DIR/used_underscore_binding.rs:102:13 + --> tests/ui/used_underscore_binding.rs:102:13 | LL | let _i = 5; | ^^ diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index e158df2664d77..c7d622ec2dcaf 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,113 +1,113 @@ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:48:18 + --> tests/ui/useless_asref.rs:48:18 | LL | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try: `rstr` | note: the lint level is defined here - --> $DIR/useless_asref.rs:1:9 + --> tests/ui/useless_asref.rs:1:9 | LL | #![deny(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:50:20 + --> tests/ui/useless_asref.rs:50:20 | LL | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try: `rslice` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:54:21 + --> tests/ui/useless_asref.rs:54:21 | LL | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:56:20 + --> tests/ui/useless_asref.rs:56:20 | LL | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:63:20 + --> tests/ui/useless_asref.rs:63:20 | LL | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try: `rrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:65:18 + --> tests/ui/useless_asref.rs:65:18 | LL | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try: `rrrrrstr` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:70:21 + --> tests/ui/useless_asref.rs:70:21 | LL | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:72:20 + --> tests/ui/useless_asref.rs:72:20 | LL | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:76:16 + --> tests/ui/useless_asref.rs:76:16 | LL | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:126:13 + --> tests/ui/useless_asref.rs:126:13 | LL | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try: `mrt` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:128:12 + --> tests/ui/useless_asref.rs:128:12 | LL | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try: `mrt` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:139:13 + --> tests/ui/useless_asref.rs:139:13 | LL | let z = x.as_ref().map(String::clone); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:141:13 + --> tests/ui/useless_asref.rs:141:13 | LL | let z = x.as_ref().map(|z| z.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:143:13 + --> tests/ui/useless_asref.rs:143:13 | LL | let z = x.as_ref().map(|z| String::clone(z)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:167:9 + --> tests/ui/useless_asref.rs:167:9 | LL | x.field.as_ref().map(|v| v.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:169:9 + --> tests/ui/useless_asref.rs:169:9 | LL | x.field.as_ref().map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:171:9 + --> tests/ui/useless_asref.rs:171:9 | LL | x.field.as_ref().map(|v| Clone::clone(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:176:9 + --> tests/ui/useless_asref.rs:176:9 | LL | Some(1).as_ref().map(|&x| x.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(1).clone()` diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index cfb429ce77fc3..19f0e02de6808 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,5 +1,5 @@ error: useless lint attribute - --> $DIR/useless_attribute.rs:8:1 + --> tests/ui/useless_attribute.rs:8:1 | LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` @@ -8,13 +8,13 @@ LL | #[allow(dead_code)] = help: to override `-D warnings` add `#[allow(clippy::useless_attribute)]` error: useless lint attribute - --> $DIR/useless_attribute.rs:9:1 + --> tests/ui/useless_attribute.rs:9:1 | LL | #[cfg_attr(clippy, allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(clippy, allow(dead_code)` error: useless lint attribute - --> $DIR/useless_attribute.rs:20:5 + --> tests/ui/useless_attribute.rs:20:5 | LL | #[allow(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]` diff --git a/tests/ui/useless_conversion.stderr b/tests/ui/useless_conversion.stderr index c1f8b6b4aa966..82f945c5e89f6 100644 --- a/tests/ui/useless_conversion.stderr +++ b/tests/ui/useless_conversion.stderr @@ -1,227 +1,227 @@ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion.rs:5:13 + --> tests/ui/useless_conversion.rs:5:13 | LL | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: the lint level is defined here - --> $DIR/useless_conversion.rs:1:9 + --> tests/ui/useless_conversion.rs:1:9 | LL | #![deny(clippy::useless_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion.rs:6:5 + --> tests/ui/useless_conversion.rs:6:5 | LL | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: useless conversion to the same type: `i32` - --> $DIR/useless_conversion.rs:18:22 + --> tests/ui/useless_conversion.rs:18:22 | LL | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:48:22 + --> tests/ui/useless_conversion.rs:48:22 | LL | if Some("ok") == lines.into_iter().next() {} | ^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `lines` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:53:21 + --> tests/ui/useless_conversion.rs:53:21 | LL | let mut lines = text.lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `text.lines()` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:59:22 + --> tests/ui/useless_conversion.rs:59:22 | LL | if Some("ok") == text.lines().into_iter().next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `text.lines()` error: useless conversion to the same type: `std::ops::Range` - --> $DIR/useless_conversion.rs:65:13 + --> tests/ui/useless_conversion.rs:65:13 | LL | let _ = NUMBERS.into_iter().next(); | ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS` error: useless conversion to the same type: `std::ops::Range` - --> $DIR/useless_conversion.rs:70:17 + --> tests/ui/useless_conversion.rs:70:17 | LL | let mut n = NUMBERS.into_iter(); | ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:132:21 + --> tests/ui/useless_conversion.rs:132:21 | LL | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:133:21 + --> tests/ui/useless_conversion.rs:133:21 | LL | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:134:13 + --> tests/ui/useless_conversion.rs:134:13 | LL | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:135:13 + --> tests/ui/useless_conversion.rs:135:13 | LL | let _ = String::from(format!("A: {:04}", 123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:136:13 + --> tests/ui/useless_conversion.rs:136:13 | LL | let _ = "".lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` error: useless conversion to the same type: `std::vec::IntoIter` - --> $DIR/useless_conversion.rs:137:13 + --> tests/ui/useless_conversion.rs:137:13 | LL | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:138:21 + --> tests/ui/useless_conversion.rs:138:21 | LL | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` error: useless conversion to the same type: `i32` - --> $DIR/useless_conversion.rs:143:13 + --> tests/ui/useless_conversion.rs:143:13 | LL | let _ = i32::from(a + b) * 3; | ^^^^^^^^^^^^^^^^ help: consider removing `i32::from()`: `(a + b)` error: useless conversion to the same type: `Foo<'a'>` - --> $DIR/useless_conversion.rs:149:23 + --> tests/ui/useless_conversion.rs:149:23 | LL | let _: Foo<'a'> = s2.into(); | ^^^^^^^^^ help: consider removing `.into()`: `s2` error: useless conversion to the same type: `Foo<'a'>` - --> $DIR/useless_conversion.rs:151:13 + --> tests/ui/useless_conversion.rs:151:13 | LL | let _ = Foo::<'a'>::from(s3); | ^^^^^^^^^^^^^^^^^^^^ help: consider removing `Foo::<'a'>::from()`: `s3` error: useless conversion to the same type: `std::vec::IntoIter>` - --> $DIR/useless_conversion.rs:153:13 + --> tests/ui/useless_conversion.rs:153:13 | LL | let _ = vec![s4, s4, s4].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![s4, s4, s4].into_iter()` error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:185:7 + --> tests/ui/useless_conversion.rs:185:7 | LL | b(vec![1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:175:13 + --> tests/ui/useless_conversion.rs:175:13 | LL | fn b>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:186:7 + --> tests/ui/useless_conversion.rs:186:7 | LL | c(vec![1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:176:18 + --> tests/ui/useless_conversion.rs:176:18 | LL | fn c(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:187:7 + --> tests/ui/useless_conversion.rs:187:7 | LL | d(vec![1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:179:12 + --> tests/ui/useless_conversion.rs:179:12 | LL | T: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:190:7 + --> tests/ui/useless_conversion.rs:190:7 | LL | b(vec![1, 2].into_iter().into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:175:13 + --> tests/ui/useless_conversion.rs:175:13 | LL | fn b>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:191:7 + --> tests/ui/useless_conversion.rs:191:7 | LL | b(vec![1, 2].into_iter().into_iter().into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:175:13 + --> tests/ui/useless_conversion.rs:175:13 | LL | fn b>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:237:24 + --> tests/ui/useless_conversion.rs:237:24 | LL | foo2::([1, 2, 3].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2, 3]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:216:12 + --> tests/ui/useless_conversion.rs:216:12 | LL | I: IntoIterator + Helper, | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:245:14 + --> tests/ui/useless_conversion.rs:245:14 | LL | foo3([1, 2, 3].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2, 3]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:225:12 + --> tests/ui/useless_conversion.rs:225:12 | LL | I: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:254:16 + --> tests/ui/useless_conversion.rs:254:16 | LL | S1.foo([1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:251:27 + --> tests/ui/useless_conversion.rs:251:27 | LL | pub fn foo(&self, _: I) {} | ^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:273:44 + --> tests/ui/useless_conversion.rs:273:44 | LL | v0.into_iter().interleave_shortest(v1.into_iter()); | ^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `v1` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:260:20 + --> tests/ui/useless_conversion.rs:260:20 | LL | J: IntoIterator, | ^^^^^^^^^^^^ diff --git a/tests/ui/useless_conversion_try.stderr b/tests/ui/useless_conversion_try.stderr index 938bfb5237bba..11fb8f38ea5c2 100644 --- a/tests/ui/useless_conversion_try.stderr +++ b/tests/ui/useless_conversion_try.stderr @@ -1,18 +1,18 @@ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion_try.rs:5:13 + --> tests/ui/useless_conversion_try.rs:5:13 | LL | let _ = T::try_from(val).unwrap(); | ^^^^^^^^^^^^^^^^ | = help: consider removing `T::try_from()` note: the lint level is defined here - --> $DIR/useless_conversion_try.rs:1:9 + --> tests/ui/useless_conversion_try.rs:1:9 | LL | #![deny(clippy::useless_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion_try.rs:7:5 + --> tests/ui/useless_conversion_try.rs:7:5 | LL | val.try_into().unwrap() | ^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | val.try_into().unwrap() = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:30:21 + --> tests/ui/useless_conversion_try.rs:30:21 | LL | let _: String = "foo".to_string().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _: String = "foo".to_string().try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:32:21 + --> tests/ui/useless_conversion_try.rs:32:21 | LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); = help: consider removing `TryFrom::try_from()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:34:13 + --> tests/ui/useless_conversion_try.rs:34:13 | LL | let _ = String::try_from("foo".to_string()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = String::try_from("foo".to_string()).unwrap(); = help: consider removing `String::try_from()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:36:13 + --> tests/ui/useless_conversion_try.rs:36:13 | LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); = help: consider removing `String::try_from()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:38:21 + --> tests/ui/useless_conversion_try.rs:38:21 | LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:40:21 + --> tests/ui/useless_conversion_try.rs:40:21 | LL | let _: String = String::new().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _: String = String::new().try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:42:27 + --> tests/ui/useless_conversion_try.rs:42:27 | LL | let _: String = match String::from("_").try_into() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index c9018f94f9d1f..6fd4748fff33c 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,5 +1,5 @@ error: useless use of `vec!` - --> $DIR/vec.rs:30:14 + --> tests/ui/vec.rs:30:14 | LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` @@ -8,115 +8,115 @@ LL | on_slice(&vec![]); = help: to override `-D warnings` add `#[allow(clippy::useless_vec)]` error: useless use of `vec!` - --> $DIR/vec.rs:32:18 + --> tests/ui/vec.rs:32:18 | LL | on_mut_slice(&mut vec![]); | ^^^^^^^^^^^ help: you can use a slice directly: `&mut []` error: useless use of `vec!` - --> $DIR/vec.rs:34:14 + --> tests/ui/vec.rs:34:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:36:18 + --> tests/ui/vec.rs:36:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:38:14 + --> tests/ui/vec.rs:38:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:40:18 + --> tests/ui/vec.rs:40:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:42:14 + --> tests/ui/vec.rs:42:14 | LL | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:44:18 + --> tests/ui/vec.rs:44:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:46:14 + --> tests/ui/vec.rs:46:14 | LL | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:48:18 + --> tests/ui/vec.rs:48:18 | LL | on_mut_slice(&mut vec![1; 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:74:19 + --> tests/ui/vec.rs:74:19 | LL | let _x: i32 = vec![1, 2, 3].iter().sum(); | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:77:17 + --> tests/ui/vec.rs:77:17 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:83:22 + --> tests/ui/vec.rs:83:22 | LL | let _x: &[i32] = &vec![1, 2, 3]; | ^^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:85:14 + --> tests/ui/vec.rs:85:14 | LL | for _ in vec![1, 2, 3] {} | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:124:20 + --> tests/ui/vec.rs:124:20 | LL | for _string in vec![repro!(true), repro!(null)] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[repro!(true), repro!(null)]` error: useless use of `vec!` - --> $DIR/vec.rs:141:18 + --> tests/ui/vec.rs:141:18 | LL | in_macro!(1, vec![1, 2], vec![1; 2]); | ^^^^^^^^^^ help: you can use an array directly: `[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:141:30 + --> tests/ui/vec.rs:141:30 | LL | in_macro!(1, vec![1, 2], vec![1; 2]); | ^^^^^^^^^^ help: you can use an array directly: `[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:160:14 + --> tests/ui/vec.rs:160:14 | LL | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:164:14 + --> tests/ui/vec.rs:164:14 | LL | for a in vec![String::new(), String::new()] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]` error: useless use of `vec!` - --> $DIR/vec.rs:196:33 + --> tests/ui/vec.rs:196:33 | LL | this_macro_doesnt_need_vec!(vec![1]); | ^^^^^^^ help: you can use an array directly: `[1]` diff --git a/tests/ui/vec_box_sized.stderr b/tests/ui/vec_box_sized.stderr index d6479271fa632..0ffcc83143402 100644 --- a/tests/ui/vec_box_sized.stderr +++ b/tests/ui/vec_box_sized.stderr @@ -1,5 +1,5 @@ error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:26:14 + --> tests/ui/vec_box_sized.rs:26:14 | LL | const C: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` @@ -8,49 +8,49 @@ LL | const C: Vec> = Vec::new(); = help: to override `-D warnings` add `#[allow(clippy::vec_box)]` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:27:15 + --> tests/ui/vec_box_sized.rs:27:15 | LL | static S: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:30:21 + --> tests/ui/vec_box_sized.rs:30:21 | LL | sized_type: Vec>, | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:33:14 + --> tests/ui/vec_box_sized.rs:33:14 | LL | struct A(Vec>); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:34:18 + --> tests/ui/vec_box_sized.rs:34:18 | LL | struct B(Vec>>); | ^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:36:42 + --> tests/ui/vec_box_sized.rs:36:42 | LL | fn allocator_global_defined_vec() -> Vec, std::alloc::Global> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:39:42 + --> tests/ui/vec_box_sized.rs:39:42 | LL | fn allocator_global_defined_box() -> Vec> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:42:29 + --> tests/ui/vec_box_sized.rs:42:29 | LL | fn allocator_match() -> Vec, DummyAllocator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:79:23 + --> tests/ui/vec_box_sized.rs:79:23 | LL | pub fn f() -> Vec> { | ^^^^^^^^^^^ help: try: `Vec` diff --git a/tests/ui/vec_init_then_push.stderr b/tests/ui/vec_init_then_push.stderr index 978201bd17aa2..58720c9a18135 100644 --- a/tests/ui/vec_init_then_push.stderr +++ b/tests/ui/vec_init_then_push.stderr @@ -1,5 +1,5 @@ error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:5:5 + --> tests/ui/vec_init_then_push.rs:5:5 | LL | / let mut def_err: Vec = Default::default(); LL | | @@ -11,7 +11,7 @@ LL | | def_err.push(0); = help: to override `-D warnings` add `#[allow(clippy::vec_init_then_push)]` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:10:5 + --> tests/ui/vec_init_then_push.rs:10:5 | LL | / let mut new_err = Vec::::new(); LL | | @@ -19,7 +19,7 @@ LL | | new_err.push(1); | |____________________^ help: consider using the `vec![]` macro: `let mut new_err = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:14:5 + --> tests/ui/vec_init_then_push.rs:14:5 | LL | / let mut cap_err = Vec::with_capacity(2); LL | | @@ -29,7 +29,7 @@ LL | | cap_err.push(2); | |____________________^ help: consider using the `vec![]` macro: `let mut cap_err = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:27:5 + --> tests/ui/vec_init_then_push.rs:27:5 | LL | / new_err = Vec::new(); LL | | @@ -37,7 +37,7 @@ LL | | new_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `new_err = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:78:5 + --> tests/ui/vec_init_then_push.rs:78:5 | LL | / let mut v = Vec::new(); LL | | @@ -46,7 +46,7 @@ LL | | v.push(1); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:87:5 + --> tests/ui/vec_init_then_push.rs:87:5 | LL | / let mut v = Vec::new(); LL | | @@ -58,7 +58,7 @@ LL | | v.push(0); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:101:5 + --> tests/ui/vec_init_then_push.rs:101:5 | LL | / let mut v2 = Vec::new(); LL | | @@ -70,7 +70,7 @@ LL | | v2.push(0); | |_______________^ help: consider using the `vec![]` macro: `let mut v2 = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:117:5 + --> tests/ui/vec_init_then_push.rs:117:5 | LL | / let mut v = Vec::new(); LL | | diff --git a/tests/ui/vec_resize_to_zero.stderr b/tests/ui/vec_resize_to_zero.stderr index c16ba4e526278..ee4efeb2009be 100644 --- a/tests/ui/vec_resize_to_zero.stderr +++ b/tests/ui/vec_resize_to_zero.stderr @@ -1,5 +1,5 @@ error: emptying a vector with `resize` - --> $DIR/vec_resize_to_zero.rs:7:5 + --> tests/ui/vec_resize_to_zero.rs:7:5 | LL | v.resize(0, 5); | ^^------------ diff --git a/tests/ui/verbose_file_reads.stderr b/tests/ui/verbose_file_reads.stderr index 04e1aedf7c5a5..e85068fc7a9c7 100644 --- a/tests/ui/verbose_file_reads.stderr +++ b/tests/ui/verbose_file_reads.stderr @@ -1,5 +1,5 @@ error: use of `File::read_to_end` - --> $DIR/verbose_file_reads.rs:23:5 + --> tests/ui/verbose_file_reads.rs:23:5 | LL | f.read_to_end(&mut buffer)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | f.read_to_end(&mut buffer)?; = help: to override `-D warnings` add `#[allow(clippy::verbose_file_reads)]` error: use of `File::read_to_string` - --> $DIR/verbose_file_reads.rs:27:5 + --> tests/ui/verbose_file_reads.rs:27:5 | LL | f.read_to_string(&mut string_buffer)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/waker_clone_wake.stderr b/tests/ui/waker_clone_wake.stderr index f1abf4d9cb050..bf2c02a76c9bb 100644 --- a/tests/ui/waker_clone_wake.stderr +++ b/tests/ui/waker_clone_wake.stderr @@ -1,5 +1,5 @@ error: cloning a `Waker` only to wake it - --> $DIR/waker_clone_wake.rs:15:5 + --> tests/ui/waker_clone_wake.rs:15:5 | LL | cx.waker().clone().wake(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `cx.waker().wake_by_ref()` @@ -8,7 +8,7 @@ LL | cx.waker().clone().wake(); = help: to override `-D warnings` add `#[allow(clippy::waker_clone_wake)]` error: cloning a `Waker` only to wake it - --> $DIR/waker_clone_wake.rs:17:5 + --> tests/ui/waker_clone_wake.rs:17:5 | LL | mac!(cx).clone().wake(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `mac!(cx).wake_by_ref()` diff --git a/tests/ui/while_let_loop.stderr b/tests/ui/while_let_loop.stderr index db887dc65c6a2..5212d4fdcc7b8 100644 --- a/tests/ui/while_let_loop.stderr +++ b/tests/ui/while_let_loop.stderr @@ -1,5 +1,5 @@ error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:6:5 + --> tests/ui/while_let_loop.rs:6:5 | LL | / loop { LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:25:5 + --> tests/ui/while_let_loop.rs:25:5 | LL | / loop { LL | | @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:33:5 + --> tests/ui/while_let_loop.rs:33:5 | LL | / loop { LL | | @@ -38,7 +38,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:43:5 + --> tests/ui/while_let_loop.rs:43:5 | LL | / loop { LL | | @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:74:5 + --> tests/ui/while_let_loop.rs:74:5 | LL | / loop { LL | | diff --git a/tests/ui/while_let_on_iterator.stderr b/tests/ui/while_let_on_iterator.stderr index 7b9a9dc049a28..8ff1f23644b16 100644 --- a/tests/ui/while_let_on_iterator.stderr +++ b/tests/ui/while_let_on_iterator.stderr @@ -1,5 +1,5 @@ error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:15:5 + --> tests/ui/while_let_on_iterator.rs:15:5 | LL | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` @@ -8,157 +8,157 @@ LL | while let Option::Some(x) = iter.next() { = help: to override `-D warnings` add `#[allow(clippy::while_let_on_iterator)]` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:20:5 + --> tests/ui/while_let_on_iterator.rs:20:5 | LL | while let Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:25:5 + --> tests/ui/while_let_on_iterator.rs:25:5 | LL | while let Some(_) = iter.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in iter` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:101:9 + --> tests/ui/while_let_on_iterator.rs:101:9 | LL | while let Some([..]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [..] in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:108:9 + --> tests/ui/while_let_on_iterator.rs:108:9 | LL | while let Some([_x]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [_x] in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:121:9 + --> tests/ui/while_let_on_iterator.rs:121:9 | LL | while let Some(x @ [_]) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x @ [_] in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:141:9 + --> tests/ui/while_let_on_iterator.rs:141:9 | LL | while let Some(_) = y.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in y` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:198:9 + --> tests/ui/while_let_on_iterator.rs:198:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:209:5 + --> tests/ui/while_let_on_iterator.rs:209:5 | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:211:9 + --> tests/ui/while_let_on_iterator.rs:211:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:220:9 + --> tests/ui/while_let_on_iterator.rs:220:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:229:9 + --> tests/ui/while_let_on_iterator.rs:229:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:246:9 + --> tests/ui/while_let_on_iterator.rs:246:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:261:13 + --> tests/ui/while_let_on_iterator.rs:261:13 | LL | while let Some(i) = self.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:293:13 + --> tests/ui/while_let_on_iterator.rs:293:13 | LL | while let Some(i) = self.0.0.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.0.0.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:322:5 + --> tests/ui/while_let_on_iterator.rs:322:5 | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:334:9 + --> tests/ui/while_let_on_iterator.rs:334:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:348:5 + --> tests/ui/while_let_on_iterator.rs:348:5 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:359:5 + --> tests/ui/while_let_on_iterator.rs:359:5 | LL | while let Some(x) = it.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.0.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:394:5 + --> tests/ui/while_let_on_iterator.rs:394:5 | LL | while let Some(x) = s.x.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in s.x.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:401:5 + --> tests/ui/while_let_on_iterator.rs:401:5 | LL | while let Some(x) = x[0].next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in x[0].by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:409:9 + --> tests/ui/while_let_on_iterator.rs:409:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:419:9 + --> tests/ui/while_let_on_iterator.rs:419:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:429:9 + --> tests/ui/while_let_on_iterator.rs:429:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:439:9 + --> tests/ui/while_let_on_iterator.rs:439:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:451:9 + --> tests/ui/while_let_on_iterator.rs:451:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:461:5 + --> tests/ui/while_let_on_iterator.rs:461:5 | LL | while let Some(..) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in it` diff --git a/tests/ui/wild_in_or_pats.stderr b/tests/ui/wild_in_or_pats.stderr index 4cfa0d99350d0..06b2415d221e9 100644 --- a/tests/ui/wild_in_or_pats.stderr +++ b/tests/ui/wild_in_or_pats.stderr @@ -1,5 +1,5 @@ error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:8:9 + --> tests/ui/wild_in_or_pats.rs:8:9 | LL | "bar" | _ => { | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | "bar" | _ => { = help: to override `-D warnings` add `#[allow(clippy::wildcard_in_or_patterns)]` error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:17:9 + --> tests/ui/wild_in_or_pats.rs:17:9 | LL | "bar" | "bar2" | _ => { | ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | "bar" | "bar2" | _ => { = help: consider handling `_` separately error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:26:9 + --> tests/ui/wild_in_or_pats.rs:26:9 | LL | _ | "bar" | _ => { | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | _ | "bar" | _ => { = help: consider handling `_` separately error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:35:9 + --> tests/ui/wild_in_or_pats.rs:35:9 | LL | _ | "bar" => { | ^^^^^^^^^ diff --git a/tests/ui/wildcard_enum_match_arm.stderr b/tests/ui/wildcard_enum_match_arm.stderr index 7fbb16e69e4c5..70ac768aaacdc 100644 --- a/tests/ui/wildcard_enum_match_arm.stderr +++ b/tests/ui/wildcard_enum_match_arm.stderr @@ -1,41 +1,41 @@ error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:39:9 + --> tests/ui/wildcard_enum_match_arm.rs:39:9 | LL | _ => eprintln!("Not red"), | ^ help: try: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` | note: the lint level is defined here - --> $DIR/wildcard_enum_match_arm.rs:2:9 + --> tests/ui/wildcard_enum_match_arm.rs:2:9 | LL | #![deny(clippy::wildcard_enum_match_arm)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:43:9 + --> tests/ui/wildcard_enum_match_arm.rs:43:9 | LL | _not_red => eprintln!("Not red"), | ^^^^^^^^ help: try: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan` error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:47:9 + --> tests/ui/wildcard_enum_match_arm.rs:47:9 | LL | not_red => format!("{:?}", not_red), | ^^^^^^^ help: try: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan` error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:63:9 + --> tests/ui/wildcard_enum_match_arm.rs:63:9 | LL | _ => "No red", | ^ help: try: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` error: wildcard matches known variants and will also match future added variants - --> $DIR/wildcard_enum_match_arm.rs:80:9 + --> tests/ui/wildcard_enum_match_arm.rs:80:9 | LL | _ => {}, | ^ help: try: `ErrorKind::PermissionDenied | _` error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:98:13 + --> tests/ui/wildcard_enum_match_arm.rs:98:13 | LL | _ => (), | ^ help: try: `Enum::B | Enum::__Private` diff --git a/tests/ui/wildcard_imports.stderr b/tests/ui/wildcard_imports.stderr index 01a5414778c10..0c69d5262c26f 100644 --- a/tests/ui/wildcard_imports.stderr +++ b/tests/ui/wildcard_imports.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports.rs:15:5 + --> tests/ui/wildcard_imports.rs:15:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` @@ -8,91 +8,91 @@ LL | use crate::fn_mod::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:16:5 + --> tests/ui/wildcard_imports.rs:16:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:17:5 + --> tests/ui/wildcard_imports.rs:17:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:19:5 + --> tests/ui/wildcard_imports.rs:19:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:23:5 + --> tests/ui/wildcard_imports.rs:23:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:24:5 + --> tests/ui/wildcard_imports.rs:24:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:94:13 + --> tests/ui/wildcard_imports.rs:94:13 | LL | use self::exports_underscore_ish::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self::exports_underscore_ish::{_Deref, dummy}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:125:13 + --> tests/ui/wildcard_imports.rs:125:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:131:75 + --> tests/ui/wildcard_imports.rs:131:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:132:13 + --> tests/ui/wildcard_imports.rs:132:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:144:20 + --> tests/ui/wildcard_imports.rs:144:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:144:30 + --> tests/ui/wildcard_imports.rs:144:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:151:13 + --> tests/ui/wildcard_imports.rs:151:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:180:9 + --> tests/ui/wildcard_imports.rs:180:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:189:9 + --> tests/ui/wildcard_imports.rs:189:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:190:9 + --> tests/ui/wildcard_imports.rs:190:9 | LL | use crate:: fn_mod:: | _________^ @@ -100,37 +100,37 @@ LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:201:13 + --> tests/ui/wildcard_imports.rs:201:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:236:17 + --> tests/ui/wildcard_imports.rs:236:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:244:13 + --> tests/ui/wildcard_imports.rs:244:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:253:17 + --> tests/ui/wildcard_imports.rs:253:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:262:13 + --> tests/ui/wildcard_imports.rs:262:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:270:13 + --> tests/ui/wildcard_imports.rs:270:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` diff --git a/tests/ui/wildcard_imports_2021.edition2018.stderr b/tests/ui/wildcard_imports_2021.edition2018.stderr index e39f240a4aa2a..11e0bd377692d 100644 --- a/tests/ui/wildcard_imports_2021.edition2018.stderr +++ b/tests/ui/wildcard_imports_2021.edition2018.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:13:5 + --> tests/ui/wildcard_imports_2021.rs:13:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` @@ -8,91 +8,91 @@ LL | use crate::fn_mod::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:14:5 + --> tests/ui/wildcard_imports_2021.rs:14:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:15:5 + --> tests/ui/wildcard_imports_2021.rs:15:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:16:5 + --> tests/ui/wildcard_imports_2021.rs:16:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:19:5 + --> tests/ui/wildcard_imports_2021.rs:19:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:21:5 + --> tests/ui/wildcard_imports_2021.rs:21:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:89:13 + --> tests/ui/wildcard_imports_2021.rs:89:13 | LL | use exports_underscore_ish::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `exports_underscore_ish::{_Deref, dummy}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:119:13 + --> tests/ui/wildcard_imports_2021.rs:119:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:125:75 + --> tests/ui/wildcard_imports_2021.rs:125:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:126:13 + --> tests/ui/wildcard_imports_2021.rs:126:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:20 + --> tests/ui/wildcard_imports_2021.rs:138:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:30 + --> tests/ui/wildcard_imports_2021.rs:138:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:145:13 + --> tests/ui/wildcard_imports_2021.rs:145:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:174:9 + --> tests/ui/wildcard_imports_2021.rs:174:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:183:9 + --> tests/ui/wildcard_imports_2021.rs:183:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:184:9 + --> tests/ui/wildcard_imports_2021.rs:184:9 | LL | use crate:: fn_mod:: | _________^ @@ -100,37 +100,37 @@ LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:195:13 + --> tests/ui/wildcard_imports_2021.rs:195:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:230:17 + --> tests/ui/wildcard_imports_2021.rs:230:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:238:13 + --> tests/ui/wildcard_imports_2021.rs:238:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:247:17 + --> tests/ui/wildcard_imports_2021.rs:247:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:256:13 + --> tests/ui/wildcard_imports_2021.rs:256:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:264:13 + --> tests/ui/wildcard_imports_2021.rs:264:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` diff --git a/tests/ui/wildcard_imports_2021.edition2021.stderr b/tests/ui/wildcard_imports_2021.edition2021.stderr index e39f240a4aa2a..11e0bd377692d 100644 --- a/tests/ui/wildcard_imports_2021.edition2021.stderr +++ b/tests/ui/wildcard_imports_2021.edition2021.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:13:5 + --> tests/ui/wildcard_imports_2021.rs:13:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` @@ -8,91 +8,91 @@ LL | use crate::fn_mod::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:14:5 + --> tests/ui/wildcard_imports_2021.rs:14:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:15:5 + --> tests/ui/wildcard_imports_2021.rs:15:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:16:5 + --> tests/ui/wildcard_imports_2021.rs:16:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:19:5 + --> tests/ui/wildcard_imports_2021.rs:19:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:21:5 + --> tests/ui/wildcard_imports_2021.rs:21:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:89:13 + --> tests/ui/wildcard_imports_2021.rs:89:13 | LL | use exports_underscore_ish::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `exports_underscore_ish::{_Deref, dummy}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:119:13 + --> tests/ui/wildcard_imports_2021.rs:119:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:125:75 + --> tests/ui/wildcard_imports_2021.rs:125:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:126:13 + --> tests/ui/wildcard_imports_2021.rs:126:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:20 + --> tests/ui/wildcard_imports_2021.rs:138:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:30 + --> tests/ui/wildcard_imports_2021.rs:138:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:145:13 + --> tests/ui/wildcard_imports_2021.rs:145:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:174:9 + --> tests/ui/wildcard_imports_2021.rs:174:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:183:9 + --> tests/ui/wildcard_imports_2021.rs:183:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:184:9 + --> tests/ui/wildcard_imports_2021.rs:184:9 | LL | use crate:: fn_mod:: | _________^ @@ -100,37 +100,37 @@ LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:195:13 + --> tests/ui/wildcard_imports_2021.rs:195:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:230:17 + --> tests/ui/wildcard_imports_2021.rs:230:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:238:13 + --> tests/ui/wildcard_imports_2021.rs:238:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:247:17 + --> tests/ui/wildcard_imports_2021.rs:247:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:256:13 + --> tests/ui/wildcard_imports_2021.rs:256:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:264:13 + --> tests/ui/wildcard_imports_2021.rs:264:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index ee0d536e954f3..9f4cdfd91e8ab 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:31:27 + --> tests/ui/write_literal.rs:31:27 | LL | write!(v, "Hello {}", "world"); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + write!(v, "Hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:34:39 + --> tests/ui/write_literal.rs:34:39 | LL | writeln!(v, "Hello {} {}", world, "world"); | ^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, "Hello {} world", world); | error: literal with an empty format string - --> $DIR/write_literal.rs:36:29 + --> tests/ui/write_literal.rs:36:29 | LL | writeln!(v, "Hello {}", "world"); | ^^^^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "Hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:38:29 + --> tests/ui/write_literal.rs:38:29 | LL | writeln!(v, "{} {:.4}", "a literal", 5); | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + writeln!(v, "a literal {:.4}", 5); | error: literal with an empty format string - --> $DIR/write_literal.rs:44:28 + --> tests/ui/write_literal.rs:44:28 | LL | writeln!(v, "{0} {1}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + writeln!(v, "hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:46:28 + --> tests/ui/write_literal.rs:46:28 | LL | writeln!(v, "{1} {0}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + writeln!(v, "world hello"); | error: literal with an empty format string - --> $DIR/write_literal.rs:50:38 + --> tests/ui/write_literal.rs:50:38 | LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + writeln!(v, "hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:52:38 + --> tests/ui/write_literal.rs:52:38 | LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + writeln!(v, "world hello"); | error: literal with an empty format string - --> $DIR/write_literal.rs:56:32 + --> tests/ui/write_literal.rs:56:32 | LL | writeln!(v, "{0} {1} {2}", "hello", 2, "world"); | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + writeln!(v, "hello {0} world", 2); | error: literal with an empty format string - --> $DIR/write_literal.rs:58:32 + --> tests/ui/write_literal.rs:58:32 | LL | writeln!(v, "{2} {1} {0}", "hello", 2, "world"); | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + writeln!(v, "world {0} hello", 2); | error: literal with an empty format string - --> $DIR/write_literal.rs:60:39 + --> tests/ui/write_literal.rs:60:39 | LL | writeln!(v, "{0} {1} {2}, {bar}", "hello", 2, 3, bar = 4); | ^^^^^^^ @@ -133,7 +133,7 @@ LL + writeln!(v, "hello {0} {1}, {bar}", 2, 3, bar = 4); | error: literal with an empty format string - --> $DIR/write_literal.rs:62:41 + --> tests/ui/write_literal.rs:62:41 | LL | writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/write_literal_2.stderr b/tests/ui/write_literal_2.stderr index 81ef49de082e7..9fba3ce548a06 100644 --- a/tests/ui/write_literal_2.stderr +++ b/tests/ui/write_literal_2.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal_2.rs:10:23 + --> tests/ui/write_literal_2.rs:10:23 | LL | writeln!(v, "{}", "{hello}"); | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + writeln!(v, "{{hello}}"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:13:24 + --> tests/ui/write_literal_2.rs:13:24 | LL | writeln!(v, r"{}", r"{hello}"); | ^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, r"{{hello}}"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:15:23 + --> tests/ui/write_literal_2.rs:15:23 | LL | writeln!(v, "{}", '\''); | ^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "'"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:17:23 + --> tests/ui/write_literal_2.rs:17:23 | LL | writeln!(v, "{}", '"'); | ^^^ @@ -49,13 +49,13 @@ LL + writeln!(v, "\""); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:19:24 + --> tests/ui/write_literal_2.rs:19:24 | LL | writeln!(v, r"{}", '"'); | ^^^ error: literal with an empty format string - --> $DIR/write_literal_2.rs:21:24 + --> tests/ui/write_literal_2.rs:21:24 | LL | writeln!(v, r"{}", '\''); | ^^^^ @@ -67,7 +67,7 @@ LL + writeln!(v, r"'"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:26:9 + --> tests/ui/write_literal_2.rs:26:9 | LL | / "hello \ LL | | world!", @@ -80,7 +80,7 @@ LL ~ world!", | error: literal with an empty format string - --> $DIR/write_literal_2.rs:34:9 + --> tests/ui/write_literal_2.rs:34:9 | LL | "1", "2", "3", | ^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL ~ 2 \\ 3", | error: literal with an empty format string - --> $DIR/write_literal_2.rs:36:23 + --> tests/ui/write_literal_2.rs:36:23 | LL | writeln!(v, "{}", "\\"); | ^^^^ @@ -104,7 +104,7 @@ LL + writeln!(v, "\\"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:38:24 + --> tests/ui/write_literal_2.rs:38:24 | LL | writeln!(v, r"{}", "\\"); | ^^^^ @@ -116,7 +116,7 @@ LL + writeln!(v, r"\"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:40:26 + --> tests/ui/write_literal_2.rs:40:26 | LL | writeln!(v, r#"{}"#, "\\"); | ^^^^ @@ -128,7 +128,7 @@ LL + writeln!(v, r#"\"#); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:42:23 + --> tests/ui/write_literal_2.rs:42:23 | LL | writeln!(v, "{}", r"\"); | ^^^^ @@ -140,7 +140,7 @@ LL + writeln!(v, "\\"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:44:23 + --> tests/ui/write_literal_2.rs:44:23 | LL | writeln!(v, "{}", "\r"); | ^^^^ @@ -152,7 +152,7 @@ LL + writeln!(v, "\r"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:47:28 + --> tests/ui/write_literal_2.rs:47:28 | LL | writeln!(v, r#"{}{}"#, '#', '"'); | ^^^^^^^^ diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index 78874ffadc0be..7eb741107a7b8 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,5 +1,5 @@ error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:12:5 + --> tests/ui/write_with_newline.rs:12:5 | LL | write!(v, "Hello\n"); | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + writeln!(v, "Hello"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:15:5 + --> tests/ui/write_with_newline.rs:15:5 | LL | write!(v, "Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, "Hello {}", "world"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:17:5 + --> tests/ui/write_with_newline.rs:17:5 | LL | write!(v, "Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "Hello {} {}", "world", "#2"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:19:5 + --> tests/ui/write_with_newline.rs:19:5 | LL | write!(v, "{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + writeln!(v, "{}", 1265); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:21:5 + --> tests/ui/write_with_newline.rs:21:5 | LL | write!(v, "\n"); | ^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + writeln!(v); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:44:5 + --> tests/ui/write_with_newline.rs:44:5 | LL | write!(v, "\\\n"); | ^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + writeln!(v, "\\"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:53:5 + --> tests/ui/write_with_newline.rs:53:5 | LL | / write!( LL | | @@ -91,7 +91,7 @@ LL ~ v | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:59:5 + --> tests/ui/write_with_newline.rs:59:5 | LL | / write!( LL | | @@ -109,7 +109,7 @@ LL ~ v | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:69:5 + --> tests/ui/write_with_newline.rs:69:5 | LL | write!(v, "\\r\n"); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 0374755436176..20ece6a419264 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,5 +1,5 @@ error: empty string literal in `writeln!` - --> $DIR/writeln_empty_string.rs:9:5 + --> tests/ui/writeln_empty_string.rs:9:5 | LL | writeln!(v, ""); | ^^^^^^^^^^----^ @@ -10,7 +10,7 @@ LL | writeln!(v, ""); = help: to override `-D warnings` add `#[allow(clippy::writeln_empty_string)]` error: empty string literal in `writeln!` - --> $DIR/writeln_empty_string.rs:12:5 + --> tests/ui/writeln_empty_string.rs:12:5 | LL | writeln!(suggestion, ""); | ^^^^^^^^^^^^^^^^^^^----^ diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index 9f457b50ce775..5c286721c4782 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,5 +1,5 @@ error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:16:17 + --> tests/ui/wrong_self_convention.rs:16:17 | LL | fn from_i32(self) {} | ^^^^ @@ -9,7 +9,7 @@ LL | fn from_i32(self) {} = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:23:21 + --> tests/ui/wrong_self_convention.rs:23:21 | LL | pub fn from_i64(self) {} | ^^^^ @@ -17,7 +17,7 @@ LL | pub fn from_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:36:15 + --> tests/ui/wrong_self_convention.rs:36:15 | LL | fn as_i32(self) {} | ^^^^ @@ -25,7 +25,7 @@ LL | fn as_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:39:17 + --> tests/ui/wrong_self_convention.rs:39:17 | LL | fn into_i32(&self) {} | ^^^^^ @@ -33,7 +33,7 @@ LL | fn into_i32(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:42:15 + --> tests/ui/wrong_self_convention.rs:42:15 | LL | fn is_i32(self) {} | ^^^^ @@ -41,7 +41,7 @@ LL | fn is_i32(self) {} = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_convention.rs:45:15 + --> tests/ui/wrong_self_convention.rs:45:15 | LL | fn to_i32(self) {} | ^^^^ @@ -49,7 +49,7 @@ LL | fn to_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:48:17 + --> tests/ui/wrong_self_convention.rs:48:17 | LL | fn from_i32(self) {} | ^^^^ @@ -57,7 +57,7 @@ LL | fn from_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:51:19 + --> tests/ui/wrong_self_convention.rs:51:19 | LL | pub fn as_i64(self) {} | ^^^^ @@ -65,7 +65,7 @@ LL | pub fn as_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:53:21 + --> tests/ui/wrong_self_convention.rs:53:21 | LL | pub fn into_i64(&self) {} | ^^^^^ @@ -73,7 +73,7 @@ LL | pub fn into_i64(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:55:19 + --> tests/ui/wrong_self_convention.rs:55:19 | LL | pub fn is_i64(self) {} | ^^^^ @@ -81,7 +81,7 @@ LL | pub fn is_i64(self) {} = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_convention.rs:57:19 + --> tests/ui/wrong_self_convention.rs:57:19 | LL | pub fn to_i64(self) {} | ^^^^ @@ -89,7 +89,7 @@ LL | pub fn to_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:59:21 + --> tests/ui/wrong_self_convention.rs:59:21 | LL | pub fn from_i64(self) {} | ^^^^ @@ -97,7 +97,7 @@ LL | pub fn from_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:105:19 + --> tests/ui/wrong_self_convention.rs:105:19 | LL | fn as_i32(self) {} | ^^^^ @@ -105,7 +105,7 @@ LL | fn as_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:109:25 + --> tests/ui/wrong_self_convention.rs:109:25 | LL | fn into_i32_ref(&self) {} | ^^^^^ @@ -113,7 +113,7 @@ LL | fn into_i32_ref(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:112:19 + --> tests/ui/wrong_self_convention.rs:112:19 | LL | fn is_i32(self) {} | ^^^^ @@ -121,7 +121,7 @@ LL | fn is_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:117:21 + --> tests/ui/wrong_self_convention.rs:117:21 | LL | fn from_i32(self) {} | ^^^^ @@ -129,7 +129,7 @@ LL | fn from_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:133:19 + --> tests/ui/wrong_self_convention.rs:133:19 | LL | fn as_i32(self); | ^^^^ @@ -137,7 +137,7 @@ LL | fn as_i32(self); = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:137:25 + --> tests/ui/wrong_self_convention.rs:137:25 | LL | fn into_i32_ref(&self); | ^^^^^ @@ -145,7 +145,7 @@ LL | fn into_i32_ref(&self); = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:140:19 + --> tests/ui/wrong_self_convention.rs:140:19 | LL | fn is_i32(self); | ^^^^ @@ -153,7 +153,7 @@ LL | fn is_i32(self); = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:145:21 + --> tests/ui/wrong_self_convention.rs:145:21 | LL | fn from_i32(self); | ^^^^ @@ -161,7 +161,7 @@ LL | fn from_i32(self); = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:164:25 + --> tests/ui/wrong_self_convention.rs:164:25 | LL | fn into_i32_ref(&self); | ^^^^^ @@ -169,7 +169,7 @@ LL | fn into_i32_ref(&self); = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:171:21 + --> tests/ui/wrong_self_convention.rs:171:21 | LL | fn from_i32(self); | ^^^^ @@ -177,7 +177,7 @@ LL | fn from_i32(self); = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value - --> $DIR/wrong_self_convention.rs:196:22 + --> tests/ui/wrong_self_convention.rs:196:22 | LL | fn to_u64_v2(&self) -> u64 { | ^^^^^ @@ -185,7 +185,7 @@ LL | fn to_u64_v2(&self) -> u64 { = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_convention.rs:206:19 + --> tests/ui/wrong_self_convention.rs:206:19 | LL | fn to_u64(self) -> u64 { | ^^^^ diff --git a/tests/ui/wrong_self_convention2.stderr b/tests/ui/wrong_self_convention2.stderr index dc12a844332eb..7aabdcd408c66 100644 --- a/tests/ui/wrong_self_convention2.stderr +++ b/tests/ui/wrong_self_convention2.stderr @@ -1,5 +1,5 @@ error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention2.rs:54:29 + --> tests/ui/wrong_self_convention2.rs:54:29 | LL | pub fn from_be_self(self) -> Self { | ^^^^ @@ -9,7 +9,7 @@ LL | pub fn from_be_self(self) -> Self { = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention2.rs:64:25 + --> tests/ui/wrong_self_convention2.rs:64:25 | LL | fn from_be_self(self) -> Self; | ^^^^ diff --git a/tests/ui/wrong_self_conventions_mut.stderr b/tests/ui/wrong_self_conventions_mut.stderr index 21255287d722e..f52a36632101c 100644 --- a/tests/ui/wrong_self_conventions_mut.stderr +++ b/tests/ui/wrong_self_conventions_mut.stderr @@ -1,5 +1,5 @@ error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_conventions_mut.rs:14:24 + --> tests/ui/wrong_self_conventions_mut.rs:14:24 | LL | pub fn to_many(&mut self) -> Option<&mut [T]> { | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | pub fn to_many(&mut self) -> Option<&mut [T]> { = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods with the following characteristics: (`to_*` and `*_mut`) usually take `self` by mutable reference - --> $DIR/wrong_self_conventions_mut.rs:23:28 + --> tests/ui/wrong_self_conventions_mut.rs:23:28 | LL | pub fn to_many_mut(&self) -> Option<&[T]> { | ^^^^^ diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 797ae2537bb37..5294ebdfa5da1 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,5 +1,5 @@ error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:4:15 + --> tests/ui/zero_div_zero.rs:4:15 | LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let nan = 0.0 / 0.0; = help: to override `-D warnings` add `#[allow(clippy::zero_divided_by_zero)]` error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:6:19 + --> tests/ui/zero_div_zero.rs:6:19 | LL | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let f64_nan = 0.0 / 0.0f64; = help: consider using `f64::NAN` if you would like a constant representing NaN error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:8:25 + --> tests/ui/zero_div_zero.rs:8:25 | LL | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let other_f64_nan = 0.0f64 / 0.0; = help: consider using `f64::NAN` if you would like a constant representing NaN error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:10:28 + --> tests/ui/zero_div_zero.rs:10:28 | LL | let one_more_f64_nan = 0.0f64 / 0.0f64; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/zero_offset.stderr b/tests/ui/zero_offset.stderr index bb616f456ae14..a1efe3904c18b 100644 --- a/tests/ui/zero_offset.stderr +++ b/tests/ui/zero_offset.stderr @@ -1,5 +1,5 @@ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:5:9 + --> tests/ui/zero_offset.rs:5:9 | LL | m.offset(0); | ^^^^^^^^^^^ @@ -7,43 +7,43 @@ LL | m.offset(0); = note: `#[deny(clippy::zst_offset)]` on by default error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:8:9 + --> tests/ui/zero_offset.rs:8:9 | LL | m.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:10:9 + --> tests/ui/zero_offset.rs:10:9 | LL | m.sub(0); | ^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:12:9 + --> tests/ui/zero_offset.rs:12:9 | LL | m.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:16:9 + --> tests/ui/zero_offset.rs:16:9 | LL | c.offset(0); | ^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:18:9 + --> tests/ui/zero_offset.rs:18:9 | LL | c.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:20:9 + --> tests/ui/zero_offset.rs:20:9 | LL | c.sub(0); | ^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:22:9 + --> tests/ui/zero_offset.rs:22:9 | LL | c.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 57679a8ac564f..a580bebd5d3aa 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -1,5 +1,5 @@ error: `0 as *const _` detected - --> $DIR/zero_ptr.rs:4:13 + --> tests/ui/zero_ptr.rs:4:13 | LL | let _ = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null::()` @@ -8,25 +8,25 @@ LL | let _ = 0 as *const usize; = help: to override `-D warnings` add `#[allow(clippy::zero_ptr)]` error: `0 as *mut _` detected - --> $DIR/zero_ptr.rs:5:13 + --> tests/ui/zero_ptr.rs:5:13 | LL | let _ = 0 as *mut f64; | ^^^^^^^^^^^^^ help: try: `std::ptr::null_mut::()` error: `0 as *const _` detected - --> $DIR/zero_ptr.rs:6:24 + --> tests/ui/zero_ptr.rs:6:24 | LL | let _: *const u8 = 0 as *const _; | ^^^^^^^^^^^^^ help: try: `std::ptr::null()` error: `0 as *const _` detected - --> $DIR/zero_ptr.rs:9:9 + --> tests/ui/zero_ptr.rs:9:9 | LL | foo(0 as *const _, 0 as *mut _); | ^^^^^^^^^^^^^ help: try: `std::ptr::null()` error: `0 as *mut _` detected - --> $DIR/zero_ptr.rs:9:24 + --> tests/ui/zero_ptr.rs:9:24 | LL | foo(0 as *const _, 0 as *mut _); | ^^^^^^^^^^^ help: try: `std::ptr::null_mut()` diff --git a/tests/ui/zero_ptr_no_std.stderr b/tests/ui/zero_ptr_no_std.stderr index 915b9c477ff4c..42a1a41ca94f4 100644 --- a/tests/ui/zero_ptr_no_std.stderr +++ b/tests/ui/zero_ptr_no_std.stderr @@ -1,23 +1,23 @@ error: `0 as *const _` detected - --> $DIR/zero_ptr_no_std.rs:7:13 + --> tests/ui/zero_ptr_no_std.rs:7:13 | LL | let _ = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ help: try: `core::ptr::null::()` | note: the lint level is defined here - --> $DIR/zero_ptr_no_std.rs:3:9 + --> tests/ui/zero_ptr_no_std.rs:3:9 | LL | #![deny(clippy::zero_ptr)] | ^^^^^^^^^^^^^^^^ error: `0 as *mut _` detected - --> $DIR/zero_ptr_no_std.rs:8:13 + --> tests/ui/zero_ptr_no_std.rs:8:13 | LL | let _ = 0 as *mut f64; | ^^^^^^^^^^^^^ help: try: `core::ptr::null_mut::()` error: `0 as *const _` detected - --> $DIR/zero_ptr_no_std.rs:9:24 + --> tests/ui/zero_ptr_no_std.rs:9:24 | LL | let _: *const u8 = 0 as *const _; | ^^^^^^^^^^^^^ help: try: `core::ptr::null()` diff --git a/tests/ui/zero_sized_btreemap_values.stderr b/tests/ui/zero_sized_btreemap_values.stderr index c48e19a760af2..65fc81e10e6c3 100644 --- a/tests/ui/zero_sized_btreemap_values.stderr +++ b/tests/ui/zero_sized_btreemap_values.stderr @@ -1,5 +1,5 @@ error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:5:28 + --> tests/ui/zero_sized_btreemap_values.rs:5:28 | LL | const CONST_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const CONST_NOT_OK: Option> = None; = help: to override `-D warnings` add `#[allow(clippy::zero_sized_map_values)]` error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:9:30 + --> tests/ui/zero_sized_btreemap_values.rs:9:30 | LL | static STATIC_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static STATIC_NOT_OK: Option> = None; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:13:17 + --> tests/ui/zero_sized_btreemap_values.rs:13:17 | LL | type NotOkMap = BTreeMap; | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type NotOkMap = BTreeMap; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:18:11 + --> tests/ui/zero_sized_btreemap_values.rs:18:11 | LL | NotOk(BTreeMap), | ^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | NotOk(BTreeMap), = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:24:13 + --> tests/ui/zero_sized_btreemap_values.rs:24:13 | LL | not_ok: BTreeMap, | ^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | not_ok: BTreeMap, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:26:22 + --> tests/ui/zero_sized_btreemap_values.rs:26:22 | LL | also_not_ok: Vec>, | ^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | also_not_ok: Vec>, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:35:30 + --> tests/ui/zero_sized_btreemap_values.rs:35:30 | LL | fn weird_map(&self, map: BTreeMap); | ^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn weird_map(&self, map: BTreeMap); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:44:25 + --> tests/ui/zero_sized_btreemap_values.rs:44:25 | LL | fn not_ok(&self) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn not_ok(&self) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:62:14 + --> tests/ui/zero_sized_btreemap_values.rs:62:14 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:62:50 + --> tests/ui/zero_sized_btreemap_values.rs:62:50 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:73:35 + --> tests/ui/zero_sized_btreemap_values.rs:73:35 | LL | let _: BTreeMap = BTreeMap::new(); | ^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: BTreeMap = BTreeMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:73:12 + --> tests/ui/zero_sized_btreemap_values.rs:73:12 | LL | let _: BTreeMap = BTreeMap::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: BTreeMap = BTreeMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:78:12 + --> tests/ui/zero_sized_btreemap_values.rs:78:12 | LL | let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect(); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/zero_sized_hashmap_values.stderr b/tests/ui/zero_sized_hashmap_values.stderr index 08b1b58f3df3a..08afef58a2aaa 100644 --- a/tests/ui/zero_sized_hashmap_values.stderr +++ b/tests/ui/zero_sized_hashmap_values.stderr @@ -1,5 +1,5 @@ error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:5:28 + --> tests/ui/zero_sized_hashmap_values.rs:5:28 | LL | const CONST_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const CONST_NOT_OK: Option> = None; = help: to override `-D warnings` add `#[allow(clippy::zero_sized_map_values)]` error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:9:30 + --> tests/ui/zero_sized_hashmap_values.rs:9:30 | LL | static STATIC_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static STATIC_NOT_OK: Option> = None; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:13:17 + --> tests/ui/zero_sized_hashmap_values.rs:13:17 | LL | type NotOkMap = HashMap; | ^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type NotOkMap = HashMap; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:18:11 + --> tests/ui/zero_sized_hashmap_values.rs:18:11 | LL | NotOk(HashMap), | ^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | NotOk(HashMap), = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:24:13 + --> tests/ui/zero_sized_hashmap_values.rs:24:13 | LL | not_ok: HashMap, | ^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | not_ok: HashMap, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:26:22 + --> tests/ui/zero_sized_hashmap_values.rs:26:22 | LL | also_not_ok: Vec>, | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | also_not_ok: Vec>, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:35:30 + --> tests/ui/zero_sized_hashmap_values.rs:35:30 | LL | fn weird_map(&self, map: HashMap); | ^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn weird_map(&self, map: HashMap); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:44:25 + --> tests/ui/zero_sized_hashmap_values.rs:44:25 | LL | fn not_ok(&self) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn not_ok(&self) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:62:14 + --> tests/ui/zero_sized_hashmap_values.rs:62:14 | LL | fn test(map: HashMap, key: &str) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:62:49 + --> tests/ui/zero_sized_hashmap_values.rs:62:49 | LL | fn test(map: HashMap, key: &str) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:73:34 + --> tests/ui/zero_sized_hashmap_values.rs:73:34 | LL | let _: HashMap = HashMap::new(); | ^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: HashMap = HashMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:73:12 + --> tests/ui/zero_sized_hashmap_values.rs:73:12 | LL | let _: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: HashMap = HashMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:78:12 + --> tests/ui/zero_sized_hashmap_values.rs:78:12 | LL | let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect(); | ^^^^^^^^^^^^^ From 740d89ee697de31ad4ede7e8b6596c148f6659c2 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sat, 17 Feb 2024 12:19:08 +0000 Subject: [PATCH 094/417] Remove $DIR replacement in docs sampling stderr files --- book/src/development/emitting_lints.md | 10 +++++----- book/src/development/writing_tests.md | 6 +++--- clippy_utils/src/diagnostics.rs | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/book/src/development/emitting_lints.md b/book/src/development/emitting_lints.md index a12f6aa91b307..d70f4fc17ebf0 100644 --- a/book/src/development/emitting_lints.md +++ b/book/src/development/emitting_lints.md @@ -82,7 +82,7 @@ The output looks something like this (from the example earlier): ```text error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:37:14 + --> tests/ui/range_plus_minus_one.rs:37:14 | LL | for _ in 1..1 + 1 {} | ^^^^^^^^ help: use: `1..=1` @@ -135,14 +135,14 @@ Examples: ```text error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:10:5 + --> tests/ui/drop_forget_ref.rs:10:5 | 10 | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:10:12 + --> tests/ui/drop_forget_ref.rs:10:12 | 10 | forget(&SomeStruct); | ^^^^^^^^^^^ @@ -158,7 +158,7 @@ Example: ```text error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:6:25 + --> tests/ui/zero_div_zero.rs:6:25 | 6 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ @@ -176,7 +176,7 @@ Example: ```text error: This `.fold` can be more succinctly expressed as `.any` ---> $DIR/methods.rs:390:13 +--> tests/ui/methods.rs:390:13 | 390 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` diff --git a/book/src/development/writing_tests.md b/book/src/development/writing_tests.md index 8937e0d8e9469..39a5ad9668851 100644 --- a/book/src/development/writing_tests.md +++ b/book/src/development/writing_tests.md @@ -97,19 +97,19 @@ failures: ---- compile_test stdout ---- normalized stderr: error: function called "foo" - --> $DIR/foo_functions.rs:6:12 + --> tests/ui/foo_functions.rs:6:12 | LL | pub fn foo(&self) {} | ^^^ | = note: `-D clippy::foo-functions` implied by `-D warnings` error: function called "foo" - --> $DIR/foo_functions.rs:13:8 + --> tests/ui/foo_functions.rs:13:8 | LL | fn foo(&self) {} | ^^^ error: function called "foo" - --> $DIR/foo_functions.rs:19:4 + --> tests/ui/foo_functions.rs:19:4 | LL | fn foo() {} | ^^^ diff --git a/clippy_utils/src/diagnostics.rs b/clippy_utils/src/diagnostics.rs index 5199959c0f2b3..8cbbe87ef07c2 100644 --- a/clippy_utils/src/diagnostics.rs +++ b/clippy_utils/src/diagnostics.rs @@ -40,7 +40,7 @@ fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) { /// /// ```ignore /// error: usage of mem::forget on Drop type -/// --> $DIR/mem_forget.rs:17:5 +/// --> tests/ui/mem_forget.rs:17:5 /// | /// 17 | std::mem::forget(seven); /// | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ pub fn span_lint(cx: &T, lint: &'static Lint, sp: impl Into $DIR/zero_div_zero.rs:6:25 +/// --> tests/ui/zero_div_zero.rs:6:25 /// | /// 6 | let other_f64_nan = 0.0f64 / 0.0; /// | ^^^^^^^^^^^^ @@ -103,14 +103,14 @@ pub fn span_lint_and_help( /// /// ```text /// error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. -/// --> $DIR/drop_forget_ref.rs:10:5 +/// --> tests/ui/drop_forget_ref.rs:10:5 /// | /// 10 | forget(&SomeStruct); /// | ^^^^^^^^^^^^^^^^^^^ /// | /// = note: `-D clippy::forget-ref` implied by `-D warnings` /// note: argument has type &SomeStruct -/// --> $DIR/drop_forget_ref.rs:10:12 +/// --> tests/ui/drop_forget_ref.rs:10:12 /// | /// 10 | forget(&SomeStruct); /// | ^^^^^^^^^^^ @@ -186,7 +186,7 @@ pub fn span_lint_hir_and_then( /// /// ```text /// error: This `.fold` can be more succinctly expressed as `.any` -/// --> $DIR/methods.rs:390:13 +/// --> tests/ui/methods.rs:390:13 /// | /// 390 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` From c1144436f69fb3c235dd0dbf90f1833bec830856 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 28 Jan 2024 13:50:06 +0100 Subject: [PATCH 095/417] Make synstructure underscore_const(true) the default since otherwise it will trigger the non_local_definitions lint --- compiler/rustc_macros/src/diagnostics/mod.rs | 9 ++++++--- compiler/rustc_macros/src/hash_stable.rs | 2 ++ compiler/rustc_macros/src/lift.rs | 1 + compiler/rustc_macros/src/serialize.rs | 12 +++++++++++- compiler/rustc_macros/src/type_foldable.rs | 2 ++ compiler/rustc_macros/src/type_visitable.rs | 2 ++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_macros/src/diagnostics/mod.rs b/compiler/rustc_macros/src/diagnostics/mod.rs index 33dffe6998a1e..044bbadf41c5a 100644 --- a/compiler/rustc_macros/src/diagnostics/mod.rs +++ b/compiler/rustc_macros/src/diagnostics/mod.rs @@ -55,7 +55,8 @@ use synstructure::Structure; /// /// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`: /// -pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream { +pub fn session_diagnostic_derive(mut s: Structure<'_>) -> TokenStream { + s.underscore_const(true); DiagnosticDerive::new(s).into_tokens() } @@ -101,7 +102,8 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// /// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`: /// -pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { +pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream { + s.underscore_const(true); LintDiagnosticDerive::new(s).into_tokens() } @@ -151,6 +153,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// /// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident }); /// ``` -pub fn session_subdiagnostic_derive(s: Structure<'_>) -> TokenStream { +pub fn session_subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream { + s.underscore_const(true); SubdiagnosticDeriveBuilder::new().into_tokens(s) } diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index a6396ba687d11..6b3210cad7be6 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -74,6 +74,8 @@ fn hash_stable_derive_with_mode( HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX), }; + s.underscore_const(true); + // no_context impl is able to derive by-field, which is closer to a perfect derive. s.add_bounds(match mode { HashStableMode::Normal | HashStableMode::Generic => synstructure::AddBounds::Generics, diff --git a/compiler/rustc_macros/src/lift.rs b/compiler/rustc_macros/src/lift.rs index 3dedd88fb19b6..f7a84ba1510d0 100644 --- a/compiler/rustc_macros/src/lift.rs +++ b/compiler/rustc_macros/src/lift.rs @@ -4,6 +4,7 @@ use syn::parse_quote; pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { s.add_bounds(synstructure::AddBounds::Generics); s.bind_with(|_| synstructure::BindStyle::Move); + s.underscore_const(true); let tcx: syn::Lifetime = parse_quote!('tcx); let newtcx: syn::GenericParam = parse_quote!('__lifted); diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 98b53945b9115..5fa11d22f0e75 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -15,6 +15,7 @@ pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_type_ir::codec::TyDecoder #bound }); s.add_bounds(synstructure::AddBounds::Fields); + s.underscore_const(true); decodable_body(s, decoder_ty) } @@ -26,6 +27,7 @@ pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_impl_generic(parse_quote! { '__a }); let decoder_ty = quote! { DecodeContext<'__a, 'tcx> }; s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); decodable_body(s, decoder_ty) } @@ -34,6 +36,7 @@ pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke let decoder_ty = quote! { __D }; s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_span::SpanDecoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); decodable_body(s, decoder_ty) } @@ -42,12 +45,13 @@ pub fn decodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macr let decoder_ty = quote! { __D }; s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_serialize::Decoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); decodable_body(s, decoder_ty) } fn decodable_body( - s: synstructure::Structure<'_>, + mut s: synstructure::Structure<'_>, decoder_ty: TokenStream, ) -> proc_macro2::TokenStream { if let syn::Data::Union(_) = s.ast().data { @@ -93,6 +97,7 @@ fn decodable_body( } } }; + s.underscore_const(true); s.bound_impl( quote!(::rustc_serialize::Decodable<#decoder_ty>), @@ -130,6 +135,7 @@ pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: let encoder_ty = quote! { __E }; s.add_impl_generic(parse_quote! {#encoder_ty: ::rustc_type_ir::codec::TyEncoder #bound }); s.add_bounds(synstructure::AddBounds::Fields); + s.underscore_const(true); encodable_body(s, encoder_ty, false) } @@ -141,6 +147,7 @@ pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_impl_generic(parse_quote! { '__a }); let encoder_ty = quote! { EncodeContext<'__a, 'tcx> }; s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); encodable_body(s, encoder_ty, true) } @@ -149,6 +156,7 @@ pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke let encoder_ty = quote! { __E }; s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); encodable_body(s, encoder_ty, false) } @@ -157,6 +165,7 @@ pub fn encodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macr let encoder_ty = quote! { __E }; s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); encodable_body(s, encoder_ty, false) } @@ -170,6 +179,7 @@ fn encodable_body( panic!("cannot derive on union") } + s.underscore_const(true); s.bind_with(|binding| { // Handle the lack of a blanket reference impl. if let syn::Type::Reference(_) = binding.ast().ty { diff --git a/compiler/rustc_macros/src/type_foldable.rs b/compiler/rustc_macros/src/type_foldable.rs index 5ee4d8793135c..5617c53b119ee 100644 --- a/compiler/rustc_macros/src/type_foldable.rs +++ b/compiler/rustc_macros/src/type_foldable.rs @@ -6,6 +6,8 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:: panic!("cannot derive on union") } + s.underscore_const(true); + if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") { s.add_impl_generic(parse_quote! { 'tcx }); } diff --git a/compiler/rustc_macros/src/type_visitable.rs b/compiler/rustc_macros/src/type_visitable.rs index dcd505a105e57..c8430380345b4 100644 --- a/compiler/rustc_macros/src/type_visitable.rs +++ b/compiler/rustc_macros/src/type_visitable.rs @@ -6,6 +6,8 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: panic!("cannot derive on union") } + s.underscore_const(true); + // ignore fields with #[type_visitable(ignore)] s.filter(|bi| { let mut ignored = false; From 61703943132eb4a509646bf63e0199268c6df4a2 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 26 Jan 2024 15:25:18 +0100 Subject: [PATCH 096/417] Implement RFC3373 non local definitions lint --- Cargo.lock | 1 + compiler/rustc_lint/Cargo.toml | 1 + compiler/rustc_lint/messages.ftl | 20 + compiler/rustc_lint/src/lib.rs | 3 + compiler/rustc_lint/src/lints.rs | 17 + compiler/rustc_lint/src/non_local_def.rs | 187 ++++++ tests/ui/lint/non_local_definitions.rs | 373 +++++++++++ tests/ui/lint/non_local_definitions.stderr | 611 ++++++++++++++++++ tests/ui/proc-macro/nested-macro-rules.rs | 1 + tests/ui/proc-macro/nested-macro-rules.stderr | 27 + 10 files changed, 1241 insertions(+) create mode 100644 compiler/rustc_lint/src/non_local_def.rs create mode 100644 tests/ui/lint/non_local_definitions.rs create mode 100644 tests/ui/lint/non_local_definitions.stderr create mode 100644 tests/ui/proc-macro/nested-macro-rules.stderr diff --git a/Cargo.lock b/Cargo.lock index f9ad78e37951d..327186bc9b1de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4164,6 +4164,7 @@ dependencies = [ "rustc_target", "rustc_trait_selection", "rustc_type_ir", + "smallvec", "tracing", "unicode-security", ] diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index fa1133e7780ff..2271321b8bf22 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -23,6 +23,7 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_type_ir = { path = "../rustc_type_ir" } +smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" unicode-security = "0.1.0" # tidy-alphabetical-end diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 785895e0ab823..4e0ba376b7d2e 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -411,6 +411,26 @@ lint_non_fmt_panic_unused = } .add_fmt_suggestion = or add a "{"{"}{"}"}" format string to use the message literally +lint_non_local_definitions_deprecation = this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +lint_non_local_definitions_impl = non-local `impl` definition, they should be avoided as they go against expectation + .help = + move this `impl` block outside the of the current {$body_kind_descr} {$depth -> + [one] `{$body_name}` + *[other] `{$body_name}` and up {$depth} bodies + } + .non_local = an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + .exception = one exception to the rule are anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module and anon-const at the same nesting as the trait or type + +lint_non_local_definitions_macro_rules = non-local `macro_rules!` definition, they should be avoided as they go against expectation + .help = + remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth -> + [one] `{$body_name}` + *[other] `{$body_name}` and up {$depth} bodies + } + .non_local = a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + .exception = one exception to the rule are anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module + lint_non_snake_case = {$sort} `{$name}` should have a snake case name .rename_or_convert_suggestion = rename the identifier or convert it to a snake case raw identifier .cannot_convert_note = `{$sc}` cannot be used as a raw identifier diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 85f9d3bd63ec7..f6d2b758525ee 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -70,6 +70,7 @@ mod methods; mod multiple_supertrait_upcastable; mod non_ascii_idents; mod non_fmt_panic; +mod non_local_def; mod nonstandard_style; mod noop_method_call; mod opaque_hidden_inferred_bound; @@ -105,6 +106,7 @@ use methods::*; use multiple_supertrait_upcastable::*; use non_ascii_idents::*; use non_fmt_panic::NonPanicFmt; +use non_local_def::*; use nonstandard_style::*; use noop_method_call::*; use opaque_hidden_inferred_bound::*; @@ -231,6 +233,7 @@ late_lint_methods!( MissingDebugImplementations: MissingDebugImplementations, MissingDoc: MissingDoc, AsyncFnInTrait: AsyncFnInTrait, + NonLocalDefinitions: NonLocalDefinitions::default(), ] ] ); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index da59ffebdc5a9..15f158961d097 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1293,6 +1293,23 @@ pub struct SuspiciousDoubleRefCloneDiag<'a> { pub ty: Ty<'a>, } +// non_local_defs.rs +#[derive(LintDiagnostic)] +pub enum NonLocalDefinitionsDiag { + #[diag(lint_non_local_definitions_impl)] + #[help] + #[note(lint_non_local)] + #[note(lint_exception)] + #[note(lint_non_local_definitions_deprecation)] + Impl { depth: u32, body_kind_descr: &'static str, body_name: String }, + #[diag(lint_non_local_definitions_macro_rules)] + #[help] + #[note(lint_non_local)] + #[note(lint_exception)] + #[note(lint_non_local_definitions_deprecation)] + MacroRules { depth: u32, body_kind_descr: &'static str, body_name: String }, +} + // pass_by_value.rs #[derive(LintDiagnostic)] #[diag(lint_pass_by_value)] diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs new file mode 100644 index 0000000000000..28bd49f36a008 --- /dev/null +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -0,0 +1,187 @@ +use rustc_hir::{def::DefKind, Body, Item, ItemKind, Path, QPath, TyKind}; +use rustc_span::{def_id::DefId, sym, symbol::kw, MacroKind}; + +use smallvec::{smallvec, SmallVec}; + +use crate::{lints::NonLocalDefinitionsDiag, LateContext, LateLintPass, LintContext}; + +declare_lint! { + /// The `non_local_definitions` lint checks for `impl` blocks and `#[macro_export]` + /// macro inside bodies (functions, enum discriminant, ...). + /// + /// ### Example + /// + /// ```rust + /// trait MyTrait {} + /// struct MyStruct; + /// + /// fn foo() { + /// impl MyTrait for MyStruct {} + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Creating non-local definitions go against expectation and can create discrepancies + /// in tooling. It should be avoided. It may become deny-by-default in edition 2024 + /// and higher, see see the tracking issue . + /// + /// An `impl` definition is non-local if it is nested inside an item and neither + /// the type nor the trait are at the same nesting level as the `impl` block. + /// + /// All nested bodies (functions, enum discriminant, array length, consts) (expect for + /// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked. + pub NON_LOCAL_DEFINITIONS, + Warn, + "checks for non-local definitions", + report_in_external_macro +} + +#[derive(Default)] +pub struct NonLocalDefinitions { + body_depth: u32, +} + +impl_lint_pass!(NonLocalDefinitions => [NON_LOCAL_DEFINITIONS]); + +// FIXME(Urgau): Figure out how to handle modules nested in bodies. +// It's currently not handled by the current logic because modules are not bodies. +// They don't even follow the correct order (check_body -> check_mod -> check_body_post) +// instead check_mod is called after every body has been handled. + +impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { + fn check_body(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) { + self.body_depth += 1; + } + + fn check_body_post(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) { + self.body_depth -= 1; + } + + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) { + if self.body_depth == 0 { + return; + } + + let parent = cx.tcx.parent(item.owner_id.def_id.into()); + let parent_def_kind = cx.tcx.def_kind(parent); + let parent_opt_item_name = cx.tcx.opt_item_name(parent); + + // Per RFC we (currently) ignore anon-const (`const _: Ty = ...`) in top-level module. + if self.body_depth == 1 + && parent_def_kind == DefKind::Const + && parent_opt_item_name == Some(kw::Underscore) + { + return; + } + + match item.kind { + ItemKind::Impl(impl_) => { + // The RFC states: + // + // > An item nested inside an expression-containing item (through any + // > level of nesting) may not define an impl Trait for Type unless + // > either the **Trait** or the **Type** is also nested inside the + // > same expression-containing item. + // + // To achieve this we get try to get the paths of the _Trait_ and + // _Type_, and we look inside thoses paths to try a find in one + // of them a type whose parent is the same as the impl definition. + // + // If that's the case this means that this impl block declaration + // is using local items and so we don't lint on it. + + // We also ignore anon-const in item by including the anon-const + // parent as well; and since it's quite uncommon, we use smallvec + // to avoid unnecessary heap allocations. + let local_parents: SmallVec<[DefId; 1]> = if parent_def_kind == DefKind::Const + && parent_opt_item_name == Some(kw::Underscore) + { + smallvec![parent, cx.tcx.parent(parent)] + } else { + smallvec![parent] + }; + + let self_ty_has_local_parent = match impl_.self_ty.kind { + TyKind::Path(QPath::Resolved(_, ty_path)) => { + path_has_local_parent(ty_path, cx, &*local_parents) + } + TyKind::TraitObject([principle_poly_trait_ref, ..], _, _) => { + path_has_local_parent( + principle_poly_trait_ref.trait_ref.path, + cx, + &*local_parents, + ) + } + TyKind::TraitObject([], _, _) + | TyKind::InferDelegation(_, _) + | TyKind::Slice(_) + | TyKind::Array(_, _) + | TyKind::Ptr(_) + | TyKind::Ref(_, _) + | TyKind::BareFn(_) + | TyKind::Never + | TyKind::Tup(_) + | TyKind::Path(_) + | TyKind::AnonAdt(_) + | TyKind::OpaqueDef(_, _, _) + | TyKind::Typeof(_) + | TyKind::Infer + | TyKind::Err(_) => false, + }; + + let of_trait_has_local_parent = impl_ + .of_trait + .map(|of_trait| path_has_local_parent(of_trait.path, cx, &*local_parents)) + .unwrap_or(false); + + // If none of them have a local parent (LOGICAL NOR) this means that + // this impl definition is a non-local definition and so we lint on it. + if !(self_ty_has_local_parent || of_trait_has_local_parent) { + cx.emit_span_lint( + NON_LOCAL_DEFINITIONS, + item.span, + NonLocalDefinitionsDiag::Impl { + depth: self.body_depth, + body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent), + body_name: parent_opt_item_name + .map(|s| s.to_ident_string()) + .unwrap_or_else(|| "".to_string()), + }, + ) + } + } + ItemKind::Macro(_macro, MacroKind::Bang) + if cx.tcx.has_attr(item.owner_id.def_id, sym::macro_export) => + { + cx.emit_span_lint( + NON_LOCAL_DEFINITIONS, + item.span, + NonLocalDefinitionsDiag::MacroRules { + depth: self.body_depth, + body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent), + body_name: parent_opt_item_name + .map(|s| s.to_ident_string()) + .unwrap_or_else(|| "".to_string()), + }, + ) + } + _ => {} + } + } +} + +/// Given a path and a parent impl def id, this checks if the if parent resolution +/// def id correspond to the def id of the parent impl definition. +/// +/// Given this path, we will look at the path (and ignore any generic args): +/// +/// ```text +/// std::convert::PartialEq> +/// ^^^^^^^^^^^^^^^^^^^^^^^ +/// ``` +fn path_has_local_parent(path: &Path<'_>, cx: &LateContext<'_>, local_parents: &[DefId]) -> bool { + path.res.opt_def_id().is_some_and(|did| local_parents.contains(&cx.tcx.parent(did))) +} diff --git a/tests/ui/lint/non_local_definitions.rs b/tests/ui/lint/non_local_definitions.rs new file mode 100644 index 0000000000000..986efbfcf0fe1 --- /dev/null +++ b/tests/ui/lint/non_local_definitions.rs @@ -0,0 +1,373 @@ +//@ check-pass +//@ edition:2021 + +#![feature(inline_const)] + +use std::fmt::{Debug, Display}; + +struct Test; + +impl Debug for Test { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } +} + +mod do_not_lint_mod { + pub trait Tait {} + + impl super::Test { + fn hugo() {} + } + + impl Tait for super::Test {} +} + +trait Uto {} +const Z: () = { + trait Uto1 {} + + impl Uto1 for Test {} // the trait is local, don't lint + + impl Uto for &Test {} + //~^ WARN non-local `impl` definition +}; + +trait Ano {} +const _: () = { + impl Ano for &Test {} // ignored since the parent is an anon-const +}; + +type A = [u32; { + impl Uto for *mut Test {} + //~^ WARN non-local `impl` definition + + 1 +}]; + +enum Enum { + Discr = { + impl Uto for Test {} + //~^ WARN non-local `impl` definition + + 1 + } +} + +trait Uto2 {} +static A: u32 = { + impl Uto2 for Test {} + //~^ WARN non-local `impl` definition + + 1 +}; + +trait Uto3 {} +const B: u32 = { + impl Uto3 for Test {} + //~^ WARN non-local `impl` definition + + #[macro_export] + macro_rules! m0 { () => { } }; + //~^ WARN non-local `macro_rules!` definition + + trait Uto4 {} + impl Uto4 for Test {} + + 1 +}; + +trait Uto5 {} +fn main() { + #[macro_export] + macro_rules! m { () => { } }; + //~^ WARN non-local `macro_rules!` definition + + impl Test { + //~^ WARN non-local `impl` definition + fn foo() {} + } + + let _array = [0i32; { + impl Test { + //~^ WARN non-local `impl` definition + fn bar() {} + } + + 1 + }]; + + const { + impl Test { + //~^ WARN non-local `impl` definition + fn hoo() {} + } + + 1 + }; + + const _: u32 = { + impl Test { + //~^ WARN non-local `impl` definition + fn foo2() {} + } + + 1 + }; + + impl Display for Test { + //~^ WARN non-local `impl` definition + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + + impl dyn Uto5 {} + //~^ WARN non-local `impl` definition + + impl Uto5 for Vec { } + //~^ WARN non-local `impl` definition + + impl Uto5 for &dyn Uto5 {} + //~^ WARN non-local `impl` definition + + impl Uto5 for *mut Test {} + //~^ WARN non-local `impl` definition + + impl Uto5 for *mut [Test] {} + //~^ WARN non-local `impl` definition + + impl Uto5 for [Test; 8] {} + //~^ WARN non-local `impl` definition + + impl Uto5 for (Test,) {} + //~^ WARN non-local `impl` definition + + impl Uto5 for fn(Test) -> () {} + //~^ WARN non-local `impl` definition + + impl Uto5 for fn() -> Test {} + //~^ WARN non-local `impl` definition + + let _a = || { + impl Uto5 for Test {} + //~^ WARN non-local `impl` definition + + 1 + }; + + type A = [u32; { + impl Uto5 for &Test {} + //~^ WARN non-local `impl` definition + + 1 + }]; + + fn a(_: [u32; { + impl Uto5 for &(Test,) {} + //~^ WARN non-local `impl` definition + + 1 + }]) {} + + fn b() -> [u32; { + impl Uto5 for &(Test,Test) {} + //~^ WARN non-local `impl` definition + + 1 + }] { todo!() } + + struct InsideMain; + + impl Uto5 for *mut InsideMain {} + //~^ WARN non-local `impl` definition + impl Uto5 for *mut [InsideMain] {} + //~^ WARN non-local `impl` definition + impl Uto5 for [InsideMain; 8] {} + //~^ WARN non-local `impl` definition + impl Uto5 for (InsideMain,) {} + //~^ WARN non-local `impl` definition + impl Uto5 for fn(InsideMain) -> () {} + //~^ WARN non-local `impl` definition + impl Uto5 for fn() -> InsideMain {} + //~^ WARN non-local `impl` definition + + impl Debug for InsideMain { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + + impl InsideMain { + fn foo() {} + } + + fn inside_inside() { + impl Display for InsideMain { + //~^ WARN non-local `impl` definition + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + + impl InsideMain { + //~^ WARN non-local `impl` definition + fn bar() { + #[macro_export] + macro_rules! m2 { () => { } }; + //~^ WARN non-local `macro_rules!` definition + } + } + } + + trait Uto6 {} + impl dyn Uto6 {} + impl Uto5 for dyn Uto6 {} + + impl Uto3 for Vec { } + //~^ WARN non-local `impl` definition +} + +trait Uto7 {} +trait Uto8 {} + +fn bad() { + struct Local; + impl Uto7 for Test where Local: std::any::Any {} + //~^ WARN non-local `impl` definition + + impl Uto8 for T {} + //~^ WARN non-local `impl` definition +} + +struct UwU(T); + +fn fun() { + #[derive(Debug)] + struct OwO; + impl Default for UwU { + //~^ WARN non-local `impl` definition + fn default() -> Self { + UwU(OwO) + } + } +} + +struct Cat; + +fn meow() { + impl From for () { + //~^ WARN non-local `impl` definition + fn from(_: Cat) -> () { + todo!() + } + } + + #[derive(Debug)] + struct Cat; + impl AsRef for () { + //~^ WARN non-local `impl` definition + fn as_ref(&self) -> &Cat { &Cat } + } +} + +struct G; + +fn fun2() { + #[derive(Debug, Default)] + struct B; + impl PartialEq for G { + //~^ WARN non-local `impl` definition + fn eq(&self, _: &B) -> bool { + true + } + } +} + +fn side_effects() { + dbg!(().as_ref()); // prints `Cat` + dbg!(UwU::default().0); + let _ = G::eq(&G, dbg!(&<_>::default())); +} + +struct Dog; + +fn woof() { + impl PartialEq for &Dog { + //~^ WARN non-local `impl` definition + fn eq(&self, _: &Dog) -> bool { + todo!() + } + } + + impl PartialEq<()> for Dog { + //~^ WARN non-local `impl` definition + fn eq(&self, _: &()) -> bool { + todo!() + } + } + + impl PartialEq<()> for &Dog { + //~^ WARN non-local `impl` definition + fn eq(&self, _: &()) -> bool { + todo!() + } + } + + impl PartialEq for () { + //~^ WARN non-local `impl` definition + fn eq(&self, _: &Dog) -> bool { + todo!() + } + } + + struct Test; + impl PartialEq for Test { + fn eq(&self, _: &Dog) -> bool { + todo!() + } + } +} + +struct Wrap(T); + +impl Wrap>> {} + +fn rawr() { + struct Lion; + + impl From>> for () { + //~^ WARN non-local `impl` definition + fn from(_: Wrap>) -> Self { + todo!() + } + } + + impl From<()> for Wrap { + //~^ WARN non-local `impl` definition + fn from(_: ()) -> Self { + todo!() + } + } +} + +macro_rules! m { + () => { + trait MacroTrait {} + struct OutsideStruct; + fn my_func() { + impl MacroTrait for OutsideStruct {} + //~^ WARN non-local `impl` definition + } + } +} + +m!(); + +fn bitflags() { + struct Flags; + + const _: () = { + impl Flags {} + }; +} diff --git a/tests/ui/lint/non_local_definitions.stderr b/tests/ui/lint/non_local_definitions.stderr new file mode 100644 index 0000000000000..f15457734bcfe --- /dev/null +++ b/tests/ui/lint/non_local_definitions.stderr @@ -0,0 +1,611 @@ +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:32:5 + | +LL | impl Uto for &Test {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant `Z` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + = note: `#[warn(non_local_definitions)]` on by default + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:42:5 + | +LL | impl Uto for *mut Test {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant expression `` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:50:9 + | +LL | impl Uto for Test {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant expression `` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:59:5 + | +LL | impl Uto2 for Test {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current static `A` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:67:5 + | +LL | impl Uto3 for Test {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant `B` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:71:5 + | +LL | macro_rules! m0 { () => { } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B` + = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:83:5 + | +LL | macro_rules! m { () => { } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current function `main` + = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:86:5 + | +LL | / impl Test { +LL | | +LL | | fn foo() {} +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:92:9 + | +LL | / impl Test { +LL | | +LL | | fn bar() {} +LL | | } + | |_________^ + | + = help: move this `impl` block outside the of the current constant expression `` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:101:9 + | +LL | / impl Test { +LL | | +LL | | fn hoo() {} +LL | | } + | |_________^ + | + = help: move this `impl` block outside the of the current inline constant `` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:110:9 + | +LL | / impl Test { +LL | | +LL | | fn foo2() {} +LL | | } + | |_________^ + | + = help: move this `impl` block outside the of the current constant `_` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:118:5 + | +LL | / impl Display for Test { +LL | | +LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:125:5 + | +LL | impl dyn Uto5 {} + | ^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:128:5 + | +LL | impl Uto5 for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:131:5 + | +LL | impl Uto5 for &dyn Uto5 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:134:5 + | +LL | impl Uto5 for *mut Test {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:137:5 + | +LL | impl Uto5 for *mut [Test] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:140:5 + | +LL | impl Uto5 for [Test; 8] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:143:5 + | +LL | impl Uto5 for (Test,) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:146:5 + | +LL | impl Uto5 for fn(Test) -> () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:149:5 + | +LL | impl Uto5 for fn() -> Test {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:153:9 + | +LL | impl Uto5 for Test {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current closure `` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:160:9 + | +LL | impl Uto5 for &Test {} + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant expression `` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:167:9 + | +LL | impl Uto5 for &(Test,) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant expression `` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:174:9 + | +LL | impl Uto5 for &(Test,Test) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant expression `` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:182:5 + | +LL | impl Uto5 for *mut InsideMain {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:184:5 + | +LL | impl Uto5 for *mut [InsideMain] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:186:5 + | +LL | impl Uto5 for [InsideMain; 8] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:188:5 + | +LL | impl Uto5 for (InsideMain,) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:190:5 + | +LL | impl Uto5 for fn(InsideMain) -> () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:192:5 + | +LL | impl Uto5 for fn() -> InsideMain {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:206:9 + | +LL | / impl Display for InsideMain { +LL | | +LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +LL | | todo!() +LL | | } +LL | | } + | |_________^ + | + = help: move this `impl` block outside the of the current function `inside_inside` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:213:9 + | +LL | / impl InsideMain { +LL | | +LL | | fn bar() { +LL | | #[macro_export] +... | +LL | | } +LL | | } + | |_________^ + | + = help: move this `impl` block outside the of the current function `inside_inside` and up 2 bodies + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:217:17 + | +LL | macro_rules! m2 { () => { } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current associated function `bar` and up 3 bodies + = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:227:5 + | +LL | impl Uto3 for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `main` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:236:5 + | +LL | impl Uto7 for Test where Local: std::any::Any {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `bad` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:239:5 + | +LL | impl Uto8 for T {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current function `bad` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:248:5 + | +LL | / impl Default for UwU { +LL | | +LL | | fn default() -> Self { +LL | | UwU(OwO) +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `fun` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:259:5 + | +LL | / impl From for () { +LL | | +LL | | fn from(_: Cat) -> () { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `meow` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:268:5 + | +LL | / impl AsRef for () { +LL | | +LL | | fn as_ref(&self) -> &Cat { &Cat } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `meow` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:279:5 + | +LL | / impl PartialEq for G { +LL | | +LL | | fn eq(&self, _: &B) -> bool { +LL | | true +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `fun2` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:296:5 + | +LL | / impl PartialEq for &Dog { +LL | | +LL | | fn eq(&self, _: &Dog) -> bool { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `woof` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:303:5 + | +LL | / impl PartialEq<()> for Dog { +LL | | +LL | | fn eq(&self, _: &()) -> bool { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `woof` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:310:5 + | +LL | / impl PartialEq<()> for &Dog { +LL | | +LL | | fn eq(&self, _: &()) -> bool { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `woof` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:317:5 + | +LL | / impl PartialEq for () { +LL | | +LL | | fn eq(&self, _: &Dog) -> bool { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `woof` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:339:5 + | +LL | / impl From>> for () { +LL | | +LL | | fn from(_: Wrap>) -> Self { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `rawr` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:346:5 + | +LL | / impl From<()> for Wrap { +LL | | +LL | | fn from(_: ()) -> Self { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: move this `impl` block outside the of the current function `rawr` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:359:13 + | +LL | impl MacroTrait for OutsideStruct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ---- in this macro invocation + | + = help: move this `impl` block outside the of the current function `my_func` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: 48 warnings emitted + diff --git a/tests/ui/proc-macro/nested-macro-rules.rs b/tests/ui/proc-macro/nested-macro-rules.rs index bb25b97df5067..0dce3c408c203 100644 --- a/tests/ui/proc-macro/nested-macro-rules.rs +++ b/tests/ui/proc-macro/nested-macro-rules.rs @@ -19,5 +19,6 @@ fn main() { nested_macro_rules::inner_macro!(print_bang, print_attr); nested_macro_rules::outer_macro!(SecondStruct, SecondAttrStruct); + //~^ WARN non-local `macro_rules!` definition inner_macro!(print_bang, print_attr); } diff --git a/tests/ui/proc-macro/nested-macro-rules.stderr b/tests/ui/proc-macro/nested-macro-rules.stderr new file mode 100644 index 0000000000000..111be8827714f --- /dev/null +++ b/tests/ui/proc-macro/nested-macro-rules.stderr @@ -0,0 +1,27 @@ +warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation + --> $DIR/auxiliary/nested-macro-rules.rs:7:9 + | +LL | macro_rules! outer_macro { + | ------------------------ in this expansion of `nested_macro_rules::outer_macro!` +... +LL | / macro_rules! inner_macro { +LL | | ($bang_macro:ident, $attr_macro:ident) => { +LL | | $bang_macro!($name); +LL | | #[$attr_macro] struct $attr_struct_name {} +LL | | } +LL | | } + | |_________^ + | + ::: $DIR/nested-macro-rules.rs:21:5 + | +LL | nested_macro_rules::outer_macro!(SecondStruct, SecondAttrStruct); + | ---------------------------------------------------------------- in this macro invocation + | + = help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current function `main` + = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + = note: `#[warn(non_local_definitions)]` on by default + +warning: 1 warning emitted + From 80c81c53ace700baf07d7d51c90e55adb2b3ff8f Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 26 Jan 2024 17:14:38 +0100 Subject: [PATCH 097/417] Allow newly added non_local_definitions lint in tests --- tests/ui/async-await/async-assoc-fn-anon-lifetimes.rs | 2 ++ tests/ui/const-generics/min_const_generics/macro.rs | 2 ++ tests/ui/consts/const_in_pattern/accept_structural.rs | 1 + tests/ui/drop/dropck-eyepatch-reorder.rs | 1 + tests/ui/drop/dropck-eyepatch.rs | 1 + tests/ui/imports/local-modularized-tricky-pass-2.rs | 1 + tests/ui/issues/issue-31776.rs | 1 + tests/ui/issues/issue-41053.rs | 2 ++ tests/ui/macros/type-macros-simple.rs | 2 ++ tests/ui/packed/issue-46152.rs | 1 + tests/ui/privacy/associated-item-privacy-trait.rs | 2 +- tests/ui/privacy/private-in-public-non-principal.rs | 1 + tests/ui/privacy/private-in-public-non-principal.stderr | 8 ++++---- tests/ui/rust-2018/uniform-paths/issue-55779.rs | 2 ++ 14 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/ui/async-await/async-assoc-fn-anon-lifetimes.rs b/tests/ui/async-await/async-assoc-fn-anon-lifetimes.rs index 28705bfc0c8f8..1a2aae8fb23a5 100644 --- a/tests/ui/async-await/async-assoc-fn-anon-lifetimes.rs +++ b/tests/ui/async-await/async-assoc-fn-anon-lifetimes.rs @@ -5,6 +5,8 @@ //@ edition:2018 +#![allow(non_local_definitions)] + struct A<'a, 'b>(&'a &'b i32); struct B<'a>(&'a i32); diff --git a/tests/ui/const-generics/min_const_generics/macro.rs b/tests/ui/const-generics/min_const_generics/macro.rs index b7e8083a86199..52f47628f8f1a 100644 --- a/tests/ui/const-generics/min_const_generics/macro.rs +++ b/tests/ui/const-generics/min_const_generics/macro.rs @@ -1,4 +1,6 @@ //@ run-pass +#![allow(non_local_definitions)] + struct Example; macro_rules! external_macro { diff --git a/tests/ui/consts/const_in_pattern/accept_structural.rs b/tests/ui/consts/const_in_pattern/accept_structural.rs index 09142c5615747..31d3b6e73312d 100644 --- a/tests/ui/consts/const_in_pattern/accept_structural.rs +++ b/tests/ui/consts/const_in_pattern/accept_structural.rs @@ -1,5 +1,6 @@ //@ run-pass +#![allow(non_local_definitions)] #![warn(indirect_structural_match)] // This test is checking our logic for structural match checking by enumerating diff --git a/tests/ui/drop/dropck-eyepatch-reorder.rs b/tests/ui/drop/dropck-eyepatch-reorder.rs index 6b394414baec0..b985beee9ec9d 100644 --- a/tests/ui/drop/dropck-eyepatch-reorder.rs +++ b/tests/ui/drop/dropck-eyepatch-reorder.rs @@ -1,5 +1,6 @@ //@ run-pass #![feature(dropck_eyepatch)] +#![allow(non_local_definitions)] // The point of this test is to test uses of `#[may_dangle]` attribute // where the formal declaration order (in the impl generics) does not diff --git a/tests/ui/drop/dropck-eyepatch.rs b/tests/ui/drop/dropck-eyepatch.rs index 2f27b72da5a65..2dffe6aba1767 100644 --- a/tests/ui/drop/dropck-eyepatch.rs +++ b/tests/ui/drop/dropck-eyepatch.rs @@ -1,5 +1,6 @@ //@ run-pass #![feature(dropck_eyepatch)] +#![allow(non_local_definitions)] // The point of this test is to illustrate that the `#[may_dangle]` // attribute specifically allows, in the context of a type diff --git a/tests/ui/imports/local-modularized-tricky-pass-2.rs b/tests/ui/imports/local-modularized-tricky-pass-2.rs index 581bab467f561..1cf97c5aa06e6 100644 --- a/tests/ui/imports/local-modularized-tricky-pass-2.rs +++ b/tests/ui/imports/local-modularized-tricky-pass-2.rs @@ -4,6 +4,7 @@ // into the root module soon enough to act as usual items and shadow globs and preludes. #![feature(decl_macro)] +#![allow(non_local_definitions)] // `macro_export` shadows globs use inner1::*; diff --git a/tests/ui/issues/issue-31776.rs b/tests/ui/issues/issue-31776.rs index 632defbcf273f..4b342a0e3b2dc 100644 --- a/tests/ui/issues/issue-31776.rs +++ b/tests/ui/issues/issue-31776.rs @@ -1,6 +1,7 @@ //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(non_local_definitions)] // Various scenarios in which `pub` is required in blocks struct S; diff --git a/tests/ui/issues/issue-41053.rs b/tests/ui/issues/issue-41053.rs index f46bf6b4aa168..18f9e209c33b7 100644 --- a/tests/ui/issues/issue-41053.rs +++ b/tests/ui/issues/issue-41053.rs @@ -1,6 +1,8 @@ //@ run-pass //@ aux-build:issue-41053.rs +#![allow(non_local_definitions)] + pub trait Trait { fn foo(&self) {} } pub struct Foo; diff --git a/tests/ui/macros/type-macros-simple.rs b/tests/ui/macros/type-macros-simple.rs index 4d1001baf59fd..d189b881f7dda 100644 --- a/tests/ui/macros/type-macros-simple.rs +++ b/tests/ui/macros/type-macros-simple.rs @@ -1,6 +1,8 @@ //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(non_local_definitions)] + macro_rules! Tuple { { $A:ty,$B:ty } => { ($A, $B) } } diff --git a/tests/ui/packed/issue-46152.rs b/tests/ui/packed/issue-46152.rs index e38b445107baf..5b2e4bbfdf243 100644 --- a/tests/ui/packed/issue-46152.rs +++ b/tests/ui/packed/issue-46152.rs @@ -1,6 +1,7 @@ //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(non_local_definitions)] #![feature(unsize, coerce_unsized)] #[repr(packed)] diff --git a/tests/ui/privacy/associated-item-privacy-trait.rs b/tests/ui/privacy/associated-item-privacy-trait.rs index f038ae9e261df..655d892e2441f 100644 --- a/tests/ui/privacy/associated-item-privacy-trait.rs +++ b/tests/ui/privacy/associated-item-privacy-trait.rs @@ -1,5 +1,5 @@ #![feature(decl_macro, associated_type_defaults)] -#![allow(private_interfaces, private_bounds)] +#![allow(private_interfaces, private_bounds, non_local_definitions)] mod priv_trait { trait PrivTr { diff --git a/tests/ui/privacy/private-in-public-non-principal.rs b/tests/ui/privacy/private-in-public-non-principal.rs index e348a181651cf..8dc90919bc9ea 100644 --- a/tests/ui/privacy/private-in-public-non-principal.rs +++ b/tests/ui/privacy/private-in-public-non-principal.rs @@ -1,5 +1,6 @@ #![feature(auto_traits)] #![feature(negative_impls)] +#![allow(non_local_definitions)] pub trait PubPrincipal {} auto trait PrivNonPrincipal {} diff --git a/tests/ui/privacy/private-in-public-non-principal.stderr b/tests/ui/privacy/private-in-public-non-principal.stderr index 73f2249bc6c05..5aa08d3f07175 100644 --- a/tests/ui/privacy/private-in-public-non-principal.stderr +++ b/tests/ui/privacy/private-in-public-non-principal.stderr @@ -1,24 +1,24 @@ warning: trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal` - --> $DIR/private-in-public-non-principal.rs:7:1 + --> $DIR/private-in-public-non-principal.rs:8:1 | LL | pub fn leak_dyn_nonprincipal() -> Box { loop {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `leak_dyn_nonprincipal` is reachable at visibility `pub` | note: but trait `PrivNonPrincipal` is only usable at visibility `pub(crate)` - --> $DIR/private-in-public-non-principal.rs:5:1 + --> $DIR/private-in-public-non-principal.rs:6:1 | LL | auto trait PrivNonPrincipal {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `#[warn(private_interfaces)]` on by default error: missing documentation for an associated function - --> $DIR/private-in-public-non-principal.rs:13:9 + --> $DIR/private-in-public-non-principal.rs:14:9 | LL | pub fn check_doc_lint() {} | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/private-in-public-non-principal.rs:10:8 + --> $DIR/private-in-public-non-principal.rs:11:8 | LL | #[deny(missing_docs)] | ^^^^^^^^^^^^ diff --git a/tests/ui/rust-2018/uniform-paths/issue-55779.rs b/tests/ui/rust-2018/uniform-paths/issue-55779.rs index 350ab324682b4..246b8dd82c5e3 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-55779.rs +++ b/tests/ui/rust-2018/uniform-paths/issue-55779.rs @@ -2,6 +2,8 @@ //@ edition:2018 //@ aux-crate:issue_55779_extern_trait=issue-55779-extern-trait.rs +#![allow(non_local_definitions)] + use issue_55779_extern_trait::Trait; struct Local; From 01bcc60ecd8aa4bf7d43dd13694e003c84ad19ee Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 26 Jan 2024 18:48:18 +0100 Subject: [PATCH 098/417] Allow newly added non_local_definitions lint in clippy --- .../undocumented_unsafe_blocks.rs | 2 +- .../clippy/tests/ui/bool_comparison.fixed | 2 +- src/tools/clippy/tests/ui/bool_comparison.rs | 2 +- src/tools/clippy/tests/ui/crashes/ice-4760.rs | 2 + src/tools/clippy/tests/ui/crashes/ice-6179.rs | 1 + .../tests/ui/explicit_into_iter_loop.fixed | 1 + .../tests/ui/explicit_into_iter_loop.rs | 1 + .../tests/ui/explicit_into_iter_loop.stderr | 12 ++--- .../clippy/tests/ui/explicit_iter_loop.fixed | 3 +- .../clippy/tests/ui/explicit_iter_loop.rs | 3 +- .../clippy/tests/ui/explicit_iter_loop.stderr | 36 ++++++------- .../clippy/tests/ui/from_over_into.fixed | 1 + src/tools/clippy/tests/ui/from_over_into.rs | 1 + .../clippy/tests/ui/from_over_into.stderr | 14 ++--- .../clippy/tests/ui/manual_str_repeat.fixed | 1 + .../clippy/tests/ui/manual_str_repeat.rs | 1 + .../clippy/tests/ui/manual_str_repeat.stderr | 20 +++---- .../clippy/tests/ui/needless_borrow.fixed | 1 + src/tools/clippy/tests/ui/needless_borrow.rs | 1 + .../clippy/tests/ui/needless_borrow.stderr | 54 +++++++++---------- 20 files changed, 86 insertions(+), 73 deletions(-) diff --git a/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs b/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs index a278139876064..8997073c8a555 100644 --- a/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs +++ b/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs @@ -4,7 +4,7 @@ //@[disabled] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/undocumented_unsafe_blocks/disabled #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] -#![allow(deref_nullptr, clippy::let_unit_value, clippy::missing_safety_doc)] +#![allow(deref_nullptr, non_local_definitions, clippy::let_unit_value, clippy::missing_safety_doc)] #![feature(lint_reasons)] extern crate proc_macro_unsafe; diff --git a/src/tools/clippy/tests/ui/bool_comparison.fixed b/src/tools/clippy/tests/ui/bool_comparison.fixed index 02f1d09b83395..600380fd1420d 100644 --- a/src/tools/clippy/tests/ui/bool_comparison.fixed +++ b/src/tools/clippy/tests/ui/bool_comparison.fixed @@ -1,4 +1,4 @@ -#![allow(clippy::needless_if)] +#![allow(non_local_definitions, clippy::needless_if)] #![warn(clippy::bool_comparison)] #![allow(clippy::non_canonical_partial_ord_impl)] diff --git a/src/tools/clippy/tests/ui/bool_comparison.rs b/src/tools/clippy/tests/ui/bool_comparison.rs index 5ef696d855eca..910df6151f8c2 100644 --- a/src/tools/clippy/tests/ui/bool_comparison.rs +++ b/src/tools/clippy/tests/ui/bool_comparison.rs @@ -1,4 +1,4 @@ -#![allow(clippy::needless_if)] +#![allow(non_local_definitions, clippy::needless_if)] #![warn(clippy::bool_comparison)] #![allow(clippy::non_canonical_partial_ord_impl)] diff --git a/src/tools/clippy/tests/ui/crashes/ice-4760.rs b/src/tools/clippy/tests/ui/crashes/ice-4760.rs index 08b06961760ff..e1265169762fc 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-4760.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-4760.rs @@ -1,3 +1,5 @@ +#![allow(non_local_definitions)] + const COUNT: usize = 2; struct Thing; trait Dummy {} diff --git a/src/tools/clippy/tests/ui/crashes/ice-6179.rs b/src/tools/clippy/tests/ui/crashes/ice-6179.rs index ce1895851e2d9..fffc0f7d0d4f2 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6179.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-6179.rs @@ -3,6 +3,7 @@ #![warn(clippy::use_self)] #![allow(dead_code, clippy::let_with_type_underscore)] +#![allow(non_local_definitions)] struct Foo; diff --git a/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed b/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed index 2521bce6a58e1..6d67488a71309 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::explicit_into_iter_loop)] fn main() { diff --git a/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs b/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs index 9eac96d182b9f..14630c07c5cc4 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::explicit_into_iter_loop)] fn main() { diff --git a/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr b/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr index c03647ab43367..a1e632271ed32 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr @@ -1,5 +1,5 @@ error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:9:18 + --> $DIR/explicit_into_iter_loop.rs:10:18 | LL | for _ in iterator.into_iter() {} | ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator` @@ -8,31 +8,31 @@ LL | for _ in iterator.into_iter() {} = help: to override `-D warnings` add `#[allow(clippy::explicit_into_iter_loop)]` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:22:14 + --> $DIR/explicit_into_iter_loop.rs:23:14 | LL | for _ in t.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:25:14 + --> $DIR/explicit_into_iter_loop.rs:26:14 | LL | for _ in r.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `r` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:33:14 + --> $DIR/explicit_into_iter_loop.rs:34:14 | LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&*mr` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:45:14 + --> $DIR/explicit_into_iter_loop.rs:46:14 | LL | for _ in u.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut u` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:48:14 + --> $DIR/explicit_into_iter_loop.rs:49:14 | LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *mr` diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.fixed b/src/tools/clippy/tests/ui/explicit_iter_loop.fixed index f08397defa539..06229a52a18c4 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.fixed +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.fixed @@ -5,7 +5,8 @@ clippy::needless_borrow, clippy::deref_addrof, clippy::unnecessary_mut_passed, - dead_code + dead_code, + non_local_definitions, )] use core::slice; diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.rs b/src/tools/clippy/tests/ui/explicit_iter_loop.rs index 2ee6825d445c2..c2bf45ab2e990 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.rs +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.rs @@ -5,7 +5,8 @@ clippy::needless_borrow, clippy::deref_addrof, clippy::unnecessary_mut_passed, - dead_code + dead_code, + non_local_definitions, )] use core::slice; diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.stderr b/src/tools/clippy/tests/ui/explicit_iter_loop.stderr index 725d9b63cf8d6..007606b52c294 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.stderr @@ -1,5 +1,5 @@ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:17:14 + --> $DIR/explicit_iter_loop.rs:18:14 | LL | for _ in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` @@ -11,103 +11,103 @@ LL | #![deny(clippy::explicit_iter_loop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:18:14 + --> $DIR/explicit_iter_loop.rs:19:14 | LL | for _ in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:21:14 + --> $DIR/explicit_iter_loop.rs:22:14 | LL | for _ in rvec.iter() {} | ^^^^^^^^^^^ help: to write this more concisely, try: `rvec` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:30:14 + --> $DIR/explicit_iter_loop.rs:31:14 | LL | for _ in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:34:14 + --> $DIR/explicit_iter_loop.rs:35:14 | LL | for _ in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:35:14 + --> $DIR/explicit_iter_loop.rs:36:14 | LL | for _ in [0; 33].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 33]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:38:14 + --> $DIR/explicit_iter_loop.rs:39:14 | LL | for _ in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:40:14 + --> $DIR/explicit_iter_loop.rs:41:14 | LL | for _ in rll.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `rll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:43:14 + --> $DIR/explicit_iter_loop.rs:44:14 | LL | for _ in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:45:14 + --> $DIR/explicit_iter_loop.rs:46:14 | LL | for _ in rvd.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `rvd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:48:14 + --> $DIR/explicit_iter_loop.rs:49:14 | LL | for _ in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:51:14 + --> $DIR/explicit_iter_loop.rs:52:14 | LL | for _ in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:54:14 + --> $DIR/explicit_iter_loop.rs:55:14 | LL | for _ in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:57:14 + --> $DIR/explicit_iter_loop.rs:58:14 | LL | for _ in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:60:14 + --> $DIR/explicit_iter_loop.rs:61:14 | LL | for _ in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:149:14 + --> $DIR/explicit_iter_loop.rs:150:14 | LL | for _ in x.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `&x` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:150:14 + --> $DIR/explicit_iter_loop.rs:151:14 | LL | for _ in x.iter_mut() {} | ^^^^^^^^^^^^ help: to write this more concisely, try: `&mut x` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:153:14 + --> $DIR/explicit_iter_loop.rs:154:14 | LL | for _ in r.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `r` diff --git a/src/tools/clippy/tests/ui/from_over_into.fixed b/src/tools/clippy/tests/ui/from_over_into.fixed index 4a68505ee0b1c..a33c1ea5738b9 100644 --- a/src/tools/clippy/tests/ui/from_over_into.fixed +++ b/src/tools/clippy/tests/ui/from_over_into.fixed @@ -1,5 +1,6 @@ #![feature(type_alias_impl_trait)] #![warn(clippy::from_over_into)] +#![allow(non_local_definitions)] #![allow(unused)] // this should throw an error diff --git a/src/tools/clippy/tests/ui/from_over_into.rs b/src/tools/clippy/tests/ui/from_over_into.rs index bf3ed0c2b6422..6cd811ae401e2 100644 --- a/src/tools/clippy/tests/ui/from_over_into.rs +++ b/src/tools/clippy/tests/ui/from_over_into.rs @@ -1,5 +1,6 @@ #![feature(type_alias_impl_trait)] #![warn(clippy::from_over_into)] +#![allow(non_local_definitions)] #![allow(unused)] // this should throw an error diff --git a/src/tools/clippy/tests/ui/from_over_into.stderr b/src/tools/clippy/tests/ui/from_over_into.stderr index f1370ed844fa9..15b4e02a264f1 100644 --- a/src/tools/clippy/tests/ui/from_over_into.stderr +++ b/src/tools/clippy/tests/ui/from_over_into.stderr @@ -1,5 +1,5 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:8:1 + --> $DIR/from_over_into.rs:9:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL ~ StringWrapper(val) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:16:1 + --> $DIR/from_over_into.rs:17:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL ~ SelfType(String::new()) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:31:1 + --> $DIR/from_over_into.rs:32:1 | LL | impl Into for X { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL ~ let _: X = val; | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:43:1 + --> $DIR/from_over_into.rs:44:1 | LL | impl core::convert::Into for crate::ExplicitPaths { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL ~ val.0 | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:63:1 + --> $DIR/from_over_into.rs:64:1 | LL | impl Into for PathInExpansion { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL ~ fn from(val: PathInExpansion) -> Self { | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:85:5 + --> $DIR/from_over_into.rs:86:5 | LL | impl Into> for Vec { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL ~ FromOverInto(val) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:95:5 + --> $DIR/from_over_into.rs:96:5 | LL | impl Into<()> for Hello { | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.fixed b/src/tools/clippy/tests/ui/manual_str_repeat.fixed index 888a466278ccc..5f2f1bd9916d8 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.fixed +++ b/src/tools/clippy/tests/ui/manual_str_repeat.fixed @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::manual_str_repeat)] use std::borrow::Cow; diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.rs b/src/tools/clippy/tests/ui/manual_str_repeat.rs index a366351ffa45a..3e3c7f4db4a27 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.rs +++ b/src/tools/clippy/tests/ui/manual_str_repeat.rs @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::manual_str_repeat)] use std::borrow::Cow; diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.stderr b/src/tools/clippy/tests/ui/manual_str_repeat.stderr index 9a13aa9722737..6eb6f2b85a8f4 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.stderr +++ b/src/tools/clippy/tests/ui/manual_str_repeat.stderr @@ -1,5 +1,5 @@ error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:7:21 + --> $DIR/manual_str_repeat.rs:8:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` @@ -8,55 +8,55 @@ LL | let _: String = std::iter::repeat("test").take(10).collect(); = help: to override `-D warnings` add `#[allow(clippy::manual_str_repeat)]` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:8:21 + --> $DIR/manual_str_repeat.rs:9:21 | LL | let _: String = std::iter::repeat('x').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"x".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:9:21 + --> $DIR/manual_str_repeat.rs:10:21 | LL | let _: String = std::iter::repeat('\'').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"'".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:10:21 + --> $DIR/manual_str_repeat.rs:11:21 | LL | let _: String = std::iter::repeat('"').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"\"".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:14:13 + --> $DIR/manual_str_repeat.rs:15:13 | LL | let _ = repeat(x).take(count + 2).collect::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count + 2)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:23:21 + --> $DIR/manual_str_repeat.rs:24:21 | LL | let _: String = repeat(*x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*x).repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:32:21 + --> $DIR/manual_str_repeat.rs:33:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:44:21 + --> $DIR/manual_str_repeat.rs:45:21 | LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Cow::Borrowed("test").repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:47:21 + --> $DIR/manual_str_repeat.rs:48:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:62:21 + --> $DIR/manual_str_repeat.rs:63:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` diff --git a/src/tools/clippy/tests/ui/needless_borrow.fixed b/src/tools/clippy/tests/ui/needless_borrow.fixed index 23e8bf8a468fd..998f5430fdf05 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.fixed +++ b/src/tools/clippy/tests/ui/needless_borrow.fixed @@ -1,6 +1,7 @@ #![feature(lint_reasons)] #![allow( unused, + non_local_definitions, clippy::uninlined_format_args, clippy::unnecessary_mut_passed, clippy::unnecessary_to_owned, diff --git a/src/tools/clippy/tests/ui/needless_borrow.rs b/src/tools/clippy/tests/ui/needless_borrow.rs index 27771a8f15b30..acb2c74d849a2 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.rs +++ b/src/tools/clippy/tests/ui/needless_borrow.rs @@ -1,6 +1,7 @@ #![feature(lint_reasons)] #![allow( unused, + non_local_definitions, clippy::uninlined_format_args, clippy::unnecessary_mut_passed, clippy::unnecessary_to_owned, diff --git a/src/tools/clippy/tests/ui/needless_borrow.stderr b/src/tools/clippy/tests/ui/needless_borrow.stderr index a21ed8382c14e..9034bd83a0b05 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.stderr +++ b/src/tools/clippy/tests/ui/needless_borrow.stderr @@ -1,5 +1,5 @@ error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:15:15 + --> $DIR/needless_borrow.rs:16:15 | LL | let _ = x(&&a); // warn | ^^^ help: change this to: `&a` @@ -8,157 +8,157 @@ LL | let _ = x(&&a); // warn = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:19:13 + --> $DIR/needless_borrow.rs:20:13 | LL | mut_ref(&mut &mut b); // warn | ^^^^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:31:13 + --> $DIR/needless_borrow.rs:32:13 | LL | &&a | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:33:15 + --> $DIR/needless_borrow.rs:34:15 | LL | 46 => &&a, | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:39:27 + --> $DIR/needless_borrow.rs:40:27 | LL | break &ref_a; | ^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:46:15 + --> $DIR/needless_borrow.rs:47:15 | LL | let _ = x(&&&a); | ^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:47:15 + --> $DIR/needless_borrow.rs:48:15 | LL | let _ = x(&mut &&a); | ^^^^^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:48:15 + --> $DIR/needless_borrow.rs:49:15 | LL | let _ = x(&&&mut b); | ^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:49:15 + --> $DIR/needless_borrow.rs:50:15 | LL | let _ = x(&&ref_a); | ^^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:52:11 + --> $DIR/needless_borrow.rs:53:11 | LL | x(&b); | ^^ help: change this to: `b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:59:13 + --> $DIR/needless_borrow.rs:60:13 | LL | mut_ref(&mut x); | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:60:13 + --> $DIR/needless_borrow.rs:61:13 | LL | mut_ref(&mut &mut x); | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:61:23 + --> $DIR/needless_borrow.rs:62:23 | LL | let y: &mut i32 = &mut x; | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:62:23 + --> $DIR/needless_borrow.rs:63:23 | LL | let y: &mut i32 = &mut &mut x; | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:71:14 + --> $DIR/needless_borrow.rs:72:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:77:14 + --> $DIR/needless_borrow.rs:78:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:89:13 + --> $DIR/needless_borrow.rs:90:13 | LL | let _ = (&x).0; | ^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:91:22 + --> $DIR/needless_borrow.rs:92:22 | LL | let _ = unsafe { (&*x).0 }; | ^^^^^ help: change this to: `(*x)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:101:5 + --> $DIR/needless_borrow.rs:102:5 | LL | (&&()).foo(); | ^^^^^^ help: change this to: `(&())` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:110:5 + --> $DIR/needless_borrow.rs:111:5 | LL | (&&5).foo(); | ^^^^^ help: change this to: `(&5)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:136:23 + --> $DIR/needless_borrow.rs:137:23 | LL | let x: (&str,) = (&"",); | ^^^ help: change this to: `""` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:178:13 + --> $DIR/needless_borrow.rs:179:13 | LL | (&self.f)() | ^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:187:13 + --> $DIR/needless_borrow.rs:188:13 | LL | (&mut self.f)() | ^^^^^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:224:22 + --> $DIR/needless_borrow.rs:225:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:231:22 + --> $DIR/needless_borrow.rs:232:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:235:22 + --> $DIR/needless_borrow.rs:236:22 | LL | let _ = &mut (&mut x.u).x; | ^^^^^^^^^^ help: change this to: `x.u` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:236:22 + --> $DIR/needless_borrow.rs:237:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` From 1b733558bf7ac425a2b56726e7229cc298982536 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 27 Jan 2024 17:37:53 +0100 Subject: [PATCH 099/417] Allow newly added non_local_definitions in std --- library/core/src/convert/mod.rs | 1 + library/core/src/hash/mod.rs | 1 + library/core/tests/iter/adapters/step_by.rs | 1 + library/core/tests/result.rs | 2 ++ 4 files changed, 5 insertions(+) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 45f6e375e8942..85740dce8668c 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -396,6 +396,7 @@ pub trait AsMut { /// For example, take this code: /// /// ``` +/// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))] /// struct Wrapper(Vec); /// impl From> for Vec { /// fn from(w: Wrapper) -> Vec { diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 153971a59c5c9..bfdd28a7399fd 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -454,6 +454,7 @@ pub trait Hasher { /// ``` /// #![feature(hasher_prefixfree_extras)] /// # // Stubs to make the `impl` below pass the compiler + /// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))] /// # struct MyCollection(Option); /// # impl MyCollection { /// # fn len(&self) -> usize { todo!() } diff --git a/library/core/tests/iter/adapters/step_by.rs b/library/core/tests/iter/adapters/step_by.rs index b4d61d28cb2e0..29adf0b42fae3 100644 --- a/library/core/tests/iter/adapters/step_by.rs +++ b/library/core/tests/iter/adapters/step_by.rs @@ -49,6 +49,7 @@ fn test_iterator_step_by_nth() { } #[test] +#[cfg_attr(not(bootstrap), allow(non_local_definitions))] fn test_iterator_step_by_nth_overflow() { #[cfg(target_pointer_width = "16")] type Bigger = u32; diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index 6c008ab2cb196..d02dc45da34c2 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -195,6 +195,7 @@ pub fn test_unwrap_or_default() { } #[test] +#[cfg_attr(not(bootstrap), allow(non_local_definitions))] pub fn test_into_ok() { fn infallible_op() -> Result { Ok(666) @@ -217,6 +218,7 @@ pub fn test_into_ok() { } #[test] +#[cfg_attr(not(bootstrap), allow(non_local_definitions))] pub fn test_into_err() { fn until_error_op() -> Result { Err(666) From 7b6057dea42c0aaec0735b155a2bc1aeaa0c0a93 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 27 Jan 2024 17:39:16 +0100 Subject: [PATCH 100/417] Allow newly added non_local_definitions in rustfmt --- src/tools/rustfmt/src/source_file.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/rustfmt/src/source_file.rs b/src/tools/rustfmt/src/source_file.rs index 958f9b0154f70..512a8593c27cd 100644 --- a/src/tools/rustfmt/src/source_file.rs +++ b/src/tools/rustfmt/src/source_file.rs @@ -66,6 +66,7 @@ where } } + #[cfg_attr(not(bootstrap), allow(non_local_definitions))] impl From<&FileName> for rustc_span::FileName { fn from(filename: &FileName) -> rustc_span::FileName { match filename { From 6320ad0b07be860232d2b1cf9e3bdf870ca28894 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 27 Jan 2024 18:26:37 +0100 Subject: [PATCH 101/417] Fix non_local_definitions lint in rustdoc --- src/librustdoc/doctest.rs | 7 +++++++ src/librustdoc/html/markdown/tests.rs | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index f9d4d1af1140f..828c72b28407d 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1208,6 +1208,13 @@ impl Tester for Collector { } } +#[cfg(test)] // used in tests +impl Tester for Vec { + fn add_test(&mut self, _test: String, _config: LangString, line: usize) { + self.push(line); + } +} + struct HirCollector<'a, 'hir, 'tcx> { sess: &'a Session, collector: &'a mut Collector, diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 4dd176b3a692a..1de97e49b8307 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -480,11 +480,6 @@ fn test_markdown_html_escape() { #[test] fn test_find_testable_code_line() { fn t(input: &str, expect: &[usize]) { - impl crate::doctest::Tester for Vec { - fn add_test(&mut self, _test: String, _config: LangString, line: usize) { - self.push(line); - } - } let mut lines = Vec::::new(); find_testable_code(input, &mut lines, ErrorCodes::No, false, None, true); assert_eq!(lines, expect); From a8ae1175c7e8f96996b69d75ca6a18e58efb7814 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 28 Jan 2024 13:49:45 +0100 Subject: [PATCH 102/417] Fix non_local_definitions lint in rustc_hir_analysis --- .../src/coherence/inherent_impls_overlap.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs index 9e1e884d9769f..3aef29f4ae4dd 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs @@ -24,6 +24,11 @@ struct InherentOverlapChecker<'tcx> { tcx: TyCtxt<'tcx>, } +rustc_index::newtype_index! { + #[orderable] + pub struct RegionId {} +} + impl<'tcx> InherentOverlapChecker<'tcx> { /// Checks whether any associated items in impls 1 and 2 share the same identifier and /// namespace. @@ -205,11 +210,6 @@ impl<'tcx> InherentOverlapChecker<'tcx> { // This is advantageous to running the algorithm over the // entire graph when there are many connected regions. - rustc_index::newtype_index! { - #[orderable] - pub struct RegionId {} - } - struct ConnectedRegion { idents: SmallVec<[Symbol; 8]>, impl_blocks: FxHashSet, From 85e3a2ee043f6404561a9fbed799c07d83f305ce Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Feb 2024 20:30:16 +0100 Subject: [PATCH 103/417] Add const-anon suggestion for non local impl --- compiler/rustc_lint/messages.ftl | 1 + compiler/rustc_lint/src/lints.rs | 8 +++++++- compiler/rustc_lint/src/non_local_def.rs | 16 +++++++++++++++- tests/ui/lint/non_local_definitions.stderr | 3 +++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 4e0ba376b7d2e..ca3941c06f427 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -421,6 +421,7 @@ lint_non_local_definitions_impl = non-local `impl` definition, they should be av } .non_local = an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block .exception = one exception to the rule are anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module and anon-const at the same nesting as the trait or type + .const_anon = use a const-anon item to suppress this lint lint_non_local_definitions_macro_rules = non-local `macro_rules!` definition, they should be avoided as they go against expectation .help = diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 15f158961d097..1a56fa751c2e7 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1301,7 +1301,13 @@ pub enum NonLocalDefinitionsDiag { #[note(lint_non_local)] #[note(lint_exception)] #[note(lint_non_local_definitions_deprecation)] - Impl { depth: u32, body_kind_descr: &'static str, body_name: String }, + Impl { + depth: u32, + body_kind_descr: &'static str, + body_name: String, + #[suggestion(lint_const_anon, code = "_", applicability = "machine-applicable")] + const_anon: Option, + }, #[diag(lint_non_local_definitions_macro_rules)] #[help] #[note(lint_non_local)] diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 28bd49f36a008..bfd7b4a72f9b3 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -1,4 +1,4 @@ -use rustc_hir::{def::DefKind, Body, Item, ItemKind, Path, QPath, TyKind}; +use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, Path, QPath, TyKind}; use rustc_span::{def_id::DefId, sym, symbol::kw, MacroKind}; use smallvec::{smallvec, SmallVec}; @@ -140,6 +140,19 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { // If none of them have a local parent (LOGICAL NOR) this means that // this impl definition is a non-local definition and so we lint on it. if !(self_ty_has_local_parent || of_trait_has_local_parent) { + let const_anon = if self.body_depth == 1 + && parent_def_kind == DefKind::Const + && parent_opt_item_name != Some(kw::Underscore) + && let Some(parent) = parent.as_local() + && let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent) + && let ItemKind::Const(ty, _, _) = item.kind + && let TyKind::Tup(&[]) = ty.kind + { + Some(item.ident.span) + } else { + None + }; + cx.emit_span_lint( NON_LOCAL_DEFINITIONS, item.span, @@ -149,6 +162,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { body_name: parent_opt_item_name .map(|s| s.to_ident_string()) .unwrap_or_else(|| "".to_string()), + const_anon, }, ) } diff --git a/tests/ui/lint/non_local_definitions.stderr b/tests/ui/lint/non_local_definitions.stderr index f15457734bcfe..8403357b11552 100644 --- a/tests/ui/lint/non_local_definitions.stderr +++ b/tests/ui/lint/non_local_definitions.stderr @@ -1,6 +1,9 @@ warning: non-local `impl` definition, they should be avoided as they go against expectation --> $DIR/non_local_definitions.rs:32:5 | +LL | const Z: () = { + | - help: use a const-anon item to suppress this lint: `_` +... LL | impl Uto for &Test {} | ^^^^^^^^^^^^^^^^^^^^^ | From 63469ab762b5710b07418e61ff758bd48d0f8b3e Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Feb 2024 20:33:30 +0100 Subject: [PATCH 104/417] Add cargo update suggestion for non local defs --- compiler/rustc_lint/messages.ftl | 2 + compiler/rustc_lint/src/lints.rs | 18 ++- compiler/rustc_lint/src/non_local_def.rs | 25 ++++- tests/ui/lint/auxiliary/non_local_macro.rs | 26 +++++ tests/ui/lint/non_local_definitions.rs | 12 ++ tests/ui/lint/non_local_definitions.stderr | 124 +++++++++++++-------- 6 files changed, 155 insertions(+), 52 deletions(-) create mode 100644 tests/ui/lint/auxiliary/non_local_macro.rs diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index ca3941c06f427..3f7abebf7b95b 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -411,6 +411,8 @@ lint_non_fmt_panic_unused = } .add_fmt_suggestion = or add a "{"{"}{"}"}" format string to use the message literally +lint_non_local_definitions_cargo_update = the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}` + lint_non_local_definitions_deprecation = this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue lint_non_local_definitions_impl = non-local `impl` definition, they should be avoided as they go against expectation diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1a56fa751c2e7..3a79520505964 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1305,6 +1305,8 @@ pub enum NonLocalDefinitionsDiag { depth: u32, body_kind_descr: &'static str, body_name: String, + #[subdiagnostic] + cargo_update: Option, #[suggestion(lint_const_anon, code = "_", applicability = "machine-applicable")] const_anon: Option, }, @@ -1313,7 +1315,21 @@ pub enum NonLocalDefinitionsDiag { #[note(lint_non_local)] #[note(lint_exception)] #[note(lint_non_local_definitions_deprecation)] - MacroRules { depth: u32, body_kind_descr: &'static str, body_name: String }, + MacroRules { + depth: u32, + body_kind_descr: &'static str, + body_name: String, + #[subdiagnostic] + cargo_update: Option, + }, +} + +#[derive(Subdiagnostic)] +#[note(lint_non_local_definitions_cargo_update)] +pub struct NonLocalDefinitionsCargoUpdateNote { + pub macro_kind: &'static str, + pub macro_name: Symbol, + pub crate_name: Symbol, } // pass_by_value.rs diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index bfd7b4a72f9b3..6cb6fd1cbd550 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -1,9 +1,11 @@ use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, Path, QPath, TyKind}; -use rustc_span::{def_id::DefId, sym, symbol::kw, MacroKind}; +use rustc_span::def_id::{DefId, LOCAL_CRATE}; +use rustc_span::{sym, symbol::kw, ExpnKind, MacroKind}; use smallvec::{smallvec, SmallVec}; -use crate::{lints::NonLocalDefinitionsDiag, LateContext, LateLintPass, LintContext}; +use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag}; +use crate::{LateContext, LateLintPass, LintContext}; declare_lint! { /// The `non_local_definitions` lint checks for `impl` blocks and `#[macro_export]` @@ -77,6 +79,23 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { return; } + let cargo_update = || { + let oexpn = item.span.ctxt().outer_expn_data(); + if let Some(def_id) = oexpn.macro_def_id + && let ExpnKind::Macro(macro_kind, macro_name) = oexpn.kind + && def_id.krate != LOCAL_CRATE + && std::env::var_os("CARGO").is_some() + { + Some(NonLocalDefinitionsCargoUpdateNote { + macro_kind: macro_kind.descr(), + macro_name, + crate_name: cx.tcx.crate_name(def_id.krate), + }) + } else { + None + } + }; + match item.kind { ItemKind::Impl(impl_) => { // The RFC states: @@ -162,6 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { body_name: parent_opt_item_name .map(|s| s.to_ident_string()) .unwrap_or_else(|| "".to_string()), + cargo_update: cargo_update(), const_anon, }, ) @@ -179,6 +199,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { body_name: parent_opt_item_name .map(|s| s.to_ident_string()) .unwrap_or_else(|| "".to_string()), + cargo_update: cargo_update(), }, ) } diff --git a/tests/ui/lint/auxiliary/non_local_macro.rs b/tests/ui/lint/auxiliary/non_local_macro.rs new file mode 100644 index 0000000000000..8c0ff8adda1b9 --- /dev/null +++ b/tests/ui/lint/auxiliary/non_local_macro.rs @@ -0,0 +1,26 @@ +#[macro_export] +macro_rules! non_local_impl { + ($a:ident) => { + const _IMPL_DEBUG: () = { + impl ::std::fmt::Debug for $a { + fn fmt(&self, _: &mut ::std::fmt::Formatter<'_>) + -> ::std::result::Result<(), ::std::fmt::Error> + { + todo!() + } + } + }; + } +} + +#[macro_export] +macro_rules! non_local_macro_rules { + ($a:ident) => { + const _MACRO_EXPORT: () = { + #[macro_export] + macro_rules! $a { + () => {} + } + }; + } +} diff --git a/tests/ui/lint/non_local_definitions.rs b/tests/ui/lint/non_local_definitions.rs index 986efbfcf0fe1..c9aaa04934631 100644 --- a/tests/ui/lint/non_local_definitions.rs +++ b/tests/ui/lint/non_local_definitions.rs @@ -1,8 +1,12 @@ //@ check-pass //@ edition:2021 +//@ aux-build:non_local_macro.rs +//@ rustc-env:CARGO=/usr/bin/cargo #![feature(inline_const)] +extern crate non_local_macro; + use std::fmt::{Debug, Display}; struct Test; @@ -364,6 +368,14 @@ macro_rules! m { m!(); +struct CargoUpdate; + +non_local_macro::non_local_impl!(CargoUpdate); +//~^ WARN non-local `impl` definition + +non_local_macro::non_local_macro_rules!(my_macro); +//~^ WARN non-local `macro_rules!` definition + fn bitflags() { struct Flags; diff --git a/tests/ui/lint/non_local_definitions.stderr b/tests/ui/lint/non_local_definitions.stderr index 8403357b11552..f9f29ec63a805 100644 --- a/tests/ui/lint/non_local_definitions.stderr +++ b/tests/ui/lint/non_local_definitions.stderr @@ -1,5 +1,5 @@ warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:32:5 + --> $DIR/non_local_definitions.rs:36:5 | LL | const Z: () = { | - help: use a const-anon item to suppress this lint: `_` @@ -14,7 +14,7 @@ LL | impl Uto for &Test {} = note: `#[warn(non_local_definitions)]` on by default warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:42:5 + --> $DIR/non_local_definitions.rs:46:5 | LL | impl Uto for *mut Test {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | impl Uto for *mut Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:50:9 + --> $DIR/non_local_definitions.rs:54:9 | LL | impl Uto for Test {} | ^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | impl Uto for Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:59:5 + --> $DIR/non_local_definitions.rs:63:5 | LL | impl Uto2 for Test {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | impl Uto2 for Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:67:5 + --> $DIR/non_local_definitions.rs:71:5 | LL | impl Uto3 for Test {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL | impl Uto3 for Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:71:5 + --> $DIR/non_local_definitions.rs:75:5 | LL | macro_rules! m0 { () => { } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | macro_rules! m0 { () => { } }; = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:83:5 + --> $DIR/non_local_definitions.rs:87:5 | LL | macro_rules! m { () => { } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | macro_rules! m { () => { } }; = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:86:5 + --> $DIR/non_local_definitions.rs:90:5 | LL | / impl Test { LL | | @@ -94,7 +94,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:92:9 + --> $DIR/non_local_definitions.rs:96:9 | LL | / impl Test { LL | | @@ -108,7 +108,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:101:9 + --> $DIR/non_local_definitions.rs:105:9 | LL | / impl Test { LL | | @@ -122,7 +122,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:110:9 + --> $DIR/non_local_definitions.rs:114:9 | LL | / impl Test { LL | | @@ -136,7 +136,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:118:5 + --> $DIR/non_local_definitions.rs:122:5 | LL | / impl Display for Test { LL | | @@ -152,7 +152,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:125:5 + --> $DIR/non_local_definitions.rs:129:5 | LL | impl dyn Uto5 {} | ^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | impl dyn Uto5 {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:128:5 + --> $DIR/non_local_definitions.rs:132:5 | LL | impl Uto5 for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ LL | impl Uto5 for Vec { } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:131:5 + --> $DIR/non_local_definitions.rs:135:5 | LL | impl Uto5 for &dyn Uto5 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -185,7 +185,7 @@ LL | impl Uto5 for &dyn Uto5 {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:134:5 + --> $DIR/non_local_definitions.rs:138:5 | LL | impl Uto5 for *mut Test {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -196,7 +196,7 @@ LL | impl Uto5 for *mut Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:137:5 + --> $DIR/non_local_definitions.rs:141:5 | LL | impl Uto5 for *mut [Test] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -207,7 +207,7 @@ LL | impl Uto5 for *mut [Test] {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:140:5 + --> $DIR/non_local_definitions.rs:144:5 | LL | impl Uto5 for [Test; 8] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -218,7 +218,7 @@ LL | impl Uto5 for [Test; 8] {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:143:5 + --> $DIR/non_local_definitions.rs:147:5 | LL | impl Uto5 for (Test,) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL | impl Uto5 for (Test,) {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:146:5 + --> $DIR/non_local_definitions.rs:150:5 | LL | impl Uto5 for fn(Test) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -240,7 +240,7 @@ LL | impl Uto5 for fn(Test) -> () {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:149:5 + --> $DIR/non_local_definitions.rs:153:5 | LL | impl Uto5 for fn() -> Test {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -251,7 +251,7 @@ LL | impl Uto5 for fn() -> Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:153:9 + --> $DIR/non_local_definitions.rs:157:9 | LL | impl Uto5 for Test {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -262,7 +262,7 @@ LL | impl Uto5 for Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:160:9 + --> $DIR/non_local_definitions.rs:164:9 | LL | impl Uto5 for &Test {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -273,7 +273,7 @@ LL | impl Uto5 for &Test {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:167:9 + --> $DIR/non_local_definitions.rs:171:9 | LL | impl Uto5 for &(Test,) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,7 +284,7 @@ LL | impl Uto5 for &(Test,) {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:174:9 + --> $DIR/non_local_definitions.rs:178:9 | LL | impl Uto5 for &(Test,Test) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +295,7 @@ LL | impl Uto5 for &(Test,Test) {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:182:5 + --> $DIR/non_local_definitions.rs:186:5 | LL | impl Uto5 for *mut InsideMain {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -306,7 +306,7 @@ LL | impl Uto5 for *mut InsideMain {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:184:5 + --> $DIR/non_local_definitions.rs:188:5 | LL | impl Uto5 for *mut [InsideMain] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -317,7 +317,7 @@ LL | impl Uto5 for *mut [InsideMain] {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:186:5 + --> $DIR/non_local_definitions.rs:190:5 | LL | impl Uto5 for [InsideMain; 8] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -328,7 +328,7 @@ LL | impl Uto5 for [InsideMain; 8] {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:188:5 + --> $DIR/non_local_definitions.rs:192:5 | LL | impl Uto5 for (InsideMain,) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -339,7 +339,7 @@ LL | impl Uto5 for (InsideMain,) {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:190:5 + --> $DIR/non_local_definitions.rs:194:5 | LL | impl Uto5 for fn(InsideMain) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -350,7 +350,7 @@ LL | impl Uto5 for fn(InsideMain) -> () {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:192:5 + --> $DIR/non_local_definitions.rs:196:5 | LL | impl Uto5 for fn() -> InsideMain {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -361,7 +361,7 @@ LL | impl Uto5 for fn() -> InsideMain {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:206:9 + --> $DIR/non_local_definitions.rs:210:9 | LL | / impl Display for InsideMain { LL | | @@ -377,7 +377,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:213:9 + --> $DIR/non_local_definitions.rs:217:9 | LL | / impl InsideMain { LL | | @@ -394,7 +394,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:217:17 + --> $DIR/non_local_definitions.rs:221:17 | LL | macro_rules! m2 { () => { } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL | macro_rules! m2 { () => { } }; = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:227:5 + --> $DIR/non_local_definitions.rs:231:5 | LL | impl Uto3 for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,7 @@ LL | impl Uto3 for Vec { } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:236:5 + --> $DIR/non_local_definitions.rs:240:5 | LL | impl Uto7 for Test where Local: std::any::Any {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -427,7 +427,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:239:5 + --> $DIR/non_local_definitions.rs:243:5 | LL | impl Uto8 for T {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -438,7 +438,7 @@ LL | impl Uto8 for T {} = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:248:5 + --> $DIR/non_local_definitions.rs:252:5 | LL | / impl Default for UwU { LL | | @@ -454,7 +454,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:259:5 + --> $DIR/non_local_definitions.rs:263:5 | LL | / impl From for () { LL | | @@ -470,7 +470,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:268:5 + --> $DIR/non_local_definitions.rs:272:5 | LL | / impl AsRef for () { LL | | @@ -484,7 +484,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:279:5 + --> $DIR/non_local_definitions.rs:283:5 | LL | / impl PartialEq for G { LL | | @@ -500,7 +500,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:296:5 + --> $DIR/non_local_definitions.rs:300:5 | LL | / impl PartialEq for &Dog { LL | | @@ -516,7 +516,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:303:5 + --> $DIR/non_local_definitions.rs:307:5 | LL | / impl PartialEq<()> for Dog { LL | | @@ -532,7 +532,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:310:5 + --> $DIR/non_local_definitions.rs:314:5 | LL | / impl PartialEq<()> for &Dog { LL | | @@ -548,7 +548,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:317:5 + --> $DIR/non_local_definitions.rs:321:5 | LL | / impl PartialEq for () { LL | | @@ -564,7 +564,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:339:5 + --> $DIR/non_local_definitions.rs:343:5 | LL | / impl From>> for () { LL | | @@ -580,7 +580,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:346:5 + --> $DIR/non_local_definitions.rs:350:5 | LL | / impl From<()> for Wrap { LL | | @@ -596,7 +596,7 @@ LL | | } = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue warning: non-local `impl` definition, they should be avoided as they go against expectation - --> $DIR/non_local_definitions.rs:359:13 + --> $DIR/non_local_definitions.rs:363:13 | LL | impl MacroTrait for OutsideStruct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -610,5 +610,31 @@ LL | m!(); = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: 48 warnings emitted +warning: non-local `impl` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:373:1 + | +LL | non_local_macro::non_local_impl!(CargoUpdate); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move this `impl` block outside the of the current constant `_IMPL_DEBUG` + = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + = note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro` + = note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation + --> $DIR/non_local_definitions.rs:376:1 + | +LL | non_local_macro::non_local_macro_rules!(my_macro); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `_MACRO_EXPORT` + = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module + = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + = note: the macro `non_local_macro::non_local_macro_rules` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro` + = note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: 50 warnings emitted From 03cec74a3c4bfea766b352c0d2ff00e769c58886 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 17 Feb 2024 14:41:15 +0100 Subject: [PATCH 105/417] add direct test of pthread_cond --- ...cond.rs => libc_pthread_cond_timedwait.rs} | 0 ...> libc_pthread_cond_timedwait_isolated.rs} | 0 .../miri/tests/pass-dep/shims/pthread-sync.rs | 56 +++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) rename src/tools/miri/tests/pass-dep/concurrency/{libc_pthread_cond.rs => libc_pthread_cond_timedwait.rs} (100%) rename src/tools/miri/tests/pass-dep/concurrency/{libc_pthread_cond_isolated.rs => libc_pthread_cond_timedwait_isolated.rs} (100%) diff --git a/src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond.rs b/src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond_timedwait.rs similarity index 100% rename from src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond.rs rename to src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond_timedwait.rs diff --git a/src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond_isolated.rs b/src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond_timedwait_isolated.rs similarity index 100% rename from src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond_isolated.rs rename to src/tools/miri/tests/pass-dep/concurrency/libc_pthread_cond_timedwait_isolated.rs diff --git a/src/tools/miri/tests/pass-dep/shims/pthread-sync.rs b/src/tools/miri/tests/pass-dep/shims/pthread-sync.rs index 077bbfff1645f..c9d10cb83d4d2 100644 --- a/src/tools/miri/tests/pass-dep/shims/pthread-sync.rs +++ b/src/tools/miri/tests/pass-dep/shims/pthread-sync.rs @@ -4,8 +4,8 @@ #![feature(sync_unsafe_cell)] use std::cell::SyncUnsafeCell; -use std::thread; -use std::{mem, ptr}; +use std::mem::MaybeUninit; +use std::{mem, ptr, thread}; fn main() { test_mutex_libc_init_recursive(); @@ -15,9 +15,10 @@ fn main() { #[cfg(target_os = "linux")] test_mutex_libc_static_initializer_recursive(); - test_mutex(); + check_mutex(); check_rwlock_write(); check_rwlock_read_no_deadlock(); + check_cond(); } fn test_mutex_libc_init_recursive() { @@ -119,7 +120,7 @@ impl Clone for SendPtr { } } -fn test_mutex() { +fn check_mutex() { // Specifically *not* using `Arc` to make sure there is no synchronization apart from the mutex. unsafe { let data = SyncUnsafeCell::new((libc::PTHREAD_MUTEX_INITIALIZER, 0)); @@ -213,6 +214,53 @@ fn check_rwlock_read_no_deadlock() { } } +fn check_cond() { + unsafe { + let mut cond: MaybeUninit = MaybeUninit::uninit(); + assert_eq!(libc::pthread_cond_init(cond.as_mut_ptr(), ptr::null()), 0); + let cond = SendPtr { ptr: cond.as_mut_ptr() }; + + let mut mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; + let mutex = SendPtr { ptr: &mut mutex }; + + let mut data = 0; + let data = SendPtr { ptr: &mut data }; + + let t = thread::spawn(move || { + let mutex = mutex; // circumvent per-field closure capture + let cond = cond; + let data = data; + assert_eq!(libc::pthread_mutex_lock(mutex.ptr), 0); + assert!(data.ptr.read() == 0); + data.ptr.write(1); + libc::pthread_cond_wait(cond.ptr, mutex.ptr); + assert!(data.ptr.read() == 3); + data.ptr.write(4); + assert_eq!(libc::pthread_mutex_unlock(mutex.ptr), 0); + }); + + thread::yield_now(); + + assert_eq!(libc::pthread_mutex_lock(mutex.ptr), 0); + assert!(data.ptr.read() == 1); + data.ptr.write(2); + assert_eq!(libc::pthread_cond_signal(cond.ptr), 0); + thread::yield_now(); // the other thread wakes up but can't get the lock yet + assert!(data.ptr.read() == 2); + data.ptr.write(3); + assert_eq!(libc::pthread_mutex_unlock(mutex.ptr), 0); + + thread::yield_now(); // now the other thread gets the lock back + + assert_eq!(libc::pthread_mutex_lock(mutex.ptr), 0); + assert!(data.ptr.read() == 4); + assert_eq!(libc::pthread_cond_broadcast(cond.ptr), 0); // just a smoke test + assert_eq!(libc::pthread_mutex_unlock(mutex.ptr), 0); + + t.join().unwrap(); + } +} + // std::sync::RwLock does not even used pthread_rwlock any more. // Do some smoke testing of the API surface. fn test_rwlock_libc_static_initializer() { From d18d4615c4f58e70799f56dc916f839a8019e2cb Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Sun, 18 Feb 2024 04:53:46 +0000 Subject: [PATCH 106/417] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index ab6f899cd3a5e..921a55d48c6c1 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -4316d0c6252cb1f833e582dfa68adb98efd5ddfb +1f8e824f111c972c9df8dbb378d87c33f67bbad4 From 7a83e2f30d92748640461edbd5812e7b9229e995 Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Sun, 18 Feb 2024 05:02:03 +0000 Subject: [PATCH 107/417] fmt --- src/tools/miri/tests/pass/overflow_checks_off.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/miri/tests/pass/overflow_checks_off.rs b/src/tools/miri/tests/pass/overflow_checks_off.rs index 7b9d4f8fff5d5..831bffb6c5e8d 100644 --- a/src/tools/miri/tests/pass/overflow_checks_off.rs +++ b/src/tools/miri/tests/pass/overflow_checks_off.rs @@ -7,10 +7,9 @@ // Miri does not implement the codegen-time hack that backs `#[rustc_inherit_overflow_checks]`. // use std::ops::*; - // Disable _compile-time_ overflow linting // so that we can test runtime overflow checks - #![allow(arithmetic_overflow)] +#![allow(arithmetic_overflow)] fn main() { assert_eq!(-{ -0x80i8 }, -0x80); From 6b17dba68cff05978c10eb2600c16d4450ad77f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sun, 18 Feb 2024 09:41:20 +0200 Subject: [PATCH 108/417] Merge commit 'ac998a74b3c8ff4b81c3eeb9a18811d4cc76226d' into sync-from-ra --- .github/rust.json | 33 + .github/workflows/autopublish.yaml | 2 +- .github/workflows/ci.yaml | 20 +- .github/workflows/fuzz.yml | 2 +- .github/workflows/metrics.yaml | 16 +- .github/workflows/publish-libs.yaml | 2 +- .github/workflows/release.yaml | 14 +- .github/workflows/rustdoc.yaml | 2 +- Cargo.lock | 17 +- Cargo.toml | 2 +- crates/base-db/src/input.rs | 230 +---- crates/base-db/src/lib.rs | 14 + crates/flycheck/src/lib.rs | 79 +- crates/hir-def/src/attr.rs | 42 +- crates/hir-def/src/body/lower.rs | 11 +- crates/hir-def/src/body/pretty.rs | 6 + crates/hir-def/src/body/scope.rs | 1 + crates/hir-def/src/data.rs | 12 +- crates/hir-def/src/expander.rs | 6 +- crates/hir-def/src/find_path.rs | 63 +- crates/hir-def/src/hir.rs | 9 + .../src/macro_expansion_tests/mbe/matching.rs | 2 +- .../macro_expansion_tests/mbe/meta_syntax.rs | 42 +- .../macro_expansion_tests/mbe/metavar_expr.rs | 6 +- .../macro_expansion_tests/mbe/regression.rs | 54 ++ .../mbe/tt_conversion.rs | 4 +- .../hir-def/src/macro_expansion_tests/mod.rs | 1 + crates/hir-def/src/nameres/collector.rs | 95 +- crates/hir-def/src/nameres/diagnostics.rs | 3 + crates/hir-expand/src/builtin_fn_macro.rs | 2 +- crates/hir-expand/src/change.rs | 34 +- crates/hir-expand/src/db.rs | 154 ++-- crates/hir-expand/src/declarative.rs | 14 +- crates/hir-expand/src/lib.rs | 26 +- crates/hir-expand/src/mod_path.rs | 15 + crates/hir-expand/src/proc_macro.rs | 46 +- crates/hir-ty/src/diagnostics/expr.rs | 13 +- .../diagnostics/match_check/pat_analysis.rs | 46 +- crates/hir-ty/src/infer.rs | 133 ++- crates/hir-ty/src/infer/closure.rs | 4 + crates/hir-ty/src/infer/expr.rs | 23 + crates/hir-ty/src/infer/mutability.rs | 4 + crates/hir-ty/src/infer/unify.rs | 83 +- crates/hir-ty/src/layout/target.rs | 8 +- crates/hir-ty/src/layout/tests.rs | 12 +- crates/hir-ty/src/lib.rs | 4 +- crates/hir-ty/src/mir/borrowck.rs | 185 +++- crates/hir-ty/src/mir/lower.rs | 4 +- crates/hir-ty/src/tests/diagnostics.rs | 42 + crates/hir-ty/src/tests/simple.rs | 3 - crates/hir/src/lib.rs | 246 ++++- crates/hir/src/term_search.rs | 298 ++++++ crates/hir/src/term_search/expr.rs | 468 ++++++++++ crates/hir/src/term_search/tactics.rs | 859 ++++++++++++++++++ .../src/handlers/fix_visibility.rs | 4 +- .../src/handlers/generate_trait_from_impl.rs | 104 +-- .../ide-assists/src/handlers/term_search.rs | 253 ++++++ crates/ide-assists/src/lib.rs | 7 +- crates/ide-assists/src/tests/generated.rs | 4 +- crates/ide-completion/src/completions.rs | 10 +- crates/ide-completion/src/completions/expr.rs | 56 ++ .../src/completions/flyimport.rs | 2 + crates/ide-completion/src/completions/type.rs | 20 + crates/ide-completion/src/config.rs | 1 + crates/ide-completion/src/context.rs | 3 +- crates/ide-completion/src/item.rs | 50 + crates/ide-completion/src/render.rs | 443 ++++++++- crates/ide-completion/src/render/function.rs | 50 +- crates/ide-completion/src/tests.rs | 1 + crates/ide-completion/src/tests/expression.rs | 32 +- crates/ide-completion/src/tests/flyimport.rs | 19 + crates/ide-completion/src/tests/record.rs | 2 + crates/ide-completion/src/tests/special.rs | 40 +- crates/ide-completion/src/tests/type_pos.rs | 40 + crates/ide-db/src/famous_defs.rs | 8 + crates/ide-db/src/path_transform.rs | 2 +- crates/ide-db/src/rename.rs | 5 +- crates/ide-db/src/source_change.rs | 68 +- crates/ide-db/src/syntax_helpers/node_ext.rs | 1 + .../src/handlers/incorrect_case.rs | 2 +- .../src/handlers/macro_error.rs | 2 +- .../src/handlers/missing_match_arms.rs | 18 + .../src/handlers/remove_trailing_return.rs | 12 + .../src/handlers/type_mismatch.rs | 3 +- .../src/handlers/typed_hole.rs | 256 +++++- crates/ide-diagnostics/src/tests.rs | 85 ++ crates/ide/src/doc_links.rs | 2 +- crates/ide/src/hover/tests.rs | 8 +- crates/ide/src/lib.rs | 12 +- crates/ide/src/parent_module.rs | 2 +- crates/ide/src/rename.rs | 41 +- crates/ide/src/shuffle_crate_graph.rs | 2 - crates/ide/src/static_index.rs | 23 +- crates/ide/src/status.rs | 8 - crates/load-cargo/src/lib.rs | 74 +- crates/mbe/src/expander/transcriber.rs | 18 +- crates/mbe/src/syntax_bridge.rs | 6 +- crates/parser/src/grammar/expressions.rs | 29 +- crates/parser/src/grammar/expressions/atom.rs | 14 + crates/parser/src/grammar/generic_params.rs | 10 + crates/parser/src/grammar/patterns.rs | 9 + crates/parser/src/syntax_kind/generated.rs | 6 +- ...cord_literal_before_ellipsis_recovery.rast | 36 +- ...0032_record_literal_field_eq_recovery.rast | 41 + .../0032_record_literal_field_eq_recovery.rs | 3 + .../0033_record_pat_field_eq_recovery.rast | 43 + .../err/0033_record_pat_field_eq_recovery.rs | 3 + .../parser/inline/ok/0209_become_expr.rast | 31 + .../parser/inline/ok/0209_become_expr.rs | 3 + .../inline/ok/0211_async_trait_bound.rast | 43 + .../inline/ok/0211_async_trait_bound.rs | 1 + .../inline/ok/0212_const_trait_bound.rast | 34 + .../inline/ok/0212_const_trait_bound.rs | 1 + crates/proc-macro-api/src/lib.rs | 8 +- crates/proc-macro-api/src/process.rs | 25 +- crates/proc-macro-srv/Cargo.toml | 1 + crates/proc-macro-srv/src/lib.rs | 5 + .../src/server/rust_analyzer_span.rs | 55 +- crates/proc-macro-srv/src/server/token_id.rs | 55 +- crates/proc-macro-srv/src/tests/mod.rs | 18 +- crates/project-model/src/build_scripts.rs | 25 +- crates/project-model/src/cargo_workspace.rs | 39 +- crates/project-model/src/project_json.rs | 3 +- crates/project-model/src/rustc_cfg.rs | 46 +- crates/project-model/src/sysroot.rs | 124 ++- .../project-model/src/target_data_layout.rs | 60 +- crates/project-model/src/tests.rs | 71 +- crates/project-model/src/workspace.rs | 549 ++++++----- .../cargo_hello_world_project_model.txt | 27 - ...project_model_with_selective_overrides.txt | 27 - ..._project_model_with_wildcard_overrides.txt | 27 - ...rust_project_hello_world_project_model.txt | 60 -- crates/rust-analyzer/src/bin/main.rs | 28 +- crates/rust-analyzer/src/bin/rustc_wrapper.rs | 19 +- crates/rust-analyzer/src/cargo_target_spec.rs | 2 +- .../rust-analyzer/src/cli/analysis_stats.rs | 216 ++++- crates/rust-analyzer/src/cli/flags.rs | 7 + crates/rust-analyzer/src/cli/scip.rs | 31 +- crates/rust-analyzer/src/config.rs | 19 +- crates/rust-analyzer/src/global_state.rs | 41 +- .../src/handlers/notification.rs | 22 +- crates/rust-analyzer/src/handlers/request.rs | 11 +- .../src/integrated_benchmarks.rs | 3 + crates/rust-analyzer/src/lib.rs | 4 +- crates/rust-analyzer/src/lsp/to_proto.rs | 673 ++++++++++++-- crates/rust-analyzer/src/main_loop.rs | 41 +- crates/rust-analyzer/src/reload.rs | 193 +++- crates/rust-analyzer/tests/crate_graph.rs | 118 +++ crates/rust-analyzer/tests/slow-tests/main.rs | 16 +- .../rust-analyzer/tests/slow-tests/support.rs | 9 +- crates/rust-analyzer/tests/slow-tests/tidy.rs | 21 - .../deduplication_crate_graph_A.json | 0 .../deduplication_crate_graph_B.json | 0 crates/salsa/src/doctest.rs | 115 --- crates/salsa/src/lib.rs | 1 - crates/syntax/rust.ungram | 6 +- crates/syntax/src/ast/edit_in_place.rs | 30 +- crates/syntax/src/ast/generated/nodes.rs | 37 +- crates/syntax/src/ast/make.rs | 2 +- crates/syntax/src/ast/node_ext.rs | 20 + crates/syntax/src/ast/prec.rs | 8 +- crates/syntax/src/lib.rs | 5 - crates/syntax/src/tests/ast_src.rs | 6 +- crates/test-fixture/src/lib.rs | 90 +- crates/test-utils/src/fixture.rs | 38 +- crates/test-utils/src/minicore.rs | 33 + crates/toolchain/src/lib.rs | 42 +- crates/tt/src/lib.rs | 1 + docs/user/generated_config.adoc | 17 +- editors/code/.vscodeignore | 3 + .../code/language-configuration-rustdoc.json | 37 + editors/code/package.json | 44 +- editors/code/rustdoc-inject.json | 93 ++ editors/code/rustdoc.json | 82 ++ editors/code/src/rust_project.ts | 19 + lib/lsp-server/LICENSE-APACHE | 1 + lib/lsp-server/LICENSE-MIT | 1 + xtask/src/metrics.rs | 2 - 178 files changed, 7095 insertions(+), 1959 deletions(-) create mode 100644 .github/rust.json create mode 100644 crates/hir/src/term_search.rs create mode 100644 crates/hir/src/term_search/expr.rs create mode 100644 crates/hir/src/term_search/tactics.rs create mode 100644 crates/ide-assists/src/handlers/term_search.rs create mode 100644 crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rast create mode 100644 crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rs create mode 100644 crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rast create mode 100644 crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rs create mode 100644 crates/parser/test_data/parser/inline/ok/0209_become_expr.rast create mode 100644 crates/parser/test_data/parser/inline/ok/0209_become_expr.rs create mode 100644 crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rast create mode 100644 crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rs create mode 100644 crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rast create mode 100644 crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rs create mode 100644 crates/rust-analyzer/tests/crate_graph.rs rename crates/{project-model => rust-analyzer/tests}/test_data/deduplication_crate_graph_A.json (100%) rename crates/{project-model => rust-analyzer/tests}/test_data/deduplication_crate_graph_B.json (100%) delete mode 100644 crates/salsa/src/doctest.rs create mode 100644 editors/code/language-configuration-rustdoc.json create mode 100644 editors/code/rustdoc-inject.json create mode 100644 editors/code/rustdoc.json create mode 120000 lib/lsp-server/LICENSE-APACHE create mode 120000 lib/lsp-server/LICENSE-MIT diff --git a/.github/rust.json b/.github/rust.json new file mode 100644 index 0000000000000..ddaa1b0824b94 --- /dev/null +++ b/.github/rust.json @@ -0,0 +1,33 @@ +{ + "problemMatcher": [ + { + "owner": "rustfmt", + "severity": "warning", + "pattern": [ + { + "regexp": "^(Diff in (.+)) at line (\\d+):$", + "message": 1, + "file": 2, + "line": 3 + } + ] + }, + { + "owner": "clippy", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[[\\d;]+m)*(warning|warn|error)(?:\\x1b\\[[\\d;]+m)*(\\[(.*)\\])?(?:\\x1b\\[[\\d;]+m)*:(?:\\x1b\\[[\\d;]+m)* ([^\\x1b]*)(?:\\x1b\\[[\\d;]+m)*$", + "severity": 1, + "message": 4, + "code": 3 + }, + { + "regexp": "^(?:\\x1b\\[[\\d;]+m)*\\s*(?:\\x1b\\[[\\d;]+m)*\\s*--> (?:\\x1b\\[[\\d;]+m)*(.*):(\\d*):(\\d*)(?:\\x1b\\[[\\d;]+m)*$", + "file": 1, + "line": 2, + "column": 3 + } + ] + } + ] +} diff --git a/.github/workflows/autopublish.yaml b/.github/workflows/autopublish.yaml index 9a5015005b3dc..4b97637088c31 100644 --- a/.github/workflows/autopublish.yaml +++ b/.github/workflows/autopublish.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 964be478fa3aa..62fbd57abc165 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: typescript: ${{ steps.filter.outputs.typescript }} proc_macros: ${{ steps.filter.outputs.proc_macros }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 id: filter with: @@ -56,7 +56,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} @@ -65,6 +65,10 @@ jobs: rustup update --no-self-update ${{ env.RUST_CHANNEL }} rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src rustup default ${{ env.RUST_CHANNEL }} + # https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json + - name: Install Rust Problem Matcher + if: matrix.os == 'ubuntu-latest' + run: echo "::add-matcher::.github/rust.json" - name: Cache Dependencies uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894 @@ -107,6 +111,10 @@ jobs: if: matrix.os == 'windows-latest' run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr + - name: rustfmt + if: matrix.os == 'ubuntu-latest' + run: cargo fmt -- --check + # Weird targets to catch non-portable code rust-cross: if: github.repository == 'rust-lang/rust-analyzer' @@ -121,7 +129,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust toolchain run: | @@ -153,13 +161,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 if: needs.changes.outputs.typescript == 'true' - name: Install Nodejs - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 18 if: needs.changes.outputs.typescript == 'true' - name: Install xvfb diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 5af8aa1f77aac..f88c7f95d5c96 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 1 diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index e6a9917a0bf3d..be9f504e59966 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -21,7 +21,7 @@ jobs: rustup component add rustfmt rust-src rustup default stable - name: Cache cargo - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/bin/ @@ -36,10 +36,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Restore cargo cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/bin/ @@ -52,7 +52,7 @@ jobs: run: cargo xtask metrics build - name: Cache target - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: target/ key: ${{ runner.os }}-target-${{ github.sha }} @@ -73,10 +73,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Restore cargo cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/bin/ @@ -86,7 +86,7 @@ jobs: key: ${{ runner.os }}-cargo-${{ github.sha }} - name: Restore target cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: target/ key: ${{ runner.os }}-target-${{ github.sha }} @@ -106,7 +106,7 @@ jobs: needs: [build_metrics, other_metrics] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download build metrics uses: actions/download-artifact@v3 diff --git a/.github/workflows/publish-libs.yaml b/.github/workflows/publish-libs.yaml index 6d026c9ad910b..862373ec1cce0 100644 --- a/.github/workflows/publish-libs.yaml +++ b/.github/workflows/publish-libs.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9077a9ac21eb6..adb1c85051610 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -59,7 +59,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: ${{ env.FETCH_DEPTH }} @@ -78,9 +78,9 @@ jobs: rustup component add rust-src - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 18 - name: Update apt repositories if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf' @@ -154,7 +154,7 @@ jobs: run: apk add --no-cache git clang lld musl-dev nodejs npm - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: ${{ env.FETCH_DEPTH }} @@ -188,9 +188,9 @@ jobs: needs: ["dist", "dist-x86_64-unknown-linux-musl"] steps: - name: Install Nodejs - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 18 - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV if: github.ref == 'refs/heads/release' @@ -199,7 +199,7 @@ jobs: - run: 'echo "TAG: $TAG"' - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: ${{ env.FETCH_DEPTH }} diff --git a/.github/workflows/rustdoc.yaml b/.github/workflows/rustdoc.yaml index 05f3e254e5f5a..12a1a791fda2e 100644 --- a/.github/workflows/rustdoc.yaml +++ b/.github/workflows/rustdoc.yaml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust toolchain run: rustup update --no-self-update stable diff --git a/Cargo.lock b/Cargo.lock index dc2bf3a76943e..7b29d7bb798df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1329,6 +1329,7 @@ dependencies = [ "paths", "proc-macro-api", "proc-macro-test", + "ra-ap-rustc_lexer", "span", "stdx", "tt", @@ -1470,12 +1471,12 @@ dependencies = [ [[package]] name = "ra-ap-rustc_index" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8a41dee58608b1fc93779ea365edaa70ac9927e3335ae914b675be0fa063cd7" +checksum = "df5a0ba0d08af366cf235dbe8eb7226cced7a4fe502c98aa434ccf416defd746" dependencies = [ "arrayvec", - "ra-ap-rustc_index_macros 0.36.0", + "ra-ap-rustc_index_macros 0.37.0", "smallvec", ] @@ -1493,9 +1494,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_index_macros" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbfe98def54c4337a2f7d8233850bd5d5349972b185fe8a0db2b979164b30ed8" +checksum = "1971ebf9a701e0e68387c264a32517dcb4861ad3a4862f2e2803c1121ade20d5" dependencies = [ "proc-macro2", "quote", @@ -1525,11 +1526,11 @@ dependencies = [ [[package]] name = "ra-ap-rustc_pattern_analysis" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5529bffec7530b4a3425640bfdfd9b95d87c4c620f740266c0de6572561aab4" +checksum = "2c3c0e7ca9c5bdc66e3b590688e237a22ac47a48e4eac7f46b05b2abbfaf0abd" dependencies = [ - "ra-ap-rustc_index 0.36.0", + "ra-ap-rustc_index 0.37.0", "rustc-hash", "rustc_apfloat", "smallvec", diff --git a/Cargo.toml b/Cargo.toml index 2b81f7b11b238..49c7d369190ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ ra-ap-rustc_lexer = { version = "0.35.0", default-features = false } ra-ap-rustc_parse_format = { version = "0.35.0", default-features = false } ra-ap-rustc_index = { version = "0.35.0", default-features = false } ra-ap-rustc_abi = { version = "0.35.0", default-features = false } -ra-ap-rustc_pattern_analysis = { version = "0.36.0", default-features = false } +ra-ap-rustc_pattern_analysis = { version = "0.37.0", default-features = false } # local crates that aren't published to crates.io. These should not have versions. sourcegen = { path = "./crates/sourcegen" } diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs index 9560826e373e0..a817cd0c3ac2f 100644 --- a/crates/base-db/src/input.rs +++ b/crates/base-db/src/input.rs @@ -11,7 +11,6 @@ use std::{fmt, mem, ops, str::FromStr}; use cfg::CfgOptions; use la_arena::{Arena, Idx, RawIdx}; use rustc_hash::{FxHashMap, FxHashSet}; -use semver::Version; use syntax::SmolStr; use triomphe::Arc; use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath}; @@ -243,6 +242,7 @@ impl CrateDisplayName { CrateDisplayName { crate_name, canonical_name } } } + pub type TargetLayoutLoadResult = Result, Arc>; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -291,71 +291,6 @@ pub struct CrateData { pub dependencies: Vec, pub origin: CrateOrigin, pub is_proc_macro: bool, - // FIXME: These things should not be per crate! These are more per workspace crate graph level - // things. This info does need to be somewhat present though as to prevent deduplication from - // happening across different workspaces with different layouts. - pub target_layout: TargetLayoutLoadResult, - pub toolchain: Option, -} - -impl CrateData { - /// Check if [`other`] is almost equal to [`self`] ignoring `CrateOrigin` value. - pub fn eq_ignoring_origin_and_deps(&self, other: &CrateData, ignore_dev_deps: bool) -> bool { - // This method has some obscure bits. These are mostly there to be compliant with - // some patches. References to the patches are given. - if self.root_file_id != other.root_file_id { - return false; - } - - if self.display_name != other.display_name { - return false; - } - - if self.is_proc_macro != other.is_proc_macro { - return false; - } - - if self.edition != other.edition { - return false; - } - - if self.version != other.version { - return false; - } - - let mut opts = self.cfg_options.difference(&other.cfg_options); - if let Some(it) = opts.next() { - // Don't care if rust_analyzer CfgAtom is the only cfg in the difference set of self's and other's cfgs. - // https://github.com/rust-lang/rust-analyzer/blob/0840038f02daec6ba3238f05d8caa037d28701a0/crates/project-model/src/workspace.rs#L894 - if it.to_string() != "rust_analyzer" { - return false; - } - - if opts.next().is_some() { - return false; - } - } - - if self.env != other.env { - return false; - } - - let slf_deps = self.dependencies.iter(); - let other_deps = other.dependencies.iter(); - - if ignore_dev_deps { - return slf_deps - .clone() - .filter(|it| it.kind != DependencyKind::Dev) - .eq(other_deps.clone().filter(|it| it.kind != DependencyKind::Dev)); - } - - slf_deps.eq(other_deps) - } - - pub fn channel(&self) -> Option { - self.toolchain.as_ref().and_then(|v| ReleaseChannel::from_str(&v.pre)) - } } #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -398,32 +333,22 @@ pub enum DependencyKind { pub struct Dependency { pub crate_id: CrateId, pub name: CrateName, - kind: DependencyKind, prelude: bool, } impl Dependency { - pub fn new(name: CrateName, crate_id: CrateId, kind: DependencyKind) -> Self { - Self { name, crate_id, prelude: true, kind } + pub fn new(name: CrateName, crate_id: CrateId) -> Self { + Self { name, crate_id, prelude: true } } - pub fn with_prelude( - name: CrateName, - crate_id: CrateId, - prelude: bool, - kind: DependencyKind, - ) -> Self { - Self { name, crate_id, prelude, kind } + pub fn with_prelude(name: CrateName, crate_id: CrateId, prelude: bool) -> Self { + Self { name, crate_id, prelude } } /// Whether this dependency is to be added to the depending crate's extern prelude. pub fn is_prelude(&self) -> bool { self.prelude } - - pub fn kind(&self) -> DependencyKind { - self.kind - } } impl CrateGraph { @@ -438,8 +363,6 @@ impl CrateGraph { env: Env, is_proc_macro: bool, origin: CrateOrigin, - target_layout: Result, Arc>, - toolchain: Option, ) -> CrateId { let data = CrateData { root_file_id, @@ -451,9 +374,7 @@ impl CrateGraph { env, dependencies: Vec::new(), origin, - target_layout, is_proc_macro, - toolchain, }; self.arena.alloc(data) } @@ -523,6 +444,10 @@ impl CrateGraph { self.arena.is_empty() } + pub fn len(&self) -> usize { + self.arena.len() + } + pub fn iter(&self) -> impl Iterator + '_ { self.arena.iter().map(|(idx, _)| idx) } @@ -623,13 +548,17 @@ impl CrateGraph { /// /// This will deduplicate the crates of the graph where possible. /// Note that for deduplication to fully work, `self`'s crate dependencies must be sorted by crate id. - /// If the crate dependencies were sorted, the resulting graph from this `extend` call will also have the crate dependencies sorted. + /// If the crate dependencies were sorted, the resulting graph from this `extend` call will also + /// have the crate dependencies sorted. + /// + /// Returns a mapping from `other`'s crate ids to the new crate ids in `self`. pub fn extend( &mut self, mut other: CrateGraph, proc_macros: &mut ProcMacroPaths, - on_finished: impl FnOnce(&FxHashMap), - ) { + merge: impl Fn((CrateId, &mut CrateData), (CrateId, &CrateData)) -> bool, + ) -> FxHashMap { + let m = self.len(); let topo = other.crates_in_topological_order(); let mut id_map: FxHashMap = FxHashMap::default(); for topo in topo { @@ -637,51 +566,21 @@ impl CrateGraph { crate_data.dependencies.iter_mut().for_each(|dep| dep.crate_id = id_map[&dep.crate_id]); crate_data.dependencies.sort_by_key(|dep| dep.crate_id); - let res = self.arena.iter().find_map(|(id, data)| { - match (&data.origin, &crate_data.origin) { - (a, b) if a == b => { - if data.eq_ignoring_origin_and_deps(crate_data, false) { - return Some((id, false)); - } - } - (a @ CrateOrigin::Local { .. }, CrateOrigin::Library { .. }) - | (a @ CrateOrigin::Library { .. }, CrateOrigin::Local { .. }) => { - // If the origins differ, check if the two crates are equal without - // considering the dev dependencies, if they are, they most likely are in - // different loaded workspaces which may cause issues. We keep the local - // version and discard the library one as the local version may have - // dev-dependencies that we want to keep resolving. See #15656 for more - // information. - if data.eq_ignoring_origin_and_deps(crate_data, true) { - return Some((id, !a.is_local())); - } - } - (_, _) => return None, - } - - None - }); - - if let Some((res, should_update_lib_to_local)) = res { - id_map.insert(topo, res); - if should_update_lib_to_local { - assert!(self.arena[res].origin.is_lib()); - assert!(crate_data.origin.is_local()); - self.arena[res].origin = crate_data.origin.clone(); - - // Move local's dev dependencies into the newly-local-formerly-lib crate. - self.arena[res].dependencies = crate_data.dependencies.clone(); - } - } else { - let id = self.arena.alloc(crate_data.clone()); - id_map.insert(topo, id); - } + let res = self + .arena + .iter_mut() + .take(m) + .find_map(|(id, data)| merge((id, data), (topo, &crate_data)).then_some(id)); + + let new_id = + if let Some(res) = res { res } else { self.arena.alloc(crate_data.clone()) }; + id_map.insert(topo, new_id); } *proc_macros = mem::take(proc_macros).into_iter().map(|(id, macros)| (id_map[&id], macros)).collect(); - on_finished(&id_map); + id_map } fn find_path( @@ -719,11 +618,9 @@ impl CrateGraph { match (cfg_if, std) { (Some(cfg_if), Some(std)) => { self.arena[cfg_if].dependencies.clear(); - self.arena[std].dependencies.push(Dependency::new( - CrateName::new("cfg_if").unwrap(), - cfg_if, - DependencyKind::Normal, - )); + self.arena[std] + .dependencies + .push(Dependency::new(CrateName::new("cfg_if").unwrap(), cfg_if)); true } _ => false, @@ -871,7 +768,7 @@ impl fmt::Display for CyclicDependenciesError { #[cfg(test)] mod tests { - use crate::{CrateOrigin, DependencyKind}; + use crate::CrateOrigin; use super::{CrateGraph, CrateName, Dependency, Edition::Edition2018, Env, FileId}; @@ -888,8 +785,6 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); let crate2 = graph.add_crate_root( FileId::from_raw(2u32), @@ -901,8 +796,6 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); let crate3 = graph.add_crate_root( FileId::from_raw(3u32), @@ -914,26 +807,15 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); assert!(graph - .add_dep( - crate1, - Dependency::new(CrateName::new("crate2").unwrap(), crate2, DependencyKind::Normal) - ) + .add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,)) .is_ok()); assert!(graph - .add_dep( - crate2, - Dependency::new(CrateName::new("crate3").unwrap(), crate3, DependencyKind::Normal) - ) + .add_dep(crate2, Dependency::new(CrateName::new("crate3").unwrap(), crate3,)) .is_ok()); assert!(graph - .add_dep( - crate3, - Dependency::new(CrateName::new("crate1").unwrap(), crate1, DependencyKind::Normal) - ) + .add_dep(crate3, Dependency::new(CrateName::new("crate1").unwrap(), crate1,)) .is_err()); } @@ -950,8 +832,6 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); let crate2 = graph.add_crate_root( FileId::from_raw(2u32), @@ -963,20 +843,12 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); assert!(graph - .add_dep( - crate1, - Dependency::new(CrateName::new("crate2").unwrap(), crate2, DependencyKind::Normal) - ) + .add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,)) .is_ok()); assert!(graph - .add_dep( - crate2, - Dependency::new(CrateName::new("crate2").unwrap(), crate2, DependencyKind::Normal) - ) + .add_dep(crate2, Dependency::new(CrateName::new("crate2").unwrap(), crate2,)) .is_err()); } @@ -993,8 +865,6 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); let crate2 = graph.add_crate_root( FileId::from_raw(2u32), @@ -1006,8 +876,6 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); let crate3 = graph.add_crate_root( FileId::from_raw(3u32), @@ -1019,20 +887,12 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); assert!(graph - .add_dep( - crate1, - Dependency::new(CrateName::new("crate2").unwrap(), crate2, DependencyKind::Normal) - ) + .add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,)) .is_ok()); assert!(graph - .add_dep( - crate2, - Dependency::new(CrateName::new("crate3").unwrap(), crate3, DependencyKind::Normal) - ) + .add_dep(crate2, Dependency::new(CrateName::new("crate3").unwrap(), crate3,)) .is_ok()); } @@ -1049,8 +909,6 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); let crate2 = graph.add_crate_root( FileId::from_raw(2u32), @@ -1062,26 +920,16 @@ mod tests { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("".into()), - None, ); assert!(graph .add_dep( crate1, - Dependency::new( - CrateName::normalize_dashes("crate-name-with-dashes"), - crate2, - DependencyKind::Normal - ) + Dependency::new(CrateName::normalize_dashes("crate-name-with-dashes"), crate2,) ) .is_ok()); assert_eq!( graph[crate1].dependencies, - vec![Dependency::new( - CrateName::new("crate_name_with_dashes").unwrap(), - crate2, - DependencyKind::Normal - )] + vec![Dependency::new(CrateName::new("crate_name_with_dashes").unwrap(), crate2,)] ); } } diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs index d7fc9d4c95cd6..cb2e6cdaa28dc 100644 --- a/crates/base-db/src/lib.rs +++ b/crates/base-db/src/lib.rs @@ -62,6 +62,20 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug { /// The crate graph. #[salsa::input] fn crate_graph(&self) -> Arc; + + // FIXME: Consider removing this, making HirDatabase::target_data_layout an input query + #[salsa::input] + fn data_layout(&self, krate: CrateId) -> TargetLayoutLoadResult; + + #[salsa::input] + fn toolchain(&self, krate: CrateId) -> Option; + + #[salsa::transparent] + fn toolchain_channel(&self, krate: CrateId) -> Option; +} + +fn toolchain_channel(db: &dyn SourceDatabase, krate: CrateId) -> Option { + db.toolchain(krate).as_ref().and_then(|v| ReleaseChannel::from_str(&v.pre)) } fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse { diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index c59aff2a8bbf8..ee39a2790bc37 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -14,7 +14,7 @@ use std::{ use command_group::{CommandGroup, GroupChild}; use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; -use paths::AbsPathBuf; +use paths::{AbsPath, AbsPathBuf}; use rustc_hash::FxHashMap; use serde::Deserialize; use stdx::process::streaming_output; @@ -23,6 +23,7 @@ pub use cargo_metadata::diagnostic::{ Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion, }; +use toolchain::Tool; #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub enum InvocationStrategy { @@ -89,9 +90,10 @@ impl FlycheckHandle { id: usize, sender: Box, config: FlycheckConfig, + sysroot_root: Option, workspace_root: AbsPathBuf, ) -> FlycheckHandle { - let actor = FlycheckActor::new(id, sender, config, workspace_root); + let actor = FlycheckActor::new(id, sender, config, sysroot_root, workspace_root); let (sender, receiver) = unbounded::(); let thread = stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker) .name("Flycheck".to_owned()) @@ -101,13 +103,15 @@ impl FlycheckHandle { } /// Schedule a re-start of the cargo check worker to do a workspace wide check. - pub fn restart_workspace(&self) { - self.sender.send(StateChange::Restart(None)).unwrap(); + pub fn restart_workspace(&self, saved_file: Option) { + self.sender.send(StateChange::Restart { package: None, saved_file }).unwrap(); } /// Schedule a re-start of the cargo check worker to do a package wide check. pub fn restart_for_package(&self, package: String) { - self.sender.send(StateChange::Restart(Some(package))).unwrap(); + self.sender + .send(StateChange::Restart { package: Some(package), saved_file: None }) + .unwrap(); } /// Stop this cargo check worker. @@ -158,7 +162,7 @@ pub enum Progress { } enum StateChange { - Restart(Option), + Restart { package: Option, saved_file: Option }, Cancel, } @@ -171,6 +175,7 @@ struct FlycheckActor { /// Either the workspace root of the workspace we are flychecking, /// or the project root of the project. root: AbsPathBuf, + sysroot_root: Option, /// CargoHandle exists to wrap around the communication needed to be able to /// run `cargo check` without blocking. Currently the Rust standard library /// doesn't provide a way to read sub-process output without blocking, so we @@ -184,15 +189,25 @@ enum Event { CheckEvent(Option), } +const SAVED_FILE_PLACEHOLDER: &str = "$saved_file"; + impl FlycheckActor { fn new( id: usize, sender: Box, config: FlycheckConfig, + sysroot_root: Option, workspace_root: AbsPathBuf, ) -> FlycheckActor { tracing::info!(%id, ?workspace_root, "Spawning flycheck"); - FlycheckActor { id, sender, config, root: workspace_root, command_handle: None } + FlycheckActor { + id, + sender, + config, + sysroot_root, + root: workspace_root, + command_handle: None, + } } fn report_progress(&self, progress: Progress) { @@ -218,7 +233,7 @@ impl FlycheckActor { tracing::debug!(flycheck_id = self.id, "flycheck cancelled"); self.cancel_check_process(); } - Event::RequestStateChange(StateChange::Restart(package)) => { + Event::RequestStateChange(StateChange::Restart { package, saved_file }) => { // Cancel the previously spawned process self.cancel_check_process(); while let Ok(restart) = inbox.recv_timeout(Duration::from_millis(50)) { @@ -228,7 +243,11 @@ impl FlycheckActor { } } - let command = self.check_command(package.as_deref()); + let command = + match self.check_command(package.as_deref(), saved_file.as_deref()) { + Some(c) => c, + None => continue, + }; let formatted_command = format!("{:?}", command); tracing::debug!(?command, "will restart flycheck"); @@ -302,7 +321,14 @@ impl FlycheckActor { } } - fn check_command(&self, package: Option<&str>) -> Command { + /// Construct a `Command` object for checking the user's code. If the user + /// has specified a custom command with placeholders that we cannot fill, + /// return None. + fn check_command( + &self, + package: Option<&str>, + saved_file: Option<&AbsPath>, + ) -> Option { let (mut cmd, args) = match &self.config { FlycheckConfig::CargoCommand { command, @@ -316,7 +342,10 @@ impl FlycheckActor { ansi_color_output, target_dir, } => { - let mut cmd = Command::new(toolchain::cargo()); + let mut cmd = Command::new(Tool::Cargo.path()); + if let Some(sysroot_root) = &self.sysroot_root { + cmd.env("RUSTUP_TOOLCHAIN", AsRef::::as_ref(sysroot_root)); + } cmd.arg(command); cmd.current_dir(&self.root); @@ -355,7 +384,7 @@ impl FlycheckActor { cmd.arg("--target-dir").arg(target_dir); } cmd.envs(extra_env); - (cmd, extra_args) + (cmd, extra_args.clone()) } FlycheckConfig::CustomCommand { command, @@ -384,12 +413,34 @@ impl FlycheckActor { } } - (cmd, args) + if args.contains(&SAVED_FILE_PLACEHOLDER.to_owned()) { + // If the custom command has a $saved_file placeholder, and + // we're saving a file, replace the placeholder in the arguments. + if let Some(saved_file) = saved_file { + let args = args + .iter() + .map(|arg| { + if arg == SAVED_FILE_PLACEHOLDER { + saved_file.to_string() + } else { + arg.clone() + } + }) + .collect(); + (cmd, args) + } else { + // The custom command has a $saved_file placeholder, + // but we had an IDE event that wasn't a file save. Do nothing. + return None; + } + } else { + (cmd, args.clone()) + } } }; cmd.args(args); - cmd + Some(cmd) } fn send(&self, check_task: Message) { diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs index c91a5497262b7..519706c65f29b 100644 --- a/crates/hir-def/src/attr.rs +++ b/crates/hir-def/src/attr.rs @@ -377,27 +377,39 @@ impl AttrsWithOwner { AttrDefId::GenericParamId(it) => match it { GenericParamId::ConstParamId(it) => { let src = it.parent().child_source(db); - RawAttrs::from_attrs_owner( - db.upcast(), - src.with_value(&src.value[it.local_id()]), - db.span_map(src.file_id).as_ref(), - ) + // FIXME: We should be never getting `None` here. + match src.value.get(it.local_id()) { + Some(val) => RawAttrs::from_attrs_owner( + db.upcast(), + src.with_value(val), + db.span_map(src.file_id).as_ref(), + ), + None => RawAttrs::EMPTY, + } } GenericParamId::TypeParamId(it) => { let src = it.parent().child_source(db); - RawAttrs::from_attrs_owner( - db.upcast(), - src.with_value(&src.value[it.local_id()]), - db.span_map(src.file_id).as_ref(), - ) + // FIXME: We should be never getting `None` here. + match src.value.get(it.local_id()) { + Some(val) => RawAttrs::from_attrs_owner( + db.upcast(), + src.with_value(val), + db.span_map(src.file_id).as_ref(), + ), + None => RawAttrs::EMPTY, + } } GenericParamId::LifetimeParamId(it) => { let src = it.parent.child_source(db); - RawAttrs::from_attrs_owner( - db.upcast(), - src.with_value(&src.value[it.local_id]), - db.span_map(src.file_id).as_ref(), - ) + // FIXME: We should be never getting `None` here. + match src.value.get(it.local_id) { + Some(val) => RawAttrs::from_attrs_owner( + db.upcast(), + src.with_value(val), + db.span_map(src.file_id).as_ref(), + ), + None => RawAttrs::EMPTY, + } } }, AttrDefId::ExternBlockId(it) => attrs_from_item_tree_loc(db, it), diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs index 29ac666277d0d..5dc5fedd23070 100644 --- a/crates/hir-def/src/body/lower.rs +++ b/crates/hir-def/src/body/lower.rs @@ -416,6 +416,11 @@ impl ExprCollector<'_> { let expr = e.expr().map(|e| self.collect_expr(e)); self.alloc_expr(Expr::Return { expr }, syntax_ptr) } + ast::Expr::BecomeExpr(e) => { + let expr = + e.expr().map(|e| self.collect_expr(e)).unwrap_or_else(|| self.missing_expr()); + self.alloc_expr(Expr::Become { expr }, syntax_ptr) + } ast::Expr::YieldExpr(e) => { self.is_lowering_coroutine = true; let expr = e.expr().map(|e| self.collect_expr(e)); @@ -1000,10 +1005,6 @@ impl ExprCollector<'_> { krate: *krate, }); } - Some(ExpandError::RecursionOverflowPoisoned) => { - // Recursion limit has been reached in the macro expansion tree, but not in - // this very macro call. Don't add diagnostics to avoid duplication. - } Some(err) => { self.source_map.diagnostics.push(BodyDiagnostic::MacroError { node: InFile::new(outer_file, syntax_ptr), @@ -1112,7 +1113,7 @@ impl ExprCollector<'_> { statements.push(Statement::Expr { expr, has_semi }); } } - ast::Stmt::Item(_item) => (), + ast::Stmt::Item(_item) => statements.push(Statement::Item), } } diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs index 4afb408651703..7007dea638ef9 100644 --- a/crates/hir-def/src/body/pretty.rs +++ b/crates/hir-def/src/body/pretty.rs @@ -261,6 +261,11 @@ impl Printer<'_> { self.print_expr(*expr); } } + Expr::Become { expr } => { + w!(self, "become"); + self.whitespace(); + self.print_expr(*expr); + } Expr::Yield { expr } => { w!(self, "yield"); if let Some(expr) = expr { @@ -623,6 +628,7 @@ impl Printer<'_> { } wln!(self); } + Statement::Item => (), } } diff --git a/crates/hir-def/src/body/scope.rs b/crates/hir-def/src/body/scope.rs index ab623250d4072..69b82ae871a4e 100644 --- a/crates/hir-def/src/body/scope.rs +++ b/crates/hir-def/src/body/scope.rs @@ -197,6 +197,7 @@ fn compute_block_scopes( Statement::Expr { expr, .. } => { compute_expr_scopes(*expr, body, scopes, scope); } + Statement::Item => (), } } if let Some(expr) = tail { diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs index 7ce05b64d022e..f506864902c47 100644 --- a/crates/hir-def/src/data.rs +++ b/crates/hir-def/src/data.rs @@ -634,7 +634,6 @@ impl<'a> AssocItemCollector<'a> { attr, ) { Ok(ResolvedAttr::Macro(call_id)) => { - self.attr_calls.push((ast_id, call_id)); // If proc attribute macro expansion is disabled, skip expanding it here if !self.db.expand_proc_attr_macros() { continue 'attrs; @@ -647,10 +646,21 @@ impl<'a> AssocItemCollector<'a> { // disabled. This is analogous to the handling in // `DefCollector::collect_macros`. if exp.is_dummy() { + self.diagnostics.push(DefDiagnostic::unresolved_proc_macro( + self.module_id.local_id, + loc.kind, + loc.def.krate, + )); + + continue 'attrs; + } + if exp.is_disabled() { continue 'attrs; } } + self.attr_calls.push((ast_id, call_id)); + let res = self.expander.enter_expand_id::(self.db, call_id); self.collect_macro_items(res, &|| loc.kind.clone()); diff --git a/crates/hir-def/src/expander.rs b/crates/hir-def/src/expander.rs index b83feeedc34c1..b99df1ed59348 100644 --- a/crates/hir-def/src/expander.rs +++ b/crates/hir-def/src/expander.rs @@ -140,13 +140,11 @@ impl Expander { // The overflow error should have been reported when it occurred (see the next branch), // so don't return overflow error here to avoid diagnostics duplication. cov_mark::hit!(overflow_but_not_me); - return ExpandResult::only_err(ExpandError::RecursionOverflowPoisoned); + return ExpandResult::ok(None); } else if self.recursion_limit.check(self.recursion_depth as usize + 1).is_err() { self.recursion_depth = u32::MAX; cov_mark::hit!(your_stack_belongs_to_me); - return ExpandResult::only_err(ExpandError::other( - "reached recursion limit during macro expansion", - )); + return ExpandResult::only_err(ExpandError::RecursionOverflow); } let ExpandResult { value, err } = op(self); diff --git a/crates/hir-def/src/find_path.rs b/crates/hir-def/src/find_path.rs index 2e137f67b4c2a..26247ba5b507d 100644 --- a/crates/hir-def/src/find_path.rs +++ b/crates/hir-def/src/find_path.rs @@ -447,18 +447,25 @@ fn select_best_path( } const STD_CRATES: [Name; 3] = [known::std, known::core, known::alloc]; - let choose = |new_path: (ModPath, _), old_path: (ModPath, _)| { - let new_has_prelude = new_path.0.segments().iter().any(|seg| seg == &known::prelude); - let old_has_prelude = old_path.0.segments().iter().any(|seg| seg == &known::prelude); + let choose = |new: (ModPath, _), old: (ModPath, _)| { + let (new_path, _) = &new; + let (old_path, _) = &old; + let new_has_prelude = new_path.segments().iter().any(|seg| seg == &known::prelude); + let old_has_prelude = old_path.segments().iter().any(|seg| seg == &known::prelude); match (new_has_prelude, old_has_prelude, prefer_prelude) { - (true, false, true) | (false, true, false) => new_path, - (true, false, false) | (false, true, true) => old_path, - // no prelude difference in the paths, so pick the smaller one + (true, false, true) | (false, true, false) => new, + (true, false, false) | (false, true, true) => old, + // no prelude difference in the paths, so pick the shorter one (true, true, _) | (false, false, _) => { - if new_path.0.len() < old_path.0.len() { - new_path + let new_path_is_shorter = new_path + .len() + .cmp(&old_path.len()) + .then_with(|| new_path.textual_len().cmp(&old_path.textual_len())) + .is_lt(); + if new_path_is_shorter { + new } else { - old_path + old } } } @@ -469,8 +476,8 @@ fn select_best_path( let rank = match prefer_no_std { false => |name: &Name| match name { name if name == &known::core => 0, - name if name == &known::alloc => 0, - name if name == &known::std => 1, + name if name == &known::alloc => 1, + name if name == &known::std => 2, _ => unreachable!(), }, true => |name: &Name| match name { @@ -1539,4 +1546,38 @@ pub mod foo { "krate::prelude::Foo", ); } + + #[test] + fn respect_segment_length() { + check_found_path( + r#" +//- /main.rs crate:main deps:petgraph +$0 +//- /petgraph.rs crate:petgraph +pub mod graph { + pub use crate::graph_impl::{ + NodeIndex + }; +} + +mod graph_impl { + pub struct NodeIndex(Ix); +} + +pub mod stable_graph { + #[doc(no_inline)] + pub use crate::graph::{NodeIndex}; +} + +pub mod prelude { + #[doc(no_inline)] + pub use crate::graph::{NodeIndex}; +} +"#, + "petgraph::graph::NodeIndex", + "petgraph::graph::NodeIndex", + "petgraph::graph::NodeIndex", + "petgraph::graph::NodeIndex", + ); + } } diff --git a/crates/hir-def/src/hir.rs b/crates/hir-def/src/hir.rs index ac44d379415c0..34b2910b4f5e5 100644 --- a/crates/hir-def/src/hir.rs +++ b/crates/hir-def/src/hir.rs @@ -182,6 +182,7 @@ pub enum Expr { tail: Option, }, Const(ConstBlockId), + // FIXME: Fold this into Block with an unsafe flag? Unsafe { id: Option, statements: Box<[Statement]>, @@ -216,6 +217,9 @@ pub enum Expr { Return { expr: Option, }, + Become { + expr: ExprId, + }, Yield { expr: Option, }, @@ -349,6 +353,9 @@ pub enum Statement { expr: ExprId, has_semi: bool, }, + // At the moment, we only use this to figure out if a return expression + // is really the last statement of a block. See #16566 + Item, } impl Expr { @@ -382,6 +389,7 @@ impl Expr { } } Statement::Expr { expr: expression, .. } => f(*expression), + Statement::Item => (), } } if let &Some(expr) = tail { @@ -410,6 +418,7 @@ impl Expr { f(expr); } } + Expr::Become { expr } => f(*expr), Expr::RecordLit { fields, spread, .. } => { for field in fields.iter() { f(field.expr); diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs index 0909d8c835443..63f211022c975 100644 --- a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs +++ b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs @@ -33,7 +33,7 @@ m!(&k"); "#, expect![[r#" macro_rules! m { ($i:literal) => {}; } -/* error: invalid token tree */"#]], +/* error: mismatched delimiters */"#]], ); } diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/meta_syntax.rs b/crates/hir-def/src/macro_expansion_tests/mbe/meta_syntax.rs index e875950e4e5f9..2d289b7683389 100644 --- a/crates/hir-def/src/macro_expansion_tests/mbe/meta_syntax.rs +++ b/crates/hir-def/src/macro_expansion_tests/mbe/meta_syntax.rs @@ -68,26 +68,26 @@ m2!(); "#, expect![[r#" macro_rules! i1 { invalid } -/* error: invalid macro definition: expected subtree */ +/* error: macro definition has parse errors */ macro_rules! e1 { $i:ident => () } -/* error: invalid macro definition: expected subtree */ +/* error: macro definition has parse errors */ macro_rules! e2 { ($i:ident) () } -/* error: invalid macro definition: expected `=` */ +/* error: macro definition has parse errors */ macro_rules! e3 { ($(i:ident)_) => () } -/* error: invalid macro definition: invalid repeat */ +/* error: macro definition has parse errors */ macro_rules! f1 { ($i) => ($i) } -/* error: invalid macro definition: missing fragment specifier */ +/* error: macro definition has parse errors */ macro_rules! f2 { ($i:) => ($i) } -/* error: invalid macro definition: missing fragment specifier */ +/* error: macro definition has parse errors */ macro_rules! f3 { ($i:_) => () } -/* error: invalid macro definition: missing fragment specifier */ +/* error: macro definition has parse errors */ macro_rules! m1 { ($$i) => () } -/* error: invalid macro definition: `$$` is not allowed on the pattern side */ +/* error: macro definition has parse errors */ macro_rules! m2 { () => ( ${invalid()} ) } -/* error: invalid macro definition: invalid metavariable expression */ +/* error: macro definition has parse errors */ "#]], ) } @@ -137,18 +137,18 @@ macro_rules! m9 { ($($($($i:ident)?)*)+) => {}; } macro_rules! mA { ($($($($i:ident)+)?)*) => {}; } macro_rules! mB { ($($($($i:ident)+)*)?) => {}; } -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ -/* error: invalid macro definition: empty token tree in repetition */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ +/* error: macro definition has parse errors */ "#]], ); } diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/metavar_expr.rs b/crates/hir-def/src/macro_expansion_tests/mbe/metavar_expr.rs index 6560d0ec4664b..bf70119838766 100644 --- a/crates/hir-def/src/macro_expansion_tests/mbe/metavar_expr.rs +++ b/crates/hir-def/src/macro_expansion_tests/mbe/metavar_expr.rs @@ -275,9 +275,9 @@ macro_rules! depth_too_large { } fn test() { - /* error: invalid macro definition: invalid metavariable expression */; - /* error: invalid macro definition: invalid metavariable expression */; - /* error: invalid macro definition: invalid metavariable expression */; + /* error: macro definition has parse errors */; + /* error: macro definition has parse errors */; + /* error: macro definition has parse errors */; } "#]], ); diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs b/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs index 6717ee1aa5fdf..4aad53c3bd71c 100644 --- a/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs +++ b/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs @@ -1090,3 +1090,57 @@ fn main() { "#]], ); } + +#[test] +fn regression_16529() { + check( + r#" +mod any { + #[macro_export] + macro_rules! nameable { + { + struct $name:ident[$a:lifetime] + } => { + $crate::any::nameable! { + struct $name[$a] + a + } + }; + { + struct $name:ident[$a:lifetime] + a + } => {}; + } + pub use nameable; + + nameable! { + Name['a] + } +} +"#, + expect![[r#" +mod any { + #[macro_export] + macro_rules! nameable { + { + struct $name:ident[$a:lifetime] + } => { + $crate::any::nameable! { + struct $name[$a] + a + } + }; + { + struct $name:ident[$a:lifetime] + a + } => {}; + } + pub use nameable; + + /* error: unexpected token in input */$crate::any::nameable! { + struct $name[$a]a + } +} +"#]], + ); +} diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/tt_conversion.rs b/crates/hir-def/src/macro_expansion_tests/mbe/tt_conversion.rs index ae56934f632f1..362c189f6a734 100644 --- a/crates/hir-def/src/macro_expansion_tests/mbe/tt_conversion.rs +++ b/crates/hir-def/src/macro_expansion_tests/mbe/tt_conversion.rs @@ -97,8 +97,8 @@ m2!(x macro_rules! m1 { ($x:ident) => { ($x } } macro_rules! m2 { ($x:ident) => {} } -/* error: invalid macro definition: expected subtree */ -/* error: invalid token tree */ +/* error: macro definition has parse errors */ +/* error: mismatched delimiters */ "#]], ) } diff --git a/crates/hir-def/src/macro_expansion_tests/mod.rs b/crates/hir-def/src/macro_expansion_tests/mod.rs index fc5a6e80a427d..23b10cfd8e6c7 100644 --- a/crates/hir-def/src/macro_expansion_tests/mod.rs +++ b/crates/hir-def/src/macro_expansion_tests/mod.rs @@ -58,6 +58,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream name: "identity_when_valid".into(), kind: ProcMacroKind::Attr, expander: sync::Arc::new(IdentityWhenValidProcMacroExpander), + disabled: false, }, )]; let db = TestDB::with_files_extra_proc_macros(ra_fixture, extra_proc_macros); diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs index 21cc28f1b3d0d..88838f58fe787 100644 --- a/crates/hir-def/src/nameres/collector.rs +++ b/crates/hir-def/src/nameres/collector.rs @@ -11,7 +11,7 @@ use either::Either; use hir_expand::{ ast_id_map::FileAstId, attrs::{Attr, AttrId}, - builtin_attr_macro::find_builtin_attr, + builtin_attr_macro::{find_builtin_attr, BuiltinAttrExpander}, builtin_derive_macro::find_builtin_derive, builtin_fn_macro::find_builtin_macro, name::{name, AsName, Name}, @@ -98,9 +98,13 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, def_map: DefMap, tree_id: TreeI }; ( name.as_name(), - CustomProcMacroExpander::new(hir_expand::proc_macro::ProcMacroId( - idx as u32, - )), + if it.disabled { + CustomProcMacroExpander::disabled() + } else { + CustomProcMacroExpander::new( + hir_expand::proc_macro::ProcMacroId::new(idx as u32), + ) + }, ) }) .collect()) @@ -604,9 +608,6 @@ impl DefCollector<'_> { id: ItemTreeId, fn_id: FunctionId, ) { - if self.def_map.block.is_some() { - return; - } let kind = def.kind.to_basedb_kind(); let (expander, kind) = match self.proc_macros.as_ref().map(|it| it.iter().find(|(n, _)| n == &def.name)) { @@ -1120,9 +1121,16 @@ impl DefCollector<'_> { let mut push_resolved = |directive: &MacroDirective, call_id| { resolved.push((directive.module_id, directive.depth, directive.container, call_id)); }; + + #[derive(PartialEq, Eq)] + enum Resolved { + Yes, + No, + } + let mut res = ReachedFixedPoint::Yes; // Retain unresolved macros after this round of resolution. - macros.retain(|directive| { + let mut retain = |directive: &MacroDirective| { let subns = match &directive.kind { MacroDirectiveKind::FnLike { .. } => MacroSubNs::Bang, MacroDirectiveKind::Attr { .. } | MacroDirectiveKind::Derive { .. } => { @@ -1156,10 +1164,11 @@ impl DefCollector<'_> { self.def_map.modules[directive.module_id] .scope .add_macro_invoc(ast_id.ast_id, call_id); + push_resolved(directive, call_id); res = ReachedFixedPoint::No; - return false; + return Resolved::Yes; } } MacroDirectiveKind::Derive { ast_id, derive_attr, derive_pos, call_site } => { @@ -1198,7 +1207,7 @@ impl DefCollector<'_> { push_resolved(directive, call_id); res = ReachedFixedPoint::No; - return false; + return Resolved::Yes; } } MacroDirectiveKind::Attr { ast_id: file_ast_id, mod_item, attr, tree } => { @@ -1221,7 +1230,7 @@ impl DefCollector<'_> { } .collect(&[*mod_item], directive.container); res = ReachedFixedPoint::No; - false + Resolved::Yes }; if let Some(ident) = path.as_ident() { @@ -1237,13 +1246,18 @@ impl DefCollector<'_> { let def = match resolver_def_id(path.clone()) { Some(def) if def.is_attribute() => def, - _ => return true, + _ => return Resolved::No, }; - if matches!( - def, - MacroDefId { kind: MacroDefKind::BuiltInAttr(expander, _),.. } - if expander.is_derive() - ) { + + if let MacroDefId { + kind: + MacroDefKind::BuiltInAttr( + BuiltinAttrExpander::Derive | BuiltinAttrExpander::DeriveConst, + _, + ), + .. + } = def + { // Resolved to `#[derive]`, we don't actually expand this attribute like // normal (as that would just be an identity expansion with extra output) // Instead we treat derive attributes special and apply them separately. @@ -1316,16 +1330,6 @@ impl DefCollector<'_> { let call_id = attr_macro_as_call_id(self.db, file_ast_id, attr, self.def_map.krate, def); - // If proc attribute macro expansion is disabled, skip expanding it here - if !self.db.expand_proc_attr_macros() { - self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro( - directive.module_id, - self.db.lookup_intern_macro_call(call_id).kind, - def.krate, - )); - return recollect_without(self); - } - // Skip #[test]/#[bench] expansion, which would merely result in more memory usage // due to duplicating functions into macro expansions if matches!( @@ -1337,17 +1341,29 @@ impl DefCollector<'_> { } if let MacroDefKind::ProcMacro(exp, ..) = def.kind { - if exp.is_dummy() { - // If there's no expander for the proc macro (e.g. - // because proc macros are disabled, or building the - // proc macro crate failed), report this and skip - // expansion like we would if it was disabled + // If proc attribute macro expansion is disabled, skip expanding it here + if !self.db.expand_proc_attr_macros() { self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro( directive.module_id, self.db.lookup_intern_macro_call(call_id).kind, def.krate, )); + return recollect_without(self); + } + // If there's no expander for the proc macro (e.g. + // because proc macros are disabled, or building the + // proc macro crate failed), report this and skip + // expansion like we would if it was disabled + if exp.is_dummy() { + self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro( + directive.module_id, + self.db.lookup_intern_macro_call(call_id).kind, + def.krate, + )); + return recollect_without(self); + } + if exp.is_disabled() { return recollect_without(self); } } @@ -1358,12 +1374,13 @@ impl DefCollector<'_> { push_resolved(directive, call_id); res = ReachedFixedPoint::No; - return false; + return Resolved::Yes; } } - true - }); + Resolved::No + }; + macros.retain(|it| retain(it) == Resolved::No); // Attribute resolution can add unresolved macro invocations, so concatenate the lists. macros.extend(mem::take(&mut self.unresolved_macros)); self.unresolved_macros = macros; @@ -1673,7 +1690,11 @@ impl ModCollector<'_, '_> { FunctionLoc { container, id: ItemTreeId::new(self.tree_id, id) }.intern(db); let vis = resolve_vis(def_map, &self.item_tree[it.visibility]); - if self.def_collector.is_proc_macro && self.module_id == DefMap::ROOT { + + if self.def_collector.def_map.block.is_none() + && self.def_collector.is_proc_macro + && self.module_id == DefMap::ROOT + { if let Some(proc_macro) = attrs.parse_proc_macro_decl(&it.name) { self.def_collector.export_proc_macro( proc_macro, @@ -2333,7 +2354,7 @@ impl ModCollector<'_, '_> { resolved_res.resolved_def.take_macros().map(|it| db.macro_def(it)) }, ) { - // FIXME: if there were errors, this mightve been in the eager expansion from an + // FIXME: if there were errors, this might've been in the eager expansion from an // unresolved macro, so we need to push this into late macro resolution. see fixme above if res.err.is_none() { // Legacy macros need to be expanded immediately, so that any macros they produce diff --git a/crates/hir-def/src/nameres/diagnostics.rs b/crates/hir-def/src/nameres/diagnostics.rs index 0a3f7bf7ec3d6..161b2c0599099 100644 --- a/crates/hir-def/src/nameres/diagnostics.rs +++ b/crates/hir-def/src/nameres/diagnostics.rs @@ -103,6 +103,9 @@ impl DefDiagnostic { } // FIXME: Whats the difference between this and unresolved_macro_call + // FIXME: This is used for a lot of things, unresolved proc macros, disabled proc macros, etc + // yet the diagnostic handler in ide-diagnostics has to figure out what happened because this + // struct loses all that information! pub(crate) fn unresolved_proc_macro( container: LocalModuleId, ast: MacroCallKind, diff --git a/crates/hir-expand/src/builtin_fn_macro.rs b/crates/hir-expand/src/builtin_fn_macro.rs index 6d3de0e55d24d..90cd3af75783d 100644 --- a/crates/hir-expand/src/builtin_fn_macro.rs +++ b/crates/hir-expand/src/builtin_fn_macro.rs @@ -446,7 +446,7 @@ fn compile_error_expand( ) -> ExpandResult { let err = match &*tt.token_trees { [tt::TokenTree::Leaf(tt::Leaf::Literal(it))] => match unquote_str(it) { - Some(unquoted) => ExpandError::other(unquoted), + Some(unquoted) => ExpandError::other(unquoted.into_boxed_str()), None => ExpandError::other("`compile_error!` argument must be a string"), }, _ => ExpandError::other("`compile_error!` argument must be a string"), diff --git a/crates/hir-expand/src/change.rs b/crates/hir-expand/src/change.rs index 67b7df198e93e..c6611438e64d8 100644 --- a/crates/hir-expand/src/change.rs +++ b/crates/hir-expand/src/change.rs @@ -1,6 +1,10 @@ //! Defines a unit of change that can applied to the database to get the next //! state. Changes are transactional. -use base_db::{salsa::Durability, CrateGraph, FileChange, SourceDatabaseExt, SourceRoot}; +use base_db::{ + salsa::Durability, CrateGraph, CrateId, FileChange, SourceDatabaseExt, SourceRoot, + TargetLayoutLoadResult, Version, +}; +use la_arena::RawIdx; use span::FileId; use triomphe::Arc; @@ -10,6 +14,8 @@ use crate::{db::ExpandDatabase, proc_macro::ProcMacros}; pub struct Change { pub source_change: FileChange, pub proc_macros: Option, + pub toolchains: Option>>, + pub target_data_layouts: Option>, } impl Change { @@ -22,6 +28,24 @@ impl Change { if let Some(proc_macros) = self.proc_macros { db.set_proc_macros_with_durability(Arc::new(proc_macros), Durability::HIGH); } + if let Some(target_data_layouts) = self.target_data_layouts { + for (id, val) in target_data_layouts.into_iter().enumerate() { + db.set_data_layout_with_durability( + CrateId::from_raw(RawIdx::from(id as u32)), + val, + Durability::HIGH, + ); + } + } + if let Some(toolchains) = self.toolchains { + for (id, val) in toolchains.into_iter().enumerate() { + db.set_toolchain_with_durability( + CrateId::from_raw(RawIdx::from(id as u32)), + val, + Durability::HIGH, + ); + } + } } pub fn change_file(&mut self, file_id: FileId, new_text: Option>) { @@ -36,6 +60,14 @@ impl Change { self.proc_macros = Some(proc_macros); } + pub fn set_toolchains(&mut self, toolchains: Vec>) { + self.toolchains = Some(toolchains); + } + + pub fn set_target_data_layouts(&mut self, target_data_layouts: Vec) { + self.target_data_layouts = Some(target_data_layouts); + } + pub fn set_roots(&mut self, roots: Vec) { self.source_change.set_roots(roots) } diff --git a/crates/hir-expand/src/db.rs b/crates/hir-expand/src/db.rs index 6a288cf91979a..7b62eaa0289dc 100644 --- a/crates/hir-expand/src/db.rs +++ b/crates/hir-expand/src/db.rs @@ -108,7 +108,7 @@ pub trait ExpandDatabase: SourceDatabase { fn macro_arg( &self, id: MacroCallId, - ) -> ValueResult, SyntaxFixupUndoInfo)>, Arc>>; + ) -> ValueResult<(Arc, SyntaxFixupUndoInfo), Arc>>; /// Fetches the expander for this macro. #[salsa::transparent] #[salsa::invoke(TokenExpander::macro_expander)] @@ -326,58 +326,77 @@ fn macro_arg( db: &dyn ExpandDatabase, id: MacroCallId, // FIXME: consider the following by putting fixup info into eager call info args - // ) -> ValueResult>, Arc>> { -) -> ValueResult, SyntaxFixupUndoInfo)>, Arc>> { - let mismatched_delimiters = |arg: &SyntaxNode| { - let first = arg.first_child_or_token().map_or(T![.], |it| it.kind()); - let last = arg.last_child_or_token().map_or(T![.], |it| it.kind()); - let well_formed_tt = - matches!((first, last), (T!['('], T![')']) | (T!['['], T![']']) | (T!['{'], T!['}'])); - if !well_formed_tt { - // Don't expand malformed (unbalanced) macro invocations. This is - // less than ideal, but trying to expand unbalanced macro calls - // sometimes produces pathological, deeply nested code which breaks - // all kinds of things. - // - // Some day, we'll have explicit recursion counters for all - // recursive things, at which point this code might be removed. - cov_mark::hit!(issue9358_bad_macro_stack_overflow); - Some(Arc::new(Box::new([SyntaxError::new( - "unbalanced token tree".to_owned(), - arg.text_range(), - )]) as Box<[_]>)) - } else { - None - } - }; + // ) -> ValueResult, Arc>> { +) -> ValueResult<(Arc, SyntaxFixupUndoInfo), Arc>> { let loc = db.lookup_intern_macro_call(id); if let Some(EagerCallInfo { arg, .. }) = matches!(loc.def.kind, MacroDefKind::BuiltInEager(..)) .then(|| loc.eager.as_deref()) .flatten() { - ValueResult::ok(Some((arg.clone(), SyntaxFixupUndoInfo::NONE))) + ValueResult::ok((arg.clone(), SyntaxFixupUndoInfo::NONE)) } else { let (parse, map) = parse_with_map(db, loc.kind.file_id()); let root = parse.syntax_node(); let syntax = match loc.kind { MacroCallKind::FnLike { ast_id, .. } => { + let dummy_tt = |kind| { + ( + Arc::new(tt::Subtree { + delimiter: tt::Delimiter { + open: loc.call_site, + close: loc.call_site, + kind, + }, + token_trees: Box::default(), + }), + SyntaxFixupUndoInfo::default(), + ) + }; + let node = &ast_id.to_ptr(db).to_node(&root); let offset = node.syntax().text_range().start(); - match node.token_tree() { - Some(tt) => { - let tt = tt.syntax(); - if let Some(e) = mismatched_delimiters(tt) { - return ValueResult::only_err(e); - } - tt.clone() - } - None => { - return ValueResult::only_err(Arc::new(Box::new([ - SyntaxError::new_at_offset("missing token tree".to_owned(), offset), - ]))); - } + let Some(tt) = node.token_tree() else { + return ValueResult::new( + dummy_tt(tt::DelimiterKind::Invisible), + Arc::new(Box::new([SyntaxError::new_at_offset( + "missing token tree".to_owned(), + offset, + )])), + ); + }; + let first = tt.left_delimiter_token().map(|it| it.kind()).unwrap_or(T!['(']); + let last = tt.right_delimiter_token().map(|it| it.kind()).unwrap_or(T![.]); + + let mismatched_delimiters = !matches!( + (first, last), + (T!['('], T![')']) | (T!['['], T![']']) | (T!['{'], T!['}']) + ); + if mismatched_delimiters { + // Don't expand malformed (unbalanced) macro invocations. This is + // less than ideal, but trying to expand unbalanced macro calls + // sometimes produces pathological, deeply nested code which breaks + // all kinds of things. + // + // So instead, we'll return an empty subtree here + cov_mark::hit!(issue9358_bad_macro_stack_overflow); + + let kind = match first { + _ if loc.def.is_proc_macro() => tt::DelimiterKind::Invisible, + T!['('] => tt::DelimiterKind::Parenthesis, + T!['['] => tt::DelimiterKind::Bracket, + T!['{'] => tt::DelimiterKind::Brace, + _ => tt::DelimiterKind::Invisible, + }; + return ValueResult::new( + dummy_tt(kind), + Arc::new(Box::new([SyntaxError::new_at_offset( + "mismatched delimiters".to_owned(), + offset, + )])), + ); } + tt.syntax().clone() } MacroCallKind::Derive { ast_id, .. } => { ast_id.to_ptr(db).to_node(&root).syntax().clone() @@ -427,15 +446,15 @@ fn macro_arg( if matches!(loc.def.kind, MacroDefKind::BuiltInEager(..)) { match parse.errors() { - [] => ValueResult::ok(Some((Arc::new(tt), undo_info))), + [] => ValueResult::ok((Arc::new(tt), undo_info)), errors => ValueResult::new( - Some((Arc::new(tt), undo_info)), + (Arc::new(tt), undo_info), // Box::<[_]>::from(res.errors()), not stable yet Arc::new(errors.to_vec().into_boxed_slice()), ), } } else { - ValueResult::ok(Some((Arc::new(tt), undo_info))) + ValueResult::ok((Arc::new(tt), undo_info)) } } } @@ -519,21 +538,20 @@ fn macro_expand( expander.expand(db, macro_call_id, &node, map.as_ref()) } _ => { - let ValueResult { value, err } = db.macro_arg(macro_call_id); - let Some((macro_arg, undo_info)) = value else { - return ExpandResult { - value: CowArc::Owned(tt::Subtree { - delimiter: tt::Delimiter::invisible_spanned(loc.call_site), - token_trees: Box::new([]), - }), - // FIXME: We should make sure to enforce an invariant that invalid macro - // calls do not reach this call path! - err: Some(ExpandError::other("invalid token tree")), - }; + let ValueResult { value: (macro_arg, undo_info), err } = db.macro_arg(macro_call_id); + let format_parse_err = |err: Arc>| { + let mut buf = String::new(); + for err in &**err { + use std::fmt::Write; + _ = write!(buf, "{}, ", err); + } + buf.pop(); + buf.pop(); + ExpandError::other(buf) }; let arg = &*macro_arg; - match loc.def.kind { + let res = match loc.def.kind { MacroDefKind::Declarative(id) => { db.decl_macro_expander(loc.def.krate, id).expand(db, arg.clone(), macro_call_id) } @@ -549,16 +567,7 @@ fn macro_expand( MacroDefKind::BuiltInEager(..) if loc.eager.is_none() => { return ExpandResult { value: CowArc::Arc(macro_arg.clone()), - err: err.map(|err| { - let mut buf = String::new(); - for err in &**err { - use std::fmt::Write; - _ = write!(buf, "{}, ", err); - } - buf.pop(); - buf.pop(); - ExpandError::other(buf) - }), + err: err.map(format_parse_err), }; } MacroDefKind::BuiltInEager(it, _) => { @@ -570,6 +579,11 @@ fn macro_expand( res } _ => unreachable!(), + }; + ExpandResult { + value: res.value, + // if the arg had parse errors, show them instead of the expansion errors + err: err.map(format_parse_err).or(res.err), } } }; @@ -597,17 +611,7 @@ fn macro_expand( fn expand_proc_macro(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult> { let loc = db.lookup_intern_macro_call(id); - let Some((macro_arg, undo_info)) = db.macro_arg(id).value else { - return ExpandResult { - value: Arc::new(tt::Subtree { - delimiter: tt::Delimiter::invisible_spanned(loc.call_site), - token_trees: Box::new([]), - }), - // FIXME: We should make sure to enforce an invariant that invalid macro - // calls do not reach this call path! - err: Some(ExpandError::other("invalid token tree")), - }; - }; + let (macro_arg, undo_info) = db.macro_arg(id).value; let expander = match loc.def.kind { MacroDefKind::ProcMacro(expander, ..) => expander, diff --git a/crates/hir-expand/src/declarative.rs b/crates/hir-expand/src/declarative.rs index 37084ee8b93c9..6874336cd2d05 100644 --- a/crates/hir-expand/src/declarative.rs +++ b/crates/hir-expand/src/declarative.rs @@ -31,7 +31,7 @@ impl DeclarativeMacroExpander { call_id: MacroCallId, ) -> ExpandResult { let loc = db.lookup_intern_macro_call(call_id); - let toolchain = &db.crate_graph()[loc.def.krate].toolchain; + let toolchain = db.toolchain(loc.def.krate); let new_meta_vars = toolchain.as_ref().map_or(false, |version| { REQUIREMENT.get_or_init(|| VersionReq::parse(">=1.76").unwrap()).matches( &base_db::Version { @@ -44,9 +44,9 @@ impl DeclarativeMacroExpander { ) }); match self.mac.err() { - Some(e) => ExpandResult::new( + Some(_) => ExpandResult::new( tt::Subtree::empty(tt::DelimSpan { open: loc.call_site, close: loc.call_site }), - ExpandError::other(format!("invalid macro definition: {e}")), + ExpandError::MacroDefinition, ), None => self .mac @@ -67,7 +67,7 @@ impl DeclarativeMacroExpander { krate: CrateId, call_site: Span, ) -> ExpandResult { - let toolchain = &db.crate_graph()[krate].toolchain; + let toolchain = db.toolchain(krate); let new_meta_vars = toolchain.as_ref().map_or(false, |version| { REQUIREMENT.get_or_init(|| VersionReq::parse(">=1.76").unwrap()).matches( &base_db::Version { @@ -80,9 +80,9 @@ impl DeclarativeMacroExpander { ) }); match self.mac.err() { - Some(e) => ExpandResult::new( + Some(_) => ExpandResult::new( tt::Subtree::empty(tt::DelimSpan { open: call_site, close: call_site }), - ExpandError::other(format!("invalid macro definition: {e}")), + ExpandError::MacroDefinition, ), None => self.mac.expand(&tt, |_| (), new_meta_vars, call_site).map_err(Into::into), } @@ -119,7 +119,7 @@ impl DeclarativeMacroExpander { _ => None, } }; - let toolchain = crate_data.toolchain.as_ref(); + let toolchain = db.toolchain(def_crate); let new_meta_vars = toolchain.as_ref().map_or(false, |version| { REQUIREMENT.get_or_init(|| VersionReq::parse(">=1.76").unwrap()).matches( &base_db::Version { diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs index fd028182faf6f..020ca75d80cb2 100644 --- a/crates/hir-expand/src/lib.rs +++ b/crates/hir-expand/src/lib.rs @@ -44,7 +44,6 @@ use crate::{ builtin_derive_macro::BuiltinDeriveExpander, builtin_fn_macro::{BuiltinFnLikeExpander, EagerExpander}, db::{ExpandDatabase, TokenExpander}, - fixup::SyntaxFixupUndoInfo, hygiene::SyntaxContextData, mod_path::ModPath, proc_macro::{CustomProcMacroExpander, ProcMacroKind}, @@ -129,8 +128,11 @@ pub type ExpandResult = ValueResult; #[derive(Debug, PartialEq, Eq, Clone, Hash)] pub enum ExpandError { UnresolvedProcMacro(CrateId), + /// The macro expansion is disabled. + MacroDisabled, + MacroDefinition, Mbe(mbe::ExpandError), - RecursionOverflowPoisoned, + RecursionOverflow, Other(Box>), ProcMacroPanic(Box>), } @@ -152,14 +154,14 @@ impl fmt::Display for ExpandError { match self { ExpandError::UnresolvedProcMacro(_) => f.write_str("unresolved proc-macro"), ExpandError::Mbe(it) => it.fmt(f), - ExpandError::RecursionOverflowPoisoned => { - f.write_str("overflow expanding the original macro") - } + ExpandError::RecursionOverflow => f.write_str("overflow expanding the original macro"), ExpandError::ProcMacroPanic(it) => { f.write_str("proc-macro panicked: ")?; f.write_str(it) } ExpandError::Other(it) => f.write_str(it), + ExpandError::MacroDisabled => f.write_str("macro disabled"), + ExpandError::MacroDefinition => f.write_str("macro definition has parse errors"), } } } @@ -225,8 +227,8 @@ pub enum MacroCallKind { }, Attr { ast_id: AstId, - // FIXME: This is being interned, subtrees can vary quickly differ just slightly causing - // leakage problems here + // FIXME: This shouldn't be here, we can derive this from `invoc_attr_index` + // but we need to fix the `cfg_attr` handling first. attr_args: Option>, /// Syntactical index of the invoking `#[attribute]`. /// @@ -758,15 +760,7 @@ impl ExpansionInfo { let (parse, exp_map) = db.parse_macro_expansion(macro_file).value; let expanded = InMacroFile { file_id: macro_file, value: parse.syntax_node() }; - let (macro_arg, _) = db.macro_arg(macro_file.macro_call_id).value.unwrap_or_else(|| { - ( - Arc::new(tt::Subtree { - delimiter: tt::Delimiter::invisible_spanned(loc.call_site), - token_trees: Box::new([]), - }), - SyntaxFixupUndoInfo::NONE, - ) - }); + let (macro_arg, _) = db.macro_arg(macro_file.macro_call_id).value; let def = loc.def.ast_id().left().and_then(|id| { let def_tt = match id.to_node(db) { diff --git a/crates/hir-expand/src/mod_path.rs b/crates/hir-expand/src/mod_path.rs index b64c3549e421e..136b0935be277 100644 --- a/crates/hir-expand/src/mod_path.rs +++ b/crates/hir-expand/src/mod_path.rs @@ -94,6 +94,21 @@ impl ModPath { } } + pub fn textual_len(&self) -> usize { + let base = match self.kind { + PathKind::Plain => 0, + PathKind::Super(0) => "self".len(), + PathKind::Super(i) => "super".len() * i as usize, + PathKind::Crate => "crate".len(), + PathKind::Abs => 0, + PathKind::DollarCrate(_) => "$crate".len(), + }; + self.segments() + .iter() + .map(|segment| segment.as_str().map_or(0, str::len)) + .fold(base, core::ops::Add::add) + } + pub fn is_ident(&self) -> bool { self.as_ident().is_some() } diff --git a/crates/hir-expand/src/proc_macro.rs b/crates/hir-expand/src/proc_macro.rs index 70b47fc54b11c..ca6fc0afe2d7d 100644 --- a/crates/hir-expand/src/proc_macro.rs +++ b/crates/hir-expand/src/proc_macro.rs @@ -12,7 +12,13 @@ use syntax::SmolStr; use crate::{db::ExpandDatabase, tt, ExpandError, ExpandResult}; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct ProcMacroId(pub u32); +pub struct ProcMacroId(u32); + +impl ProcMacroId { + pub fn new(u32: u32) -> Self { + ProcMacroId(u32) + } +} #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)] pub enum ProcMacroKind { @@ -49,6 +55,7 @@ pub struct ProcMacro { pub name: SmolStr, pub kind: ProcMacroKind, pub expander: sync::Arc, + pub disabled: bool, } #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] @@ -56,20 +63,35 @@ pub struct CustomProcMacroExpander { proc_macro_id: ProcMacroId, } -const DUMMY_ID: u32 = !0; - impl CustomProcMacroExpander { + const DUMMY_ID: u32 = !0; + const DISABLED_ID: u32 = !1; + pub fn new(proc_macro_id: ProcMacroId) -> Self { - assert_ne!(proc_macro_id.0, DUMMY_ID); + assert_ne!(proc_macro_id.0, Self::DUMMY_ID); + assert_ne!(proc_macro_id.0, Self::DISABLED_ID); Self { proc_macro_id } } - pub fn dummy() -> Self { - Self { proc_macro_id: ProcMacroId(DUMMY_ID) } + /// A dummy expander that always errors. This is used for proc-macros that are missing, usually + /// due to them not being built yet. + pub const fn dummy() -> Self { + Self { proc_macro_id: ProcMacroId(Self::DUMMY_ID) } + } + + /// The macro was not yet resolved. + pub const fn is_dummy(&self) -> bool { + self.proc_macro_id.0 == Self::DUMMY_ID + } + + /// A dummy expander that always errors. This expander is used for macros that have been disabled. + pub const fn disabled() -> Self { + Self { proc_macro_id: ProcMacroId(Self::DISABLED_ID) } } - pub fn is_dummy(&self) -> bool { - self.proc_macro_id.0 == DUMMY_ID + /// The macro is explicitly disabled and cannot be expanded. + pub const fn is_disabled(&self) -> bool { + self.proc_macro_id.0 == Self::DISABLED_ID } pub fn expand( @@ -84,10 +106,14 @@ impl CustomProcMacroExpander { mixed_site: Span, ) -> ExpandResult { match self.proc_macro_id { - ProcMacroId(DUMMY_ID) => ExpandResult::new( + ProcMacroId(Self::DUMMY_ID) => ExpandResult::new( tt::Subtree::empty(tt::DelimSpan { open: call_site, close: call_site }), ExpandError::UnresolvedProcMacro(def_crate), ), + ProcMacroId(Self::DISABLED_ID) => ExpandResult::new( + tt::Subtree::empty(tt::DelimSpan { open: call_site, close: call_site }), + ExpandError::MacroDisabled, + ), ProcMacroId(id) => { let proc_macros = db.proc_macros(); let proc_macros = match proc_macros.get(&def_crate) { @@ -110,7 +136,7 @@ impl CustomProcMacroExpander { ); return ExpandResult::new( tt::Subtree::empty(tt::DelimSpan { open: call_site, close: call_site }), - ExpandError::other("Internal error"), + ExpandError::other("Internal error: proc-macro index out of bounds"), ); } }; diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index 7f8fb7f4b5214..c4329a7b82bf8 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -169,9 +169,9 @@ impl ExprValidator { return; } - let pattern_arena = Arena::new(); - let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db, &pattern_arena); + let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db); + let pattern_arena = Arena::new(); let mut m_arms = Vec::with_capacity(arms.len()); let mut has_lowering_errors = false; for arm in arms { @@ -196,8 +196,9 @@ impl ExprValidator { // If we had a NotUsefulMatchArm diagnostic, we could // check the usefulness of each pattern as we added it // to the matrix here. + let pat = self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors); let m_arm = pat_analysis::MatchArm { - pat: self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors), + pat: pattern_arena.alloc(pat), has_guard: arm.guard.is_some(), arm_data: (), }; @@ -223,7 +224,7 @@ impl ExprValidator { ValidityConstraint::ValidOnly, ) { Ok(report) => report, - Err(void) => match void {}, + Err(()) => return, }; // FIXME Report unreachable arms @@ -245,10 +246,10 @@ impl ExprValidator { db: &dyn HirDatabase, body: &Body, have_errors: &mut bool, - ) -> &'p DeconstructedPat<'p> { + ) -> DeconstructedPat<'p> { let mut patcx = match_check::PatCtxt::new(db, &self.infer, body); let pattern = patcx.lower_pattern(pat); - let pattern = cx.pattern_arena.alloc(cx.lower_pat(&pattern)); + let pattern = cx.lower_pat(&pattern); if !patcx.errors.is_empty() { *have_errors = true; } diff --git a/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs b/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs index 712842372b625..e98a946a8708c 100644 --- a/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs +++ b/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs @@ -1,6 +1,7 @@ //! Interface with `rustc_pattern_analysis`. use std::fmt; +use tracing::debug; use hir_def::{DefWithBodyId, EnumVariantId, HasModule, LocalFieldId, ModuleId, VariantId}; use rustc_hash::FxHashMap; @@ -11,7 +12,6 @@ use rustc_pattern_analysis::{ }; use smallvec::{smallvec, SmallVec}; use stdx::never; -use typed_arena::Arena; use crate::{ db::HirDatabase, @@ -26,7 +26,7 @@ use Constructor::*; // Re-export r-a-specific versions of all these types. pub(crate) type DeconstructedPat<'p> = - rustc_pattern_analysis::pat::DeconstructedPat<'p, MatchCheckCtx<'p>>; + rustc_pattern_analysis::pat::DeconstructedPat>; pub(crate) type MatchArm<'p> = rustc_pattern_analysis::MatchArm<'p, MatchCheckCtx<'p>>; pub(crate) type WitnessPat<'p> = rustc_pattern_analysis::pat::WitnessPat>; @@ -40,7 +40,6 @@ pub(crate) struct MatchCheckCtx<'p> { module: ModuleId, body: DefWithBodyId, pub(crate) db: &'p dyn HirDatabase, - pub(crate) pattern_arena: &'p Arena>, exhaustive_patterns: bool, min_exhaustive_patterns: bool, } @@ -52,17 +51,12 @@ pub(crate) struct PatData<'p> { } impl<'p> MatchCheckCtx<'p> { - pub(crate) fn new( - module: ModuleId, - body: DefWithBodyId, - db: &'p dyn HirDatabase, - pattern_arena: &'p Arena>, - ) -> Self { + pub(crate) fn new(module: ModuleId, body: DefWithBodyId, db: &'p dyn HirDatabase) -> Self { let def_map = db.crate_def_map(module.krate()); let exhaustive_patterns = def_map.is_unstable_feature_enabled("exhaustive_patterns"); let min_exhaustive_patterns = def_map.is_unstable_feature_enabled("min_exhaustive_patterns"); - Self { module, body, db, pattern_arena, exhaustive_patterns, min_exhaustive_patterns } + Self { module, body, db, exhaustive_patterns, min_exhaustive_patterns } } fn is_uninhabited(&self, ty: &Ty) -> bool { @@ -131,15 +125,15 @@ impl<'p> MatchCheckCtx<'p> { } pub(crate) fn lower_pat(&self, pat: &Pat) -> DeconstructedPat<'p> { - let singleton = |pat| std::slice::from_ref(self.pattern_arena.alloc(pat)); + let singleton = |pat| vec![pat]; let ctor; - let fields: &[_]; + let fields: Vec<_>; match pat.kind.as_ref() { PatKind::Binding { subpattern: Some(subpat), .. } => return self.lower_pat(subpat), PatKind::Binding { subpattern: None, .. } | PatKind::Wild => { ctor = Wildcard; - fields = &[]; + fields = Vec::new(); } PatKind::Deref { subpattern } => { ctor = match pat.ty.kind(Interner) { @@ -157,7 +151,7 @@ impl<'p> MatchCheckCtx<'p> { match pat.ty.kind(Interner) { TyKind::Tuple(_, substs) => { ctor = Struct; - let mut wilds: SmallVec<[_; 2]> = substs + let mut wilds: Vec<_> = substs .iter(Interner) .map(|arg| arg.assert_ty_ref(Interner).clone()) .map(DeconstructedPat::wildcard) @@ -166,7 +160,7 @@ impl<'p> MatchCheckCtx<'p> { let idx: u32 = pat.field.into_raw().into(); wilds[idx as usize] = self.lower_pat(&pat.pattern); } - fields = self.pattern_arena.alloc_extend(wilds) + fields = wilds } TyKind::Adt(adt, substs) if is_box(self.db, adt.0) => { // The only legal patterns of type `Box` (outside `std`) are `_` and box @@ -216,33 +210,29 @@ impl<'p> MatchCheckCtx<'p> { field_id_to_id[field_idx as usize] = Some(i); ty }); - let mut wilds: SmallVec<[_; 2]> = - tys.map(DeconstructedPat::wildcard).collect(); + let mut wilds: Vec<_> = tys.map(DeconstructedPat::wildcard).collect(); for pat in subpatterns { let field_idx: u32 = pat.field.into_raw().into(); if let Some(i) = field_id_to_id[field_idx as usize] { wilds[i] = self.lower_pat(&pat.pattern); } } - fields = self.pattern_arena.alloc_extend(wilds); + fields = wilds; } _ => { never!("pattern has unexpected type: pat: {:?}, ty: {:?}", pat, &pat.ty); ctor = Wildcard; - fields = &[]; + fields = Vec::new(); } } } &PatKind::LiteralBool { value } => { ctor = Bool(value); - fields = &[]; + fields = Vec::new(); } PatKind::Or { pats } => { ctor = Or; - // Collect here because `Arena::alloc_extend` panics on reentrancy. - let subpats: SmallVec<[_; 2]> = - pats.iter().map(|pat| self.lower_pat(pat)).collect(); - fields = self.pattern_arena.alloc_extend(subpats); + fields = pats.iter().map(|pat| self.lower_pat(pat)).collect(); } } let data = PatData { db: self.db }; @@ -307,7 +297,7 @@ impl<'p> MatchCheckCtx<'p> { } impl<'p> TypeCx for MatchCheckCtx<'p> { - type Error = Void; + type Error = (); type Ty = Ty; type VariantIdx = EnumVariantId; type StrLit = Void; @@ -463,7 +453,7 @@ impl<'p> TypeCx for MatchCheckCtx<'p> { fn write_variant_name( f: &mut fmt::Formatter<'_>, - pat: &rustc_pattern_analysis::pat::DeconstructedPat<'_, Self>, + pat: &rustc_pattern_analysis::pat::DeconstructedPat, ) -> fmt::Result { let variant = pat.ty().as_adt().and_then(|(adt, _)| Self::variant_id_for_adt(pat.ctor(), adt)); @@ -485,8 +475,8 @@ impl<'p> TypeCx for MatchCheckCtx<'p> { Ok(()) } - fn bug(&self, fmt: fmt::Arguments<'_>) -> ! { - panic!("{}", fmt) + fn bug(&self, fmt: fmt::Arguments<'_>) { + debug!("{}", fmt) } } diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index 71c3f89716d82..1977f00517cd1 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -26,7 +26,7 @@ use std::{convert::identity, ops::Index}; use chalk_ir::{ cast::Cast, fold::TypeFoldable, interner::HasInterner, DebruijnIndex, Mutability, Safety, - Scalar, TyKind, TypeFlags, + Scalar, TyKind, TypeFlags, Variance, }; use either::Either; use hir_def::{ @@ -58,8 +58,9 @@ use crate::{ static_lifetime, to_assoc_type_id, traits::FnTrait, utils::{InTypeConstIdMetadata, UnevaluatedConstEvaluatorFolder}, - AliasEq, AliasTy, ClosureId, DomainGoal, GenericArg, Goal, ImplTraitId, InEnvironment, - Interner, ProjectionTy, RpitId, Substitution, TraitEnvironment, TraitRef, Ty, TyBuilder, TyExt, + AliasEq, AliasTy, Binders, ClosureId, Const, DomainGoal, GenericArg, Goal, ImplTraitId, + InEnvironment, Interner, Lifetime, ProjectionTy, RpitId, Substitution, TraitEnvironment, + TraitRef, Ty, TyBuilder, TyExt, }; // This lint has a false positive here. See the link below for details. @@ -68,7 +69,7 @@ use crate::{ #[allow(unreachable_pub)] pub use coerce::could_coerce; #[allow(unreachable_pub)] -pub use unify::could_unify; +pub use unify::{could_unify, could_unify_deeply}; use cast::CastCheck; pub(crate) use closure::{CaptureKind, CapturedItem, CapturedItemWithoutTy}; @@ -688,10 +689,17 @@ impl<'a> InferenceContext<'a> { for ty in type_of_for_iterator.values_mut() { *ty = table.resolve_completely(ty.clone()); } - for mismatch in type_mismatches.values_mut() { + type_mismatches.retain(|_, mismatch| { mismatch.expected = table.resolve_completely(mismatch.expected.clone()); mismatch.actual = table.resolve_completely(mismatch.actual.clone()); - } + chalk_ir::zip::Zip::zip_with( + &mut UnknownMismatch(self.db), + Variance::Invariant, + &mismatch.expected, + &mismatch.actual, + ) + .is_ok() + }); diagnostics.retain_mut(|diagnostic| { use InferenceDiagnostic::*; match diagnostic { @@ -1502,3 +1510,116 @@ impl std::ops::BitOrAssign for Diverges { *self = *self | other; } } +/// A zipper that checks for unequal `{unknown}` occurrences in the two types. Used to filter out +/// mismatch diagnostics that only differ in `{unknown}`. These mismatches are usually not helpful. +/// As the cause is usually an underlying name resolution problem. +struct UnknownMismatch<'db>(&'db dyn HirDatabase); +impl chalk_ir::zip::Zipper for UnknownMismatch<'_> { + fn zip_tys(&mut self, variance: Variance, a: &Ty, b: &Ty) -> chalk_ir::Fallible<()> { + let zip_substs = |this: &mut Self, + variances, + sub_a: &Substitution, + sub_b: &Substitution| { + this.zip_substs(variance, variances, sub_a.as_slice(Interner), sub_b.as_slice(Interner)) + }; + match (a.kind(Interner), b.kind(Interner)) { + (TyKind::Adt(id_a, sub_a), TyKind::Adt(id_b, sub_b)) if id_a == id_b => zip_substs( + self, + Some(self.unification_database().adt_variance(*id_a)), + sub_a, + sub_b, + )?, + ( + TyKind::AssociatedType(assoc_ty_a, sub_a), + TyKind::AssociatedType(assoc_ty_b, sub_b), + ) if assoc_ty_a == assoc_ty_b => zip_substs(self, None, sub_a, sub_b)?, + (TyKind::Tuple(arity_a, sub_a), TyKind::Tuple(arity_b, sub_b)) + if arity_a == arity_b => + { + zip_substs(self, None, sub_a, sub_b)? + } + (TyKind::OpaqueType(opaque_ty_a, sub_a), TyKind::OpaqueType(opaque_ty_b, sub_b)) + if opaque_ty_a == opaque_ty_b => + { + zip_substs(self, None, sub_a, sub_b)? + } + (TyKind::Slice(ty_a), TyKind::Slice(ty_b)) => self.zip_tys(variance, ty_a, ty_b)?, + (TyKind::FnDef(fn_def_a, sub_a), TyKind::FnDef(fn_def_b, sub_b)) + if fn_def_a == fn_def_b => + { + zip_substs( + self, + Some(self.unification_database().fn_def_variance(*fn_def_a)), + sub_a, + sub_b, + )? + } + (TyKind::Ref(mutability_a, _, ty_a), TyKind::Ref(mutability_b, _, ty_b)) + if mutability_a == mutability_b => + { + self.zip_tys(variance, ty_a, ty_b)? + } + (TyKind::Raw(mutability_a, ty_a), TyKind::Raw(mutability_b, ty_b)) + if mutability_a == mutability_b => + { + self.zip_tys(variance, ty_a, ty_b)? + } + (TyKind::Array(ty_a, const_a), TyKind::Array(ty_b, const_b)) if const_a == const_b => { + self.zip_tys(variance, ty_a, ty_b)? + } + (TyKind::Closure(id_a, sub_a), TyKind::Closure(id_b, sub_b)) if id_a == id_b => { + zip_substs(self, None, sub_a, sub_b)? + } + (TyKind::Coroutine(coroutine_a, sub_a), TyKind::Coroutine(coroutine_b, sub_b)) + if coroutine_a == coroutine_b => + { + zip_substs(self, None, sub_a, sub_b)? + } + ( + TyKind::CoroutineWitness(coroutine_a, sub_a), + TyKind::CoroutineWitness(coroutine_b, sub_b), + ) if coroutine_a == coroutine_b => zip_substs(self, None, sub_a, sub_b)?, + (TyKind::Function(fn_ptr_a), TyKind::Function(fn_ptr_b)) + if fn_ptr_a.sig == fn_ptr_b.sig && fn_ptr_a.num_binders == fn_ptr_b.num_binders => + { + zip_substs(self, None, &fn_ptr_a.substitution.0, &fn_ptr_b.substitution.0)? + } + (TyKind::Error, TyKind::Error) => (), + (TyKind::Error, _) | (_, TyKind::Error) => return Err(chalk_ir::NoSolution), + _ => (), + } + + Ok(()) + } + + fn zip_lifetimes(&mut self, _: Variance, _: &Lifetime, _: &Lifetime) -> chalk_ir::Fallible<()> { + Ok(()) + } + + fn zip_consts(&mut self, _: Variance, _: &Const, _: &Const) -> chalk_ir::Fallible<()> { + Ok(()) + } + + fn zip_binders( + &mut self, + variance: Variance, + a: &Binders, + b: &Binders, + ) -> chalk_ir::Fallible<()> + where + T: Clone + + HasInterner + + chalk_ir::zip::Zip + + TypeFoldable, + { + chalk_ir::zip::Zip::zip_with(self, variance, a.skip_binders(), b.skip_binders()) + } + + fn interner(&self) -> Interner { + Interner + } + + fn unification_database(&self) -> &dyn chalk_ir::UnificationDatabase { + &self.0 + } +} diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs index c3746f787067c..22a70f951ea7a 100644 --- a/crates/hir-ty/src/infer/closure.rs +++ b/crates/hir-ty/src/infer/closure.rs @@ -485,6 +485,7 @@ impl InferenceContext<'_> { Statement::Expr { expr, has_semi: _ } => { self.consume_expr(*expr); } + Statement::Item => (), } } if let Some(tail) = tail { @@ -531,6 +532,9 @@ impl InferenceContext<'_> { self.consume_expr(expr); } } + &Expr::Become { expr } => { + self.consume_expr(expr); + } Expr::RecordLit { fields, spread, .. } => { if let &Some(expr) = spread { self.consume_expr(expr); diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs index 8b8e97b0081c6..428ed6748c6c2 100644 --- a/crates/hir-ty/src/infer/expr.rs +++ b/crates/hir-ty/src/infer/expr.rs @@ -502,6 +502,7 @@ impl InferenceContext<'_> { self.result.standard_types.never.clone() } &Expr::Return { expr } => self.infer_expr_return(tgt_expr, expr), + &Expr::Become { expr } => self.infer_expr_become(expr), Expr::Yield { expr } => { if let Some((resume_ty, yield_ty)) = self.resume_yield_tys.clone() { if let Some(expr) = expr { @@ -1084,6 +1085,27 @@ impl InferenceContext<'_> { self.result.standard_types.never.clone() } + fn infer_expr_become(&mut self, expr: ExprId) -> Ty { + match &self.return_coercion { + Some(return_coercion) => { + let ret_ty = return_coercion.expected_ty(); + + let call_expr_ty = + self.infer_expr_inner(expr, &Expectation::HasType(ret_ty.clone())); + + // NB: this should *not* coerce. + // tail calls don't support any coercions except lifetimes ones (like `&'static u8 -> &'a u8`). + self.unify(&call_expr_ty, &ret_ty); + } + None => { + // FIXME: diagnose `become` outside of functions + self.infer_expr_no_expect(expr); + } + } + + self.result.standard_types.never.clone() + } + fn infer_expr_box(&mut self, inner_expr: ExprId, expected: &Expectation) -> Ty { if let Some(box_id) = self.resolve_boxed_box() { let table = &mut self.table; @@ -1367,6 +1389,7 @@ impl InferenceContext<'_> { ); } } + Statement::Item => (), } } diff --git a/crates/hir-ty/src/infer/mutability.rs b/crates/hir-ty/src/infer/mutability.rs index 663ea85323189..00e5eac229fb6 100644 --- a/crates/hir-ty/src/infer/mutability.rs +++ b/crates/hir-ty/src/infer/mutability.rs @@ -65,6 +65,7 @@ impl InferenceContext<'_> { Statement::Expr { expr, has_semi: _ } => { self.infer_mut_expr(*expr, Mutability::Not); } + Statement::Item => (), } } if let Some(tail) = tail { @@ -93,6 +94,9 @@ impl InferenceContext<'_> { self.infer_mut_expr(expr, Mutability::Not); } } + Expr::Become { expr } => { + self.infer_mut_expr(*expr, Mutability::Not); + } Expr::RecordLit { path: _, fields, spread, ellipsis: _, is_assignee_expr: _ } => { self.infer_mut_not_expr_iter(fields.iter().map(|it| it.expr).chain(*spread)) } diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs index de23ca34990be..709760b64fd3f 100644 --- a/crates/hir-ty/src/infer/unify.rs +++ b/crates/hir-ty/src/infer/unify.rs @@ -74,6 +74,12 @@ impl> Canonicalized { } } +/// Check if types unify. +/// +/// Note that we consider placeholder types to unify with everything. +/// This means that there may be some unresolved goals that actually set bounds for the placeholder +/// type for the types to unify. For example `Option` and `Option` unify although there is +/// unresolved goal `T = U`. pub fn could_unify( db: &dyn HirDatabase, env: Arc, @@ -82,21 +88,35 @@ pub fn could_unify( unify(db, env, tys).is_some() } +/// Check if types unify eagerly making sure there are no unresolved goals. +/// +/// This means that placeholder types are not considered to unify if there are any bounds set on +/// them. For example `Option` and `Option` do not unify as we cannot show that `T = U` +pub fn could_unify_deeply( + db: &dyn HirDatabase, + env: Arc, + tys: &Canonical<(Ty, Ty)>, +) -> bool { + let mut table = InferenceTable::new(db, env); + let vars = make_substitutions(tys, &mut table); + let ty1_with_vars = vars.apply(tys.value.0.clone(), Interner); + let ty2_with_vars = vars.apply(tys.value.1.clone(), Interner); + let ty1_with_vars = table.normalize_associated_types_in(ty1_with_vars); + let ty2_with_vars = table.normalize_associated_types_in(ty2_with_vars); + table.resolve_obligations_as_possible(); + table.propagate_diverging_flag(); + let ty1_with_vars = table.resolve_completely(ty1_with_vars); + let ty2_with_vars = table.resolve_completely(ty2_with_vars); + table.unify_deeply(&ty1_with_vars, &ty2_with_vars) +} + pub(crate) fn unify( db: &dyn HirDatabase, env: Arc, tys: &Canonical<(Ty, Ty)>, ) -> Option { let mut table = InferenceTable::new(db, env); - let vars = Substitution::from_iter( - Interner, - tys.binders.iter(Interner).map(|it| match &it.kind { - chalk_ir::VariableKind::Ty(_) => table.new_type_var().cast(Interner), - // FIXME: maybe wrong? - chalk_ir::VariableKind::Lifetime => table.new_type_var().cast(Interner), - chalk_ir::VariableKind::Const(ty) => table.new_const_var(ty.clone()).cast(Interner), - }), - ); + let vars = make_substitutions(tys, &mut table); let ty1_with_vars = vars.apply(tys.value.0.clone(), Interner); let ty2_with_vars = vars.apply(tys.value.1.clone(), Interner); if !table.unify(&ty1_with_vars, &ty2_with_vars) { @@ -125,6 +145,21 @@ pub(crate) fn unify( )) } +fn make_substitutions( + tys: &chalk_ir::Canonical<(chalk_ir::Ty, chalk_ir::Ty)>, + table: &mut InferenceTable<'_>, +) -> chalk_ir::Substitution { + Substitution::from_iter( + Interner, + tys.binders.iter(Interner).map(|it| match &it.kind { + chalk_ir::VariableKind::Ty(_) => table.new_type_var().cast(Interner), + // FIXME: maybe wrong? + chalk_ir::VariableKind::Lifetime => table.new_type_var().cast(Interner), + chalk_ir::VariableKind::Const(ty) => table.new_const_var(ty.clone()).cast(Interner), + }), + ) +} + bitflags::bitflags! { #[derive(Default, Clone, Copy)] pub(crate) struct TypeVariableFlags: u8 { @@ -431,6 +466,18 @@ impl<'a> InferenceTable<'a> { true } + /// Unify two relatable values (e.g. `Ty`) and check whether trait goals which arise from that could be fulfilled + pub(crate) fn unify_deeply>(&mut self, ty1: &T, ty2: &T) -> bool { + let result = match self.try_unify(ty1, ty2) { + Ok(r) => r, + Err(_) => return false, + }; + result.goals.iter().all(|goal| { + let canonicalized = self.canonicalize(goal.clone()); + self.try_resolve_obligation(&canonicalized).is_some() + }) + } + /// Unify two relatable values (e.g. `Ty`) and return new trait goals arising from it, so the /// caller needs to deal with them. pub(crate) fn try_unify>( @@ -501,7 +548,8 @@ impl<'a> InferenceTable<'a> { fn register_obligation_in_env(&mut self, goal: InEnvironment) { let canonicalized = self.canonicalize(goal); - if !self.try_resolve_obligation(&canonicalized) { + let solution = self.try_resolve_obligation(&canonicalized); + if matches!(solution, Some(Solution::Ambig(_))) { self.pending_obligations.push(canonicalized); } } @@ -627,38 +675,35 @@ impl<'a> InferenceTable<'a> { fn try_resolve_obligation( &mut self, canonicalized: &Canonicalized>, - ) -> bool { + ) -> Option> { let solution = self.db.trait_solve( self.trait_env.krate, self.trait_env.block, canonicalized.value.clone(), ); - match solution { + match &solution { Some(Solution::Unique(canonical_subst)) => { canonicalized.apply_solution( self, Canonical { - binders: canonical_subst.binders, + binders: canonical_subst.binders.clone(), // FIXME: handle constraints - value: canonical_subst.value.subst, + value: canonical_subst.value.subst.clone(), }, ); - true } Some(Solution::Ambig(Guidance::Definite(substs))) => { - canonicalized.apply_solution(self, substs); - false + canonicalized.apply_solution(self, substs.clone()); } Some(_) => { // FIXME use this when trying to resolve everything at the end - false } None => { // FIXME obligation cannot be fulfilled => diagnostic - true } } + solution } pub(crate) fn callable_sig( diff --git a/crates/hir-ty/src/layout/target.rs b/crates/hir-ty/src/layout/target.rs index 5bfe7bf010f1c..9b1424548c2a9 100644 --- a/crates/hir-ty/src/layout/target.rs +++ b/crates/hir-ty/src/layout/target.rs @@ -11,10 +11,8 @@ pub fn target_data_layout_query( db: &dyn HirDatabase, krate: CrateId, ) -> Result, Arc> { - let crate_graph = db.crate_graph(); - let res = crate_graph[krate].target_layout.as_deref(); - match res { - Ok(it) => match TargetDataLayout::parse_from_llvm_datalayout_string(it) { + match db.data_layout(krate) { + Ok(it) => match TargetDataLayout::parse_from_llvm_datalayout_string(&it) { Ok(it) => Ok(Arc::new(it)), Err(e) => { Err(match e { @@ -44,6 +42,6 @@ pub fn target_data_layout_query( }.into()) } }, - Err(e) => Err(Arc::from(&**e)), + Err(e) => Err(e), } } diff --git a/crates/hir-ty/src/layout/tests.rs b/crates/hir-ty/src/layout/tests.rs index ba3dfe8100d17..6c1eccb75e631 100644 --- a/crates/hir-ty/src/layout/tests.rs +++ b/crates/hir-ty/src/layout/tests.rs @@ -1,6 +1,7 @@ use chalk_ir::{AdtId, TyKind}; use either::Either; use hir_def::db::DefDatabase; +use project_model::target_data_layout::RustcDataLayoutConfig; use rustc_hash::FxHashMap; use test_fixture::WithFixture; use triomphe::Arc; @@ -15,13 +16,18 @@ use crate::{ mod closure; fn current_machine_data_layout() -> String { - project_model::target_data_layout::get(None, None, &FxHashMap::default()).unwrap() + project_model::target_data_layout::get( + RustcDataLayoutConfig::Rustc(None), + None, + &FxHashMap::default(), + ) + .unwrap() } fn eval_goal(ra_fixture: &str, minicore: &str) -> Result, LayoutError> { let target_data_layout = current_machine_data_layout(); let ra_fixture = format!( - "{minicore}//- /main.rs crate:test target_data_layout:{target_data_layout}\n{ra_fixture}", + "//- target_data_layout: {target_data_layout}\n{minicore}//- /main.rs crate:test\n{ra_fixture}", ); let (db, file_ids) = TestDB::with_many_files(&ra_fixture); @@ -70,7 +76,7 @@ fn eval_goal(ra_fixture: &str, minicore: &str) -> Result, LayoutErro fn eval_expr(ra_fixture: &str, minicore: &str) -> Result, LayoutError> { let target_data_layout = current_machine_data_layout(); let ra_fixture = format!( - "{minicore}//- /main.rs crate:test target_data_layout:{target_data_layout}\nfn main(){{let goal = {{{ra_fixture}}};}}", + "//- target_data_layout: {target_data_layout}\n{minicore}//- /main.rs crate:test\nfn main(){{let goal = {{{ra_fixture}}};}}", ); let (db, file_id) = TestDB::with_single_file(&ra_fixture); diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs index 70138633341ce..ec97bdc2c4343 100644 --- a/crates/hir-ty/src/lib.rs +++ b/crates/hir-ty/src/lib.rs @@ -79,8 +79,8 @@ pub use builder::{ParamKind, TyBuilder}; pub use chalk_ext::*; pub use infer::{ closure::{CaptureKind, CapturedItem}, - could_coerce, could_unify, Adjust, Adjustment, AutoBorrow, BindingMode, InferenceDiagnostic, - InferenceResult, OverloadedDeref, PointerCast, + could_coerce, could_unify, could_unify_deeply, Adjust, Adjustment, AutoBorrow, BindingMode, + InferenceDiagnostic, InferenceResult, OverloadedDeref, PointerCast, }; pub use interner::Interner; pub use lower::{ diff --git a/crates/hir-ty/src/mir/borrowck.rs b/crates/hir-ty/src/mir/borrowck.rs index 9089c11c5d9bb..63fa87ad66288 100644 --- a/crates/hir-ty/src/mir/borrowck.rs +++ b/crates/hir-ty/src/mir/borrowck.rs @@ -7,6 +7,7 @@ use std::iter; use hir_def::{DefWithBodyId, HasModule}; use la_arena::ArenaMap; +use rustc_hash::FxHashMap; use stdx::never; use triomphe::Arc; @@ -14,7 +15,7 @@ use crate::{ db::{HirDatabase, InternedClosure}, mir::Operand, utils::ClosureSubst, - ClosureId, Interner, Ty, TyExt, TypeFlags, + ClosureId, Interner, Substitution, Ty, TyExt, TypeFlags, }; use super::{ @@ -36,11 +37,27 @@ pub struct MovedOutOfRef { pub span: MirSpan, } +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PartiallyMoved { + pub ty: Ty, + pub span: MirSpan, + pub local: LocalId, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct BorrowRegion { + pub local: LocalId, + pub kind: BorrowKind, + pub places: Vec, +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct BorrowckResult { pub mir_body: Arc, pub mutability_of_locals: ArenaMap, pub moved_out_of_ref: Vec, + pub partially_moved: Vec, + pub borrow_regions: Vec, } fn all_mir_bodies( @@ -80,12 +97,26 @@ pub fn borrowck_query( res.push(BorrowckResult { mutability_of_locals: mutability_of_locals(db, &body), moved_out_of_ref: moved_out_of_ref(db, &body), + partially_moved: partially_moved(db, &body), + borrow_regions: borrow_regions(db, &body), mir_body: body, }); })?; Ok(res.into()) } +fn make_fetch_closure_field( + db: &dyn HirDatabase, +) -> impl FnOnce(ClosureId, &Substitution, usize) -> Ty + '_ { + |c: ClosureId, subst: &Substitution, f: usize| { + let InternedClosure(def, _) = db.lookup_intern_closure(c.into()); + let infer = db.infer(def); + let (captures, _) = infer.closure_info(&c); + let parent_subst = ClosureSubst(subst).parent_subst(); + captures.get(f).expect("broken closure field").ty.clone().substitute(Interner, parent_subst) + } +} + fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec { let mut result = vec![]; let mut for_operand = |op: &Operand, span: MirSpan| match op { @@ -99,18 +130,7 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec ty = proj.projected_ty( ty, db, - |c, subst, f| { - let InternedClosure(def, _) = db.lookup_intern_closure(c.into()); - let infer = db.infer(def); - let (captures, _) = infer.closure_info(&c); - let parent_subst = ClosureSubst(subst).parent_subst(); - captures - .get(f) - .expect("broken closure field") - .ty - .clone() - .substitute(Interner, parent_subst) - }, + make_fetch_closure_field(db), body.owner.module(db.upcast()).krate(), ); } @@ -188,6 +208,132 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec result } +fn partially_moved(db: &dyn HirDatabase, body: &MirBody) -> Vec { + let mut result = vec![]; + let mut for_operand = |op: &Operand, span: MirSpan| match op { + Operand::Copy(p) | Operand::Move(p) => { + let mut ty: Ty = body.locals[p.local].ty.clone(); + for proj in p.projection.lookup(&body.projection_store) { + ty = proj.projected_ty( + ty, + db, + make_fetch_closure_field(db), + body.owner.module(db.upcast()).krate(), + ); + } + if !ty.clone().is_copy(db, body.owner) + && !ty.data(Interner).flags.intersects(TypeFlags::HAS_ERROR) + { + result.push(PartiallyMoved { span, ty, local: p.local }); + } + } + Operand::Constant(_) | Operand::Static(_) => (), + }; + for (_, block) in body.basic_blocks.iter() { + db.unwind_if_cancelled(); + for statement in &block.statements { + match &statement.kind { + StatementKind::Assign(_, r) => match r { + Rvalue::ShallowInitBoxWithAlloc(_) => (), + Rvalue::ShallowInitBox(o, _) + | Rvalue::UnaryOp(_, o) + | Rvalue::Cast(_, o, _) + | Rvalue::Repeat(o, _) + | Rvalue::Use(o) => for_operand(o, statement.span), + Rvalue::CopyForDeref(_) + | Rvalue::Discriminant(_) + | Rvalue::Len(_) + | Rvalue::Ref(_, _) => (), + Rvalue::CheckedBinaryOp(_, o1, o2) => { + for_operand(o1, statement.span); + for_operand(o2, statement.span); + } + Rvalue::Aggregate(_, ops) => { + for op in ops.iter() { + for_operand(op, statement.span); + } + } + }, + StatementKind::FakeRead(_) + | StatementKind::Deinit(_) + | StatementKind::StorageLive(_) + | StatementKind::StorageDead(_) + | StatementKind::Nop => (), + } + } + match &block.terminator { + Some(terminator) => match &terminator.kind { + TerminatorKind::SwitchInt { discr, .. } => for_operand(discr, terminator.span), + TerminatorKind::FalseEdge { .. } + | TerminatorKind::FalseUnwind { .. } + | TerminatorKind::Goto { .. } + | TerminatorKind::UnwindResume + | TerminatorKind::CoroutineDrop + | TerminatorKind::Abort + | TerminatorKind::Return + | TerminatorKind::Unreachable + | TerminatorKind::Drop { .. } => (), + TerminatorKind::DropAndReplace { value, .. } => { + for_operand(value, terminator.span); + } + TerminatorKind::Call { func, args, .. } => { + for_operand(func, terminator.span); + args.iter().for_each(|it| for_operand(it, terminator.span)); + } + TerminatorKind::Assert { cond, .. } => { + for_operand(cond, terminator.span); + } + TerminatorKind::Yield { value, .. } => { + for_operand(value, terminator.span); + } + }, + None => (), + } + } + result.shrink_to_fit(); + result +} + +fn borrow_regions(db: &dyn HirDatabase, body: &MirBody) -> Vec { + let mut borrows = FxHashMap::default(); + for (_, block) in body.basic_blocks.iter() { + db.unwind_if_cancelled(); + for statement in &block.statements { + if let StatementKind::Assign(_, Rvalue::Ref(kind, p)) = &statement.kind { + borrows + .entry(p.local) + .and_modify(|it: &mut BorrowRegion| { + it.places.push(statement.span); + }) + .or_insert_with(|| BorrowRegion { + local: p.local, + kind: *kind, + places: vec![statement.span], + }); + } + } + match &block.terminator { + Some(terminator) => match &terminator.kind { + TerminatorKind::FalseEdge { .. } + | TerminatorKind::FalseUnwind { .. } + | TerminatorKind::Goto { .. } + | TerminatorKind::UnwindResume + | TerminatorKind::CoroutineDrop + | TerminatorKind::Abort + | TerminatorKind::Return + | TerminatorKind::Unreachable + | TerminatorKind::Drop { .. } => (), + TerminatorKind::DropAndReplace { .. } => {} + TerminatorKind::Call { .. } => {} + _ => (), + }, + None => (), + } + } + + borrows.into_values().collect() +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum ProjectionCase { /// Projection is a local @@ -217,18 +363,7 @@ fn place_case(db: &dyn HirDatabase, body: &MirBody, lvalue: &Place) -> Projectio ty = proj.projected_ty( ty, db, - |c, subst, f| { - let InternedClosure(def, _) = db.lookup_intern_closure(c.into()); - let infer = db.infer(def); - let (captures, _) = infer.closure_info(&c); - let parent_subst = ClosureSubst(subst).parent_subst(); - captures - .get(f) - .expect("broken closure field") - .ty - .clone() - .substitute(Interner, parent_subst) - }, + make_fetch_closure_field(db), body.owner.module(db.upcast()).krate(), ); } diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index 1572a6d497c57..b038900cdacba 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -775,6 +775,7 @@ impl<'ctx> MirLowerCtx<'ctx> { self.set_terminator(current, TerminatorKind::Return, expr_id.into()); Ok(None) } + Expr::Become { .. } => not_supported!("tail-calls"), Expr::Yield { .. } => not_supported!("yield"), Expr::RecordLit { fields, path, spread, ellipsis: _, is_assignee_expr: _ } => { let spread_place = match spread { @@ -1246,7 +1247,7 @@ impl<'ctx> MirLowerCtx<'ctx> { self.push_assignment(current, place, op.into(), expr_id.into()); Ok(Some(current)) } - Expr::Underscore => not_supported!("underscore"), + Expr::Underscore => Ok(Some(current)), } } @@ -1780,6 +1781,7 @@ impl<'ctx> MirLowerCtx<'ctx> { self.push_fake_read(c, p, expr.into()); current = scope2.pop_and_drop(self, c, expr.into()); } + hir_def::hir::Statement::Item => (), } } if let Some(tail) = tail { diff --git a/crates/hir-ty/src/tests/diagnostics.rs b/crates/hir-ty/src/tests/diagnostics.rs index 1876be303ad44..80f92eaf43553 100644 --- a/crates/hir-ty/src/tests/diagnostics.rs +++ b/crates/hir-ty/src/tests/diagnostics.rs @@ -1,3 +1,5 @@ +use crate::tests::check_no_mismatches; + use super::check; #[test] @@ -94,3 +96,43 @@ fn test(x: bool) { "#, ); } + +#[test] +fn no_mismatches_on_atpit() { + check_no_mismatches( + r#" +//- minicore: option, sized +#![feature(impl_trait_in_assoc_type)] + +trait WrappedAssoc { + type Assoc; + fn do_thing(&self) -> Option; +} + +struct Foo; +impl WrappedAssoc for Foo { + type Assoc = impl Sized; + + fn do_thing(&self) -> Option { + Some(()) + } +} +"#, + ); + check_no_mismatches( + r#" +//- minicore: option, sized +#![feature(impl_trait_in_assoc_type)] + +trait Trait { + type Assoc; + const DEFINE: Option; +} + +impl Trait for () { + type Assoc = impl Sized; + const DEFINE: Option = Option::Some(()); +} +"#, + ); +} diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs index 8474782282606..6c7dbe1db6ff7 100644 --- a/crates/hir-ty/src/tests/simple.rs +++ b/crates/hir-ty/src/tests/simple.rs @@ -3376,11 +3376,8 @@ fn main() { [x,] = &[1,]; //^^^^expected &[i32; 1], got [{unknown}; _] - // FIXME we only want the outermost error, but this matches the current - // behavior of slice patterns let x; [(x,),] = &[(1,),]; - // ^^^^expected {unknown}, got ({unknown},) //^^^^^^^expected &[(i32,); 1], got [{unknown}; _] let x; diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 32abbc80c6af4..08f7bb14caa3a 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -31,6 +31,7 @@ mod has_source; pub mod db; pub mod diagnostics; pub mod symbols; +pub mod term_search; mod display; @@ -1084,6 +1085,27 @@ impl Field { Type::new(db, var_id, ty) } + // FIXME: Find better API to also handle const generics + pub fn ty_with_args(&self, db: &dyn HirDatabase, generics: impl Iterator) -> Type { + let var_id = self.parent.into(); + let def_id: AdtId = match self.parent { + VariantDef::Struct(it) => it.id.into(), + VariantDef::Union(it) => it.id.into(), + VariantDef::Variant(it) => it.parent_enum(db).id.into(), + }; + let mut generics = generics.map(|it| it.ty.clone()); + let substs = TyBuilder::subst_for_def(db, def_id, None) + .fill(|x| match x { + ParamKind::Type => { + generics.next().unwrap_or_else(|| TyKind::Error.intern(Interner)).cast(Interner) + } + ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()), + }) + .build(); + let ty = db.field_types(var_id)[self.id].clone().substitute(Interner, &substs); + Type::new(db, var_id, ty) + } + pub fn layout(&self, db: &dyn HirDatabase) -> Result { db.layout_of_ty( self.ty(db).ty, @@ -1152,6 +1174,10 @@ impl Struct { fn variant_data(self, db: &dyn HirDatabase) -> Arc { db.struct_data(self.id).variant_data.clone() } + + pub fn is_unstable(self, db: &dyn HirDatabase) -> bool { + db.attrs(self.id.into()).is_unstable() + } } impl HasVisibility for Struct { @@ -1194,6 +1220,10 @@ impl Union { fn variant_data(self, db: &dyn HirDatabase) -> Arc { db.union_data(self.id).variant_data.clone() } + + pub fn is_unstable(self, db: &dyn HirDatabase) -> bool { + db.attrs(self.id.into()).is_unstable() + } } impl HasVisibility for Union { @@ -1269,6 +1299,10 @@ impl Enum { pub fn layout(self, db: &dyn HirDatabase) -> Result { Adt::from(self).layout(db) } + + pub fn is_unstable(self, db: &dyn HirDatabase) -> bool { + db.attrs(self.id.into()).is_unstable() + } } impl HasVisibility for Enum { @@ -1344,6 +1378,10 @@ impl Variant { _ => parent_layout, }) } + + pub fn is_unstable(self, db: &dyn HirDatabase) -> bool { + db.attrs(self.id.into()).is_unstable() + } } /// Variants inherit visibility from the parent enum. @@ -1394,9 +1432,9 @@ impl Adt { /// Turns this ADT into a type with the given type parameters. This isn't /// the greatest API, FIXME find a better one. - pub fn ty_with_args(self, db: &dyn HirDatabase, args: &[Type]) -> Type { + pub fn ty_with_args(self, db: &dyn HirDatabase, args: impl Iterator) -> Type { let id = AdtId::from(self); - let mut it = args.iter().map(|t| t.ty.clone()); + let mut it = args.map(|t| t.ty.clone()); let ty = TyBuilder::def_ty(db, id.into(), None) .fill(|x| { let r = it.next().unwrap_or_else(|| TyKind::Error.intern(Interner)); @@ -1789,6 +1827,35 @@ impl Function { Type::new_with_resolver_inner(db, &resolver, ty) } + // FIXME: Find better API to also handle const generics + pub fn ret_type_with_args( + self, + db: &dyn HirDatabase, + generics: impl Iterator, + ) -> Type { + let resolver = self.id.resolver(db.upcast()); + let parent_id: Option = match self.id.lookup(db.upcast()).container { + ItemContainerId::ImplId(it) => Some(it.into()), + ItemContainerId::TraitId(it) => Some(it.into()), + ItemContainerId::ModuleId(_) | ItemContainerId::ExternBlockId(_) => None, + }; + let mut generics = generics.map(|it| it.ty.clone()); + let mut filler = |x: &_| match x { + ParamKind::Type => { + generics.next().unwrap_or_else(|| TyKind::Error.intern(Interner)).cast(Interner) + } + ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()), + }; + + let parent_substs = + parent_id.map(|id| TyBuilder::subst_for_def(db, id, None).fill(&mut filler).build()); + let substs = TyBuilder::subst_for_def(db, self.id, parent_substs).fill(&mut filler).build(); + + let callable_sig = db.callable_item_signature(self.id.into()).substitute(Interner, &substs); + let ty = callable_sig.ret().clone(); + Type::new_with_resolver_inner(db, &resolver, ty) + } + pub fn async_ret_type(self, db: &dyn HirDatabase) -> Option { if !self.is_async(db) { return None; @@ -1855,6 +1922,51 @@ impl Function { .collect() } + // FIXME: Find better API to also handle const generics + pub fn params_without_self_with_args( + self, + db: &dyn HirDatabase, + generics: impl Iterator, + ) -> Vec { + let environment = db.trait_environment(self.id.into()); + let parent_id: Option = match self.id.lookup(db.upcast()).container { + ItemContainerId::ImplId(it) => Some(it.into()), + ItemContainerId::TraitId(it) => Some(it.into()), + ItemContainerId::ModuleId(_) | ItemContainerId::ExternBlockId(_) => None, + }; + let mut generics = generics.map(|it| it.ty.clone()); + let parent_substs = parent_id.map(|id| { + TyBuilder::subst_for_def(db, id, None) + .fill(|x| match x { + ParamKind::Type => generics + .next() + .unwrap_or_else(|| TyKind::Error.intern(Interner)) + .cast(Interner), + ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()), + }) + .build() + }); + + let substs = TyBuilder::subst_for_def(db, self.id, parent_substs) + .fill(|_| { + let ty = generics.next().unwrap_or_else(|| TyKind::Error.intern(Interner)); + GenericArg::new(Interner, GenericArgData::Ty(ty)) + }) + .build(); + let callable_sig = db.callable_item_signature(self.id.into()).substitute(Interner, &substs); + let skip = if db.function_data(self.id).has_self_param() { 1 } else { 0 }; + callable_sig + .params() + .iter() + .enumerate() + .skip(skip) + .map(|(idx, ty)| { + let ty = Type { env: environment.clone(), ty: ty.clone() }; + Param { func: self, ty, idx } + }) + .collect() + } + pub fn is_const(self, db: &dyn HirDatabase) -> bool { db.function_data(self.id).has_const_kw() } @@ -1889,6 +2001,11 @@ impl Function { db.function_data(self.id).attrs.is_bench() } + /// Is this function marked as unstable with `#[feature]` attribute? + pub fn is_unstable(self, db: &dyn HirDatabase) -> bool { + db.function_data(self.id).attrs.is_unstable() + } + pub fn is_unsafe_to_call(self, db: &dyn HirDatabase) -> bool { hir_ty::is_fn_unsafe_to_call(db, self.id) } @@ -2052,6 +2169,34 @@ impl SelfParam { let ty = callable_sig.params()[0].clone(); Type { env: environment, ty } } + + // FIXME: Find better API to also handle const generics + pub fn ty_with_args(&self, db: &dyn HirDatabase, generics: impl Iterator) -> Type { + let parent_id: GenericDefId = match self.func.lookup(db.upcast()).container { + ItemContainerId::ImplId(it) => it.into(), + ItemContainerId::TraitId(it) => it.into(), + ItemContainerId::ModuleId(_) | ItemContainerId::ExternBlockId(_) => { + panic!("Never get here") + } + }; + + let mut generics = generics.map(|it| it.ty.clone()); + let mut filler = |x: &_| match x { + ParamKind::Type => { + generics.next().unwrap_or_else(|| TyKind::Error.intern(Interner)).cast(Interner) + } + ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()), + }; + + let parent_substs = TyBuilder::subst_for_def(db, parent_id, None).fill(&mut filler).build(); + let substs = + TyBuilder::subst_for_def(db, self.func, Some(parent_substs)).fill(&mut filler).build(); + let callable_sig = + db.callable_item_signature(self.func.into()).substitute(Interner, &substs); + let environment = db.trait_environment(self.func.into()); + let ty = callable_sig.params()[0].clone(); + Type { env: environment, ty } + } } impl HasVisibility for Function { @@ -2754,7 +2899,7 @@ impl GenericDef { .collect() } - pub fn type_params(self, db: &dyn HirDatabase) -> Vec { + pub fn type_or_const_params(self, db: &dyn HirDatabase) -> Vec { let generics = db.generic_params(self.into()); generics .type_or_consts @@ -3126,12 +3271,16 @@ impl TypeParam { let ty = generic_arg_from_param(db, self.id.into())?; let resolver = self.id.parent().resolver(db.upcast()); match ty.data(Interner) { - GenericArgData::Ty(it) => { + GenericArgData::Ty(it) if *it.kind(Interner) != TyKind::Error => { Some(Type::new_with_resolver_inner(db, &resolver, it.clone())) } _ => None, } } + + pub fn is_unstable(self, db: &dyn HirDatabase) -> bool { + db.attrs(GenericParamId::from(self.id).into()).is_unstable() + } } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -3241,6 +3390,26 @@ impl TypeOrConstParam { Either::Right(it) => it.ty(db), } } + + pub fn as_type_param(self, db: &dyn HirDatabase) -> Option { + let params = db.generic_params(self.id.parent); + match ¶ms.type_or_consts[self.id.local_id] { + hir_def::generics::TypeOrConstParamData::TypeParamData(_) => { + Some(TypeParam { id: TypeParamId::from_unchecked(self.id) }) + } + hir_def::generics::TypeOrConstParamData::ConstParamData(_) => None, + } + } + + pub fn as_const_param(self, db: &dyn HirDatabase) -> Option { + let params = db.generic_params(self.id.parent); + match ¶ms.type_or_consts[self.id.local_id] { + hir_def::generics::TypeOrConstParamData::TypeParamData(_) => None, + hir_def::generics::TypeOrConstParamData::ConstParamData(_) => { + Some(ConstParam { id: ConstParamId::from_unchecked(self.id) }) + } + } + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -3285,12 +3454,11 @@ impl Impl { .filter(filter), ) }); + for id in def_crates .iter() .flat_map(|&id| Crate { id }.transitive_reverse_dependencies(db)) .map(|Crate { id }| id) - .chain(def_crates.iter().copied()) - .unique() { all.extend( db.trait_impls_in_crate(id) @@ -3520,7 +3688,7 @@ pub enum CaptureKind { Move, } -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct Type { env: Arc, ty: Ty, @@ -3620,6 +3788,50 @@ impl Type { matches!(self.ty.kind(Interner), TyKind::Ref(..)) } + pub fn contains_reference(&self, db: &dyn HirDatabase) -> bool { + return go(db, self.env.krate, &self.ty); + + fn go(db: &dyn HirDatabase, krate: CrateId, ty: &Ty) -> bool { + match ty.kind(Interner) { + // Reference itself + TyKind::Ref(_, _, _) => true, + + // For non-phantom_data adts we check variants/fields as well as generic parameters + TyKind::Adt(adt_id, substitution) + if !db.struct_datum(krate, *adt_id).flags.phantom_data => + { + let adt_datum = &db.struct_datum(krate, *adt_id); + let adt_datum_bound = + adt_datum.binders.clone().substitute(Interner, substitution); + adt_datum_bound + .variants + .into_iter() + .flat_map(|variant| variant.fields.into_iter()) + .any(|ty| go(db, krate, &ty)) + || substitution + .iter(Interner) + .filter_map(|x| x.ty(Interner)) + .any(|ty| go(db, krate, ty)) + } + // And for `PhantomData`, we check `T`. + TyKind::Adt(_, substitution) + | TyKind::Tuple(_, substitution) + | TyKind::OpaqueType(_, substitution) + | TyKind::AssociatedType(_, substitution) + | TyKind::FnDef(_, substitution) => substitution + .iter(Interner) + .filter_map(|x| x.ty(Interner)) + .any(|ty| go(db, krate, ty)), + + // For `[T]` or `*T` we check `T` + TyKind::Array(ty, _) | TyKind::Slice(ty) | TyKind::Raw(_, ty) => go(db, krate, ty), + + // Consider everything else as not reference + _ => false, + } + } + } + pub fn as_reference(&self) -> Option<(Type, Mutability)> { let (ty, _lt, m) = self.ty.as_reference()?; let m = Mutability::from_mutable(matches!(m, hir_ty::Mutability::Mut)); @@ -3727,14 +3939,16 @@ impl Type { ) } + // FIXME: Find better API that also handles const generics pub fn impls_trait(&self, db: &dyn HirDatabase, trait_: Trait, args: &[Type]) -> bool { let mut it = args.iter().map(|t| t.ty.clone()); let trait_ref = TyBuilder::trait_ref(db, trait_.id) .push(self.ty.clone()) .fill(|x| { - let r = it.next().unwrap(); match x { - ParamKind::Type => r.cast(Interner), + ParamKind::Type => { + it.next().unwrap_or_else(|| TyKind::Error.intern(Interner)).cast(Interner) + } ParamKind::Const(ty) => { // FIXME: this code is not covered in tests. unknown_const_as_generic(ty.clone()) @@ -4368,12 +4582,24 @@ impl Type { walk_type(db, self, &mut cb); } - + /// Check if type unifies with another type. + /// + /// Note that we consider placeholder types to unify with everything. + /// For example `Option` and `Option` unify although there is unresolved goal `T = U`. pub fn could_unify_with(&self, db: &dyn HirDatabase, other: &Type) -> bool { let tys = hir_ty::replace_errors_with_variables(&(self.ty.clone(), other.ty.clone())); hir_ty::could_unify(db, self.env.clone(), &tys) } + /// Check if type unifies with another type eagerly making sure there are no unresolved goals. + /// + /// This means that placeholder types are not considered to unify if there are any bounds set on + /// them. For example `Option` and `Option` do not unify as we cannot show that `T = U` + pub fn could_unify_with_deeply(&self, db: &dyn HirDatabase, other: &Type) -> bool { + let tys = hir_ty::replace_errors_with_variables(&(self.ty.clone(), other.ty.clone())); + hir_ty::could_unify_deeply(db, self.env.clone(), &tys) + } + pub fn could_coerce_to(&self, db: &dyn HirDatabase, to: &Type) -> bool { let tys = hir_ty::replace_errors_with_variables(&(self.ty.clone(), to.ty.clone())); hir_ty::could_coerce(db, self.env.clone(), &tys) diff --git a/crates/hir/src/term_search.rs b/crates/hir/src/term_search.rs new file mode 100644 index 0000000000000..72762007dc98f --- /dev/null +++ b/crates/hir/src/term_search.rs @@ -0,0 +1,298 @@ +//! Term search + +use hir_def::type_ref::Mutability; +use hir_ty::db::HirDatabase; +use itertools::Itertools; +use rustc_hash::{FxHashMap, FxHashSet}; + +use crate::{ModuleDef, ScopeDef, Semantics, SemanticsScope, Type}; + +mod expr; +pub use expr::Expr; + +mod tactics; + +/// Key for lookup table to query new types reached. +#[derive(Debug, Hash, PartialEq, Eq)] +enum NewTypesKey { + ImplMethod, + StructProjection, +} + +/// Helper enum to squash big number of alternative trees into `Many` variant as there is too many +/// to take into account. +#[derive(Debug)] +enum AlternativeExprs { + /// There are few trees, so we keep track of them all + Few(FxHashSet), + /// There are too many trees to keep track of + Many, +} + +impl AlternativeExprs { + /// Construct alternative trees + /// + /// # Arguments + /// `threshold` - threshold value for many trees (more than that is many) + /// `exprs` - expressions iterator + fn new(threshold: usize, exprs: impl Iterator) -> AlternativeExprs { + let mut it = AlternativeExprs::Few(Default::default()); + it.extend_with_threshold(threshold, exprs); + it + } + + /// Get type trees stored in alternative trees (or `Expr::Many` in case of many) + /// + /// # Arguments + /// `ty` - Type of expressions queried (this is used to give type to `Expr::Many`) + fn exprs(&self, ty: &Type) -> Vec { + match self { + AlternativeExprs::Few(exprs) => exprs.iter().cloned().collect(), + AlternativeExprs::Many => vec![Expr::Many(ty.clone())], + } + } + + /// Extend alternative expressions + /// + /// # Arguments + /// `threshold` - threshold value for many trees (more than that is many) + /// `exprs` - expressions iterator + fn extend_with_threshold(&mut self, threshold: usize, exprs: impl Iterator) { + match self { + AlternativeExprs::Few(tts) => { + for it in exprs { + if tts.len() > threshold { + *self = AlternativeExprs::Many; + break; + } + + tts.insert(it); + } + } + AlternativeExprs::Many => (), + } + } +} + +/// # Lookup table for term search +/// +/// Lookup table keeps all the state during term search. +/// This means it knows what types and how are reachable. +/// +/// The secondary functionality for lookup table is to keep track of new types reached since last +/// iteration as well as keeping track of which `ScopeDef` items have been used. +/// Both of them are to speed up the term search by leaving out types / ScopeDefs that likely do +/// not produce any new results. +#[derive(Default, Debug)] +struct LookupTable { + /// All the `Expr`s in "value" produce the type of "key" + data: FxHashMap, + /// New types reached since last query by the `NewTypesKey` + new_types: FxHashMap>, + /// ScopeDefs that are not interesting any more + exhausted_scopedefs: FxHashSet, + /// ScopeDefs that were used in current round + round_scopedef_hits: FxHashSet, + /// Amount of rounds since scopedef was first used. + rounds_since_sopedef_hit: FxHashMap, + /// Types queried but not present + types_wishlist: FxHashSet, + /// Threshold to squash trees to `Many` + many_threshold: usize, +} + +impl LookupTable { + /// Initialize lookup table + fn new(many_threshold: usize) -> Self { + let mut res = Self { many_threshold, ..Default::default() }; + res.new_types.insert(NewTypesKey::ImplMethod, Vec::new()); + res.new_types.insert(NewTypesKey::StructProjection, Vec::new()); + res + } + + /// Find all `Expr`s that unify with the `ty` + fn find(&self, db: &dyn HirDatabase, ty: &Type) -> Option> { + self.data + .iter() + .find(|(t, _)| t.could_unify_with_deeply(db, ty)) + .map(|(t, tts)| tts.exprs(t)) + } + + /// Same as find but automatically creates shared reference of types in the lookup + /// + /// For example if we have type `i32` in data and we query for `&i32` it map all the type + /// trees we have for `i32` with `Expr::Reference` and returns them. + fn find_autoref(&self, db: &dyn HirDatabase, ty: &Type) -> Option> { + self.data + .iter() + .find(|(t, _)| t.could_unify_with_deeply(db, ty)) + .map(|(t, it)| it.exprs(t)) + .or_else(|| { + self.data + .iter() + .find(|(t, _)| { + Type::reference(t, Mutability::Shared).could_unify_with_deeply(db, ty) + }) + .map(|(t, it)| { + it.exprs(t) + .into_iter() + .map(|expr| Expr::Reference(Box::new(expr))) + .collect() + }) + }) + } + + /// Insert new type trees for type + /// + /// Note that the types have to be the same, unification is not enough as unification is not + /// transitive. For example Vec and FxHashSet both unify with Iterator, + /// but they clearly do not unify themselves. + fn insert(&mut self, ty: Type, exprs: impl Iterator) { + match self.data.get_mut(&ty) { + Some(it) => it.extend_with_threshold(self.many_threshold, exprs), + None => { + self.data.insert(ty.clone(), AlternativeExprs::new(self.many_threshold, exprs)); + for it in self.new_types.values_mut() { + it.push(ty.clone()); + } + } + } + } + + /// Iterate all the reachable types + fn iter_types(&self) -> impl Iterator + '_ { + self.data.keys().cloned() + } + + /// Query new types reached since last query by key + /// + /// Create new key if you wish to query it to avoid conflicting with existing queries. + fn new_types(&mut self, key: NewTypesKey) -> Vec { + match self.new_types.get_mut(&key) { + Some(it) => std::mem::take(it), + None => Vec::new(), + } + } + + /// Mark `ScopeDef` as exhausted meaning it is not interesting for us any more + fn mark_exhausted(&mut self, def: ScopeDef) { + self.exhausted_scopedefs.insert(def); + } + + /// Mark `ScopeDef` as used meaning we managed to produce something useful from it + fn mark_fulfilled(&mut self, def: ScopeDef) { + self.round_scopedef_hits.insert(def); + } + + /// Start new round (meant to be called at the beginning of iteration in `term_search`) + /// + /// This functions marks some `ScopeDef`s as exhausted if there have been + /// `MAX_ROUNDS_AFTER_HIT` rounds after first using a `ScopeDef`. + fn new_round(&mut self) { + for def in &self.round_scopedef_hits { + let hits = + self.rounds_since_sopedef_hit.entry(*def).and_modify(|n| *n += 1).or_insert(0); + const MAX_ROUNDS_AFTER_HIT: u32 = 2; + if *hits > MAX_ROUNDS_AFTER_HIT { + self.exhausted_scopedefs.insert(*def); + } + } + self.round_scopedef_hits.clear(); + } + + /// Get exhausted `ScopeDef`s + fn exhausted_scopedefs(&self) -> &FxHashSet { + &self.exhausted_scopedefs + } + + /// Types queried but not found + fn take_types_wishlist(&mut self) -> FxHashSet { + std::mem::take(&mut self.types_wishlist) + } +} + +/// Context for the `term_search` function +#[derive(Debug)] +pub struct TermSearchCtx<'a, DB: HirDatabase> { + /// Semantics for the program + pub sema: &'a Semantics<'a, DB>, + /// Semantic scope, captures context for the term search + pub scope: &'a SemanticsScope<'a>, + /// Target / expected output type + pub goal: Type, + /// Configuration for term search + pub config: TermSearchConfig, +} + +/// Configuration options for the term search +#[derive(Debug, Clone, Copy)] +pub struct TermSearchConfig { + /// Enable borrow checking, this guarantees the outputs of the `term_search` to borrow-check + pub enable_borrowcheck: bool, + /// Indicate when to squash multiple trees to `Many` as there are too many to keep track + pub many_alternatives_threshold: usize, + /// Depth of the search eg. number of cycles to run + pub depth: usize, +} + +impl Default for TermSearchConfig { + fn default() -> Self { + Self { enable_borrowcheck: true, many_alternatives_threshold: 1, depth: 6 } + } +} + +/// # Term search +/// +/// Search for terms (expressions) that unify with the `goal` type. +/// +/// # Arguments +/// * `ctx` - Context for term search +/// +/// Internally this function uses Breadth First Search to find path to `goal` type. +/// The general idea is following: +/// 1. Populate lookup (frontier for BFS) from values (local variables, statics, constants, etc) +/// as well as from well knows values (such as `true/false` and `()`) +/// 2. Iteratively expand the frontier (or contents of the lookup) by trying different type +/// transformation tactics. For example functions take as from set of types (arguments) to some +/// type (return type). Other transformations include methods on type, type constructors and +/// projections to struct fields (field access). +/// 3. Once we manage to find path to type we are interested in we continue for single round to see +/// if we can find more paths that take us to the `goal` type. +/// 4. Return all the paths (type trees) that take us to the `goal` type. +/// +/// Note that there are usually more ways we can get to the `goal` type but some are discarded to +/// reduce the memory consumption. It is also unlikely anyone is willing ti browse through +/// thousands of possible responses so we currently take first 10 from every tactic. +pub fn term_search(ctx: &TermSearchCtx<'_, DB>) -> Vec { + let module = ctx.scope.module(); + let mut defs = FxHashSet::default(); + defs.insert(ScopeDef::ModuleDef(ModuleDef::Module(module))); + + ctx.scope.process_all_names(&mut |_, def| { + defs.insert(def); + }); + + let mut lookup = LookupTable::new(ctx.config.many_alternatives_threshold); + + // Try trivial tactic first, also populates lookup table + let mut solutions: Vec = tactics::trivial(ctx, &defs, &mut lookup).collect(); + // Use well known types tactic before iterations as it does not depend on other tactics + solutions.extend(tactics::famous_types(ctx, &defs, &mut lookup)); + + for _ in 0..ctx.config.depth { + lookup.new_round(); + + solutions.extend(tactics::type_constructor(ctx, &defs, &mut lookup)); + solutions.extend(tactics::free_function(ctx, &defs, &mut lookup)); + solutions.extend(tactics::impl_method(ctx, &defs, &mut lookup)); + solutions.extend(tactics::struct_projection(ctx, &defs, &mut lookup)); + solutions.extend(tactics::impl_static_method(ctx, &defs, &mut lookup)); + + // Discard not interesting `ScopeDef`s for speedup + for def in lookup.exhausted_scopedefs() { + defs.remove(def); + } + } + + solutions.into_iter().filter(|it| !it.is_many()).unique().collect() +} diff --git a/crates/hir/src/term_search/expr.rs b/crates/hir/src/term_search/expr.rs new file mode 100644 index 0000000000000..254fbe7e2b53e --- /dev/null +++ b/crates/hir/src/term_search/expr.rs @@ -0,0 +1,468 @@ +//! Type tree for term search + +use hir_def::find_path::PrefixKind; +use hir_expand::mod_path::ModPath; +use hir_ty::{ + db::HirDatabase, + display::{DisplaySourceCodeError, HirDisplay}, +}; +use itertools::Itertools; + +use crate::{ + Adt, AsAssocItem, Const, ConstParam, Field, Function, GenericDef, Local, ModuleDef, + SemanticsScope, Static, Struct, StructKind, Trait, Type, Variant, +}; + +/// Helper function to get path to `ModuleDef` +fn mod_item_path( + sema_scope: &SemanticsScope<'_>, + def: &ModuleDef, + prefer_no_std: bool, + prefer_prelude: bool, +) -> Option { + let db = sema_scope.db; + // Account for locals shadowing items from module + let name_hit_count = def.name(db).map(|def_name| { + let mut name_hit_count = 0; + sema_scope.process_all_names(&mut |name, _| { + if name == def_name { + name_hit_count += 1; + } + }); + name_hit_count + }); + + let m = sema_scope.module(); + match name_hit_count { + Some(0..=1) | None => m.find_use_path(db.upcast(), *def, prefer_no_std, prefer_prelude), + Some(_) => m.find_use_path_prefixed( + db.upcast(), + *def, + PrefixKind::ByCrate, + prefer_no_std, + prefer_prelude, + ), + } +} + +/// Helper function to get path to `ModuleDef` as string +fn mod_item_path_str( + sema_scope: &SemanticsScope<'_>, + def: &ModuleDef, + prefer_no_std: bool, + prefer_prelude: bool, +) -> Result { + let path = mod_item_path(sema_scope, def, prefer_no_std, prefer_prelude); + path.map(|it| it.display(sema_scope.db.upcast()).to_string()) + .ok_or(DisplaySourceCodeError::PathNotFound) +} + +/// Helper function to get path to `Type` +fn type_path( + sema_scope: &SemanticsScope<'_>, + ty: &Type, + prefer_no_std: bool, + prefer_prelude: bool, +) -> Result { + let db = sema_scope.db; + let m = sema_scope.module(); + + match ty.as_adt() { + Some(adt) => { + let ty_name = ty.display_source_code(db, m.id, true)?; + + let mut path = + mod_item_path(sema_scope, &ModuleDef::Adt(adt), prefer_no_std, prefer_prelude) + .unwrap(); + path.pop_segment(); + let path = path.display(db.upcast()).to_string(); + let res = match path.is_empty() { + true => ty_name, + false => format!("{path}::{ty_name}"), + }; + Ok(res) + } + None => ty.display_source_code(db, m.id, true), + } +} + +/// Helper function to filter out generic parameters that are default +fn non_default_generics(db: &dyn HirDatabase, def: GenericDef, generics: &[Type]) -> Vec { + def.type_or_const_params(db) + .into_iter() + .filter_map(|it| it.as_type_param(db)) + .zip(generics) + .filter(|(tp, arg)| tp.default(db).as_ref() != Some(arg)) + .map(|(_, arg)| arg.clone()) + .collect() +} + +/// Type tree shows how can we get from set of types to some type. +/// +/// Consider the following code as an example +/// ``` +/// fn foo(x: i32, y: bool) -> Option { None } +/// fn bar() { +/// let a = 1; +/// let b = true; +/// let c: Option = _; +/// } +/// ``` +/// If we generate type tree in the place of `_` we get +/// ```txt +/// Option +/// | +/// foo(i32, bool) +/// / \ +/// a: i32 b: bool +/// ``` +/// So in short it pretty much gives us a way to get type `Option` using the items we have in +/// scope. +#[derive(Debug, Clone, Eq, Hash, PartialEq)] +pub enum Expr { + /// Constant + Const(Const), + /// Static variable + Static(Static), + /// Local variable + Local(Local), + /// Constant generic parameter + ConstParam(ConstParam), + /// Well known type (such as `true` for bool) + FamousType { ty: Type, value: &'static str }, + /// Function call (does not take self param) + Function { func: Function, generics: Vec, params: Vec }, + /// Method call (has self param) + Method { func: Function, generics: Vec, target: Box, params: Vec }, + /// Enum variant construction + Variant { variant: Variant, generics: Vec, params: Vec }, + /// Struct construction + Struct { strukt: Struct, generics: Vec, params: Vec }, + /// Struct field access + Field { expr: Box, field: Field }, + /// Passing type as reference (with `&`) + Reference(Box), + /// Indicates possibility of many different options that all evaluate to `ty` + Many(Type), +} + +impl Expr { + /// Generate source code for type tree. + /// + /// Note that trait imports are not added to generated code. + /// To make sure that the code is valid, callee has to also ensure that all the traits listed + /// by `traits_used` method are also imported. + pub fn gen_source_code( + &self, + sema_scope: &SemanticsScope<'_>, + many_formatter: &mut dyn FnMut(&Type) -> String, + prefer_no_std: bool, + prefer_prelude: bool, + ) -> Result { + let db = sema_scope.db; + let mod_item_path_str = |s, def| mod_item_path_str(s, def, prefer_no_std, prefer_prelude); + match self { + Expr::Const(it) => mod_item_path_str(sema_scope, &ModuleDef::Const(*it)), + Expr::Static(it) => mod_item_path_str(sema_scope, &ModuleDef::Static(*it)), + Expr::Local(it) => Ok(it.name(db).display(db.upcast()).to_string()), + Expr::ConstParam(it) => Ok(it.name(db).display(db.upcast()).to_string()), + Expr::FamousType { value, .. } => Ok(value.to_string()), + Expr::Function { func, params, .. } => { + let args = params + .iter() + .map(|f| { + f.gen_source_code(sema_scope, many_formatter, prefer_no_std, prefer_prelude) + }) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + + match func.as_assoc_item(db).map(|it| it.container(db)) { + Some(container) => { + let container_name = match container { + crate::AssocItemContainer::Trait(trait_) => { + mod_item_path_str(sema_scope, &ModuleDef::Trait(trait_))? + } + crate::AssocItemContainer::Impl(imp) => { + let self_ty = imp.self_ty(db); + // Should it be guaranteed that `mod_item_path` always exists? + match self_ty.as_adt().and_then(|adt| { + mod_item_path( + sema_scope, + &adt.into(), + prefer_no_std, + prefer_prelude, + ) + }) { + Some(path) => path.display(sema_scope.db.upcast()).to_string(), + None => self_ty.display(db).to_string(), + } + } + }; + let fn_name = func.name(db).display(db.upcast()).to_string(); + Ok(format!("{container_name}::{fn_name}({args})")) + } + None => { + let fn_name = mod_item_path_str(sema_scope, &ModuleDef::Function(*func))?; + Ok(format!("{fn_name}({args})")) + } + } + } + Expr::Method { func, target, params, .. } => { + if target.contains_many_in_illegal_pos() { + return Ok(many_formatter(&target.ty(db))); + } + + let func_name = func.name(db).display(db.upcast()).to_string(); + let self_param = func.self_param(db).unwrap(); + let target = target.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude, + )?; + let args = params + .iter() + .map(|f| { + f.gen_source_code(sema_scope, many_formatter, prefer_no_std, prefer_prelude) + }) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + + match func.as_assoc_item(db).and_then(|it| it.container_or_implemented_trait(db)) { + Some(trait_) => { + let trait_name = mod_item_path_str(sema_scope, &ModuleDef::Trait(trait_))?; + let target = match self_param.access(db) { + crate::Access::Shared => format!("&{target}"), + crate::Access::Exclusive => format!("&mut {target}"), + crate::Access::Owned => target, + }; + let res = match args.is_empty() { + true => format!("{trait_name}::{func_name}({target})",), + false => format!("{trait_name}::{func_name}({target}, {args})",), + }; + Ok(res) + } + None => Ok(format!("{target}.{func_name}({args})")), + } + } + Expr::Variant { variant, generics, params } => { + let generics = non_default_generics(db, (*variant).into(), generics); + let generics_str = match generics.is_empty() { + true => String::new(), + false => { + let generics = generics + .iter() + .map(|it| type_path(sema_scope, it, prefer_no_std, prefer_prelude)) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + format!("::<{generics}>") + } + }; + let inner = match variant.kind(db) { + StructKind::Tuple => { + let args = params + .iter() + .map(|f| { + f.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude, + ) + }) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + format!("{generics_str}({args})") + } + StructKind::Record => { + let fields = variant.fields(db); + let args = params + .iter() + .zip(fields.iter()) + .map(|(a, f)| { + let tmp = format!( + "{}: {}", + f.name(db).display(db.upcast()), + a.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude + )? + ); + Ok(tmp) + }) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + format!("{generics_str}{{ {args} }}") + } + StructKind::Unit => generics_str, + }; + + let prefix = mod_item_path_str(sema_scope, &ModuleDef::Variant(*variant))?; + Ok(format!("{prefix}{inner}")) + } + Expr::Struct { strukt, generics, params } => { + let generics = non_default_generics(db, (*strukt).into(), generics); + let inner = match strukt.kind(db) { + StructKind::Tuple => { + let args = params + .iter() + .map(|a| { + a.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude, + ) + }) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + format!("({args})") + } + StructKind::Record => { + let fields = strukt.fields(db); + let args = params + .iter() + .zip(fields.iter()) + .map(|(a, f)| { + let tmp = format!( + "{}: {}", + f.name(db).display(db.upcast()), + a.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude + )? + ); + Ok(tmp) + }) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + format!(" {{ {args} }}") + } + StructKind::Unit => match generics.is_empty() { + true => String::new(), + false => { + let generics = generics + .iter() + .map(|it| type_path(sema_scope, it, prefer_no_std, prefer_prelude)) + .collect::, DisplaySourceCodeError>>()? + .into_iter() + .join(", "); + format!("::<{generics}>") + } + }, + }; + + let prefix = mod_item_path_str(sema_scope, &ModuleDef::Adt(Adt::Struct(*strukt)))?; + Ok(format!("{prefix}{inner}")) + } + Expr::Field { expr, field } => { + if expr.contains_many_in_illegal_pos() { + return Ok(many_formatter(&expr.ty(db))); + } + + let strukt = expr.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude, + )?; + let field = field.name(db).display(db.upcast()).to_string(); + Ok(format!("{strukt}.{field}")) + } + Expr::Reference(expr) => { + if expr.contains_many_in_illegal_pos() { + return Ok(many_formatter(&expr.ty(db))); + } + + let inner = expr.gen_source_code( + sema_scope, + many_formatter, + prefer_no_std, + prefer_prelude, + )?; + Ok(format!("&{inner}")) + } + Expr::Many(ty) => Ok(many_formatter(ty)), + } + } + + /// Get type of the type tree. + /// + /// Same as getting the type of root node + pub fn ty(&self, db: &dyn HirDatabase) -> Type { + match self { + Expr::Const(it) => it.ty(db), + Expr::Static(it) => it.ty(db), + Expr::Local(it) => it.ty(db), + Expr::ConstParam(it) => it.ty(db), + Expr::FamousType { ty, .. } => ty.clone(), + Expr::Function { func, generics, .. } => { + func.ret_type_with_args(db, generics.iter().cloned()) + } + Expr::Method { func, generics, target, .. } => func.ret_type_with_args( + db, + target.ty(db).type_arguments().chain(generics.iter().cloned()), + ), + Expr::Variant { variant, generics, .. } => { + Adt::from(variant.parent_enum(db)).ty_with_args(db, generics.iter().cloned()) + } + Expr::Struct { strukt, generics, .. } => { + Adt::from(*strukt).ty_with_args(db, generics.iter().cloned()) + } + Expr::Field { expr, field } => field.ty_with_args(db, expr.ty(db).type_arguments()), + Expr::Reference(it) => it.ty(db), + Expr::Many(ty) => ty.clone(), + } + } + + /// List the traits used in type tree + pub fn traits_used(&self, db: &dyn HirDatabase) -> Vec { + let mut res = Vec::new(); + + if let Expr::Method { func, params, .. } = self { + res.extend(params.iter().flat_map(|it| it.traits_used(db))); + if let Some(it) = func.as_assoc_item(db) { + if let Some(it) = it.container_or_implemented_trait(db) { + res.push(it); + } + } + } + + res + } + + /// Check in the tree contains `Expr::Many` variant in illegal place to insert `todo`, + /// `unimplemented` or similar macro + /// + /// Some examples are following + /// ```no_compile + /// macro!().foo + /// macro!().bar() + /// ¯o!() + /// ``` + fn contains_many_in_illegal_pos(&self) -> bool { + match self { + Expr::Method { target, .. } => target.contains_many_in_illegal_pos(), + Expr::Field { expr, .. } => expr.contains_many_in_illegal_pos(), + Expr::Reference(target) => target.is_many(), + Expr::Many(_) => true, + _ => false, + } + } + + /// Helper function to check if outermost type tree is `Expr::Many` variant + pub fn is_many(&self) -> bool { + matches!(self, Expr::Many(_)) + } +} diff --git a/crates/hir/src/term_search/tactics.rs b/crates/hir/src/term_search/tactics.rs new file mode 100644 index 0000000000000..666d63ac1558b --- /dev/null +++ b/crates/hir/src/term_search/tactics.rs @@ -0,0 +1,859 @@ +//! Tactics for term search +//! +//! All the tactics take following arguments +//! * `ctx` - Context for the term search +//! * `defs` - Set of items in scope at term search target location +//! * `lookup` - Lookup table for types +//! And they return iterator that yields type trees that unify with the `goal` type. + +use std::iter; + +use hir_ty::db::HirDatabase; +use hir_ty::mir::BorrowKind; +use hir_ty::TyBuilder; +use itertools::Itertools; +use rustc_hash::FxHashSet; + +use crate::{ + Adt, AssocItem, Enum, GenericDef, GenericParam, HasVisibility, Impl, ModuleDef, ScopeDef, Type, + TypeParam, Variant, +}; + +use crate::term_search::{Expr, TermSearchConfig}; + +use super::{LookupTable, NewTypesKey, TermSearchCtx}; + +/// # Trivial tactic +/// +/// Attempts to fulfill the goal by trying items in scope +/// Also works as a starting point to move all items in scope to lookup table. +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +/// +/// Returns iterator that yields elements that unify with `goal`. +/// +/// _Note that there is no use of calling this tactic in every iteration as the output does not +/// depend on the current state of `lookup`_ +pub(super) fn trivial<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + defs.iter().filter_map(|def| { + let expr = match def { + ScopeDef::ModuleDef(ModuleDef::Const(it)) => Some(Expr::Const(*it)), + ScopeDef::ModuleDef(ModuleDef::Static(it)) => Some(Expr::Static(*it)), + ScopeDef::GenericParam(GenericParam::ConstParam(it)) => Some(Expr::ConstParam(*it)), + ScopeDef::Local(it) => { + if ctx.config.enable_borrowcheck { + let borrowck = db.borrowck(it.parent).ok()?; + + let invalid = borrowck.iter().any(|b| { + b.partially_moved.iter().any(|moved| { + Some(&moved.local) == b.mir_body.binding_locals.get(it.binding_id) + }) || b.borrow_regions.iter().any(|region| { + // Shared borrows are fine + Some(®ion.local) == b.mir_body.binding_locals.get(it.binding_id) + && region.kind != BorrowKind::Shared + }) + }); + + if invalid { + return None; + } + } + + Some(Expr::Local(*it)) + } + _ => None, + }?; + + lookup.mark_exhausted(*def); + + let ty = expr.ty(db); + lookup.insert(ty.clone(), std::iter::once(expr.clone())); + + // Don't suggest local references as they are not valid for return + if matches!(expr, Expr::Local(_)) && ty.contains_reference(db) { + return None; + } + + ty.could_unify_with_deeply(db, &ctx.goal).then_some(expr) + }) +} + +/// # Type constructor tactic +/// +/// Attempts different type constructors for enums and structs in scope +/// +/// Updates lookup by new types reached and returns iterator that yields +/// elements that unify with `goal`. +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +pub(super) fn type_constructor<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + let module = ctx.scope.module(); + fn variant_helper( + db: &dyn HirDatabase, + lookup: &mut LookupTable, + parent_enum: Enum, + variant: Variant, + goal: &Type, + config: &TermSearchConfig, + ) -> Vec<(Type, Vec)> { + // Ignore unstable + if variant.is_unstable(db) { + return Vec::new(); + } + + let generics = GenericDef::from(variant.parent_enum(db)); + let Some(type_params) = generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>() + else { + // Ignore enums with const generics + return Vec::new(); + }; + + // We currently do not check lifetime bounds so ignore all types that have something to do + // with them + if !generics.lifetime_params(db).is_empty() { + return Vec::new(); + } + + // Only account for stable type parameters for now, unstable params can be default + // tho, for example in `Box` + if type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) { + return Vec::new(); + } + + let non_default_type_params_len = + type_params.iter().filter(|it| it.default(db).is_none()).count(); + + let generic_params = lookup + .iter_types() + .collect::>() // Force take ownership + .into_iter() + .permutations(non_default_type_params_len); + + generic_params + .filter_map(move |generics| { + // Insert default type params + let mut g = generics.into_iter(); + let generics: Vec<_> = type_params + .iter() + .map(|it| it.default(db).unwrap_or_else(|| g.next().expect("No generic"))) + .collect(); + + let enum_ty = Adt::from(parent_enum).ty_with_args(db, generics.iter().cloned()); + + // Allow types with generics only if they take us straight to goal for + // performance reasons + if !generics.is_empty() && !enum_ty.could_unify_with_deeply(db, goal) { + return None; + } + + // Ignore types that have something to do with lifetimes + if config.enable_borrowcheck && enum_ty.contains_reference(db) { + return None; + } + + // Early exit if some param cannot be filled from lookup + let param_exprs: Vec> = variant + .fields(db) + .into_iter() + .map(|field| lookup.find(db, &field.ty_with_args(db, generics.iter().cloned()))) + .collect::>()?; + + // Note that we need special case for 0 param constructors because of multi cartesian + // product + let variant_exprs: Vec = if param_exprs.is_empty() { + vec![Expr::Variant { variant, generics: generics.clone(), params: Vec::new() }] + } else { + param_exprs + .into_iter() + .multi_cartesian_product() + .map(|params| Expr::Variant { variant, generics: generics.clone(), params }) + .collect() + }; + lookup.insert(enum_ty.clone(), variant_exprs.iter().cloned()); + + Some((enum_ty, variant_exprs)) + }) + .collect() + } + defs.iter() + .filter_map(move |def| match def { + ScopeDef::ModuleDef(ModuleDef::Variant(it)) => { + let variant_exprs = + variant_helper(db, lookup, it.parent_enum(db), *it, &ctx.goal, &ctx.config); + if variant_exprs.is_empty() { + return None; + } + lookup.mark_fulfilled(ScopeDef::ModuleDef(ModuleDef::Variant(*it))); + Some(variant_exprs) + } + ScopeDef::ModuleDef(ModuleDef::Adt(Adt::Enum(enum_))) => { + let exprs: Vec<(Type, Vec)> = enum_ + .variants(db) + .into_iter() + .flat_map(|it| variant_helper(db, lookup, *enum_, it, &ctx.goal, &ctx.config)) + .collect(); + + if !exprs.is_empty() { + lookup.mark_fulfilled(ScopeDef::ModuleDef(ModuleDef::Adt(Adt::Enum(*enum_)))); + } + + Some(exprs) + } + ScopeDef::ModuleDef(ModuleDef::Adt(Adt::Struct(it))) => { + // Ignore unstable and not visible + if it.is_unstable(db) || !it.is_visible_from(db, module) { + return None; + } + + let generics = GenericDef::from(*it); + + // Ignore const params for now + let type_params = generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>()?; + + // We currently do not check lifetime bounds so ignore all types that have something to do + // with them + if !generics.lifetime_params(db).is_empty() { + return None; + } + + // Only account for stable type parameters for now, unstable params can be default + // tho, for example in `Box` + if type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) { + return None; + } + + let non_default_type_params_len = + type_params.iter().filter(|it| it.default(db).is_none()).count(); + + let generic_params = lookup + .iter_types() + .collect::>() // Force take ownership + .into_iter() + .permutations(non_default_type_params_len); + + let exprs = generic_params + .filter_map(|generics| { + // Insert default type params + let mut g = generics.into_iter(); + let generics: Vec<_> = type_params + .iter() + .map(|it| { + it.default(db) + .unwrap_or_else(|| g.next().expect("Missing type param")) + }) + .collect(); + + let struct_ty = Adt::from(*it).ty_with_args(db, generics.iter().cloned()); + + // Allow types with generics only if they take us straight to goal for + // performance reasons + if non_default_type_params_len != 0 + && struct_ty.could_unify_with_deeply(db, &ctx.goal) + { + return None; + } + + // Ignore types that have something to do with lifetimes + if ctx.config.enable_borrowcheck && struct_ty.contains_reference(db) { + return None; + } + let fileds = it.fields(db); + // Check if all fields are visible, otherwise we cannot fill them + if fileds.iter().any(|it| !it.is_visible_from(db, module)) { + return None; + } + + // Early exit if some param cannot be filled from lookup + let param_exprs: Vec> = fileds + .into_iter() + .map(|field| lookup.find(db, &field.ty(db))) + .collect::>()?; + + // Note that we need special case for 0 param constructors because of multi cartesian + // product + let struct_exprs: Vec = if param_exprs.is_empty() { + vec![Expr::Struct { strukt: *it, generics, params: Vec::new() }] + } else { + param_exprs + .into_iter() + .multi_cartesian_product() + .map(|params| Expr::Struct { + strukt: *it, + generics: generics.clone(), + params, + }) + .collect() + }; + + lookup + .mark_fulfilled(ScopeDef::ModuleDef(ModuleDef::Adt(Adt::Struct(*it)))); + lookup.insert(struct_ty.clone(), struct_exprs.iter().cloned()); + + Some((struct_ty, struct_exprs)) + }) + .collect(); + Some(exprs) + } + _ => None, + }) + .flatten() + .filter_map(|(ty, exprs)| ty.could_unify_with_deeply(db, &ctx.goal).then_some(exprs)) + .flatten() +} + +/// # Free function tactic +/// +/// Attempts to call different functions in scope with parameters from lookup table. +/// Functions that include generics are not used for performance reasons. +/// +/// Updates lookup by new types reached and returns iterator that yields +/// elements that unify with `goal`. +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +pub(super) fn free_function<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + let module = ctx.scope.module(); + defs.iter() + .filter_map(move |def| match def { + ScopeDef::ModuleDef(ModuleDef::Function(it)) => { + let generics = GenericDef::from(*it); + + // Ignore const params for now + let type_params = generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>()?; + + // Ignore lifetimes as we do not check them + if !generics.lifetime_params(db).is_empty() { + return None; + } + + // Only account for stable type parameters for now, unstable params can be default + // tho, for example in `Box` + if type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) { + return None; + } + + let non_default_type_params_len = + type_params.iter().filter(|it| it.default(db).is_none()).count(); + + // Ignore bigger number of generics for now as they kill the performance + if non_default_type_params_len > 0 { + return None; + } + + let generic_params = lookup + .iter_types() + .collect::>() // Force take ownership + .into_iter() + .permutations(non_default_type_params_len); + + let exprs: Vec<_> = generic_params + .filter_map(|generics| { + // Insert default type params + let mut g = generics.into_iter(); + let generics: Vec<_> = type_params + .iter() + .map(|it| match it.default(db) { + Some(ty) => Some(ty), + None => { + let generic = g.next().expect("Missing type param"); + // Filter out generics that do not unify due to trait bounds + it.ty(db).could_unify_with(db, &generic).then_some(generic) + } + }) + .collect::>()?; + + let ret_ty = it.ret_type_with_args(db, generics.iter().cloned()); + // Filter out private and unsafe functions + if !it.is_visible_from(db, module) + || it.is_unsafe_to_call(db) + || it.is_unstable(db) + || ctx.config.enable_borrowcheck && ret_ty.contains_reference(db) + || ret_ty.is_raw_ptr() + { + return None; + } + + // Early exit if some param cannot be filled from lookup + let param_exprs: Vec> = it + .params_without_self_with_args(db, generics.iter().cloned()) + .into_iter() + .map(|field| { + let ty = field.ty(); + match ty.is_mutable_reference() { + true => None, + false => lookup.find_autoref(db, ty), + } + }) + .collect::>()?; + + // Note that we need special case for 0 param constructors because of multi cartesian + // product + let fn_exprs: Vec = if param_exprs.is_empty() { + vec![Expr::Function { func: *it, generics, params: Vec::new() }] + } else { + param_exprs + .into_iter() + .multi_cartesian_product() + .map(|params| Expr::Function { + func: *it, + generics: generics.clone(), + + params, + }) + .collect() + }; + + lookup.mark_fulfilled(ScopeDef::ModuleDef(ModuleDef::Function(*it))); + lookup.insert(ret_ty.clone(), fn_exprs.iter().cloned()); + Some((ret_ty, fn_exprs)) + }) + .collect(); + Some(exprs) + } + _ => None, + }) + .flatten() + .filter_map(|(ty, exprs)| ty.could_unify_with_deeply(db, &ctx.goal).then_some(exprs)) + .flatten() +} + +/// # Impl method tactic +/// +/// Attempts to to call methods on types from lookup table. +/// This includes both functions from direct impl blocks as well as functions from traits. +/// Methods defined in impl blocks that are generic and methods that are themselves have +/// generics are ignored for performance reasons. +/// +/// Updates lookup by new types reached and returns iterator that yields +/// elements that unify with `goal`. +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +pub(super) fn impl_method<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + _defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + let module = ctx.scope.module(); + lookup + .new_types(NewTypesKey::ImplMethod) + .into_iter() + .flat_map(|ty| { + Impl::all_for_type(db, ty.clone()).into_iter().map(move |imp| (ty.clone(), imp)) + }) + .flat_map(|(ty, imp)| imp.items(db).into_iter().map(move |item| (imp, ty.clone(), item))) + .filter_map(|(imp, ty, it)| match it { + AssocItem::Function(f) => Some((imp, ty, f)), + _ => None, + }) + .filter_map(move |(imp, ty, it)| { + let fn_generics = GenericDef::from(it); + let imp_generics = GenericDef::from(imp); + + // Ignore const params for now + let imp_type_params = imp_generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>()?; + + // Ignore const params for now + let fn_type_params = fn_generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>()?; + + // Ignore all functions that have something to do with lifetimes as we don't check them + if !fn_generics.lifetime_params(db).is_empty() { + return None; + } + + // Ignore functions without self param + if !it.has_self_param(db) { + return None; + } + + // Filter out private and unsafe functions + if !it.is_visible_from(db, module) || it.is_unsafe_to_call(db) || it.is_unstable(db) { + return None; + } + + // Only account for stable type parameters for now, unstable params can be default + // tho, for example in `Box` + if imp_type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) + || fn_type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) + { + return None; + } + + let non_default_type_params_len = imp_type_params + .iter() + .chain(fn_type_params.iter()) + .filter(|it| it.default(db).is_none()) + .count(); + + // Ignore bigger number of generics for now as they kill the performance + if non_default_type_params_len > 0 { + return None; + } + + let generic_params = lookup + .iter_types() + .collect::>() // Force take ownership + .into_iter() + .permutations(non_default_type_params_len); + + let exprs: Vec<_> = generic_params + .filter_map(|generics| { + // Insert default type params + let mut g = generics.into_iter(); + let generics: Vec<_> = imp_type_params + .iter() + .chain(fn_type_params.iter()) + .map(|it| match it.default(db) { + Some(ty) => Some(ty), + None => { + let generic = g.next().expect("Missing type param"); + // Filter out generics that do not unify due to trait bounds + it.ty(db).could_unify_with(db, &generic).then_some(generic) + } + }) + .collect::>()?; + + let ret_ty = it.ret_type_with_args( + db, + ty.type_arguments().chain(generics.iter().cloned()), + ); + // Filter out functions that return references + if ctx.config.enable_borrowcheck && ret_ty.contains_reference(db) + || ret_ty.is_raw_ptr() + { + return None; + } + + // Ignore functions that do not change the type + if ty.could_unify_with_deeply(db, &ret_ty) { + return None; + } + + let self_ty = it + .self_param(db) + .expect("No self param") + .ty_with_args(db, ty.type_arguments().chain(generics.iter().cloned())); + + // Ignore functions that have different self type + if !self_ty.autoderef(db).any(|s_ty| ty == s_ty) { + return None; + } + + let target_type_exprs = lookup.find(db, &ty).expect("Type not in lookup"); + + // Early exit if some param cannot be filled from lookup + let param_exprs: Vec> = it + .params_without_self_with_args( + db, + ty.type_arguments().chain(generics.iter().cloned()), + ) + .into_iter() + .map(|field| lookup.find_autoref(db, field.ty())) + .collect::>()?; + + let fn_exprs: Vec = std::iter::once(target_type_exprs) + .chain(param_exprs) + .multi_cartesian_product() + .map(|params| { + let mut params = params.into_iter(); + let target = Box::new(params.next().unwrap()); + Expr::Method { + func: it, + generics: generics.clone(), + target, + params: params.collect(), + } + }) + .collect(); + + lookup.insert(ret_ty.clone(), fn_exprs.iter().cloned()); + Some((ret_ty, fn_exprs)) + }) + .collect(); + Some(exprs) + }) + .flatten() + .filter_map(|(ty, exprs)| ty.could_unify_with_deeply(db, &ctx.goal).then_some(exprs)) + .flatten() +} + +/// # Struct projection tactic +/// +/// Attempts different struct fields (`foo.bar.baz`) +/// +/// Updates lookup by new types reached and returns iterator that yields +/// elements that unify with `goal`. +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +pub(super) fn struct_projection<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + _defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + let module = ctx.scope.module(); + lookup + .new_types(NewTypesKey::StructProjection) + .into_iter() + .map(|ty| (ty.clone(), lookup.find(db, &ty).expect("Expr not in lookup"))) + .flat_map(move |(ty, targets)| { + ty.fields(db).into_iter().filter_map(move |(field, filed_ty)| { + if !field.is_visible_from(db, module) { + return None; + } + let exprs = targets + .clone() + .into_iter() + .map(move |target| Expr::Field { field, expr: Box::new(target) }); + Some((filed_ty, exprs)) + }) + }) + .filter_map(|(ty, exprs)| ty.could_unify_with_deeply(db, &ctx.goal).then_some(exprs)) + .flatten() +} + +/// # Famous types tactic +/// +/// Attempts different values of well known types such as `true` or `false`. +/// +/// Updates lookup by new types reached and returns iterator that yields +/// elements that unify with `goal`. +/// +/// _Note that there is no point of calling it iteratively as the output is always the same_ +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +pub(super) fn famous_types<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + _defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + let module = ctx.scope.module(); + [ + Expr::FamousType { ty: Type::new(db, module.id, TyBuilder::bool()), value: "true" }, + Expr::FamousType { ty: Type::new(db, module.id, TyBuilder::bool()), value: "false" }, + Expr::FamousType { ty: Type::new(db, module.id, TyBuilder::unit()), value: "()" }, + ] + .into_iter() + .map(|exprs| { + lookup.insert(exprs.ty(db), std::iter::once(exprs.clone())); + exprs + }) + .filter(|expr| expr.ty(db).could_unify_with_deeply(db, &ctx.goal)) +} + +/// # Impl static method (without self type) tactic +/// +/// Attempts different functions from impl blocks that take no self parameter. +/// +/// Updates lookup by new types reached and returns iterator that yields +/// elements that unify with `goal`. +/// +/// # Arguments +/// * `ctx` - Context for the term search +/// * `defs` - Set of items in scope at term search target location +/// * `lookup` - Lookup table for types +pub(super) fn impl_static_method<'a, DB: HirDatabase>( + ctx: &'a TermSearchCtx<'a, DB>, + _defs: &'a FxHashSet, + lookup: &'a mut LookupTable, +) -> impl Iterator + 'a { + let db = ctx.sema.db; + let module = ctx.scope.module(); + lookup + .take_types_wishlist() + .into_iter() + .chain(iter::once(ctx.goal.clone())) + .flat_map(|ty| { + Impl::all_for_type(db, ty.clone()).into_iter().map(move |imp| (ty.clone(), imp)) + }) + .filter(|(_, imp)| !imp.is_unsafe(db)) + .flat_map(|(ty, imp)| imp.items(db).into_iter().map(move |item| (imp, ty.clone(), item))) + .filter_map(|(imp, ty, it)| match it { + AssocItem::Function(f) => Some((imp, ty, f)), + _ => None, + }) + .filter_map(move |(imp, ty, it)| { + let fn_generics = GenericDef::from(it); + let imp_generics = GenericDef::from(imp); + + // Ignore const params for now + let imp_type_params = imp_generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>()?; + + // Ignore const params for now + let fn_type_params = fn_generics + .type_or_const_params(db) + .into_iter() + .map(|it| it.as_type_param(db)) + .collect::>>()?; + + // Ignore all functions that have something to do with lifetimes as we don't check them + if !fn_generics.lifetime_params(db).is_empty() + || !imp_generics.lifetime_params(db).is_empty() + { + return None; + } + + // Ignore functions with self param + if it.has_self_param(db) { + return None; + } + + // Filter out private and unsafe functions + if !it.is_visible_from(db, module) || it.is_unsafe_to_call(db) || it.is_unstable(db) { + return None; + } + + // Only account for stable type parameters for now, unstable params can be default + // tho, for example in `Box` + if imp_type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) + || fn_type_params.iter().any(|it| it.is_unstable(db) && it.default(db).is_none()) + { + return None; + } + + let non_default_type_params_len = imp_type_params + .iter() + .chain(fn_type_params.iter()) + .filter(|it| it.default(db).is_none()) + .count(); + + // Ignore bigger number of generics for now as they kill the performance + if non_default_type_params_len > 1 { + return None; + } + + let generic_params = lookup + .iter_types() + .collect::>() // Force take ownership + .into_iter() + .permutations(non_default_type_params_len); + + let exprs: Vec<_> = generic_params + .filter_map(|generics| { + // Insert default type params + let mut g = generics.into_iter(); + let generics: Vec<_> = imp_type_params + .iter() + .chain(fn_type_params.iter()) + .map(|it| match it.default(db) { + Some(ty) => Some(ty), + None => { + let generic = g.next().expect("Missing type param"); + it.trait_bounds(db) + .into_iter() + .all(|bound| generic.impls_trait(db, bound, &[])); + // Filter out generics that do not unify due to trait bounds + it.ty(db).could_unify_with(db, &generic).then_some(generic) + } + }) + .collect::>()?; + + let ret_ty = it.ret_type_with_args( + db, + ty.type_arguments().chain(generics.iter().cloned()), + ); + // Filter out functions that return references + if ctx.config.enable_borrowcheck && ret_ty.contains_reference(db) + || ret_ty.is_raw_ptr() + { + return None; + } + + // Ignore functions that do not change the type + // if ty.could_unify_with_deeply(db, &ret_ty) { + // return None; + // } + + // Early exit if some param cannot be filled from lookup + let param_exprs: Vec> = it + .params_without_self_with_args( + db, + ty.type_arguments().chain(generics.iter().cloned()), + ) + .into_iter() + .map(|field| lookup.find_autoref(db, field.ty())) + .collect::>()?; + + // Note that we need special case for 0 param constructors because of multi cartesian + // product + let fn_exprs: Vec = if param_exprs.is_empty() { + vec![Expr::Function { func: it, generics, params: Vec::new() }] + } else { + param_exprs + .into_iter() + .multi_cartesian_product() + .map(|params| Expr::Function { + func: it, + generics: generics.clone(), + params, + }) + .collect() + }; + + lookup.insert(ret_ty.clone(), fn_exprs.iter().cloned()); + Some((ret_ty, fn_exprs)) + }) + .collect(); + Some(exprs) + }) + .flatten() + .filter_map(|(ty, exprs)| ty.could_unify_with_deeply(db, &ctx.goal).then_some(exprs)) + .flatten() +} diff --git a/crates/ide-assists/src/handlers/fix_visibility.rs b/crates/ide-assists/src/handlers/fix_visibility.rs index 204e796fa2c0d..589591a6777ee 100644 --- a/crates/ide-assists/src/handlers/fix_visibility.rs +++ b/crates/ide-assists/src/handlers/fix_visibility.rs @@ -79,7 +79,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext<'_>) edit.edit_file(target_file); let vis_owner = edit.make_mut(vis_owner); - vis_owner.set_visibility(missing_visibility.clone_for_update()); + vis_owner.set_visibility(Some(missing_visibility.clone_for_update())); if let Some((cap, vis)) = ctx.config.snippet_cap.zip(vis_owner.visibility()) { edit.add_tabstop_before(cap, vis); @@ -131,7 +131,7 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext<'_> edit.edit_file(target_file); let vis_owner = edit.make_mut(vis_owner); - vis_owner.set_visibility(missing_visibility.clone_for_update()); + vis_owner.set_visibility(Some(missing_visibility.clone_for_update())); if let Some((cap, vis)) = ctx.config.snippet_cap.zip(vis_owner.visibility()) { edit.add_tabstop_before(cap, vis); diff --git a/crates/ide-assists/src/handlers/generate_trait_from_impl.rs b/crates/ide-assists/src/handlers/generate_trait_from_impl.rs index 24094de22c8d1..5f7350bc2812b 100644 --- a/crates/ide-assists/src/handlers/generate_trait_from_impl.rs +++ b/crates/ide-assists/src/handlers/generate_trait_from_impl.rs @@ -1,8 +1,13 @@ use crate::assist_context::{AssistContext, Assists}; use ide_db::assists::AssistId; use syntax::{ - ast::{self, edit::IndentLevel, make, HasGenericParams, HasVisibility}, - ted, AstNode, SyntaxKind, + ast::{ + self, + edit_in_place::{HasVisibilityEdit, Indent}, + make, HasGenericParams, HasName, + }, + ted::{self, Position}, + AstNode, SyntaxKind, T, }; // NOTES : @@ -44,7 +49,7 @@ use syntax::{ // }; // } // -// trait ${0:TraitName} { +// trait ${0:NewTrait} { // // Used as an associated constant. // const CONST_ASSOC: usize = N * 4; // @@ -53,7 +58,7 @@ use syntax::{ // const_maker! {i32, 7} // } // -// impl ${0:TraitName} for Foo { +// impl ${0:NewTrait} for Foo { // // Used as an associated constant. // const CONST_ASSOC: usize = N * 4; // @@ -94,8 +99,10 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_ "Generate trait from impl", impl_ast.syntax().text_range(), |builder| { + let impl_ast = builder.make_mut(impl_ast); let trait_items = assoc_items.clone_for_update(); - let impl_items = assoc_items.clone_for_update(); + let impl_items = builder.make_mut(assoc_items); + let impl_name = builder.make_mut(impl_name); trait_items.assoc_items().for_each(|item| { strip_body(&item); @@ -112,46 +119,42 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_ impl_ast.generic_param_list(), impl_ast.where_clause(), trait_items, - ); + ) + .clone_for_update(); + + let trait_name = trait_ast.name().expect("new trait should have a name"); + let trait_name_ref = make::name_ref(&trait_name.to_string()).clone_for_update(); // Change `impl Foo` to `impl NewTrait for Foo` - let arg_list = if let Some(genpars) = impl_ast.generic_param_list() { - genpars.to_generic_args().to_string() - } else { - "".to_owned() - }; - - if let Some(snippet_cap) = ctx.config.snippet_cap { - builder.replace_snippet( - snippet_cap, - impl_name.syntax().text_range(), - format!("${{0:TraitName}}{} for {}", arg_list, impl_name), - ); + let mut elements = vec![ + trait_name_ref.syntax().clone().into(), + make::tokens::single_space().into(), + make::token(T![for]).into(), + ]; + + if let Some(params) = impl_ast.generic_param_list() { + let gen_args = ¶ms.to_generic_args().clone_for_update(); + elements.insert(1, gen_args.syntax().clone().into()); + } - // Insert trait before TraitImpl - builder.insert_snippet( - snippet_cap, - impl_ast.syntax().text_range().start(), - format!( - "{}\n\n{}", - trait_ast.to_string().replace("NewTrait", "${0:TraitName}"), - IndentLevel::from_node(impl_ast.syntax()) - ), - ); - } else { - builder.replace( - impl_name.syntax().text_range(), - format!("NewTrait{} for {}", arg_list, impl_name), - ); + ted::insert_all(Position::before(impl_name.syntax()), elements); + + // Insert trait before TraitImpl + ted::insert_all_raw( + Position::before(impl_ast.syntax()), + vec![ + trait_ast.syntax().clone().into(), + make::tokens::whitespace(&format!("\n\n{}", impl_ast.indent_level())).into(), + ], + ); - // Insert trait before TraitImpl - builder.insert( - impl_ast.syntax().text_range().start(), - format!("{}\n\n{}", trait_ast, IndentLevel::from_node(impl_ast.syntax())), + // Link the trait name & trait ref names together as a placeholder snippet group + if let Some(cap) = ctx.config.snippet_cap { + builder.add_placeholder_snippet_group( + cap, + vec![trait_name.syntax().clone(), trait_name_ref.syntax().clone()], ); } - - builder.replace(assoc_items.syntax().text_range(), impl_items.to_string()); }, ); @@ -160,23 +163,8 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_ /// `E0449` Trait items always share the visibility of their trait fn remove_items_visibility(item: &ast::AssocItem) { - match item { - ast::AssocItem::Const(c) => { - if let Some(vis) = c.visibility() { - ted::remove(vis.syntax()); - } - } - ast::AssocItem::Fn(f) => { - if let Some(vis) = f.visibility() { - ted::remove(vis.syntax()); - } - } - ast::AssocItem::TypeAlias(t) => { - if let Some(vis) = t.visibility() { - ted::remove(vis.syntax()); - } - } - _ => (), + if let Some(has_vis) = ast::AnyHasVisibility::cast(item.syntax().clone()) { + has_vis.set_visibility(None); } } @@ -404,12 +392,12 @@ impl F$0oo { r#" struct Foo([i32; N]); -trait ${0:TraitName} { +trait ${0:NewTrait} { // Used as an associated constant. const CONST: usize = N * 4; } -impl ${0:TraitName} for Foo { +impl ${0:NewTrait} for Foo { // Used as an associated constant. const CONST: usize = N * 4; } diff --git a/crates/ide-assists/src/handlers/term_search.rs b/crates/ide-assists/src/handlers/term_search.rs new file mode 100644 index 0000000000000..51a1a406f316d --- /dev/null +++ b/crates/ide-assists/src/handlers/term_search.rs @@ -0,0 +1,253 @@ +//! Term search assist +use hir::term_search::TermSearchCtx; +use ide_db::{ + assists::{AssistId, AssistKind, GroupLabel}, + famous_defs::FamousDefs, +}; + +use itertools::Itertools; +use syntax::{ast, AstNode}; + +use crate::assist_context::{AssistContext, Assists}; + +pub(crate) fn term_search(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> { + let unexpanded = ctx.find_node_at_offset::()?; + let syntax = unexpanded.syntax(); + let goal_range = syntax.text_range(); + + let parent = syntax.parent()?; + let scope = ctx.sema.scope(&parent)?; + + let macro_call = ctx.sema.resolve_macro_call(&unexpanded)?; + + let famous_defs = FamousDefs(&ctx.sema, scope.krate()); + let std_todo = famous_defs.core_macros_todo()?; + let std_unimplemented = famous_defs.core_macros_unimplemented()?; + + if macro_call != std_todo && macro_call != std_unimplemented { + return None; + } + + let target_ty = ctx.sema.type_of_expr(&ast::Expr::cast(parent.clone())?)?.adjusted(); + + let term_search_ctx = TermSearchCtx { + sema: &ctx.sema, + scope: &scope, + goal: target_ty, + config: Default::default(), + }; + let paths = hir::term_search::term_search(&term_search_ctx); + + if paths.is_empty() { + return None; + } + + let mut formatter = |_: &hir::Type| String::from("todo!()"); + + let paths = paths + .into_iter() + .filter_map(|path| { + path.gen_source_code( + &scope, + &mut formatter, + ctx.config.prefer_no_std, + ctx.config.prefer_prelude, + ) + .ok() + }) + .unique(); + + for code in paths { + acc.add_group( + &GroupLabel(String::from("Term search")), + AssistId("term_search", AssistKind::Generate), + format!("Replace todo!() with {code}"), + goal_range, + |builder| { + builder.replace(goal_range, code); + }, + ); + } + + Some(()) +} + +#[cfg(test)] +mod tests { + use crate::tests::{check_assist, check_assist_not_applicable}; + + use super::*; + + #[test] + fn test_complete_local() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f() { let a: u128 = 1; let b: u128 = todo$0!() }"#, + r#"fn f() { let a: u128 = 1; let b: u128 = a }"#, + ) + } + + #[test] + fn test_complete_todo_with_msg() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f() { let a: u128 = 1; let b: u128 = todo$0!("asd") }"#, + r#"fn f() { let a: u128 = 1; let b: u128 = a }"#, + ) + } + + #[test] + fn test_complete_unimplemented_with_msg() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f() { let a: u128 = 1; let b: u128 = todo$0!("asd") }"#, + r#"fn f() { let a: u128 = 1; let b: u128 = a }"#, + ) + } + + #[test] + fn test_complete_unimplemented() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f() { let a: u128 = 1; let b: u128 = todo$0!("asd") }"#, + r#"fn f() { let a: u128 = 1; let b: u128 = a }"#, + ) + } + + #[test] + fn test_complete_struct_field() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +struct A { pub x: i32, y: bool } +fn f() { let a = A { x: 1, y: true }; let b: i32 = todo$0!(); }"#, + r#"struct A { pub x: i32, y: bool } +fn f() { let a = A { x: 1, y: true }; let b: i32 = a.x; }"#, + ) + } + + #[test] + fn test_enum_with_generics() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented, option +fn f() { let a: i32 = 1; let b: Option = todo$0!(); }"#, + r#"fn f() { let a: i32 = 1; let b: Option = None; }"#, + ) + } + + #[test] + fn test_enum_with_generics2() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +enum Option { None, Some(T) } +fn f() { let a: i32 = 1; let b: Option = todo$0!(); }"#, + r#"enum Option { None, Some(T) } +fn f() { let a: i32 = 1; let b: Option = Option::Some(a); }"#, + ) + } + + #[test] + fn test_enum_with_generics3() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +enum Option { None, Some(T) } +fn f() { let a: Option = Option::None; let b: Option> = todo$0!(); }"#, + r#"enum Option { None, Some(T) } +fn f() { let a: Option = Option::None; let b: Option> = Option::Some(a); }"#, + ) + } + + #[test] + fn test_enum_with_generics4() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +enum Foo { Foo(T) } +fn f() { let a = 0; let b: Foo = todo$0!(); }"#, + r#"enum Foo { Foo(T) } +fn f() { let a = 0; let b: Foo = Foo::Foo(a); }"#, + ); + + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +enum Foo { Foo(T) } +fn f() { let a: Foo = Foo::Foo(0); let b: Foo = todo$0!(); }"#, + r#"enum Foo { Foo(T) } +fn f() { let a: Foo = Foo::Foo(0); let b: Foo = a; }"#, + ) + } + + #[test] + fn test_newtype() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +struct Foo(i32); +fn f() { let a: i32 = 1; let b: Foo = todo$0!(); }"#, + r#"struct Foo(i32); +fn f() { let a: i32 = 1; let b: Foo = Foo(a); }"#, + ) + } + + #[test] + fn test_shadowing() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f() { let a: i32 = 1; let b: i32 = 2; let a: u32 = 0; let c: i32 = todo$0!(); }"#, + r#"fn f() { let a: i32 = 1; let b: i32 = 2; let a: u32 = 0; let c: i32 = b; }"#, + ) + } + + #[test] + fn test_famous_bool() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f() { let a: bool = todo$0!(); }"#, + r#"fn f() { let a: bool = false; }"#, + ) + } + + #[test] + fn test_fn_with_reference_types() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f(a: &i32) -> f32 { a as f32 } +fn g() { let a = 1; let b: f32 = todo$0!(); }"#, + r#"fn f(a: &i32) -> f32 { a as f32 } +fn g() { let a = 1; let b: f32 = f(&a); }"#, + ) + } + + #[test] + fn test_fn_with_reference_types2() { + check_assist( + term_search, + r#"//- minicore: todo, unimplemented +fn f(a: &i32) -> f32 { a as f32 } +fn g() { let a = &1; let b: f32 = todo$0!(); }"#, + r#"fn f(a: &i32) -> f32 { a as f32 } +fn g() { let a = &1; let b: f32 = f(a); }"#, + ) + } + + #[test] + fn test_fn_with_reference_types3() { + check_assist_not_applicable( + term_search, + r#"//- minicore: todo, unimplemented + fn f(a: &i32) -> f32 { a as f32 } + fn g() { let a = &mut 1; let b: f32 = todo$0!(); }"#, + ) + } +} diff --git a/crates/ide-assists/src/lib.rs b/crates/ide-assists/src/lib.rs index 2fec104323dc7..dcc89014b956b 100644 --- a/crates/ide-assists/src/lib.rs +++ b/crates/ide-assists/src/lib.rs @@ -60,11 +60,6 @@ #![warn(rust_2018_idioms, unused_lifetimes)] -#[allow(unused)] -macro_rules! eprintln { - ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; -} - mod assist_config; mod assist_context; #[cfg(test)] @@ -210,6 +205,7 @@ mod handlers { mod replace_turbofish_with_explicit_type; mod sort_items; mod split_import; + mod term_search; mod toggle_ignore; mod unmerge_match_arm; mod unmerge_use; @@ -332,6 +328,7 @@ mod handlers { replace_arith_op::replace_arith_with_saturating, sort_items::sort_items, split_import::split_import, + term_search::term_search, toggle_ignore::toggle_ignore, unmerge_match_arm::unmerge_match_arm, unmerge_use::unmerge_use, diff --git a/crates/ide-assists/src/tests/generated.rs b/crates/ide-assists/src/tests/generated.rs index 8ad735d0ae801..268ba3225b668 100644 --- a/crates/ide-assists/src/tests/generated.rs +++ b/crates/ide-assists/src/tests/generated.rs @@ -1665,7 +1665,7 @@ macro_rules! const_maker { }; } -trait ${0:TraitName} { +trait ${0:NewTrait} { // Used as an associated constant. const CONST_ASSOC: usize = N * 4; @@ -1674,7 +1674,7 @@ trait ${0:TraitName} { const_maker! {i32, 7} } -impl ${0:TraitName} for Foo { +impl ${0:NewTrait} for Foo { // Used as an associated constant. const CONST_ASSOC: usize = N * 4; diff --git a/crates/ide-completion/src/completions.rs b/crates/ide-completion/src/completions.rs index ba3c0cf3fd60e..1ea7220960d25 100644 --- a/crates/ide-completion/src/completions.rs +++ b/crates/ide-completion/src/completions.rs @@ -40,7 +40,8 @@ use crate::{ literal::{render_struct_literal, render_variant_lit}, macro_::render_macro, pattern::{render_struct_pat, render_variant_pat}, - render_field, render_path_resolution, render_pattern_resolution, render_tuple_field, + render_expr, render_field, render_path_resolution, render_pattern_resolution, + render_tuple_field, type_alias::{render_type_alias, render_type_alias_with_eq}, union_literal::render_union_literal, RenderContext, @@ -157,6 +158,12 @@ impl Completions { item.add_to(self, ctx.db); } + pub(crate) fn add_expr(&mut self, ctx: &CompletionContext<'_>, expr: &hir::term_search::Expr) { + if let Some(item) = render_expr(ctx, expr) { + item.add_to(self, ctx.db) + } + } + pub(crate) fn add_crate_roots( &mut self, ctx: &CompletionContext<'_>, @@ -694,6 +701,7 @@ pub(super) fn complete_name_ref( match &path_ctx.kind { PathKind::Expr { expr_ctx } => { expr::complete_expr_path(acc, ctx, path_ctx, expr_ctx); + expr::complete_expr(acc, ctx); dot::complete_undotted_self(acc, ctx, path_ctx, expr_ctx); item_list::complete_item_list_in_expr(acc, ctx, path_ctx, expr_ctx); diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs index 77fd5dd98b8d3..802e9bc3a8077 100644 --- a/crates/ide-completion/src/completions/expr.rs +++ b/crates/ide-completion/src/completions/expr.rs @@ -328,3 +328,59 @@ pub(crate) fn complete_expr_path( } } } + +pub(crate) fn complete_expr(acc: &mut Completions, ctx: &CompletionContext<'_>) { + let _p = tracing::span!(tracing::Level::INFO, "complete_expr").entered(); + + if !ctx.config.enable_term_search { + return; + } + + if !ctx.qualifier_ctx.none() { + return; + } + + if let Some(ty) = &ctx.expected_type { + // Ignore unit types as they are not very interesting + if ty.is_unit() || ty.is_unknown() { + return; + } + + let term_search_ctx = hir::term_search::TermSearchCtx { + sema: &ctx.sema, + scope: &ctx.scope, + goal: ty.clone(), + config: hir::term_search::TermSearchConfig { + enable_borrowcheck: false, + many_alternatives_threshold: 1, + depth: 6, + }, + }; + let exprs = hir::term_search::term_search(&term_search_ctx); + for expr in exprs { + // Expand method calls + match expr { + hir::term_search::Expr::Method { func, generics, target, params } + if target.is_many() => + { + let target_ty = target.ty(ctx.db); + let term_search_ctx = + hir::term_search::TermSearchCtx { goal: target_ty, ..term_search_ctx }; + let target_exprs = hir::term_search::term_search(&term_search_ctx); + + for expr in target_exprs { + let expanded_expr = hir::term_search::Expr::Method { + func, + generics: generics.clone(), + target: Box::new(expr), + params: params.clone(), + }; + + acc.add_expr(ctx, &expanded_expr) + } + } + _ => acc.add_expr(ctx, &expr), + } + } + } +} diff --git a/crates/ide-completion/src/completions/flyimport.rs b/crates/ide-completion/src/completions/flyimport.rs index b9f91d34b2c2b..3bc329ecd748f 100644 --- a/crates/ide-completion/src/completions/flyimport.rs +++ b/crates/ide-completion/src/completions/flyimport.rs @@ -238,6 +238,8 @@ fn import_on_the_fly( (PathKind::Type { location }, ItemInNs::Types(ty)) => { if matches!(location, TypeLocation::TypeBound) { matches!(ty, ModuleDef::Trait(_)) + } else if matches!(location, TypeLocation::ImplTrait) { + matches!(ty, ModuleDef::Trait(_) | ModuleDef::Module(_)) } else { true } diff --git a/crates/ide-completion/src/completions/type.rs b/crates/ide-completion/src/completions/type.rs index e6a4335c3fec8..e4678089462a3 100644 --- a/crates/ide-completion/src/completions/type.rs +++ b/crates/ide-completion/src/completions/type.rs @@ -31,6 +31,11 @@ pub(crate) fn complete_type_path( ScopeDef::ImplSelfType(_) => location.complete_self_type(), // Don't suggest attribute macros and derives. ScopeDef::ModuleDef(Macro(mac)) => mac.is_fn_like(ctx.db), + ScopeDef::ModuleDef(Trait(_) | Module(_)) + if matches!(location, TypeLocation::ImplTrait) => + { + true + } // Type things are fine ScopeDef::ModuleDef( BuiltinType(_) | Adt(_) | Module(_) | Trait(_) | TraitAlias(_) | TypeAlias(_), @@ -184,6 +189,21 @@ pub(crate) fn complete_type_path( } } } + TypeLocation::ImplTrait => { + acc.add_nameref_keywords_with_colon(ctx); + ctx.process_all_names(&mut |name, def, doc_aliases| { + let is_trait_or_module = matches!( + def, + ScopeDef::ModuleDef( + hir::ModuleDef::Module(_) | hir::ModuleDef::Trait(_) + ) + ); + if is_trait_or_module { + acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases); + } + }); + return; + } _ => {} }; diff --git a/crates/ide-completion/src/config.rs b/crates/ide-completion/src/config.rs index ed5ddde8fbfe9..04563fb0f469b 100644 --- a/crates/ide-completion/src/config.rs +++ b/crates/ide-completion/src/config.rs @@ -14,6 +14,7 @@ pub struct CompletionConfig { pub enable_imports_on_the_fly: bool, pub enable_self_on_the_fly: bool, pub enable_private_editable: bool, + pub enable_term_search: bool, pub full_function_signatures: bool, pub callable: Option, pub snippet_cap: Option, diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs index 2a0004f60b820..aa22155feffe2 100644 --- a/crates/ide-completion/src/context.rs +++ b/crates/ide-completion/src/context.rs @@ -202,6 +202,7 @@ impl TypeLocation { } TypeLocation::AssocConstEq => false, TypeLocation::AssocTypeEq => true, + TypeLocation::ImplTrait => false, _ => true, } } @@ -716,7 +717,7 @@ impl<'a> CompletionContext<'a> { let krate = scope.krate(); let module = scope.module(); - let toolchain = db.crate_graph()[krate.into()].channel(); + let toolchain = db.toolchain_channel(krate.into()); // `toolchain == None` means we're in some detached files. Since we have no information on // the toolchain being used, let's just allow unstable items to be listed. let is_nightly = matches!(toolchain, Some(base_db::ReleaseChannel::Nightly) | None); diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs index 8552a20392abf..c2c0641961a6a 100644 --- a/crates/ide-completion/src/item.rs +++ b/crates/ide-completion/src/item.rs @@ -166,6 +166,8 @@ pub struct CompletionRelevance { pub postfix_match: Option, /// This is set for type inference results pub is_definite: bool, + /// This is set for items that are function (associated or method) + pub function: Option, } #[derive(Debug, Clone, Copy, Eq, PartialEq)] @@ -207,6 +209,24 @@ pub enum CompletionRelevancePostfixMatch { Exact, } +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +pub struct CompletionRelevanceFn { + pub has_params: bool, + pub has_self_param: bool, + pub return_type: CompletionRelevanceReturnType, +} + +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +pub enum CompletionRelevanceReturnType { + Other, + /// Returns the Self type of the impl/trait + DirectConstructor, + /// Returns something that indirectly constructs the `Self` type of the impl/trait e.g. `Result`, `Option` + Constructor, + /// Returns a possible builder for the type + Builder, +} + impl CompletionRelevance { /// Provides a relevance score. Higher values are more relevant. /// @@ -231,6 +251,7 @@ impl CompletionRelevance { postfix_match, is_definite, is_item_from_notable_trait, + function, } = self; // lower rank private things @@ -275,6 +296,33 @@ impl CompletionRelevance { if is_definite { score += 10; } + + score += function + .map(|asf| { + let mut fn_score = match asf.return_type { + CompletionRelevanceReturnType::DirectConstructor => 15, + CompletionRelevanceReturnType::Builder => 10, + CompletionRelevanceReturnType::Constructor => 5, + CompletionRelevanceReturnType::Other => 0, + }; + + // When a fn is bumped due to return type: + // Bump Constructor or Builder methods with no arguments, + // over them tha with self arguments + if fn_score > 0 { + if !asf.has_params { + // bump associated functions + fn_score += 1; + } else if asf.has_self_param { + // downgrade methods (below Constructor) + fn_score = 1; + } + } + + fn_score + }) + .unwrap_or_default(); + score } @@ -297,6 +345,7 @@ pub enum CompletionItemKind { Method, Snippet, UnresolvedReference, + Expression, } impl_from!(SymbolKind for CompletionItemKind); @@ -341,6 +390,7 @@ impl CompletionItemKind { CompletionItemKind::Method => "me", CompletionItemKind::Snippet => "sn", CompletionItemKind::UnresolvedReference => "??", + CompletionItemKind::Expression => "ex", } } } diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs index 2ed080a834790..3f374b307fbe3 100644 --- a/crates/ide-completion/src/render.rs +++ b/crates/ide-completion/src/render.rs @@ -17,7 +17,7 @@ use ide_db::{ imports::import_assets::LocatedImport, RootDatabase, SnippetCap, SymbolKind, }; -use syntax::{format_smolstr, AstNode, SmolStr, SyntaxKind, TextRange}; +use syntax::{ast, format_smolstr, AstNode, SmolStr, SyntaxKind, TextRange}; use text_edit::TextEdit; use crate::{ @@ -272,6 +272,82 @@ pub(crate) fn render_resolution_with_import_pat( Some(render_resolution_pat(ctx, pattern_ctx, local_name, Some(import_edit), resolution)) } +pub(crate) fn render_expr( + ctx: &CompletionContext<'_>, + expr: &hir::term_search::Expr, +) -> Option { + let mut i = 1; + let mut snippet_formatter = |ty: &hir::Type| { + let arg_name = ty + .as_adt() + .and_then(|adt| adt.name(ctx.db).as_text()) + .map(|s| stdx::to_lower_snake_case(s.as_str())) + .unwrap_or_else(|| String::from("_")); + let res = format!("${{{i}:{arg_name}}}"); + i += 1; + res + }; + + let mut label_formatter = |ty: &hir::Type| { + ty.as_adt() + .and_then(|adt| adt.name(ctx.db).as_text()) + .map(|s| stdx::to_lower_snake_case(s.as_str())) + .unwrap_or_else(|| String::from("...")) + }; + + let label = expr + .gen_source_code( + &ctx.scope, + &mut label_formatter, + ctx.config.prefer_no_std, + ctx.config.prefer_prelude, + ) + .ok()?; + + let source_range = match ctx.original_token.parent() { + Some(node) => match node.ancestors().find_map(ast::Path::cast) { + Some(path) => path.syntax().text_range(), + None => node.text_range(), + }, + None => ctx.source_range(), + }; + + let mut item = CompletionItem::new(CompletionItemKind::Expression, source_range, label.clone()); + + let snippet = format!( + "{}$0", + expr.gen_source_code( + &ctx.scope, + &mut snippet_formatter, + ctx.config.prefer_no_std, + ctx.config.prefer_prelude + ) + .ok()? + ); + let edit = TextEdit::replace(source_range, snippet); + item.snippet_edit(ctx.config.snippet_cap?, edit); + item.documentation(Documentation::new(String::from("Autogenerated expression by term search"))); + item.set_relevance(crate::CompletionRelevance { + type_match: compute_type_match(ctx, &expr.ty(ctx.db)), + ..Default::default() + }); + for trait_ in expr.traits_used(ctx.db) { + let trait_item = hir::ItemInNs::from(hir::ModuleDef::from(trait_)); + let Some(path) = ctx.module.find_use_path( + ctx.db, + trait_item, + ctx.config.prefer_no_std, + ctx.config.prefer_prelude, + ) else { + continue; + }; + + item.add_import(LocatedImport::new(path, trait_item, trait_item)); + } + + Some(item) +} + fn scope_def_to_name( resolution: ScopeDef, ctx: &RenderContext<'_>, @@ -599,6 +675,16 @@ mod tests { expect.assert_debug_eq(&actual); } + #[track_caller] + fn check_function_relevance(ra_fixture: &str, expect: Expect) { + let actual: Vec<_> = do_completion(ra_fixture, CompletionItemKind::Method) + .into_iter() + .map(|item| (item.detail.unwrap_or_default(), item.relevance.function)) + .collect(); + + expect.assert_debug_eq(&actual); + } + #[track_caller] fn check_relevance_for_kinds(ra_fixture: &str, kinds: &[CompletionItemKind], expect: Expect) { let mut actual = get_all_items(TEST_CONFIG, ra_fixture, None); @@ -961,6 +1047,7 @@ fn func(input: Struct) { } st Self [type] sp Self [type] st Struct [type] + ex Struct [type] lc self [local] fn func(…) [] me self.test() [] @@ -985,6 +1072,9 @@ fn main() { "#, expect![[r#" lc input [type+name+local] + ex input [type] + ex true [type] + ex false [type] lc inputbad [local] fn main() [] fn test(…) [] @@ -1174,6 +1264,7 @@ fn main() { let _: m::Spam = S$0 } is_private_editable: false, postfix_match: None, is_definite: false, + function: None, }, trigger_call_info: true, }, @@ -1201,6 +1292,7 @@ fn main() { let _: m::Spam = S$0 } is_private_editable: false, postfix_match: None, is_definite: false, + function: None, }, trigger_call_info: true, }, @@ -1280,6 +1372,7 @@ fn foo() { A { the$0 } } is_private_editable: false, postfix_match: None, is_definite: false, + function: None, }, }, ] @@ -1313,6 +1406,26 @@ impl S { documentation: Documentation( "Method docs", ), + relevance: CompletionRelevance { + exact_name_match: false, + type_match: None, + is_local: false, + is_item_from_trait: false, + is_item_from_notable_trait: false, + is_name_already_imported: false, + requires_import: false, + is_op_method: false, + is_private_editable: false, + postfix_match: None, + is_definite: false, + function: Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Other, + }, + ), + }, }, CompletionItem { label: "foo", @@ -1418,6 +1531,26 @@ fn foo(s: S) { s.$0 } kind: Method, lookup: "the_method", detail: "fn(&self)", + relevance: CompletionRelevance { + exact_name_match: false, + type_match: None, + is_local: false, + is_item_from_trait: false, + is_item_from_notable_trait: false, + is_name_already_imported: false, + requires_import: false, + is_op_method: false, + is_private_editable: false, + postfix_match: None, + is_definite: false, + function: Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Other, + }, + ), + }, }, ] "#]], @@ -1665,6 +1798,10 @@ fn f() { A { bar: b$0 }; } expect![[r#" fn bar() [type+name] fn baz() [type] + ex baz() [type] + ex bar() [type] + ex A { bar: baz() }.bar [type] + ex A { bar: bar() }.bar [type] st A [] fn f() [] "#]], @@ -1749,6 +1886,8 @@ fn main() { lc s [type+name+local] st S [type] st S [type] + ex s [type] + ex S [type] fn foo(…) [] fn main() [] "#]], @@ -1766,6 +1905,8 @@ fn main() { lc ssss [type+local] st S [type] st S [type] + ex ssss [type] + ex S [type] fn foo(…) [] fn main() [] "#]], @@ -1798,6 +1939,8 @@ fn main() { } "#, expect![[r#" + ex core::ops::Deref::deref(&T(S)) (use core::ops::Deref) [type_could_unify] + ex core::ops::Deref::deref(&t) (use core::ops::Deref) [type_could_unify] lc m [local] lc t [local] lc &t [type+local] @@ -1846,6 +1989,8 @@ fn main() { } "#, expect![[r#" + ex core::ops::DerefMut::deref_mut(&mut T(S)) (use core::ops::DerefMut) [type_could_unify] + ex core::ops::DerefMut::deref_mut(&mut t) (use core::ops::DerefMut) [type_could_unify] lc m [local] lc t [local] lc &mut t [type+local] @@ -1894,6 +2039,8 @@ fn bar(t: Foo) {} ev Foo::A [type] ev Foo::B [type] en Foo [type] + ex Foo::A [type] + ex Foo::B [type] fn bar(…) [] fn foo() [] "#]], @@ -1947,6 +2094,8 @@ fn main() { } "#, expect![[r#" + ex core::ops::Deref::deref(&T(S)) (use core::ops::Deref) [type_could_unify] + ex core::ops::Deref::deref(&bar()) (use core::ops::Deref) [type_could_unify] st S [] st &S [type] st S [] @@ -2002,6 +2151,254 @@ fn main() { ); } + #[test] + fn constructor_order_simple() { + check_relevance( + r#" +struct Foo; +struct Other; +struct Option(T); + +impl Foo { + fn fn_ctr() -> Foo { unimplemented!() } + fn fn_another(n: u32) -> Other { unimplemented!() } + fn fn_ctr_self() -> Option { unimplemented!() } +} + +fn test() { + let a = Foo::$0; +} +"#, + expect![[r#" + fn fn_ctr() [type_could_unify] + fn fn_ctr_self() [type_could_unify] + fn fn_another(…) [type_could_unify] + "#]], + ); + } + + #[test] + fn constructor_order_kind() { + check_function_relevance( + r#" +struct Foo; +struct Bar; +struct Option(T); +enum Result { Ok(T), Err(E) }; + +impl Foo { + fn fn_ctr(&self) -> Foo { unimplemented!() } + fn fn_ctr_with_args(&self, n: u32) -> Foo { unimplemented!() } + fn fn_another(&self, n: u32) -> Bar { unimplemented!() } + fn fn_ctr_wrapped(&self, ) -> Option { unimplemented!() } + fn fn_ctr_wrapped_2(&self, ) -> Result { unimplemented!() } + fn fn_ctr_wrapped_3(&self, ) -> Result { unimplemented!() } // Self is not the first type + fn fn_ctr_wrapped_with_args(&self, m: u32) -> Option { unimplemented!() } + fn fn_another_unit(&self) { unimplemented!() } +} + +fn test() { + let a = self::Foo::$0; +} +"#, + expect![[r#" + [ + ( + "fn(&self, u32) -> Bar", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Other, + }, + ), + ), + ( + "fn(&self)", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Other, + }, + ), + ), + ( + "fn(&self) -> Foo", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: DirectConstructor, + }, + ), + ), + ( + "fn(&self, u32) -> Foo", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: DirectConstructor, + }, + ), + ), + ( + "fn(&self) -> Option", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Constructor, + }, + ), + ), + ( + "fn(&self) -> Result", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Constructor, + }, + ), + ), + ( + "fn(&self) -> Result", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Constructor, + }, + ), + ), + ( + "fn(&self, u32) -> Option", + Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Constructor, + }, + ), + ), + ] + "#]], + ); + } + + #[test] + fn constructor_order_relevance() { + check_relevance( + r#" +struct Foo; +struct FooBuilder; +struct Result(T); + +impl Foo { + fn fn_no_ret(&self) {} + fn fn_ctr_with_args(input: u32) -> Foo { unimplemented!() } + fn fn_direct_ctr() -> Self { unimplemented!() } + fn fn_ctr() -> Result { unimplemented!() } + fn fn_other() -> Result { unimplemented!() } + fn fn_builder() -> FooBuilder { unimplemented!() } +} + +fn test() { + let a = self::Foo::$0; +} +"#, + // preference: + // Direct Constructor + // Direct Constructor with args + // Builder + // Constructor + // Others + expect![[r#" + fn fn_direct_ctr() [type_could_unify] + fn fn_ctr_with_args(…) [type_could_unify] + fn fn_builder() [type_could_unify] + fn fn_ctr() [type_could_unify] + me fn_no_ret(…) [type_could_unify] + fn fn_other() [type_could_unify] + "#]], + ); + + // + } + + #[test] + fn function_relevance_generic_1() { + check_relevance( + r#" +struct Foo(T); +struct FooBuilder; +struct Option(T); +enum Result{Ok(T), Err(E)}; + +impl Foo { + fn fn_returns_unit(&self) {} + fn fn_ctr_with_args(input: T) -> Foo { unimplemented!() } + fn fn_direct_ctr() -> Self { unimplemented!() } + fn fn_ctr_wrapped() -> Option { unimplemented!() } + fn fn_ctr_wrapped_2() -> Result { unimplemented!() } + fn fn_other() -> Option { unimplemented!() } + fn fn_builder() -> FooBuilder { unimplemented!() } +} + +fn test() { + let a = self::Foo::::$0; +} + "#, + expect![[r#" + fn fn_direct_ctr() [type_could_unify] + fn fn_ctr_with_args(…) [type_could_unify] + fn fn_builder() [type_could_unify] + fn fn_ctr_wrapped() [type_could_unify] + fn fn_ctr_wrapped_2() [type_could_unify] + me fn_returns_unit(…) [type_could_unify] + fn fn_other() [type_could_unify] + "#]], + ); + } + + #[test] + fn function_relevance_generic_2() { + // Generic 2 + check_relevance( + r#" +struct Foo(T); +struct FooBuilder; +struct Option(T); +enum Result{Ok(T), Err(E)}; + +impl Foo { + fn fn_no_ret(&self) {} + fn fn_ctr_with_args(input: T) -> Foo { unimplemented!() } + fn fn_direct_ctr() -> Self { unimplemented!() } + fn fn_ctr() -> Option { unimplemented!() } + fn fn_ctr2() -> Result { unimplemented!() } + fn fn_other() -> Option { unimplemented!() } + fn fn_builder() -> FooBuilder { unimplemented!() } +} + +fn test() { + let a : Res> = Foo::$0; +} + "#, + expect![[r#" + fn fn_direct_ctr() [type_could_unify] + fn fn_ctr_with_args(…) [type_could_unify] + fn fn_builder() [type_could_unify] + fn fn_ctr() [type_could_unify] + fn fn_ctr2() [type_could_unify] + me fn_no_ret(…) [type_could_unify] + fn fn_other() [type_could_unify] + "#]], + ); + } + #[test] fn struct_field_method_ref() { check_kinds( @@ -2022,6 +2419,26 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 } kind: Method, lookup: "baz", detail: "fn(&self) -> u32", + relevance: CompletionRelevance { + exact_name_match: false, + type_match: None, + is_local: false, + is_item_from_trait: false, + is_item_from_notable_trait: false, + is_name_already_imported: false, + requires_import: false, + is_op_method: false, + is_private_editable: false, + postfix_match: None, + is_definite: false, + function: Some( + CompletionRelevanceFn { + has_params: true, + has_self_param: true, + return_type: Other, + }, + ), + }, ref_match: "&@107", }, CompletionItem { @@ -2096,6 +2513,7 @@ fn foo() { is_private_editable: false, postfix_match: None, is_definite: false, + function: None, }, }, ] @@ -2133,6 +2551,26 @@ fn main() { ), lookup: "foo", detail: "fn() -> S", + relevance: CompletionRelevance { + exact_name_match: false, + type_match: None, + is_local: false, + is_item_from_trait: false, + is_item_from_notable_trait: false, + is_name_already_imported: false, + requires_import: false, + is_op_method: false, + is_private_editable: false, + postfix_match: None, + is_definite: false, + function: Some( + CompletionRelevanceFn { + has_params: false, + has_self_param: false, + return_type: Other, + }, + ), + }, ref_match: "&@92", }, ] @@ -2160,6 +2598,7 @@ fn foo() { "#, expect![[r#" lc foo [type+local] + ex foo [type] ev Foo::A(…) [type_could_unify] ev Foo::B [type_could_unify] en Foo [type_could_unify] @@ -2493,6 +2932,7 @@ fn main() { is_private_editable: false, postfix_match: None, is_definite: false, + function: None, }, }, CompletionItem { @@ -2515,6 +2955,7 @@ fn main() { is_private_editable: false, postfix_match: None, is_definite: false, + function: None, }, }, ] diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs index 27186a2b7ffbe..cf9fe1ab30728 100644 --- a/crates/ide-completion/src/render/function.rs +++ b/crates/ide-completion/src/render/function.rs @@ -8,8 +8,13 @@ use syntax::{format_smolstr, AstNode, SmolStr}; use crate::{ context::{CompletionContext, DotAccess, DotAccessKind, PathCompletionCtx, PathKind}, - item::{Builder, CompletionItem, CompletionItemKind, CompletionRelevance}, - render::{compute_exact_name_match, compute_ref_match, compute_type_match, RenderContext}, + item::{ + Builder, CompletionItem, CompletionItemKind, CompletionRelevance, CompletionRelevanceFn, + CompletionRelevanceReturnType, + }, + render::{ + compute_exact_name_match, compute_ref_match, compute_type_match, match_types, RenderContext, + }, CallableSnippets, }; @@ -61,9 +66,9 @@ fn render( ), _ => (name.unescaped().to_smol_str(), name.to_smol_str()), }; - + let has_self_param = func.self_param(db).is_some(); let mut item = CompletionItem::new( - if func.self_param(db).is_some() { + if has_self_param { CompletionItemKind::Method } else { CompletionItemKind::SymbolKind(SymbolKind::Function) @@ -99,6 +104,15 @@ fn render( .filter(|_| !has_call_parens) .and_then(|cap| Some((cap, params(ctx.completion, func, &func_kind, has_dot_receiver)?))); + let function = assoc_item + .and_then(|assoc_item| assoc_item.implementing_ty(db)) + .map(|self_type| compute_return_type_match(db, &ctx, self_type, &ret_type)) + .map(|return_type| CompletionRelevanceFn { + has_params: has_self_param || func.num_params(db) > 0, + has_self_param, + return_type, + }); + item.set_relevance(CompletionRelevance { type_match: if has_call_parens || complete_call_parens.is_some() { compute_type_match(completion, &ret_type) @@ -106,6 +120,7 @@ fn render( compute_type_match(completion, &func.ty(db)) }, exact_name_match: compute_exact_name_match(completion, &call), + function, is_op_method, is_item_from_notable_trait, ..ctx.completion_relevance() @@ -156,6 +171,33 @@ fn render( item } +fn compute_return_type_match( + db: &dyn HirDatabase, + ctx: &RenderContext<'_>, + self_type: hir::Type, + ret_type: &hir::Type, +) -> CompletionRelevanceReturnType { + if match_types(ctx.completion, &self_type, ret_type).is_some() { + // fn([..]) -> Self + CompletionRelevanceReturnType::DirectConstructor + } else if ret_type + .type_arguments() + .any(|ret_type_arg| match_types(ctx.completion, &self_type, &ret_type_arg).is_some()) + { + // fn([..]) -> Result OR Wrapped + CompletionRelevanceReturnType::Constructor + } else if ret_type + .as_adt() + .and_then(|adt| adt.name(db).as_str().map(|name| name.ends_with("Builder"))) + .unwrap_or(false) + { + // fn([..]) -> [..]Builder + CompletionRelevanceReturnType::Builder + } else { + CompletionRelevanceReturnType::Other + } +} + pub(super) fn add_call_parens<'b>( builder: &'b mut Builder, ctx: &CompletionContext<'_>, diff --git a/crates/ide-completion/src/tests.rs b/crates/ide-completion/src/tests.rs index 154b69875aea8..1f032c7df480d 100644 --- a/crates/ide-completion/src/tests.rs +++ b/crates/ide-completion/src/tests.rs @@ -65,6 +65,7 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig { enable_imports_on_the_fly: true, enable_self_on_the_fly: true, enable_private_editable: false, + enable_term_search: true, full_function_signatures: false, callable: Some(CallableSnippets::FillArguments), snippet_cap: SnippetCap::new(true), diff --git a/crates/ide-completion/src/tests/expression.rs b/crates/ide-completion/src/tests/expression.rs index 78907a2896c4a..7749fac40b9dc 100644 --- a/crates/ide-completion/src/tests/expression.rs +++ b/crates/ide-completion/src/tests/expression.rs @@ -97,6 +97,11 @@ fn func(param0 @ (param1, param2): (i32, i32)) { kw unsafe kw while kw while let + ex ifletlocal + ex letlocal + ex matcharm + ex param1 + ex param2 "#]], ); } @@ -241,6 +246,8 @@ fn complete_in_block() { sn macro_rules sn pd sn ppd + ex false + ex true "#]], ) } @@ -542,7 +549,26 @@ fn quux(x: i32) { m!(x$0 } "#, - expect![[r#""#]], + expect![[r#" + fn quux(…) fn(i32) + lc x i32 + lc y i32 + ma m!(…) macro_rules! m + bt u32 u32 + kw crate:: + kw false + kw for + kw if + kw if let + kw loop + kw match + kw return + kw self:: + kw true + kw unsafe + kw while + kw while let + "#]], ); } @@ -682,7 +708,9 @@ fn main() { } "#, expect![[r#" - fn test() fn() -> Zulu + fn test() fn() -> Zulu + ex Zulu + ex Zulu::test() "#]], ); } diff --git a/crates/ide-completion/src/tests/flyimport.rs b/crates/ide-completion/src/tests/flyimport.rs index eaa1bebc03c7e..fff193ba4c9bd 100644 --- a/crates/ide-completion/src/tests/flyimport.rs +++ b/crates/ide-completion/src/tests/flyimport.rs @@ -1397,3 +1397,22 @@ pub use bridge2::server2::Span2; "#]], ); } + +#[test] +fn flyimport_only_traits_in_impl_trait_block() { + check( + r#" +//- /main.rs crate:main deps:dep +pub struct Bar; + +impl Foo$0 for Bar { } +//- /lib.rs crate:dep +pub trait FooTrait; + +pub struct FooStruct; +"#, + expect![[r#" + tt FooTrait (use dep::FooTrait) + "#]], + ); +} diff --git a/crates/ide-completion/src/tests/record.rs b/crates/ide-completion/src/tests/record.rs index 18afde1b7cefd..e64ec74c6106e 100644 --- a/crates/ide-completion/src/tests/record.rs +++ b/crates/ide-completion/src/tests/record.rs @@ -192,6 +192,8 @@ fn main() { bt u32 u32 kw crate:: kw self:: + ex Foo::default() + ex foo "#]], ); check( diff --git a/crates/ide-completion/src/tests/special.rs b/crates/ide-completion/src/tests/special.rs index a87d16c789faf..ff32eccfbff4c 100644 --- a/crates/ide-completion/src/tests/special.rs +++ b/crates/ide-completion/src/tests/special.rs @@ -225,10 +225,10 @@ impl S { fn foo() { let _ = lib::S::$0 } "#, expect![[r#" - ct PUBLIC_CONST pub const PUBLIC_CONST: u32 - fn public_method() fn() - ta PublicType pub type PublicType = u32 - "#]], + ct PUBLIC_CONST pub const PUBLIC_CONST: u32 + fn public_method() fn() + ta PublicType pub type PublicType = u32 + "#]], ); } @@ -242,8 +242,8 @@ impl U { fn m() { } } fn foo() { let _ = U::$0 } "#, expect![[r#" - fn m() fn() - "#]], + fn m() fn() + "#]], ); } @@ -256,8 +256,8 @@ trait Trait { fn m(); } fn foo() { let _ = Trait::$0 } "#, expect![[r#" - fn m() (as Trait) fn() - "#]], + fn m() (as Trait) fn() + "#]], ); } @@ -273,8 +273,8 @@ impl Trait for S {} fn foo() { let _ = S::$0 } "#, expect![[r#" - fn m() (as Trait) fn() - "#]], + fn m() (as Trait) fn() + "#]], ); } @@ -290,8 +290,8 @@ impl Trait for S {} fn foo() { let _ = ::$0 } "#, expect![[r#" - fn m() (as Trait) fn() - "#]], + fn m() (as Trait) fn() + "#]], ); } @@ -396,9 +396,9 @@ macro_rules! foo { () => {} } fn main() { let _ = crate::$0 } "#, expect![[r#" - fn main() fn() - ma foo!(…) macro_rules! foo - "#]], + fn main() fn() + ma foo!(…) macro_rules! foo + "#]], ); } @@ -694,8 +694,10 @@ fn bar() -> Bar { } "#, expect![[r#" - fn foo() (as Foo) fn() -> Self - "#]], + fn foo() (as Foo) fn() -> Self + ex Bar + ex bar() + "#]], ); } @@ -722,6 +724,8 @@ fn bar() -> Bar { expect![[r#" fn bar() fn() fn foo() (as Foo) fn() -> Self + ex Bar + ex bar() "#]], ); } @@ -748,6 +752,8 @@ fn bar() -> Bar { "#, expect![[r#" fn foo() (as Foo) fn() -> Self + ex Bar + ex bar() "#]], ); } diff --git a/crates/ide-completion/src/tests/type_pos.rs b/crates/ide-completion/src/tests/type_pos.rs index c7161f82ce74f..db4ac9381cedb 100644 --- a/crates/ide-completion/src/tests/type_pos.rs +++ b/crates/ide-completion/src/tests/type_pos.rs @@ -989,3 +989,43 @@ fn foo<'a>() { S::<'static, F$0, _, _>; } "#]], ); } + +#[test] +fn complete_traits_on_impl_trait_block() { + check( + r#" +trait Foo {} + +struct Bar; + +impl $0 for Bar { } +"#, + expect![[r#" + md module + tt Foo + tt Trait + kw crate:: + kw self:: + "#]], + ); +} + +#[test] +fn complete_traits_with_path_on_impl_trait_block() { + check( + r#" +mod outer { + pub trait Foo {} + pub struct Bar; + pub mod inner { + } +} + +impl outer::$0 for Bar { } +"#, + expect![[r#" + md inner + tt Foo + "#]], + ); +} diff --git a/crates/ide-db/src/famous_defs.rs b/crates/ide-db/src/famous_defs.rs index 4edfa37b32905..3106772e63b12 100644 --- a/crates/ide-db/src/famous_defs.rs +++ b/crates/ide-db/src/famous_defs.rs @@ -114,6 +114,14 @@ impl FamousDefs<'_, '_> { self.find_function("core:mem:drop") } + pub fn core_macros_todo(&self) -> Option { + self.find_macro("core:todo") + } + + pub fn core_macros_unimplemented(&self) -> Option { + self.find_macro("core:unimplemented") + } + pub fn builtin_crates(&self) -> impl Iterator { IntoIterator::into_iter([ self.std(), diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs index 3862acc2af4da..7e1811b4cacb6 100644 --- a/crates/ide-db/src/path_transform.rs +++ b/crates/ide-db/src/path_transform.rs @@ -148,7 +148,7 @@ impl<'a> PathTransform<'a> { let mut defaulted_params: Vec = Default::default(); self.generic_def .into_iter() - .flat_map(|it| it.type_params(db)) + .flat_map(|it| it.type_or_const_params(db)) .skip(skip) // The actual list of trait type parameters may be longer than the one // used in the `impl` block due to trailing default type parameters. diff --git a/crates/ide-db/src/rename.rs b/crates/ide-db/src/rename.rs index 032b8338ab85d..6a7042988a9c4 100644 --- a/crates/ide-db/src/rename.rs +++ b/crates/ide-db/src/rename.rs @@ -71,7 +71,6 @@ impl Definition { &self, sema: &Semantics<'_, RootDatabase>, new_name: &str, - rename_external: bool, ) -> Result { // self.krate() returns None if // self is a built-in attr, built-in type or tool module. @@ -80,8 +79,8 @@ impl Definition { if let Some(krate) = self.krate(sema.db) { // Can we not rename non-local items? // Then bail if non-local - if !rename_external && !krate.origin(sema.db).is_local() { - bail!("Cannot rename a non-local definition as the config for it is disabled") + if !krate.origin(sema.db).is_local() { + bail!("Cannot rename a non-local definition") } } diff --git a/crates/ide-db/src/source_change.rs b/crates/ide-db/src/source_change.rs index 73be6a4071e47..f59d8d08c8924 100644 --- a/crates/ide-db/src/source_change.rs +++ b/crates/ide-db/src/source_change.rs @@ -138,7 +138,7 @@ impl SnippetEdit { .into_iter() .zip(1..) .with_position() - .map(|pos| { + .flat_map(|pos| { let (snippet, index) = match pos { (itertools::Position::First, it) | (itertools::Position::Middle, it) => it, // last/only snippet gets index 0 @@ -146,11 +146,13 @@ impl SnippetEdit { | (itertools::Position::Only, (snippet, _)) => (snippet, 0), }; - let range = match snippet { - Snippet::Tabstop(pos) => TextRange::empty(pos), - Snippet::Placeholder(range) => range, - }; - (index, range) + match snippet { + Snippet::Tabstop(pos) => vec![(index, TextRange::empty(pos))], + Snippet::Placeholder(range) => vec![(index, range)], + Snippet::PlaceholderGroup(ranges) => { + ranges.into_iter().map(|range| (index, range)).collect() + } + } }) .collect_vec(); @@ -248,7 +250,7 @@ impl SourceChangeBuilder { fn commit(&mut self) { let snippet_edit = self.snippet_builder.take().map(|builder| { SnippetEdit::new( - builder.places.into_iter().map(PlaceSnippet::finalize_position).collect_vec(), + builder.places.into_iter().flat_map(PlaceSnippet::finalize_position).collect(), ) }); @@ -287,30 +289,10 @@ impl SourceChangeBuilder { pub fn insert(&mut self, offset: TextSize, text: impl Into) { self.edit.insert(offset, text.into()) } - /// Append specified `snippet` at the given `offset` - pub fn insert_snippet( - &mut self, - _cap: SnippetCap, - offset: TextSize, - snippet: impl Into, - ) { - self.source_change.is_snippet = true; - self.insert(offset, snippet); - } /// Replaces specified `range` of text with a given string. pub fn replace(&mut self, range: TextRange, replace_with: impl Into) { self.edit.replace(range, replace_with.into()) } - /// Replaces specified `range` of text with a given `snippet`. - pub fn replace_snippet( - &mut self, - _cap: SnippetCap, - range: TextRange, - snippet: impl Into, - ) { - self.source_change.is_snippet = true; - self.replace(range, snippet); - } pub fn replace_ast(&mut self, old: N, new: N) { algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) } @@ -356,6 +338,17 @@ impl SourceChangeBuilder { self.add_snippet(PlaceSnippet::Over(node.syntax().clone().into())) } + /// Adds a snippet to move the cursor selected over `nodes` + /// + /// This allows for renaming newly generated items without having to go + /// through a separate rename step. + pub fn add_placeholder_snippet_group(&mut self, _cap: SnippetCap, nodes: Vec) { + assert!(nodes.iter().all(|node| node.parent().is_some())); + self.add_snippet(PlaceSnippet::OverGroup( + nodes.into_iter().map(|node| node.into()).collect(), + )) + } + fn add_snippet(&mut self, snippet: PlaceSnippet) { let snippet_builder = self.snippet_builder.get_or_insert(SnippetBuilder { places: vec![] }); snippet_builder.places.push(snippet); @@ -400,6 +393,13 @@ pub enum Snippet { Tabstop(TextSize), /// A placeholder snippet (e.g. `${0:placeholder}`). Placeholder(TextRange), + /// A group of placeholder snippets, e.g. + /// + /// ```no_run + /// let ${0:new_var} = 4; + /// fun(1, 2, 3, ${0:new_var}); + /// ``` + PlaceholderGroup(Vec), } enum PlaceSnippet { @@ -409,14 +409,20 @@ enum PlaceSnippet { After(SyntaxElement), /// Place a placeholder snippet in place of the element Over(SyntaxElement), + /// Place a group of placeholder snippets which are linked together + /// in place of the elements + OverGroup(Vec), } impl PlaceSnippet { - fn finalize_position(self) -> Snippet { + fn finalize_position(self) -> Vec { match self { - PlaceSnippet::Before(it) => Snippet::Tabstop(it.text_range().start()), - PlaceSnippet::After(it) => Snippet::Tabstop(it.text_range().end()), - PlaceSnippet::Over(it) => Snippet::Placeholder(it.text_range()), + PlaceSnippet::Before(it) => vec![Snippet::Tabstop(it.text_range().start())], + PlaceSnippet::After(it) => vec![Snippet::Tabstop(it.text_range().end())], + PlaceSnippet::Over(it) => vec![Snippet::Placeholder(it.text_range())], + PlaceSnippet::OverGroup(it) => { + vec![Snippet::PlaceholderGroup(it.into_iter().map(|it| it.text_range()).collect())] + } } } } diff --git a/crates/ide-db/src/syntax_helpers/node_ext.rs b/crates/ide-db/src/syntax_helpers/node_ext.rs index e4e735cecd89d..4f706e26af2b3 100644 --- a/crates/ide-db/src/syntax_helpers/node_ext.rs +++ b/crates/ide-db/src/syntax_helpers/node_ext.rs @@ -329,6 +329,7 @@ pub fn for_each_tail_expr(expr: &ast::Expr, cb: &mut dyn FnMut(&ast::Expr)) { | ast::Expr::RecordExpr(_) | ast::Expr::RefExpr(_) | ast::Expr::ReturnExpr(_) + | ast::Expr::BecomeExpr(_) | ast::Expr::TryExpr(_) | ast::Expr::TupleExpr(_) | ast::Expr::LetExpr(_) diff --git a/crates/ide-diagnostics/src/handlers/incorrect_case.rs b/crates/ide-diagnostics/src/handlers/incorrect_case.rs index dd64b93e4548b..5e2541795ca1c 100644 --- a/crates/ide-diagnostics/src/handlers/incorrect_case.rs +++ b/crates/ide-diagnostics/src/handlers/incorrect_case.rs @@ -43,7 +43,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCase) -> Option {} + // ^^^^ error: expected (bool, bool), found bool + // ^^^^^ error: expected (bool, bool), found bool + None => {} + } +} + "#, + ); + } + #[test] fn mismatched_types_in_or_patterns() { cov_mark::check_count!(validate_match_bailed_out, 2); diff --git a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs index a0d5d742d3622..b7667dc318f0c 100644 --- a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs +++ b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs @@ -182,6 +182,18 @@ fn foo() -> u8 { ); } + #[test] + fn no_diagnostic_if_not_last_statement2() { + check_diagnostics( + r#" +fn foo() -> u8 { + return 2; + fn bar() {} +} +"#, + ); + } + #[test] fn replace_with_expr() { check_fix( diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs index e93eea8ce29e5..8c97281b78328 100644 --- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs +++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs @@ -112,7 +112,8 @@ fn add_missing_ok_or_some( let variant_name = if Some(expected_enum) == core_result { "Ok" } else { "Some" }; - let wrapped_actual_ty = expected_adt.ty_with_args(ctx.sema.db, &[d.actual.clone()]); + let wrapped_actual_ty = + expected_adt.ty_with_args(ctx.sema.db, std::iter::once(d.actual.clone())); if !d.expected.could_unify_with(ctx.sema.db, &wrapped_actual_ty) { return None; diff --git a/crates/ide-diagnostics/src/handlers/typed_hole.rs b/crates/ide-diagnostics/src/handlers/typed_hole.rs index 6441343ebacdc..56c8181e84ce6 100644 --- a/crates/ide-diagnostics/src/handlers/typed_hole.rs +++ b/crates/ide-diagnostics/src/handlers/typed_hole.rs @@ -1,14 +1,20 @@ -use hir::{db::ExpandDatabase, ClosureStyle, HirDisplay, StructKind}; +use hir::{ + db::ExpandDatabase, + term_search::{term_search, TermSearchCtx}, + ClosureStyle, HirDisplay, +}; use ide_db::{ assists::{Assist, AssistId, AssistKind, GroupLabel}, label::Label, source_change::SourceChange, }; -use syntax::AstNode; +use itertools::Itertools; use text_edit::TextEdit; use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext}; +use syntax::AstNode; + // Diagnostic: typed-hole // // This diagnostic is triggered when an underscore expression is used in an invalid position. @@ -36,50 +42,54 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::TypedHole) -> Option let (original_range, _) = d.expr.as_ref().map(|it| it.to_node(&root)).syntax().original_file_range_opt(db)?; let scope = ctx.sema.scope(d.expr.value.to_node(&root).syntax())?; - let mut assists = vec![]; - scope.process_all_names(&mut |name, def| { - let ty = match def { - hir::ScopeDef::ModuleDef(it) => match it { - hir::ModuleDef::Function(it) => it.ty(db), - hir::ModuleDef::Adt(hir::Adt::Struct(it)) if it.kind(db) != StructKind::Record => { - it.constructor_ty(db) - } - hir::ModuleDef::Variant(it) if it.kind(db) != StructKind::Record => { - it.constructor_ty(db) - } - hir::ModuleDef::Const(it) => it.ty(db), - hir::ModuleDef::Static(it) => it.ty(db), - _ => return, - }, - hir::ScopeDef::GenericParam(hir::GenericParam::ConstParam(it)) => it.ty(db), - hir::ScopeDef::Local(it) => it.ty(db), - _ => return, - }; - // FIXME: should also check coercions if it is at a coercion site - if !ty.contains_unknown() && ty.could_unify_with(db, &d.expected) { - assists.push(Assist { - id: AssistId("typed-hole", AssistKind::QuickFix), - label: Label::new(format!("Replace `_` with `{}`", name.display(db))), - group: Some(GroupLabel("Replace `_` with a matching entity in scope".to_owned())), - target: original_range.range, - source_change: Some(SourceChange::from_text_edit( - original_range.file_id, - TextEdit::replace(original_range.range, name.display(db).to_string()), - )), - trigger_signature_help: false, - }); - } - }); - if assists.is_empty() { - None - } else { + + let term_search_ctx = TermSearchCtx { + sema: &ctx.sema, + scope: &scope, + goal: d.expected.clone(), + config: Default::default(), + }; + let paths = term_search(&term_search_ctx); + + let mut formatter = |_: &hir::Type| String::from("_"); + + let assists: Vec = paths + .into_iter() + .filter_map(|path| { + path.gen_source_code( + &scope, + &mut formatter, + ctx.config.prefer_no_std, + ctx.config.prefer_prelude, + ) + .ok() + }) + .unique() + .map(|code| Assist { + id: AssistId("typed-hole", AssistKind::QuickFix), + label: Label::new(format!("Replace `_` with `{}`", &code)), + group: Some(GroupLabel("Replace `_` with a term".to_owned())), + target: original_range.range, + source_change: Some(SourceChange::from_text_edit( + original_range.file_id, + TextEdit::replace(original_range.range, code), + )), + trigger_signature_help: false, + }) + .collect(); + + if !assists.is_empty() { Some(assists) + } else { + None } } #[cfg(test)] mod tests { - use crate::tests::{check_diagnostics, check_fixes}; + use crate::tests::{ + check_diagnostics, check_fixes_unordered, check_has_fix, check_has_single_fix, + }; #[test] fn unknown() { @@ -99,7 +109,7 @@ fn main() { r#" fn main() { if _ {} - //^ error: invalid `_` expression, expected type `bool` + //^ 💡 error: invalid `_` expression, expected type `bool` let _: fn() -> i32 = _; //^ error: invalid `_` expression, expected type `fn() -> i32` let _: fn() -> () = _; // FIXME: This should trigger an assist because `main` matches via *coercion* @@ -129,7 +139,7 @@ fn main() { fn main() { let mut x = t(); x = _; - //^ 💡 error: invalid `_` expression, expected type `&str` + //^ error: invalid `_` expression, expected type `&str` x = ""; } fn t() -> T { loop {} } @@ -143,7 +153,8 @@ fn t() -> T { loop {} } r#" fn main() { let _x = [(); _]; - let _y: [(); 10] = [(); _]; + // FIXME: This should trigger error + // let _y: [(); 10] = [(); _]; _ = 0; (_,) = (1,); } @@ -153,7 +164,7 @@ fn main() { #[test] fn check_quick_fix() { - check_fixes( + check_fixes_unordered( r#" enum Foo { Bar @@ -175,7 +186,7 @@ use Foo::Bar; const C: Foo = Foo::Bar; fn main(param: Foo) { let local = Foo::Bar; - let _: Foo = local; + let _: Foo = Bar; //^ error: invalid `_` expression, expected type `fn()` } "#, @@ -187,7 +198,7 @@ use Foo::Bar; const C: Foo = Foo::Bar; fn main(param: Foo) { let local = Foo::Bar; - let _: Foo = param; + let _: Foo = local; //^ error: invalid `_` expression, expected type `fn()` } "#, @@ -199,7 +210,7 @@ use Foo::Bar; const C: Foo = Foo::Bar; fn main(param: Foo) { let local = Foo::Bar; - let _: Foo = CP; + let _: Foo = param; //^ error: invalid `_` expression, expected type `fn()` } "#, @@ -211,7 +222,7 @@ use Foo::Bar; const C: Foo = Foo::Bar; fn main(param: Foo) { let local = Foo::Bar; - let _: Foo = Bar; + let _: Foo = CP; //^ error: invalid `_` expression, expected type `fn()` } "#, @@ -230,4 +241,153 @@ fn main(param: Foo) { ], ); } + + #[test] + fn local_item_use_trait() { + check_has_fix( + r#" +struct Bar; +struct Baz; +trait Foo { + fn foo(self) -> Bar; +} +impl Foo for Baz { + fn foo(self) -> Bar { + unimplemented!() + } +} +fn asd() -> Bar { + let a = Baz; + _$0 +} +"#, + r" +struct Bar; +struct Baz; +trait Foo { + fn foo(self) -> Bar; +} +impl Foo for Baz { + fn foo(self) -> Bar { + unimplemented!() + } +} +fn asd() -> Bar { + let a = Baz; + Foo::foo(a) +} +", + ); + } + + #[test] + fn init_struct() { + check_has_fix( + r#"struct Abc {} +struct Qwe { a: i32, b: Abc } +fn main() { + let a: i32 = 1; + let c: Qwe = _$0; +}"#, + r#"struct Abc {} +struct Qwe { a: i32, b: Abc } +fn main() { + let a: i32 = 1; + let c: Qwe = Qwe { a: a, b: Abc { } }; +}"#, + ); + } + + #[test] + fn ignore_impl_func_with_incorrect_return() { + check_has_single_fix( + r#" +struct Bar {} +trait Foo { + type Res; + fn foo(&self) -> Self::Res; +} +impl Foo for i32 { + type Res = Self; + fn foo(&self) -> Self::Res { 1 } +} +fn main() { + let a: i32 = 1; + let c: Bar = _$0; +}"#, + r#" +struct Bar {} +trait Foo { + type Res; + fn foo(&self) -> Self::Res; +} +impl Foo for i32 { + type Res = Self; + fn foo(&self) -> Self::Res { 1 } +} +fn main() { + let a: i32 = 1; + let c: Bar = Bar { }; +}"#, + ); + } + + #[test] + fn use_impl_func_with_correct_return() { + check_has_fix( + r#" +struct Bar {} +struct A; +trait Foo { + type Res; + fn foo(&self) -> Self::Res; +} +impl Foo for A { + type Res = Bar; + fn foo(&self) -> Self::Res { Bar { } } +} +fn main() { + let a = A; + let c: Bar = _$0; +}"#, + r#" +struct Bar {} +struct A; +trait Foo { + type Res; + fn foo(&self) -> Self::Res; +} +impl Foo for A { + type Res = Bar; + fn foo(&self) -> Self::Res { Bar { } } +} +fn main() { + let a = A; + let c: Bar = Foo::foo(&a); +}"#, + ); + } + + #[test] + fn local_shadow_fn() { + check_fixes_unordered( + r#" +fn f() { + let f: i32 = 0; + _$0 +}"#, + vec![ + r#" +fn f() { + let f: i32 = 0; + () +}"#, + r#" +fn f() { + let f: i32 = 0; + crate::f() +}"#, + ], + ); + } } diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs index b62bb5affdd8e..4e4a851f67e0a 100644 --- a/crates/ide-diagnostics/src/tests.rs +++ b/crates/ide-diagnostics/src/tests.rs @@ -91,6 +91,91 @@ fn check_nth_fix_with_config( assert_eq_text!(&after, &actual); } +pub(crate) fn check_fixes_unordered(ra_fixture_before: &str, ra_fixtures_after: Vec<&str>) { + for ra_fixture_after in ra_fixtures_after.iter() { + check_has_fix(ra_fixture_before, ra_fixture_after) + } +} + +#[track_caller] +pub(crate) fn check_has_fix(ra_fixture_before: &str, ra_fixture_after: &str) { + let after = trim_indent(ra_fixture_after); + + let (db, file_position) = RootDatabase::with_position(ra_fixture_before); + let mut conf = DiagnosticsConfig::test_sample(); + conf.expr_fill_default = ExprFillDefaultMode::Default; + let fix = super::diagnostics(&db, &conf, &AssistResolveStrategy::All, file_position.file_id) + .into_iter() + .find(|d| { + d.fixes + .as_ref() + .and_then(|fixes| { + fixes.iter().find(|fix| { + if !fix.target.contains_inclusive(file_position.offset) { + return false; + } + let actual = { + let source_change = fix.source_change.as_ref().unwrap(); + let file_id = *source_change.source_file_edits.keys().next().unwrap(); + let mut actual = db.file_text(file_id).to_string(); + + for (edit, snippet_edit) in source_change.source_file_edits.values() { + edit.apply(&mut actual); + if let Some(snippet_edit) = snippet_edit { + snippet_edit.apply(&mut actual); + } + } + actual + }; + after == actual + }) + }) + .is_some() + }); + assert!(fix.is_some(), "no diagnostic with desired fix"); +} + +#[track_caller] +pub(crate) fn check_has_single_fix(ra_fixture_before: &str, ra_fixture_after: &str) { + let after = trim_indent(ra_fixture_after); + + let (db, file_position) = RootDatabase::with_position(ra_fixture_before); + let mut conf = DiagnosticsConfig::test_sample(); + conf.expr_fill_default = ExprFillDefaultMode::Default; + let mut n_fixes = 0; + let fix = super::diagnostics(&db, &conf, &AssistResolveStrategy::All, file_position.file_id) + .into_iter() + .find(|d| { + d.fixes + .as_ref() + .and_then(|fixes| { + n_fixes += fixes.len(); + fixes.iter().find(|fix| { + if !fix.target.contains_inclusive(file_position.offset) { + return false; + } + let actual = { + let source_change = fix.source_change.as_ref().unwrap(); + let file_id = *source_change.source_file_edits.keys().next().unwrap(); + let mut actual = db.file_text(file_id).to_string(); + + for (edit, snippet_edit) in source_change.source_file_edits.values() { + edit.apply(&mut actual); + if let Some(snippet_edit) = snippet_edit { + snippet_edit.apply(&mut actual); + } + } + actual + }; + after == actual + }) + }) + .is_some() + }); + assert!(fix.is_some(), "no diagnostic with desired fix"); + assert!(n_fixes == 1, "Too many fixes suggested"); +} + /// Checks that there's a diagnostic *without* fix at `$0`. pub(crate) fn check_no_fix(ra_fixture: &str) { let (db, file_position) = RootDatabase::with_position(ra_fixture); diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index dbe6a5507cc3e..18821bd78bfac 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -501,7 +501,7 @@ fn get_doc_base_urls( let Some(krate) = def.krate(db) else { return Default::default() }; let Some(display_name) = krate.display_name(db) else { return Default::default() }; let crate_data = &db.crate_graph()[krate.into()]; - let channel = crate_data.channel().unwrap_or(ReleaseChannel::Nightly).as_str(); + let channel = db.toolchain_channel(krate.into()).unwrap_or(ReleaseChannel::Nightly).as_str(); let (web_base, local_base) = match &crate_data.origin { // std and co do not specify `html_root_url` any longer so we gotta handwrite this ourself. diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 30bfe6ee9dc34..69ddc1e45efbd 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -7263,8 +7263,8 @@ impl Iterator for S { file_id: FileId( 1, ), - full_range: 6157..6365, - focus_range: 6222..6228, + full_range: 6290..6498, + focus_range: 6355..6361, name: "Future", kind: Trait, container_name: "future", @@ -7277,8 +7277,8 @@ impl Iterator for S { file_id: FileId( 1, ), - full_range: 6995..7461, - focus_range: 7039..7047, + full_range: 7128..7594, + focus_range: 7172..7180, name: "Iterator", kind: Trait, container_name: "iterator", diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index effdbf2c1f041..3238887257a47 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -12,11 +12,6 @@ #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] #![recursion_limit = "128"] -#[allow(unused)] -macro_rules! eprintln { - ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; -} - #[cfg(test)] mod fixture; @@ -258,11 +253,11 @@ impl Analysis { Env::default(), false, CrateOrigin::Local { repo: None, name: None }, - Err("Analysis::from_single_file has no target layout".into()), - None, ); change.change_file(file_id, Some(Arc::from(text))); change.set_crate_graph(crate_graph); + change.set_target_data_layouts(vec![Err("fixture has no layout".into())]); + change.set_toolchains(vec![None]); host.apply_change(change); (host.analysis(), file_id) } @@ -680,9 +675,8 @@ impl Analysis { &self, position: FilePosition, new_name: &str, - rename_external: bool, ) -> Cancellable> { - self.with_db(|db| rename::rename(db, position, new_name, rename_external)) + self.with_db(|db| rename::rename(db, position, new_name)) } pub fn prepare_rename( diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs index 413dbf9c5dfc6..f67aea2d5b9c1 100644 --- a/crates/ide/src/parent_module.rs +++ b/crates/ide/src/parent_module.rs @@ -54,7 +54,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec Vec { db.relevant_crates(file_id) .iter() diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs index 9fce4bb0f8271..f2eedfa431693 100644 --- a/crates/ide/src/rename.rs +++ b/crates/ide/src/rename.rs @@ -84,7 +84,6 @@ pub(crate) fn rename( db: &RootDatabase, position: FilePosition, new_name: &str, - rename_external: bool, ) -> RenameResult { let sema = Semantics::new(db); let source_file = sema.parse(position.file_id); @@ -104,7 +103,7 @@ pub(crate) fn rename( return rename_to_self(&sema, local); } } - def.rename(&sema, new_name, rename_external) + def.rename(&sema, new_name) }) .collect(); @@ -123,9 +122,9 @@ pub(crate) fn will_rename_file( let module = sema.to_module_def(file_id)?; let def = Definition::Module(module); let mut change = if is_raw_identifier(new_name_stem) { - def.rename(&sema, &SmolStr::from_iter(["r#", new_name_stem]), true).ok()? + def.rename(&sema, &SmolStr::from_iter(["r#", new_name_stem])).ok()? } else { - def.rename(&sema, new_name_stem, true).ok()? + def.rename(&sema, new_name_stem).ok()? }; change.file_system_edits.clear(); Some(change) @@ -377,16 +376,11 @@ mod tests { use super::{RangeInfo, RenameError}; fn check(new_name: &str, ra_fixture_before: &str, ra_fixture_after: &str) { - check_with_rename_config(new_name, ra_fixture_before, ra_fixture_after, true); + check_with_rename_config(new_name, ra_fixture_before, ra_fixture_after); } #[track_caller] - fn check_with_rename_config( - new_name: &str, - ra_fixture_before: &str, - ra_fixture_after: &str, - rename_external: bool, - ) { + fn check_with_rename_config(new_name: &str, ra_fixture_before: &str, ra_fixture_after: &str) { let ra_fixture_after = &trim_indent(ra_fixture_after); let (analysis, position) = fixture::position(ra_fixture_before); if !ra_fixture_after.starts_with("error: ") { @@ -395,7 +389,7 @@ mod tests { } } let rename_result = analysis - .rename(position, new_name, rename_external) + .rename(position, new_name) .unwrap_or_else(|err| panic!("Rename to '{new_name}' was cancelled: {err}")); match rename_result { Ok(source_change) => { @@ -426,10 +420,8 @@ mod tests { fn check_expect(new_name: &str, ra_fixture: &str, expect: Expect) { let (analysis, position) = fixture::position(ra_fixture); - let source_change = analysis - .rename(position, new_name, true) - .unwrap() - .expect("Expect returned a RenameError"); + let source_change = + analysis.rename(position, new_name).unwrap().expect("Expect returned a RenameError"); expect.assert_eq(&filter_expect(source_change)) } @@ -2636,19 +2628,7 @@ pub struct S; //- /main.rs crate:main deps:lib new_source_root:local use lib::S$0; "#, - "error: Cannot rename a non-local definition as the config for it is disabled", - false, - ); - - check( - "Baz", - r#" -//- /lib.rs crate:lib new_source_root:library -pub struct S; -//- /main.rs crate:main deps:lib new_source_root:local -use lib::S$0; -"#, - "use lib::Baz;\n", + "error: Cannot rename a non-local definition", ); } @@ -2663,8 +2643,7 @@ use core::hash::Hash; #[derive(H$0ash)] struct A; "#, - "error: Cannot rename a non-local definition as the config for it is disabled", - false, + "error: Cannot rename a non-local definition", ); } diff --git a/crates/ide/src/shuffle_crate_graph.rs b/crates/ide/src/shuffle_crate_graph.rs index bf6ad47a49527..453d1836e16e4 100644 --- a/crates/ide/src/shuffle_crate_graph.rs +++ b/crates/ide/src/shuffle_crate_graph.rs @@ -39,8 +39,6 @@ pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) { data.env.clone(), data.is_proc_macro, data.origin.clone(), - data.target_layout.clone(), - data.toolchain.clone(), ); new_proc_macros.insert(new_id, proc_macros[&old_id].clone()); map.insert(old_id, new_id); diff --git a/crates/ide/src/static_index.rs b/crates/ide/src/static_index.rs index dee5afbf8d9e8..5feaf21aa9795 100644 --- a/crates/ide/src/static_index.rs +++ b/crates/ide/src/static_index.rs @@ -1,14 +1,16 @@ //! This module provides `StaticIndex` which is used for powering //! read-only code browsers and emitting LSIF -use hir::{db::HirDatabase, Crate, HirFileIdExt, Module}; +use hir::{db::HirDatabase, Crate, HirFileIdExt, Module, Semantics}; use ide_db::{ base_db::{FileId, FileRange, SourceDatabaseExt}, defs::Definition, + documentation::Documentation, + famous_defs::FamousDefs, helpers::get_definition, FxHashMap, FxHashSet, RootDatabase, }; -use syntax::{AstNode, SyntaxKind::*, TextRange, T}; +use syntax::{AstNode, SyntaxKind::*, SyntaxNode, TextRange, T}; use crate::inlay_hints::InlayFieldsToResolve; use crate::navigation_target::UpmappingResult; @@ -22,7 +24,7 @@ use crate::{ /// A static representation of fully analyzed source code. /// -/// The intended use-case is powering read-only code browsers and emitting LSIF +/// The intended use-case is powering read-only code browsers and emitting LSIF/SCIP. #[derive(Debug)] pub struct StaticIndex<'a> { pub files: Vec, @@ -40,6 +42,7 @@ pub struct ReferenceData { #[derive(Debug)] pub struct TokenStaticData { + pub documentation: Option, pub hover: Option, pub definition: Option, pub references: Vec, @@ -103,6 +106,19 @@ fn all_modules(db: &dyn HirDatabase) -> Vec { modules } +fn documentation_for_definition( + sema: &Semantics<'_, RootDatabase>, + def: Definition, + scope_node: &SyntaxNode, +) -> Option { + let famous_defs = match &def { + Definition::BuiltinType(_) => Some(FamousDefs(sema, sema.scope(scope_node)?.krate())), + _ => None, + }; + + def.docs(sema.db, famous_defs.as_ref()) +} + impl StaticIndex<'_> { fn add_file(&mut self, file_id: FileId) { let current_crate = crates_for(self.db, file_id).pop().map(Into::into); @@ -169,6 +185,7 @@ impl StaticIndex<'_> { *it } else { let it = self.tokens.insert(TokenStaticData { + documentation: documentation_for_definition(&sema, def, &node), hover: hover_for_definition(&sema, file_id, def, &node, &hover_config), definition: def.try_to_nav(self.db).map(UpmappingResult::call_site).map(|it| { FileRange { file_id: it.file_id, range: it.focus_or_full_range() } diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 3321a0513b6f3..c3d85e38936d9 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -72,8 +72,6 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { dependencies, origin, is_proc_macro, - target_layout, - toolchain, } = &crate_graph[crate_id]; format_to!( buf, @@ -91,12 +89,6 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { format_to!(buf, " Env: {:?}\n", env); format_to!(buf, " Origin: {:?}\n", origin); format_to!(buf, " Is a proc macro crate: {}\n", is_proc_macro); - format_to!(buf, " Workspace Target Layout: {:?}\n", target_layout); - format_to!( - buf, - " Workspace Toolchain: {}\n", - toolchain.as_ref().map_or_else(|| "n/a".into(), |v| v.to_string()) - ); let deps = dependencies .iter() .map(|dep| format!("{}={}", dep.name, dep.crate_id.into_raw())) diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs index c6dc071c394e0..8c5592da63ecd 100644 --- a/crates/load-cargo/src/lib.rs +++ b/crates/load-cargo/src/lib.rs @@ -2,7 +2,7 @@ //! for incorporating changes. // Note, don't remove any public api from this. This API is consumed by external tools // to run rust-analyzer as a library. -use std::{collections::hash_map::Entry, mem, path::Path, sync}; +use std::{collections::hash_map::Entry, iter, mem, path::Path, sync}; use crossbeam_channel::{unbounded, Receiver}; use hir_expand::proc_macro::{ @@ -18,7 +18,6 @@ use itertools::Itertools; use proc_macro_api::{MacroDylib, ProcMacroServer}; use project_model::{CargoConfig, PackageRoot, ProjectManifest, ProjectWorkspace}; use span::Span; -use tt::DelimSpan; use vfs::{file_set::FileSetConfig, loader::Handle, AbsPath, AbsPathBuf, VfsPath}; pub struct LoadCargoConfig { @@ -68,9 +67,9 @@ pub fn load_workspace( let proc_macro_server = match &load_config.with_proc_macro_server { ProcMacroServerChoice::Sysroot => ws .find_sysroot_proc_macro_srv() - .and_then(|it| ProcMacroServer::spawn(it).map_err(Into::into)), + .and_then(|it| ProcMacroServer::spawn(it, extra_env).map_err(Into::into)), ProcMacroServerChoice::Explicit(path) => { - ProcMacroServer::spawn(path.clone()).map_err(Into::into) + ProcMacroServer::spawn(path.clone(), extra_env).map_err(Into::into) } ProcMacroServerChoice::None => Err(anyhow::format_err!("proc macro server disabled")), }; @@ -107,7 +106,7 @@ pub fn load_workspace( .collect() }; - let project_folders = ProjectFolders::new(&[ws], &[]); + let project_folders = ProjectFolders::new(std::slice::from_ref(&ws), &[]); loader.set_config(vfs::loader::Config { load: project_folders.load, watch: vec![], @@ -115,6 +114,7 @@ pub fn load_workspace( }); let host = load_crate_graph( + &ws, crate_graph, proc_macros, project_folders.source_root_config, @@ -273,7 +273,7 @@ impl SourceRootConfig { pub fn load_proc_macro( server: &ProcMacroServer, path: &AbsPath, - dummy_replace: &[Box], + ignored_macros: &[Box], ) -> ProcMacroLoadResult { let res: Result, String> = (|| { let dylib = MacroDylib::new(path.to_path_buf()); @@ -283,7 +283,7 @@ pub fn load_proc_macro( } Ok(vec .into_iter() - .map(|expander| expander_to_proc_macro(expander, dummy_replace)) + .map(|expander| expander_to_proc_macro(expander, ignored_macros)) .collect()) })(); match res { @@ -302,6 +302,7 @@ pub fn load_proc_macro( } fn load_crate_graph( + ws: &ProjectWorkspace, crate_graph: CrateGraph, proc_macros: ProcMacros, source_root_config: SourceRootConfig, @@ -340,8 +341,17 @@ fn load_crate_graph( let source_roots = source_root_config.partition(vfs); analysis_change.set_roots(source_roots); + let num_crates = crate_graph.len(); analysis_change.set_crate_graph(crate_graph); analysis_change.set_proc_macros(proc_macros); + if let ProjectWorkspace::Cargo { toolchain, target_layout, .. } + | ProjectWorkspace::Json { toolchain, target_layout, .. } = ws + { + analysis_change.set_target_data_layouts( + iter::repeat(target_layout.clone()).take(num_crates).collect(), + ); + analysis_change.set_toolchains(iter::repeat(toolchain.clone()).take(num_crates).collect()); + } host.apply_change(analysis_change); host @@ -349,7 +359,7 @@ fn load_crate_graph( fn expander_to_proc_macro( expander: proc_macro_api::ProcMacro, - dummy_replace: &[Box], + ignored_macros: &[Box], ) -> ProcMacro { let name = From::from(expander.name()); let kind = match expander.kind() { @@ -357,16 +367,8 @@ fn expander_to_proc_macro( proc_macro_api::ProcMacroKind::FuncLike => ProcMacroKind::FuncLike, proc_macro_api::ProcMacroKind::Attr => ProcMacroKind::Attr, }; - let expander: sync::Arc = - if dummy_replace.iter().any(|replace| **replace == name) { - match kind { - ProcMacroKind::Attr => sync::Arc::new(IdentityExpander), - _ => sync::Arc::new(EmptyExpander), - } - } else { - sync::Arc::new(Expander(expander)) - }; - ProcMacro { name, kind, expander } + let disabled = ignored_macros.iter().any(|replace| **replace == name); + ProcMacro { name, kind, expander: sync::Arc::new(Expander(expander)), disabled } } #[derive(Debug)] @@ -391,42 +393,6 @@ impl ProcMacroExpander for Expander { } } -/// Dummy identity expander, used for attribute proc-macros that are deliberately ignored by the user. -#[derive(Debug)] -struct IdentityExpander; - -impl ProcMacroExpander for IdentityExpander { - fn expand( - &self, - subtree: &tt::Subtree, - _: Option<&tt::Subtree>, - _: &Env, - _: Span, - _: Span, - _: Span, - ) -> Result, ProcMacroExpansionError> { - Ok(subtree.clone()) - } -} - -/// Empty expander, used for proc-macros that are deliberately ignored by the user. -#[derive(Debug)] -struct EmptyExpander; - -impl ProcMacroExpander for EmptyExpander { - fn expand( - &self, - _: &tt::Subtree, - _: Option<&tt::Subtree>, - _: &Env, - call_site: Span, - _: Span, - _: Span, - ) -> Result, ProcMacroExpansionError> { - Ok(tt::Subtree::empty(DelimSpan { open: call_site, close: call_site })) - } -} - #[cfg(test)] mod tests { use ide_db::base_db::SourceDatabase; diff --git a/crates/mbe/src/expander/transcriber.rs b/crates/mbe/src/expander/transcriber.rs index 9291f799cca73..6d3055da28608 100644 --- a/crates/mbe/src/expander/transcriber.rs +++ b/crates/mbe/src/expander/transcriber.rs @@ -101,10 +101,20 @@ impl Bindings { }))) } MetaVarKind::Lifetime => { - Fragment::Tokens(tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { - text: SmolStr::new_static("'missing"), - span, - }))) + Fragment::Tokens(tt::TokenTree::Subtree(tt::Subtree { + delimiter: tt::Delimiter::invisible_spanned(span), + token_trees: Box::new([ + tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { + char: '\'', + span, + spacing: tt::Spacing::Joint, + })), + tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { + text: SmolStr::new_static("missing"), + span, + })), + ]), + })) } MetaVarKind::Literal => { Fragment::Tokens(tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index bfc5d197f6834..3c270e30a9ba8 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs @@ -700,10 +700,12 @@ impl SynToken { } impl SrcToken, S> for SynToken { - fn kind(&self, ctx: &Converter) -> SyntaxKind { + fn kind(&self, _ctx: &Converter) -> SyntaxKind { match self { SynToken::Ordinary(token) => token.kind(), - SynToken::Punct { .. } => SyntaxKind::from_char(self.to_char(ctx).unwrap()).unwrap(), + SynToken::Punct { token, offset: i } => { + SyntaxKind::from_char(token.text().chars().nth(*i).unwrap()).unwrap() + } SynToken::Leaf(_) => { never!(); SyntaxKind::ERROR diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index f40c515fa079d..6b660180f8238 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -678,27 +678,38 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) { attributes::outer_attrs(p); match p.current() { - IDENT | INT_NUMBER => { + IDENT | INT_NUMBER if p.nth_at(1, T![::]) => { // test_err record_literal_missing_ellipsis_recovery // fn main() { // S { S::default() } // } - if p.nth_at(1, T![::]) { - m.abandon(p); - p.expect(T![..]); - expr(p); - } else { + m.abandon(p); + p.expect(T![..]); + expr(p); + } + IDENT | INT_NUMBER => { + if p.nth_at(1, T![..]) { // test_err record_literal_before_ellipsis_recovery // fn main() { // S { field ..S::default() } // } - if p.nth_at(1, T![:]) || p.nth_at(1, T![..]) { + name_ref_or_index(p); + p.error("expected `:`"); + } else { + // test_err record_literal_field_eq_recovery + // fn main() { + // S { field = foo } + // } + if p.nth_at(1, T![:]) { + name_ref_or_index(p); + p.bump(T![:]); + } else if p.nth_at(1, T![=]) { name_ref_or_index(p); - p.expect(T![:]); + p.err_and_bump("expected `:`"); } expr(p); - m.complete(p, RECORD_EXPR_FIELD); } + m.complete(p, RECORD_EXPR_FIELD); } T![.] if p.at(T![..]) => { m.abandon(p); diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 4197f248e0a97..48600641ad05b 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -58,6 +58,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = T![match], T![move], T![return], + T![become], T![static], T![try], T![unsafe], @@ -102,6 +103,7 @@ pub(super) fn atom_expr( T![try] => try_block_expr(p, None), T![match] => match_expr(p), T![return] => return_expr(p), + T![become] => become_expr(p), T![yield] => yield_expr(p), T![do] if p.nth_at_contextual_kw(1, T![yeet]) => yeet_expr(p), T![continue] => continue_expr(p), @@ -621,6 +623,18 @@ fn return_expr(p: &mut Parser<'_>) -> CompletedMarker { m.complete(p, RETURN_EXPR) } +// test become_expr +// fn foo() { +// become foo(); +// } +fn become_expr(p: &mut Parser<'_>) -> CompletedMarker { + assert!(p.at(T![become])); + let m = p.start(); + p.bump(T![become]); + expr(p); + m.complete(p, BECOME_EXPR) +} + // test yield_expr // fn foo() { // yield; diff --git a/crates/parser/src/grammar/generic_params.rs b/crates/parser/src/grammar/generic_params.rs index 3c577aa3cb499..4498daf21a3d8 100644 --- a/crates/parser/src/grammar/generic_params.rs +++ b/crates/parser/src/grammar/generic_params.rs @@ -157,6 +157,16 @@ fn type_bound(p: &mut Parser<'_>) -> bool { p.bump_any(); p.expect(T![const]); } + // test const_trait_bound + // const fn foo(_: impl const Trait) {} + T![const] => { + p.bump_any(); + } + // test async_trait_bound + // fn async_foo(_: impl async Fn(&i32)) {} + T![async] => { + p.bump_any(); + } _ => (), } if paths::is_use_path_start(p) { diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 39ded41bb2413..5036742337921 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs @@ -323,6 +323,15 @@ fn record_pat_field(p: &mut Parser<'_>) { p.bump(T![:]); pattern(p); } + // test_err record_pat_field_eq_recovery + // fn main() { + // let S { field = foo }; + // } + IDENT | INT_NUMBER if p.nth(1) == T![=] => { + name_ref_or_index(p); + p.err_and_bump("expected `:`"); + pattern(p); + } T![box] => { // FIXME: not all box patterns should be allowed box_pat(p); diff --git a/crates/parser/src/syntax_kind/generated.rs b/crates/parser/src/syntax_kind/generated.rs index 4b589037672f4..6ecfdc9f4664c 100644 --- a/crates/parser/src/syntax_kind/generated.rs +++ b/crates/parser/src/syntax_kind/generated.rs @@ -90,6 +90,7 @@ pub enum SyntaxKind { PUB_KW, REF_KW, RETURN_KW, + BECOME_KW, SELF_KW, SELF_TYPE_KW, STATIC_KW, @@ -195,6 +196,7 @@ pub enum SyntaxKind { BLOCK_EXPR, STMT_LIST, RETURN_EXPR, + BECOME_EXPR, YIELD_EXPR, YEET_EXPR, LET_EXPR, @@ -307,6 +309,7 @@ impl SyntaxKind { | PUB_KW | REF_KW | RETURN_KW + | BECOME_KW | SELF_KW | SELF_TYPE_KW | STATIC_KW @@ -425,6 +428,7 @@ impl SyntaxKind { "pub" => PUB_KW, "ref" => REF_KW, "return" => RETURN_KW, + "become" => BECOME_KW, "self" => SELF_KW, "Self" => SELF_TYPE_KW, "static" => STATIC_KW, @@ -496,4 +500,4 @@ impl SyntaxKind { } } #[macro_export] -macro_rules ! T { [;] => { $ crate :: SyntaxKind :: SEMICOLON } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: SyntaxKind :: R_CURLY } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; [<] => { $ crate :: SyntaxKind :: L_ANGLE } ; [>] => { $ crate :: SyntaxKind :: R_ANGLE } ; [@] => { $ crate :: SyntaxKind :: AT } ; [#] => { $ crate :: SyntaxKind :: POUND } ; [~] => { $ crate :: SyntaxKind :: TILDE } ; [?] => { $ crate :: SyntaxKind :: QUESTION } ; [$] => { $ crate :: SyntaxKind :: DOLLAR } ; [&] => { $ crate :: SyntaxKind :: AMP } ; [|] => { $ crate :: SyntaxKind :: PIPE } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [*] => { $ crate :: SyntaxKind :: STAR } ; [/] => { $ crate :: SyntaxKind :: SLASH } ; [^] => { $ crate :: SyntaxKind :: CARET } ; [%] => { $ crate :: SyntaxKind :: PERCENT } ; [_] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [..] => { $ crate :: SyntaxKind :: DOT2 } ; [...] => { $ crate :: SyntaxKind :: DOT3 } ; [..=] => { $ crate :: SyntaxKind :: DOT2EQ } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLON2 } ; [=] => { $ crate :: SyntaxKind :: EQ } ; [==] => { $ crate :: SyntaxKind :: EQ2 } ; [=>] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: SyntaxKind :: BANG } ; [!=] => { $ crate :: SyntaxKind :: NEQ } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [->] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [<=] => { $ crate :: SyntaxKind :: LTEQ } ; [>=] => { $ crate :: SyntaxKind :: GTEQ } ; [+=] => { $ crate :: SyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: SyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: SyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: SyntaxKind :: AMPEQ } ; [^=] => { $ crate :: SyntaxKind :: CARETEQ } ; [/=] => { $ crate :: SyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: SyntaxKind :: STAREQ } ; [%=] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: SyntaxKind :: AMP2 } ; [||] => { $ crate :: SyntaxKind :: PIPE2 } ; [<<] => { $ crate :: SyntaxKind :: SHL } ; [>>] => { $ crate :: SyntaxKind :: SHR } ; [<<=] => { $ crate :: SyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: SyntaxKind :: SHREQ } ; [as] => { $ crate :: SyntaxKind :: AS_KW } ; [async] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [box] => { $ crate :: SyntaxKind :: BOX_KW } ; [break] => { $ crate :: SyntaxKind :: BREAK_KW } ; [const] => { $ crate :: SyntaxKind :: CONST_KW } ; [continue] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [crate] => { $ crate :: SyntaxKind :: CRATE_KW } ; [do] => { $ crate :: SyntaxKind :: DO_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: SyntaxKind :: ENUM_KW } ; [extern] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [fn] => { $ crate :: SyntaxKind :: FN_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [impl] => { $ crate :: SyntaxKind :: IMPL_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [let] => { $ crate :: SyntaxKind :: LET_KW } ; [loop] => { $ crate :: SyntaxKind :: LOOP_KW } ; [macro] => { $ crate :: SyntaxKind :: MACRO_KW } ; [match] => { $ crate :: SyntaxKind :: MATCH_KW } ; [mod] => { $ crate :: SyntaxKind :: MOD_KW } ; [move] => { $ crate :: SyntaxKind :: MOVE_KW } ; [mut] => { $ crate :: SyntaxKind :: MUT_KW } ; [pub] => { $ crate :: SyntaxKind :: PUB_KW } ; [ref] => { $ crate :: SyntaxKind :: REF_KW } ; [return] => { $ crate :: SyntaxKind :: RETURN_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [Self] => { $ crate :: SyntaxKind :: SELF_TYPE_KW } ; [static] => { $ crate :: SyntaxKind :: STATIC_KW } ; [struct] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [trait] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [try] => { $ crate :: SyntaxKind :: TRY_KW } ; [type] => { $ crate :: SyntaxKind :: TYPE_KW } ; [unsafe] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [use] => { $ crate :: SyntaxKind :: USE_KW } ; [where] => { $ crate :: SyntaxKind :: WHERE_KW } ; [while] => { $ crate :: SyntaxKind :: WHILE_KW } ; [yield] => { $ crate :: SyntaxKind :: YIELD_KW } ; [auto] => { $ crate :: SyntaxKind :: AUTO_KW } ; [builtin] => { $ crate :: SyntaxKind :: BUILTIN_KW } ; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [existential] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [union] => { $ crate :: SyntaxKind :: UNION_KW } ; [raw] => { $ crate :: SyntaxKind :: RAW_KW } ; [macro_rules] => { $ crate :: SyntaxKind :: MACRO_RULES_KW } ; [yeet] => { $ crate :: SyntaxKind :: YEET_KW } ; [offset_of] => { $ crate :: SyntaxKind :: OFFSET_OF_KW } ; [asm] => { $ crate :: SyntaxKind :: ASM_KW } ; [format_args] => { $ crate :: SyntaxKind :: FORMAT_ARGS_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; } +macro_rules ! T { [;] => { $ crate :: SyntaxKind :: SEMICOLON } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: SyntaxKind :: R_CURLY } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; [<] => { $ crate :: SyntaxKind :: L_ANGLE } ; [>] => { $ crate :: SyntaxKind :: R_ANGLE } ; [@] => { $ crate :: SyntaxKind :: AT } ; [#] => { $ crate :: SyntaxKind :: POUND } ; [~] => { $ crate :: SyntaxKind :: TILDE } ; [?] => { $ crate :: SyntaxKind :: QUESTION } ; [$] => { $ crate :: SyntaxKind :: DOLLAR } ; [&] => { $ crate :: SyntaxKind :: AMP } ; [|] => { $ crate :: SyntaxKind :: PIPE } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [*] => { $ crate :: SyntaxKind :: STAR } ; [/] => { $ crate :: SyntaxKind :: SLASH } ; [^] => { $ crate :: SyntaxKind :: CARET } ; [%] => { $ crate :: SyntaxKind :: PERCENT } ; [_] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [..] => { $ crate :: SyntaxKind :: DOT2 } ; [...] => { $ crate :: SyntaxKind :: DOT3 } ; [..=] => { $ crate :: SyntaxKind :: DOT2EQ } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLON2 } ; [=] => { $ crate :: SyntaxKind :: EQ } ; [==] => { $ crate :: SyntaxKind :: EQ2 } ; [=>] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: SyntaxKind :: BANG } ; [!=] => { $ crate :: SyntaxKind :: NEQ } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [->] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [<=] => { $ crate :: SyntaxKind :: LTEQ } ; [>=] => { $ crate :: SyntaxKind :: GTEQ } ; [+=] => { $ crate :: SyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: SyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: SyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: SyntaxKind :: AMPEQ } ; [^=] => { $ crate :: SyntaxKind :: CARETEQ } ; [/=] => { $ crate :: SyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: SyntaxKind :: STAREQ } ; [%=] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: SyntaxKind :: AMP2 } ; [||] => { $ crate :: SyntaxKind :: PIPE2 } ; [<<] => { $ crate :: SyntaxKind :: SHL } ; [>>] => { $ crate :: SyntaxKind :: SHR } ; [<<=] => { $ crate :: SyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: SyntaxKind :: SHREQ } ; [as] => { $ crate :: SyntaxKind :: AS_KW } ; [async] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [box] => { $ crate :: SyntaxKind :: BOX_KW } ; [break] => { $ crate :: SyntaxKind :: BREAK_KW } ; [const] => { $ crate :: SyntaxKind :: CONST_KW } ; [continue] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [crate] => { $ crate :: SyntaxKind :: CRATE_KW } ; [do] => { $ crate :: SyntaxKind :: DO_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: SyntaxKind :: ENUM_KW } ; [extern] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [fn] => { $ crate :: SyntaxKind :: FN_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [impl] => { $ crate :: SyntaxKind :: IMPL_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [let] => { $ crate :: SyntaxKind :: LET_KW } ; [loop] => { $ crate :: SyntaxKind :: LOOP_KW } ; [macro] => { $ crate :: SyntaxKind :: MACRO_KW } ; [match] => { $ crate :: SyntaxKind :: MATCH_KW } ; [mod] => { $ crate :: SyntaxKind :: MOD_KW } ; [move] => { $ crate :: SyntaxKind :: MOVE_KW } ; [mut] => { $ crate :: SyntaxKind :: MUT_KW } ; [pub] => { $ crate :: SyntaxKind :: PUB_KW } ; [ref] => { $ crate :: SyntaxKind :: REF_KW } ; [return] => { $ crate :: SyntaxKind :: RETURN_KW } ; [become] => { $ crate :: SyntaxKind :: BECOME_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [Self] => { $ crate :: SyntaxKind :: SELF_TYPE_KW } ; [static] => { $ crate :: SyntaxKind :: STATIC_KW } ; [struct] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [trait] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [try] => { $ crate :: SyntaxKind :: TRY_KW } ; [type] => { $ crate :: SyntaxKind :: TYPE_KW } ; [unsafe] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [use] => { $ crate :: SyntaxKind :: USE_KW } ; [where] => { $ crate :: SyntaxKind :: WHERE_KW } ; [while] => { $ crate :: SyntaxKind :: WHILE_KW } ; [yield] => { $ crate :: SyntaxKind :: YIELD_KW } ; [auto] => { $ crate :: SyntaxKind :: AUTO_KW } ; [builtin] => { $ crate :: SyntaxKind :: BUILTIN_KW } ; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [existential] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [union] => { $ crate :: SyntaxKind :: UNION_KW } ; [raw] => { $ crate :: SyntaxKind :: RAW_KW } ; [macro_rules] => { $ crate :: SyntaxKind :: MACRO_RULES_KW } ; [yeet] => { $ crate :: SyntaxKind :: YEET_KW } ; [offset_of] => { $ crate :: SyntaxKind :: OFFSET_OF_KW } ; [asm] => { $ crate :: SyntaxKind :: ASM_KW } ; [format_args] => { $ crate :: SyntaxKind :: FORMAT_ARGS_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; } diff --git a/crates/parser/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast b/crates/parser/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast index f511960040d5f..741b7845e7f14 100644 --- a/crates/parser/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast +++ b/crates/parser/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast @@ -24,26 +24,26 @@ SOURCE_FILE RECORD_EXPR_FIELD NAME_REF IDENT "field" - WHITESPACE " " - RANGE_EXPR - DOT2 ".." - CALL_EXPR - PATH_EXPR - PATH - PATH - PATH_SEGMENT - NAME_REF - IDENT "S" - COLON2 "::" - PATH_SEGMENT - NAME_REF - IDENT "default" - ARG_LIST - L_PAREN "(" - R_PAREN ")" + WHITESPACE " " + DOT2 ".." + CALL_EXPR + PATH_EXPR + PATH + PATH + PATH_SEGMENT + NAME_REF + IDENT "S" + COLON2 "::" + PATH_SEGMENT + NAME_REF + IDENT "default" + ARG_LIST + L_PAREN "(" + R_PAREN ")" WHITESPACE " " R_CURLY "}" WHITESPACE "\n" R_CURLY "}" WHITESPACE "\n" -error 25: expected COLON +error 25: expected `:` +error 25: expected COMMA diff --git a/crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rast b/crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rast new file mode 100644 index 0000000000000..ad4deeb0b67c9 --- /dev/null +++ b/crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rast @@ -0,0 +1,41 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "main" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\n " + RECORD_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "S" + WHITESPACE " " + RECORD_EXPR_FIELD_LIST + L_CURLY "{" + WHITESPACE " " + RECORD_EXPR_FIELD + NAME_REF + IDENT "field" + WHITESPACE " " + ERROR + EQ "=" + WHITESPACE " " + PATH_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "foo" + WHITESPACE " " + R_CURLY "}" + WHITESPACE "\n" + R_CURLY "}" + WHITESPACE "\n" +error 26: expected `:` diff --git a/crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rs b/crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rs new file mode 100644 index 0000000000000..1eb1aa9b92642 --- /dev/null +++ b/crates/parser/test_data/parser/inline/err/0032_record_literal_field_eq_recovery.rs @@ -0,0 +1,3 @@ +fn main() { + S { field = foo } +} diff --git a/crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rast b/crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rast new file mode 100644 index 0000000000000..6940a84b68302 --- /dev/null +++ b/crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rast @@ -0,0 +1,43 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "main" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\n " + LET_STMT + LET_KW "let" + WHITESPACE " " + RECORD_PAT + PATH + PATH_SEGMENT + NAME_REF + IDENT "S" + WHITESPACE " " + RECORD_PAT_FIELD_LIST + L_CURLY "{" + WHITESPACE " " + RECORD_PAT_FIELD + NAME_REF + IDENT "field" + WHITESPACE " " + ERROR + EQ "=" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\n" + R_CURLY "}" + WHITESPACE "\n" +error 30: expected `:` diff --git a/crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rs b/crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rs new file mode 100644 index 0000000000000..c4949d6e12e7a --- /dev/null +++ b/crates/parser/test_data/parser/inline/err/0033_record_pat_field_eq_recovery.rs @@ -0,0 +1,3 @@ +fn main() { + let S { field = foo }; +} diff --git a/crates/parser/test_data/parser/inline/ok/0209_become_expr.rast b/crates/parser/test_data/parser/inline/ok/0209_become_expr.rast new file mode 100644 index 0000000000000..c544cf4e5e3ef --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0209_become_expr.rast @@ -0,0 +1,31 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "foo" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\n " + EXPR_STMT + BECOME_EXPR + BECOME_KW "become" + WHITESPACE " " + CALL_EXPR + PATH_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "foo" + ARG_LIST + L_PAREN "(" + R_PAREN ")" + SEMICOLON ";" + WHITESPACE "\n" + R_CURLY "}" + WHITESPACE "\n" diff --git a/crates/parser/test_data/parser/inline/ok/0209_become_expr.rs b/crates/parser/test_data/parser/inline/ok/0209_become_expr.rs new file mode 100644 index 0000000000000..918a83ca6e83e --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0209_become_expr.rs @@ -0,0 +1,3 @@ +fn foo() { + become foo(); +} diff --git a/crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rast b/crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rast new file mode 100644 index 0000000000000..ebf758286a7c2 --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rast @@ -0,0 +1,43 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "async_foo" + PARAM_LIST + L_PAREN "(" + PARAM + WILDCARD_PAT + UNDERSCORE "_" + COLON ":" + WHITESPACE " " + IMPL_TRAIT_TYPE + IMPL_KW "impl" + WHITESPACE " " + TYPE_BOUND_LIST + TYPE_BOUND + ASYNC_KW "async" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "Fn" + PARAM_LIST + L_PAREN "(" + PARAM + REF_TYPE + AMP "&" + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "i32" + R_PAREN ")" + R_PAREN ")" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + R_CURLY "}" + WHITESPACE "\n" diff --git a/crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rs b/crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rs new file mode 100644 index 0000000000000..04d44175d778d --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0211_async_trait_bound.rs @@ -0,0 +1 @@ +fn async_foo(_: impl async Fn(&i32)) {} diff --git a/crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rast b/crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rast new file mode 100644 index 0000000000000..646873881bcb0 --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rast @@ -0,0 +1,34 @@ +SOURCE_FILE + FN + CONST_KW "const" + WHITESPACE " " + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "foo" + PARAM_LIST + L_PAREN "(" + PARAM + WILDCARD_PAT + UNDERSCORE "_" + COLON ":" + WHITESPACE " " + IMPL_TRAIT_TYPE + IMPL_KW "impl" + WHITESPACE " " + TYPE_BOUND_LIST + TYPE_BOUND + CONST_KW "const" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "Trait" + R_PAREN ")" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + R_CURLY "}" + WHITESPACE "\n" diff --git a/crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rs b/crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rs new file mode 100644 index 0000000000000..8eb8f84c91f45 --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0212_const_trait_bound.rs @@ -0,0 +1 @@ +const fn foo(_: impl const Trait) {} diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs index 1dadfc40ac431..6b16711a8d87b 100644 --- a/crates/proc-macro-api/src/lib.rs +++ b/crates/proc-macro-api/src/lib.rs @@ -13,6 +13,7 @@ mod version; use indexmap::IndexSet; use paths::AbsPathBuf; +use rustc_hash::FxHashMap; use span::Span; use std::{ fmt, io, @@ -107,8 +108,11 @@ pub struct MacroPanic { impl ProcMacroServer { /// Spawns an external process as the proc macro server and returns a client connected to it. - pub fn spawn(process_path: AbsPathBuf) -> io::Result { - let process = ProcMacroProcessSrv::run(process_path)?; + pub fn spawn( + process_path: AbsPathBuf, + env: &FxHashMap, + ) -> io::Result { + let process = ProcMacroProcessSrv::run(process_path, env)?; Ok(ProcMacroServer { process: Arc::new(Mutex::new(process)) }) } diff --git a/crates/proc-macro-api/src/process.rs b/crates/proc-macro-api/src/process.rs index 96f97bf5e205e..12eafcea442d3 100644 --- a/crates/proc-macro-api/src/process.rs +++ b/crates/proc-macro-api/src/process.rs @@ -7,6 +7,7 @@ use std::{ }; use paths::{AbsPath, AbsPathBuf}; +use rustc_hash::FxHashMap; use stdx::JodChild; use crate::{ @@ -26,9 +27,12 @@ pub(crate) struct ProcMacroProcessSrv { } impl ProcMacroProcessSrv { - pub(crate) fn run(process_path: AbsPathBuf) -> io::Result { + pub(crate) fn run( + process_path: AbsPathBuf, + env: &FxHashMap, + ) -> io::Result { let create_srv = |null_stderr| { - let mut process = Process::run(process_path.clone(), null_stderr)?; + let mut process = Process::run(process_path.clone(), env, null_stderr)?; let (stdin, stdout) = process.stdio().expect("couldn't access child stdio"); io::Result::Ok(ProcMacroProcessSrv { @@ -147,8 +151,12 @@ struct Process { } impl Process { - fn run(path: AbsPathBuf, null_stderr: bool) -> io::Result { - let child = JodChild(mk_child(&path, null_stderr)?); + fn run( + path: AbsPathBuf, + env: &FxHashMap, + null_stderr: bool, + ) -> io::Result { + let child = JodChild(mk_child(&path, env, null_stderr)?); Ok(Process { child }) } @@ -161,9 +169,14 @@ impl Process { } } -fn mk_child(path: &AbsPath, null_stderr: bool) -> io::Result { +fn mk_child( + path: &AbsPath, + env: &FxHashMap, + null_stderr: bool, +) -> io::Result { let mut cmd = Command::new(path.as_os_str()); - cmd.env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable") + cmd.envs(env) + .env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(if null_stderr { Stdio::null() } else { Stdio::inherit() }); diff --git a/crates/proc-macro-srv/Cargo.toml b/crates/proc-macro-srv/Cargo.toml index ba17ea6f7b439..bd7a31654584f 100644 --- a/crates/proc-macro-srv/Cargo.toml +++ b/crates/proc-macro-srv/Cargo.toml @@ -29,6 +29,7 @@ paths.workspace = true base-db.workspace = true span.workspace = true proc-macro-api.workspace = true +ra-ap-rustc_lexer.workspace = true [dev-dependencies] expect-test = "1.4.0" diff --git a/crates/proc-macro-srv/src/lib.rs b/crates/proc-macro-srv/src/lib.rs index 460a96c07f367..831632c64c0a2 100644 --- a/crates/proc-macro-srv/src/lib.rs +++ b/crates/proc-macro-srv/src/lib.rs @@ -20,6 +20,11 @@ extern crate proc_macro; #[cfg(feature = "in-rust-tree")] extern crate rustc_driver as _; +#[cfg(not(feature = "in-rust-tree"))] +extern crate ra_ap_rustc_lexer as rustc_lexer; +#[cfg(feature = "in-rust-tree")] +extern crate rustc_lexer; + mod dylib; mod proc_macros; mod server; diff --git a/crates/proc-macro-srv/src/server/rust_analyzer_span.rs b/crates/proc-macro-srv/src/server/rust_analyzer_span.rs index 8a9d52a37a2f3..c6a0a6665553f 100644 --- a/crates/proc-macro-srv/src/server/rust_analyzer_span.rs +++ b/crates/proc-macro-srv/src/server/rust_analyzer_span.rs @@ -70,11 +70,58 @@ impl server::FreeFunctions for RaSpanServer { &mut self, s: &str, ) -> Result, ()> { - // FIXME: keep track of LitKind and Suffix + use proc_macro::bridge::LitKind; + use rustc_lexer::{LiteralKind, Token, TokenKind}; + + let mut tokens = rustc_lexer::tokenize(s); + let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 }); + + let lit = if minus_or_lit.kind == TokenKind::Minus { + let lit = tokens.next().ok_or(())?; + if !matches!( + lit.kind, + TokenKind::Literal { + kind: LiteralKind::Int { .. } | LiteralKind::Float { .. }, + .. + } + ) { + return Err(()); + } + lit + } else { + minus_or_lit + }; + + if tokens.next().is_some() { + return Err(()); + } + + let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) }; + let kind = match kind { + LiteralKind::Int { .. } => LitKind::Integer, + LiteralKind::Float { .. } => LitKind::Float, + LiteralKind::Char { .. } => LitKind::Char, + LiteralKind::Byte { .. } => LitKind::Byte, + LiteralKind::Str { .. } => LitKind::Str, + LiteralKind::ByteStr { .. } => LitKind::ByteStr, + LiteralKind::CStr { .. } => LitKind::CStr, + LiteralKind::RawStr { n_hashes } => LitKind::StrRaw(n_hashes.unwrap_or_default()), + LiteralKind::RawByteStr { n_hashes } => { + LitKind::ByteStrRaw(n_hashes.unwrap_or_default()) + } + LiteralKind::RawCStr { n_hashes } => LitKind::CStrRaw(n_hashes.unwrap_or_default()), + }; + + let (lit, suffix) = s.split_at(suffix_start as usize); + let suffix = match suffix { + "" | "_" => None, + suffix => Some(Symbol::intern(self.interner, suffix)), + }; + Ok(bridge::Literal { - kind: bridge::LitKind::Integer, // dummy - symbol: Symbol::intern(self.interner, s), - suffix: None, + kind, + symbol: Symbol::intern(self.interner, lit), + suffix, span: self.call_site, }) } diff --git a/crates/proc-macro-srv/src/server/token_id.rs b/crates/proc-macro-srv/src/server/token_id.rs index 15a9e0deae44f..7e9d8057ac9a5 100644 --- a/crates/proc-macro-srv/src/server/token_id.rs +++ b/crates/proc-macro-srv/src/server/token_id.rs @@ -62,11 +62,58 @@ impl server::FreeFunctions for TokenIdServer { &mut self, s: &str, ) -> Result, ()> { - // FIXME: keep track of LitKind and Suffix + use proc_macro::bridge::LitKind; + use rustc_lexer::{LiteralKind, Token, TokenKind}; + + let mut tokens = rustc_lexer::tokenize(s); + let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 }); + + let lit = if minus_or_lit.kind == TokenKind::Minus { + let lit = tokens.next().ok_or(())?; + if !matches!( + lit.kind, + TokenKind::Literal { + kind: LiteralKind::Int { .. } | LiteralKind::Float { .. }, + .. + } + ) { + return Err(()); + } + lit + } else { + minus_or_lit + }; + + if tokens.next().is_some() { + return Err(()); + } + + let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) }; + let kind = match kind { + LiteralKind::Int { .. } => LitKind::Integer, + LiteralKind::Float { .. } => LitKind::Float, + LiteralKind::Char { .. } => LitKind::Char, + LiteralKind::Byte { .. } => LitKind::Byte, + LiteralKind::Str { .. } => LitKind::Str, + LiteralKind::ByteStr { .. } => LitKind::ByteStr, + LiteralKind::CStr { .. } => LitKind::CStr, + LiteralKind::RawStr { n_hashes } => LitKind::StrRaw(n_hashes.unwrap_or_default()), + LiteralKind::RawByteStr { n_hashes } => { + LitKind::ByteStrRaw(n_hashes.unwrap_or_default()) + } + LiteralKind::RawCStr { n_hashes } => LitKind::CStrRaw(n_hashes.unwrap_or_default()), + }; + + let (lit, suffix) = s.split_at(suffix_start as usize); + let suffix = match suffix { + "" | "_" => None, + suffix => Some(Symbol::intern(self.interner, suffix)), + }; + Ok(bridge::Literal { - kind: bridge::LitKind::Integer, // dummy - symbol: Symbol::intern(self.interner, s), - suffix: None, + kind, + symbol: Symbol::intern(self.interner, lit), + suffix, span: self.call_site, }) } diff --git a/crates/proc-macro-srv/src/tests/mod.rs b/crates/proc-macro-srv/src/tests/mod.rs index 87d832cc76fa0..e5bfe5ee92cd8 100644 --- a/crates/proc-macro-srv/src/tests/mod.rs +++ b/crates/proc-macro-srv/src/tests/mod.rs @@ -169,8 +169,8 @@ fn test_fn_like_mk_idents() { fn test_fn_like_macro_clone_literals() { assert_expand( "fn_like_clone_tokens", - r#"1u16, 2_u32, -4i64, 3.14f32, "hello bridge""#, - expect![[r#" + r###"1u16, 2_u32, -4i64, 3.14f32, "hello bridge", "suffixed"suffix, r##"raw"##"###, + expect![[r###" SUBTREE $$ 1 1 LITERAL 1u16 1 PUNCH , [alone] 1 @@ -181,8 +181,12 @@ fn test_fn_like_macro_clone_literals() { PUNCH , [alone] 1 LITERAL 3.14f32 1 PUNCH , [alone] 1 - LITERAL "hello bridge" 1"#]], - expect![[r#" + LITERAL ""hello bridge"" 1 + PUNCH , [alone] 1 + LITERAL ""suffixed""suffix 1 + PUNCH , [alone] 1 + LITERAL r##"r##"raw"##"## 1"###]], + expect![[r###" SUBTREE $$ SpanData { range: 0..100, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } SpanData { range: 0..100, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } LITERAL 1u16 SpanData { range: 0..4, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } PUNCH , [alone] SpanData { range: 4..5, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } @@ -193,7 +197,11 @@ fn test_fn_like_macro_clone_literals() { PUNCH , [alone] SpanData { range: 18..19, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } LITERAL 3.14f32 SpanData { range: 20..27, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } PUNCH , [alone] SpanData { range: 27..28, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } - LITERAL "hello bridge" SpanData { range: 29..43, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) }"#]], + LITERAL ""hello bridge"" SpanData { range: 29..43, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } + PUNCH , [alone] SpanData { range: 43..44, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } + LITERAL ""suffixed""suffix SpanData { range: 45..61, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } + PUNCH , [alone] SpanData { range: 61..62, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) } + LITERAL r##"r##"raw"##"## SpanData { range: 63..73, anchor: SpanAnchor(FileId(42), 2), ctx: SyntaxContextId(0) }"###]], ); } diff --git a/crates/project-model/src/build_scripts.rs b/crates/project-model/src/build_scripts.rs index a2c9856a3f733..ab72f1fba09dd 100644 --- a/crates/project-model/src/build_scripts.rs +++ b/crates/project-model/src/build_scripts.rs @@ -20,10 +20,11 @@ use paths::{AbsPath, AbsPathBuf}; use rustc_hash::{FxHashMap, FxHashSet}; use semver::Version; use serde::Deserialize; +use toolchain::Tool; use crate::{ cfg_flag::CfgFlag, utf8_stdout, CargoConfig, CargoFeatures, CargoWorkspace, InvocationLocation, - InvocationStrategy, Package, + InvocationStrategy, Package, Sysroot, TargetKind, }; #[derive(Debug, Default, Clone, PartialEq, Eq)] @@ -61,6 +62,7 @@ impl WorkspaceBuildScripts { config: &CargoConfig, allowed_features: &FxHashSet, workspace_root: &AbsPathBuf, + sysroot: Option<&Sysroot>, ) -> io::Result { let mut cmd = match config.run_build_script_command.as_deref() { Some([program, args @ ..]) => { @@ -69,7 +71,8 @@ impl WorkspaceBuildScripts { cmd } _ => { - let mut cmd = Command::new(toolchain::cargo()); + let mut cmd = Command::new(Tool::Cargo.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); cmd.args(["check", "--quiet", "--workspace", "--message-format=json"]); cmd.args(&config.extra_args); @@ -133,6 +136,7 @@ impl WorkspaceBuildScripts { workspace: &CargoWorkspace, progress: &dyn Fn(String), toolchain: &Option, + sysroot: Option<&Sysroot>, ) -> io::Result { const RUST_1_62: Version = Version::new(1, 62, 0); @@ -151,6 +155,7 @@ impl WorkspaceBuildScripts { config, &allowed_features, &workspace.workspace_root().to_path_buf(), + sysroot, )?, workspace, current_dir, @@ -165,6 +170,7 @@ impl WorkspaceBuildScripts { config, &allowed_features, &workspace.workspace_root().to_path_buf(), + sysroot, )?; cmd.args(["-Z", "unstable-options", "--keep-going"]).env("RUSTC_BOOTSTRAP", "1"); let mut res = Self::run_per_ws(cmd, workspace, current_dir, progress)?; @@ -194,7 +200,7 @@ impl WorkspaceBuildScripts { )) } }; - let cmd = Self::build_command(config, &Default::default(), workspace_root)?; + let cmd = Self::build_command(config, &Default::default(), workspace_root, None)?; // NB: Cargo.toml could have been modified between `cargo metadata` and // `cargo check`. We shouldn't assume that package ids we see here are // exactly those from `config`. @@ -415,6 +421,7 @@ impl WorkspaceBuildScripts { rustc: &CargoWorkspace, current_dir: &AbsPath, extra_env: &FxHashMap, + sysroot: Option<&Sysroot>, ) -> Self { let mut bs = WorkspaceBuildScripts::default(); for p in rustc.packages() { @@ -422,7 +429,8 @@ impl WorkspaceBuildScripts { } let res = (|| { let target_libdir = (|| { - let mut cargo_config = Command::new(toolchain::cargo()); + let mut cargo_config = Command::new(Tool::Cargo.path()); + Sysroot::set_rustup_toolchain_env(&mut cargo_config, sysroot); cargo_config.envs(extra_env); cargo_config .current_dir(current_dir) @@ -431,7 +439,8 @@ impl WorkspaceBuildScripts { if let Ok(it) = utf8_stdout(cargo_config) { return Ok(it); } - let mut cmd = Command::new(toolchain::rustc()); + let mut cmd = Command::new(Tool::Rustc.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); cmd.envs(extra_env); cmd.args(["--print", "target-libdir"]); utf8_stdout(cmd) @@ -458,7 +467,11 @@ impl WorkspaceBuildScripts { .collect(); for p in rustc.packages() { let package = &rustc[p]; - if package.targets.iter().any(|&it| rustc[it].is_proc_macro) { + if package + .targets + .iter() + .any(|&it| matches!(rustc[it].kind, TargetKind::Lib { is_proc_macro: true })) + { if let Some((_, path)) = proc_macro_dylibs .iter() .find(|(name, _)| *name.trim_start_matches("lib") == package.name) diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs index a99ee6e664c5f..08d86fd7b0fee 100644 --- a/crates/project-model/src/cargo_workspace.rs +++ b/crates/project-model/src/cargo_workspace.rs @@ -12,8 +12,9 @@ use paths::{AbsPath, AbsPathBuf}; use rustc_hash::{FxHashMap, FxHashSet}; use serde::Deserialize; use serde_json::from_value; +use toolchain::Tool; -use crate::{utf8_stdout, InvocationLocation, ManifestPath}; +use crate::{utf8_stdout, InvocationLocation, ManifestPath, Sysroot}; use crate::{CfgOverrides, InvocationStrategy}; /// [`CargoWorkspace`] represents the logical structure of, well, a Cargo @@ -188,8 +189,6 @@ pub struct TargetData { pub root: AbsPathBuf, /// Kind of target pub kind: TargetKind, - /// Is this target a proc-macro - pub is_proc_macro: bool, /// Required features of the target without which it won't build pub required_features: Vec, } @@ -198,7 +197,10 @@ pub struct TargetData { pub enum TargetKind { Bin, /// Any kind of Cargo lib crate-type (dylib, rlib, proc-macro, ...). - Lib, + Lib { + /// Is this target a proc-macro + is_proc_macro: bool, + }, Example, Test, Bench, @@ -215,8 +217,8 @@ impl TargetKind { "bench" => TargetKind::Bench, "example" => TargetKind::Example, "custom-build" => TargetKind::BuildScript, - "proc-macro" => TargetKind::Lib, - _ if kind.contains("lib") => TargetKind::Lib, + "proc-macro" => TargetKind::Lib { is_proc_macro: true }, + _ if kind.contains("lib") => TargetKind::Lib { is_proc_macro: false }, _ => continue, }; } @@ -236,12 +238,13 @@ impl CargoWorkspace { cargo_toml: &ManifestPath, current_dir: &AbsPath, config: &CargoConfig, + sysroot: Option<&Sysroot>, progress: &dyn Fn(String), ) -> anyhow::Result { - let targets = find_list_of_build_targets(config, cargo_toml); + let targets = find_list_of_build_targets(config, cargo_toml, sysroot); let mut meta = MetadataCommand::new(); - meta.cargo_path(toolchain::cargo()); + meta.cargo_path(Tool::Cargo.path()); meta.manifest_path(cargo_toml.to_path_buf()); match &config.features { CargoFeatures::All => { @@ -289,6 +292,7 @@ impl CargoWorkspace { (|| -> Result { let mut command = meta.cargo_command(); + Sysroot::set_rustup_toolchain_env(&mut command, sysroot); command.envs(&config.extra_env); let output = command.output()?; if !output.status.success() { @@ -368,7 +372,6 @@ impl CargoWorkspace { name, root: AbsPathBuf::assert(src_path.into()), kind: TargetKind::new(&kind), - is_proc_macro: *kind == ["proc-macro"], required_features, }); pkg_data.targets.push(tgt); @@ -476,24 +479,30 @@ impl CargoWorkspace { } } -fn find_list_of_build_targets(config: &CargoConfig, cargo_toml: &ManifestPath) -> Vec { +fn find_list_of_build_targets( + config: &CargoConfig, + cargo_toml: &ManifestPath, + sysroot: Option<&Sysroot>, +) -> Vec { if let Some(target) = &config.target { return [target.into()].to_vec(); } - let build_targets = cargo_config_build_target(cargo_toml, &config.extra_env); + let build_targets = cargo_config_build_target(cargo_toml, &config.extra_env, sysroot); if !build_targets.is_empty() { return build_targets; } - rustc_discover_host_triple(cargo_toml, &config.extra_env).into_iter().collect() + rustc_discover_host_triple(cargo_toml, &config.extra_env, sysroot).into_iter().collect() } fn rustc_discover_host_triple( cargo_toml: &ManifestPath, extra_env: &FxHashMap, + sysroot: Option<&Sysroot>, ) -> Option { - let mut rustc = Command::new(toolchain::rustc()); + let mut rustc = Command::new(Tool::Rustc.path()); + Sysroot::set_rustup_toolchain_env(&mut rustc, sysroot); rustc.envs(extra_env); rustc.current_dir(cargo_toml.parent()).arg("-vV"); tracing::debug!("Discovering host platform by {:?}", rustc); @@ -519,8 +528,10 @@ fn rustc_discover_host_triple( fn cargo_config_build_target( cargo_toml: &ManifestPath, extra_env: &FxHashMap, + sysroot: Option<&Sysroot>, ) -> Vec { - let mut cargo_config = Command::new(toolchain::cargo()); + let mut cargo_config = Command::new(Tool::Cargo.path()); + Sysroot::set_rustup_toolchain_env(&mut cargo_config, sysroot); cargo_config.envs(extra_env); cargo_config .current_dir(cargo_toml.parent()) diff --git a/crates/project-model/src/project_json.rs b/crates/project-model/src/project_json.rs index cf3231498f3e7..fba0aaa8ce9f4 100644 --- a/crates/project-model/src/project_json.rs +++ b/crates/project-model/src/project_json.rs @@ -49,7 +49,7 @@ //! user explores them belongs to that extension (it's totally valid to change //! rust-project.json over time via configuration request!) -use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, DependencyKind, Edition}; +use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition}; use la_arena::RawIdx; use paths::{AbsPath, AbsPathBuf}; use rustc_hash::FxHashMap; @@ -135,7 +135,6 @@ impl ProjectJson { Dependency::new( dep_data.name, CrateId::from_raw(RawIdx::from(dep_data.krate as u32)), - DependencyKind::Normal, ) }) .collect::>(), diff --git a/crates/project-model/src/rustc_cfg.rs b/crates/project-model/src/rustc_cfg.rs index 0aee002fbb3ff..1ad6e7255bf10 100644 --- a/crates/project-model/src/rustc_cfg.rs +++ b/crates/project-model/src/rustc_cfg.rs @@ -8,17 +8,13 @@ use rustc_hash::FxHashMap; use crate::{cfg_flag::CfgFlag, utf8_stdout, ManifestPath, Sysroot}; /// Determines how `rustc --print cfg` is discovered and invoked. -/// -/// There options are supported: -/// - [`RustcCfgConfig::Cargo`], which relies on `cargo rustc --print cfg` -/// and `RUSTC_BOOTSTRAP`. -/// - [`RustcCfgConfig::Explicit`], which uses an explicit path to the `rustc` -/// binary in the sysroot. -/// - [`RustcCfgConfig::Discover`], which uses [`toolchain::rustc`]. pub(crate) enum RustcCfgConfig<'a> { - Cargo(&'a ManifestPath), - Explicit(&'a Sysroot), - Discover, + /// Use `rustc --print cfg`, either from with the binary from the sysroot or by discovering via + /// [`toolchain::rustc`]. + Rustc(Option<&'a Sysroot>), + /// Use `cargo --print cfg`, either from with the binary from the sysroot or by discovering via + /// [`toolchain::cargo`]. + Cargo(Option<&'a Sysroot>, &'a ManifestPath), } pub(crate) fn get( @@ -71,9 +67,10 @@ fn get_rust_cfgs( extra_env: &FxHashMap, config: RustcCfgConfig<'_>, ) -> anyhow::Result { - let mut cmd = match config { - RustcCfgConfig::Cargo(cargo_toml) => { - let mut cmd = Command::new(toolchain::cargo()); + let sysroot = match config { + RustcCfgConfig::Cargo(sysroot, cargo_toml) => { + let mut cmd = Command::new(toolchain::Tool::Cargo.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); cmd.envs(extra_env); cmd.current_dir(cargo_toml.parent()) .args(["rustc", "-Z", "unstable-options", "--print", "cfg"]) @@ -82,25 +79,24 @@ fn get_rust_cfgs( cmd.args(["--target", target]); } - return utf8_stdout(cmd).context("Unable to run `cargo rustc`"); - } - RustcCfgConfig::Explicit(sysroot) => { - let rustc: std::path::PathBuf = sysroot.discover_rustc()?.into(); - tracing::debug!(?rustc, "using explicit rustc from sysroot"); - Command::new(rustc) - } - RustcCfgConfig::Discover => { - let rustc = toolchain::rustc(); - tracing::debug!(?rustc, "using rustc from env"); - Command::new(rustc) + match utf8_stdout(cmd) { + Ok(it) => return Ok(it), + Err(e) => { + tracing::warn!("failed to run `cargo rustc --print cfg`, falling back to invoking rustc directly: {e}"); + sysroot + } + } } + RustcCfgConfig::Rustc(sysroot) => sysroot, }; + let mut cmd = Command::new(toolchain::Tool::Rustc.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); cmd.envs(extra_env); cmd.args(["--print", "cfg", "-O"]); if let Some(target) = target { cmd.args(["--target", target]); } - utf8_stdout(cmd).context("Unable to run `rustc`") + utf8_stdout(cmd).context("unable to fetch cfgs via `rustc --print cfg -O`") } diff --git a/crates/project-model/src/sysroot.rs b/crates/project-model/src/sysroot.rs index 9e19a5258388f..07cfaba2d2ca2 100644 --- a/crates/project-model/src/sysroot.rs +++ b/crates/project-model/src/sysroot.rs @@ -4,24 +4,38 @@ //! but we can't process `.rlib` and need source code instead. The source code //! is typically installed with `rustup component add rust-src` command. -use std::{env, fs, iter, ops, path::PathBuf, process::Command}; +use std::{env, fs, iter, ops, path::PathBuf, process::Command, sync::Arc}; -use anyhow::{format_err, Context, Result}; +use anyhow::{format_err, Result}; use base_db::CrateName; use itertools::Itertools; use la_arena::{Arena, Idx}; use paths::{AbsPath, AbsPathBuf}; use rustc_hash::FxHashMap; +use toolchain::probe_for_binary; use crate::{utf8_stdout, CargoConfig, CargoWorkspace, ManifestPath}; -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone)] pub struct Sysroot { root: AbsPathBuf, - src_root: AbsPathBuf, + src_root: Option>>, mode: SysrootMode, } +impl Eq for Sysroot {} +impl PartialEq for Sysroot { + fn eq(&self, other: &Self) -> bool { + self.root == other.root + && self.mode == other.mode + && match (&self.src_root, &other.src_root) { + (Some(Ok(this)), Some(Ok(other))) => this == other, + (None, None) | (Some(Err(_)), Some(Err(_))) => true, + _ => false, + } + } +} + #[derive(Debug, Clone, Eq, PartialEq)] pub(crate) enum SysrootMode { Workspace(CargoWorkspace), @@ -86,8 +100,8 @@ impl Sysroot { /// Returns the sysroot "source" directory, where stdlib sources are located, like: /// `$HOME/.rustup/toolchains/nightly-2022-07-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library` - pub fn src_root(&self) -> &AbsPath { - &self.src_root + pub fn src_root(&self) -> Option<&AbsPath> { + self.src_root.as_ref()?.as_deref().ok() } pub fn is_empty(&self) -> bool { @@ -98,6 +112,11 @@ impl Sysroot { } pub fn loading_warning(&self) -> Option { + let src_root = match &self.src_root { + None => return Some(format!("sysroot at `{}` has no library sources", self.root)), + Some(Ok(src_root)) => src_root, + Some(Err(e)) => return Some(e.to_string()), + }; let has_core = match &self.mode { SysrootMode::Workspace(ws) => ws.packages().any(|p| ws[p].name == "core"), SysrootMode::Stitched(stitched) => stitched.by_name("core").is_some(), @@ -108,10 +127,7 @@ impl Sysroot { } else { " try running `rustup component add rust-src` to possible fix this" }; - Some(format!( - "could not find libcore in loaded sysroot at `{}`{var_note}", - self.src_root.as_path(), - )) + Some(format!("could not find libcore in loaded sysroot at `{}`{var_note}", src_root,)) } else { None } @@ -140,8 +156,19 @@ impl Sysroot { tracing::debug!("discovering sysroot for {dir}"); let sysroot_dir = discover_sysroot_dir(dir, extra_env)?; let sysroot_src_dir = - discover_sysroot_src_dir_or_add_component(&sysroot_dir, dir, extra_env)?; - Ok(Sysroot::load(sysroot_dir, sysroot_src_dir, metadata)) + discover_sysroot_src_dir_or_add_component(&sysroot_dir, dir, extra_env); + Ok(Sysroot::load(sysroot_dir, Some(sysroot_src_dir), metadata)) + } + + pub fn discover_no_source( + dir: &AbsPath, + extra_env: &FxHashMap, + ) -> Result { + tracing::debug!("discovering sysroot for {dir}"); + let sysroot_dir = discover_sysroot_dir(dir, extra_env)?; + let sysroot_src_dir = + discover_sysroot_src_dir_or_add_component(&sysroot_dir, dir, extra_env); + Ok(Sysroot::load(sysroot_dir, Some(sysroot_src_dir), false)) } pub fn discover_with_src_override( @@ -152,33 +179,59 @@ impl Sysroot { ) -> Result { tracing::debug!("discovering sysroot for {current_dir}"); let sysroot_dir = discover_sysroot_dir(current_dir, extra_env)?; - Ok(Sysroot::load(sysroot_dir, src, metadata)) + Ok(Sysroot::load(sysroot_dir, Some(Ok(src)), metadata)) } pub fn discover_rustc_src(&self) -> Option { get_rustc_src(&self.root) } - pub fn discover_rustc(&self) -> anyhow::Result { - let rustc = self.root.join("bin/rustc"); - tracing::debug!(?rustc, "checking for rustc binary at location"); - match fs::metadata(&rustc) { - Ok(_) => Ok(rustc), - Err(e) => Err(e).context(format!( - "failed to discover rustc in sysroot: {:?}", - AsRef::::as_ref(&self.root) - )), - } - } - pub fn with_sysroot_dir(sysroot_dir: AbsPathBuf, metadata: bool) -> Result { let sysroot_src_dir = discover_sysroot_src_dir(&sysroot_dir).ok_or_else(|| { format_err!("can't load standard library from sysroot path {sysroot_dir}") - })?; - Ok(Sysroot::load(sysroot_dir, sysroot_src_dir, metadata)) + }); + Ok(Sysroot::load(sysroot_dir, Some(sysroot_src_dir), metadata)) + } + + pub fn set_rustup_toolchain_env(cmd: &mut Command, sysroot: Option<&Self>) { + if let Some(sysroot) = sysroot { + cmd.env("RUSTUP_TOOLCHAIN", AsRef::::as_ref(&sysroot.root)); + } + } + + pub fn discover_proc_macro_srv(&self) -> anyhow::Result { + ["libexec", "lib"] + .into_iter() + .map(|segment| self.root().join(segment).join("rust-analyzer-proc-macro-srv")) + .find_map(|server_path| probe_for_binary(server_path.into())) + .map(AbsPathBuf::assert) + .ok_or_else(|| { + anyhow::format_err!("cannot find proc-macro server in sysroot `{}`", self.root()) + }) } - pub fn load(sysroot_dir: AbsPathBuf, sysroot_src_dir: AbsPathBuf, metadata: bool) -> Sysroot { + pub fn load( + sysroot_dir: AbsPathBuf, + sysroot_src_dir: Option>, + metadata: bool, + ) -> Sysroot { + let sysroot_src_dir = match sysroot_src_dir { + Some(Ok(sysroot_src_dir)) => sysroot_src_dir, + Some(Err(e)) => { + return Sysroot { + root: sysroot_dir, + src_root: Some(Err(Arc::new(e))), + mode: SysrootMode::Stitched(Stitched { crates: Arena::default() }), + } + } + None => { + return Sysroot { + root: sysroot_dir, + src_root: None, + mode: SysrootMode::Stitched(Stitched { crates: Arena::default() }), + } + } + }; if metadata { let sysroot: Option<_> = (|| { let sysroot_cargo_toml = ManifestPath::try_from( @@ -187,10 +240,19 @@ impl Sysroot { .ok()?; let current_dir = AbsPathBuf::try_from(&*format!("{sysroot_src_dir}/sysroot")).ok()?; + + let mut cargo_config = CargoConfig::default(); + // the sysroot uses `public-dependency`, so we make cargo think it's a nightly + cargo_config.extra_env.insert( + "__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS".to_owned(), + "nightly".to_owned(), + ); + let res = CargoWorkspace::fetch_metadata( &sysroot_cargo_toml, ¤t_dir, - &CargoConfig::default(), + &cargo_config, + None, &|_| (), ) .map_err(|e| { @@ -274,7 +336,7 @@ impl Sysroot { let cargo_workspace = CargoWorkspace::new(res); Some(Sysroot { root: sysroot_dir.clone(), - src_root: sysroot_src_dir.clone(), + src_root: Some(Ok(sysroot_src_dir.clone())), mode: SysrootMode::Workspace(cargo_workspace), }) })(); @@ -326,7 +388,7 @@ impl Sysroot { } Sysroot { root: sysroot_dir, - src_root: sysroot_src_dir, + src_root: Some(Ok(sysroot_src_dir)), mode: SysrootMode::Stitched(stitched), } } diff --git a/crates/project-model/src/target_data_layout.rs b/crates/project-model/src/target_data_layout.rs index cb995857ec7dc..af635dda5782d 100644 --- a/crates/project-model/src/target_data_layout.rs +++ b/crates/project-model/src/target_data_layout.rs @@ -3,38 +3,58 @@ use std::process::Command; use rustc_hash::FxHashMap; -use crate::{utf8_stdout, ManifestPath}; +use crate::{utf8_stdout, ManifestPath, Sysroot}; + +/// Determines how `rustc --print target-spec-json` is discovered and invoked. +pub enum RustcDataLayoutConfig<'a> { + /// Use `rustc --print target-spec-json`, either from with the binary from the sysroot or by discovering via + /// [`toolchain::rustc`]. + Rustc(Option<&'a Sysroot>), + /// Use `cargo --print target-spec-json`, either from with the binary from the sysroot or by discovering via + /// [`toolchain::cargo`]. + Cargo(Option<&'a Sysroot>, &'a ManifestPath), +} pub fn get( - cargo_toml: Option<&ManifestPath>, + config: RustcDataLayoutConfig<'_>, target: Option<&str>, extra_env: &FxHashMap, ) -> anyhow::Result { - let output = (|| { - if let Some(cargo_toml) = cargo_toml { - let mut cmd = Command::new(toolchain::rustc()); + let process = |output: String| { + (|| Some(output.split_once(r#""data-layout": ""#)?.1.split_once('"')?.0.to_owned()))() + .ok_or_else(|| { + anyhow::format_err!("could not fetch target-spec-json from command output") + }) + }; + let sysroot = match config { + RustcDataLayoutConfig::Cargo(sysroot, cargo_toml) => { + let mut cmd = Command::new(toolchain::Tool::Cargo.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); cmd.envs(extra_env); cmd.current_dir(cargo_toml.parent()) - .args(["-Z", "unstable-options", "--print", "target-spec-json"]) + .args(["rustc", "--", "-Z", "unstable-options", "--print", "target-spec-json"]) .env("RUSTC_BOOTSTRAP", "1"); if let Some(target) = target { cmd.args(["--target", target]); } match utf8_stdout(cmd) { - Ok(it) => return Ok(it), - Err(e) => tracing::debug!("{e:?}: falling back to querying rustc for cfgs"), + Ok(output) => return process(output), + Err(e) => { + tracing::warn!("failed to run `cargo rustc --print target-spec-json`, falling back to invoking rustc directly: {e}"); + sysroot + } } } - // using unstable cargo features failed, fall back to using plain rustc - let mut cmd = Command::new(toolchain::rustc()); - cmd.envs(extra_env) - .args(["-Z", "unstable-options", "--print", "target-spec-json"]) - .env("RUSTC_BOOTSTRAP", "1"); - if let Some(target) = target { - cmd.args(["--target", target]); - } - utf8_stdout(cmd) - })()?; - (|| Some(output.split_once(r#""data-layout": ""#)?.1.split_once('"')?.0.to_owned()))() - .ok_or_else(|| anyhow::format_err!("could not fetch target-spec-json from command output")) + RustcDataLayoutConfig::Rustc(sysroot) => sysroot, + }; + + let mut cmd = Command::new(toolchain::Tool::Rustc.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); + cmd.envs(extra_env) + .args(["-Z", "unstable-options", "--print", "target-spec-json"]) + .env("RUSTC_BOOTSTRAP", "1"); + if let Some(target) = target { + cmd.args(["--target", target]); + } + process(utf8_stdout(cmd)?) } diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs index 74042e925ede4..b9b1b701f6d40 100644 --- a/crates/project-model/src/tests.rs +++ b/crates/project-model/src/tests.rs @@ -9,6 +9,7 @@ use expect_test::{expect_file, ExpectFile}; use paths::{AbsPath, AbsPathBuf}; use rustc_hash::FxHashMap; use serde::de::DeserializeOwned; +use triomphe::Arc; use crate::{ CargoWorkspace, CfgOverrides, ProjectJson, ProjectJsonData, ProjectWorkspace, Sysroot, @@ -34,6 +35,7 @@ fn load_cargo_with_overrides( cfg_overrides, toolchain: None, target_layout: Err("target_data_layout not loaded".into()), + cargo_config_extra_env: Default::default(), }; to_crate_graph(project_workspace) } @@ -53,6 +55,7 @@ fn load_cargo_with_fake_sysroot( cfg_overrides: Default::default(), toolchain: None, target_layout: Err("target_data_layout not loaded".into()), + cargo_config_extra_env: Default::default(), }; project_workspace.to_crate_graph( &mut { @@ -69,8 +72,13 @@ fn load_rust_project(file: &str) -> (CrateGraph, ProcMacroPaths) { let data = get_test_json_file(file); let project = rooted_project_json(data); let sysroot = Ok(get_fake_sysroot()); - let project_workspace = - ProjectWorkspace::Json { project, sysroot, rustc_cfg: Vec::new(), toolchain: None }; + let project_workspace = ProjectWorkspace::Json { + project, + sysroot, + rustc_cfg: Vec::new(), + toolchain: None, + target_layout: Err(Arc::from("test has no data layout")), + }; to_crate_graph(project_workspace) } @@ -125,7 +133,7 @@ fn get_fake_sysroot() -> Sysroot { // fake sysroot, so we give them both the same path: let sysroot_dir = AbsPathBuf::assert(sysroot_path); let sysroot_src_dir = sysroot_dir.clone(); - Sysroot::load(sysroot_dir, sysroot_src_dir, false) + Sysroot::load(sysroot_dir, Some(Ok(sysroot_src_dir)), false) } fn rooted_project_json(data: ProjectJsonData) -> ProjectJson { @@ -230,7 +238,7 @@ fn crate_graph_dedup_identical() { let (d_crate_graph, mut d_proc_macros) = (crate_graph.clone(), proc_macros.clone()); - crate_graph.extend(d_crate_graph.clone(), &mut d_proc_macros, |_| ()); + crate_graph.extend(d_crate_graph.clone(), &mut d_proc_macros, |(_, a), (_, b)| a == b); assert!(crate_graph.iter().eq(d_crate_graph.iter())); assert_eq!(proc_macros, d_proc_macros); } @@ -246,62 +254,10 @@ fn crate_graph_dedup() { load_cargo_with_fake_sysroot(path_map, "regex-metadata.json"); assert_eq!(regex_crate_graph.iter().count(), 60); - crate_graph.extend(regex_crate_graph, &mut regex_proc_macros, |_| ()); + crate_graph.extend(regex_crate_graph, &mut regex_proc_macros, |(_, a), (_, b)| a == b); assert_eq!(crate_graph.iter().count(), 118); } -#[test] -fn test_deduplicate_origin_dev() { - let path_map = &mut Default::default(); - let (mut crate_graph, _proc_macros) = - load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_A.json"); - crate_graph.sort_deps(); - let (crate_graph_1, mut _proc_macros_2) = - load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_B.json"); - - crate_graph.extend(crate_graph_1, &mut _proc_macros_2, |_| ()); - - let mut crates_named_p2 = vec![]; - for id in crate_graph.iter() { - let krate = &crate_graph[id]; - if let Some(name) = krate.display_name.as_ref() { - if name.to_string() == "p2" { - crates_named_p2.push(krate); - } - } - } - - assert!(crates_named_p2.len() == 1); - let p2 = crates_named_p2[0]; - assert!(p2.origin.is_local()); -} - -#[test] -fn test_deduplicate_origin_dev_rev() { - let path_map = &mut Default::default(); - let (mut crate_graph, _proc_macros) = - load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_B.json"); - crate_graph.sort_deps(); - let (crate_graph_1, mut _proc_macros_2) = - load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_A.json"); - - crate_graph.extend(crate_graph_1, &mut _proc_macros_2, |_| ()); - - let mut crates_named_p2 = vec![]; - for id in crate_graph.iter() { - let krate = &crate_graph[id]; - if let Some(name) = krate.display_name.as_ref() { - if name.to_string() == "p2" { - crates_named_p2.push(krate); - } - } - } - - assert!(crates_named_p2.len() == 1); - let p2 = crates_named_p2[0]; - assert!(p2.origin.is_local()); -} - #[test] fn smoke_test_real_sysroot_cargo() { if std::env::var("SYSROOT_CARGO_METADATA").is_err() { @@ -327,6 +283,7 @@ fn smoke_test_real_sysroot_cargo() { cfg_overrides: Default::default(), toolchain: None, target_layout: Err("target_data_layout not loaded".into()), + cargo_config_extra_env: Default::default(), }; project_workspace.to_crate_graph( &mut { diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index cda5ad2f1109f..b7ae76be8cec0 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -6,14 +6,15 @@ use std::{collections::VecDeque, fmt, fs, iter, process::Command, str::FromStr, use anyhow::{format_err, Context}; use base_db::{ - CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, DependencyKind, - Edition, Env, FileId, LangCrateOrigin, ProcMacroPaths, TargetLayoutLoadResult, + CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env, + FileId, LangCrateOrigin, ProcMacroPaths, TargetLayoutLoadResult, }; use cfg::{CfgAtom, CfgDiff, CfgOptions}; use paths::{AbsPath, AbsPathBuf}; use rustc_hash::{FxHashMap, FxHashSet}; use semver::Version; use stdx::always; +use toolchain::Tool; use triomphe::Arc; use crate::{ @@ -23,8 +24,9 @@ use crate::{ project_json::Crate, rustc_cfg::{self, RustcCfgConfig}, sysroot::{SysrootCrate, SysrootMode}, - target_data_layout, utf8_stdout, CargoConfig, CargoWorkspace, InvocationStrategy, ManifestPath, - Package, ProjectJson, ProjectManifest, Sysroot, TargetData, TargetKind, WorkspaceBuildScripts, + target_data_layout::{self, RustcDataLayoutConfig}, + utf8_stdout, CargoConfig, CargoWorkspace, InvocationStrategy, ManifestPath, Package, + ProjectJson, ProjectManifest, Sysroot, TargetData, TargetKind, WorkspaceBuildScripts, }; /// A set of cfg-overrides per crate. @@ -69,7 +71,8 @@ pub enum ProjectWorkspace { rustc_cfg: Vec, cfg_overrides: CfgOverrides, toolchain: Option, - target_layout: Result, + target_layout: TargetLayoutLoadResult, + cargo_config_extra_env: FxHashMap, }, /// Project workspace was manually specified using a `rust-project.json` file. Json { @@ -79,6 +82,7 @@ pub enum ProjectWorkspace { /// `rustc --print cfg`. rustc_cfg: Vec, toolchain: Option, + target_layout: TargetLayoutLoadResult, }, // FIXME: The primary limitation of this approach is that the set of detached files needs to be fixed at the beginning. // That's not the end user experience we should strive for. @@ -111,7 +115,8 @@ impl fmt::Debug for ProjectWorkspace { rustc_cfg, cfg_overrides, toolchain, - target_layout: data_layout, + target_layout, + cargo_config_extra_env, } => f .debug_struct("Cargo") .field("root", &cargo.workspace_root().file_name()) @@ -124,16 +129,25 @@ impl fmt::Debug for ProjectWorkspace { .field("n_rustc_cfg", &rustc_cfg.len()) .field("n_cfg_overrides", &cfg_overrides.len()) .field("toolchain", &toolchain) - .field("data_layout", &data_layout) + .field("data_layout", &target_layout) + .field("cargo_config_extra_env", &cargo_config_extra_env) .finish(), - ProjectWorkspace::Json { project, sysroot, rustc_cfg, toolchain } => { + ProjectWorkspace::Json { + project, + sysroot, + rustc_cfg, + toolchain, + target_layout: data_layout, + } => { let mut debug_struct = f.debug_struct("Json"); debug_struct.field("n_crates", &project.n_crates()); if let Ok(sysroot) = sysroot { debug_struct.field("n_sysroot_crates", &sysroot.num_packages()); } - debug_struct.field("toolchain", &toolchain); - debug_struct.field("n_rustc_cfg", &rustc_cfg.len()); + debug_struct + .field("toolchain", &toolchain) + .field("n_rustc_cfg", &rustc_cfg.len()) + .field("data_layout", &data_layout); debug_struct.finish() } ProjectWorkspace::DetachedFiles { files, sysroot, rustc_cfg } => f @@ -146,6 +160,28 @@ impl fmt::Debug for ProjectWorkspace { } } +fn get_toolchain_version( + current_dir: &AbsPath, + sysroot: Option<&Sysroot>, + tool: Tool, + extra_env: &FxHashMap, + prefix: &str, +) -> Result, anyhow::Error> { + let cargo_version = utf8_stdout({ + let mut cmd = Command::new(tool.path()); + Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); + cmd.envs(extra_env); + cmd.arg("--version").current_dir(current_dir); + cmd + }) + .with_context(|| format!("Failed to query rust toolchain version at {current_dir}, is your toolchain setup correctly?"))?; + anyhow::Ok( + cargo_version + .get(prefix.len()..) + .and_then(|it| Version::parse(it.split_whitespace().next()?).ok()), + ) +} + impl ProjectWorkspace { pub fn load( manifest: ProjectManifest, @@ -161,20 +197,6 @@ impl ProjectWorkspace { config: &CargoConfig, progress: &dyn Fn(String), ) -> anyhow::Result { - let version = |current_dir, cmd_path, prefix: &str| { - let cargo_version = utf8_stdout({ - let mut cmd = Command::new(cmd_path); - cmd.envs(&config.extra_env); - cmd.arg("--version").current_dir(current_dir); - cmd - }) - .with_context(|| format!("Failed to query rust toolchain version at {current_dir}, is your toolchain setup correctly?"))?; - anyhow::Ok( - cargo_version - .get(prefix.len()..) - .and_then(|it| Version::parse(it.split_whitespace().next()?).ok()), - ) - }; let res = match manifest { ProjectManifest::ProjectJson(project_json) => { let file = fs::read_to_string(project_json) @@ -182,30 +204,14 @@ impl ProjectWorkspace { let data = serde_json::from_str(&file) .with_context(|| format!("Failed to deserialize json file {project_json}"))?; let project_location = project_json.parent().to_path_buf(); - let toolchain = version(&*project_location, toolchain::rustc(), "rustc ")?; - let project_json = ProjectJson::new(&project_location, data); + let project_json: ProjectJson = ProjectJson::new(&project_location, data); ProjectWorkspace::load_inline( project_json, config.target.as_deref(), &config.extra_env, - toolchain, ) } ProjectManifest::CargoToml(cargo_toml) => { - let toolchain = version(cargo_toml.parent(), toolchain::cargo(), "cargo ")?; - let meta = CargoWorkspace::fetch_metadata( - cargo_toml, - cargo_toml.parent(), - config, - progress, - ) - .with_context(|| { - format!( - "Failed to read Cargo metadata from Cargo.toml file {cargo_toml}, {toolchain:?}", - ) - })?; - let cargo = CargoWorkspace::new(meta); - let sysroot = match (&config.sysroot, &config.sysroot_src) { (Some(RustLibSource::Path(path)), None) => { Sysroot::with_sysroot_dir(path.clone(), config.sysroot_query_metadata).map_err(|e| { @@ -218,7 +224,7 @@ impl ProjectWorkspace { }) } (Some(RustLibSource::Path(sysroot)), Some(sysroot_src)) => { - Ok(Sysroot::load(sysroot.clone(), sysroot_src.clone(), config.sysroot_query_metadata)) + Ok(Sysroot::load(sysroot.clone(), Some(Ok(sysroot_src.clone())), config.sysroot_query_metadata)) } (Some(RustLibSource::Discover), Some(sysroot_src)) => { Sysroot::discover_with_src_override( @@ -231,18 +237,19 @@ impl ProjectWorkspace { } (None, _) => Err(None), }; + let sysroot_ref = sysroot.as_ref().ok(); if let Ok(sysroot) = &sysroot { - tracing::info!(workspace = %cargo_toml, src_root = %sysroot.src_root(), root = %sysroot.root(), "Using sysroot"); + tracing::info!(workspace = %cargo_toml, src_root = ?sysroot.src_root(), root = %sysroot.root(), "Using sysroot"); } let rustc_dir = match &config.rustc_source { Some(RustLibSource::Path(path)) => ManifestPath::try_from(path.clone()) .map_err(|p| Some(format!("rustc source path is not absolute: {p}"))), Some(RustLibSource::Discover) => { - sysroot.as_ref().ok().and_then(Sysroot::discover_rustc_src).ok_or_else( - || Some("Failed to discover rustc source for sysroot.".to_owned()), - ) + sysroot_ref.and_then(Sysroot::discover_rustc_src).ok_or_else(|| { + Some("Failed to discover rustc source for sysroot.".to_owned()) + }) } None => Err(None), }; @@ -256,6 +263,7 @@ impl ProjectWorkspace { features: crate::CargoFeatures::default(), ..config.clone() }, + sysroot_ref, progress, ) { Ok(meta) => { @@ -264,6 +272,7 @@ impl ProjectWorkspace { &workspace, cargo_toml.parent(), &config.extra_env, + sysroot_ref ); Ok(Box::new((workspace, buildscripts))) } @@ -279,21 +288,45 @@ impl ProjectWorkspace { } }); + let toolchain = get_toolchain_version( + cargo_toml.parent(), + sysroot_ref, + toolchain::Tool::Cargo, + &config.extra_env, + "cargo ", + )?; let rustc_cfg = rustc_cfg::get( config.target.as_deref(), &config.extra_env, - RustcCfgConfig::Cargo(cargo_toml), + RustcCfgConfig::Cargo(sysroot_ref, cargo_toml), ); let cfg_overrides = config.cfg_overrides.clone(); let data_layout = target_data_layout::get( - Some(cargo_toml), + RustcDataLayoutConfig::Cargo(sysroot_ref, cargo_toml), config.target.as_deref(), &config.extra_env, ); if let Err(e) = &data_layout { tracing::error!(%e, "failed fetching data layout for {cargo_toml:?} workspace"); } + + let meta = CargoWorkspace::fetch_metadata( + cargo_toml, + cargo_toml.parent(), + config, + sysroot_ref, + progress, + ) + .with_context(|| { + format!( + "Failed to read Cargo metadata from Cargo.toml file {cargo_toml}, {toolchain:?}", + ) + })?; + let cargo = CargoWorkspace::new(meta); + + let cargo_config_extra_env = + cargo_config_env(cargo_toml, &config.extra_env, sysroot_ref); ProjectWorkspace::Cargo { cargo, build_scripts: WorkspaceBuildScripts::default(), @@ -302,7 +335,10 @@ impl ProjectWorkspace { rustc_cfg, cfg_overrides, toolchain, - target_layout: data_layout.map_err(|it| it.to_string()), + target_layout: data_layout + .map(Arc::from) + .map_err(|it| Arc::from(it.to_string())), + cargo_config_extra_env, } } }; @@ -314,15 +350,16 @@ impl ProjectWorkspace { project_json: ProjectJson, target: Option<&str>, extra_env: &FxHashMap, - toolchain: Option, ) -> ProjectWorkspace { let sysroot = match (project_json.sysroot.clone(), project_json.sysroot_src.clone()) { - (Some(sysroot), Some(sysroot_src)) => Ok(Sysroot::load(sysroot, sysroot_src, false)), + (Some(sysroot), Some(sysroot_src)) => { + Ok(Sysroot::load(sysroot, Some(Ok(sysroot_src)), false)) + } (Some(sysroot), None) => { // assume sysroot is structured like rustup's and guess `sysroot_src` let sysroot_src = sysroot.join("lib").join("rustlib").join("src").join("rust").join("library"); - Ok(Sysroot::load(sysroot, sysroot_src, false)) + Ok(Sysroot::load(sysroot, Some(Ok(sysroot_src)), false)) } (None, Some(sysroot_src)) => { // assume sysroot is structured like rustup's and guess `sysroot` @@ -330,23 +367,36 @@ impl ProjectWorkspace { for _ in 0..5 { sysroot.pop(); } - Ok(Sysroot::load(sysroot, sysroot_src, false)) + Ok(Sysroot::load(sysroot, Some(Ok(sysroot_src)), false)) } (None, None) => Err(None), }; - let config = match &sysroot { - Ok(sysroot) => { - tracing::debug!(src_root = %sysroot.src_root(), root = %sysroot.root(), "Using sysroot"); - RustcCfgConfig::Explicit(sysroot) - } - Err(_) => { - tracing::debug!("discovering sysroot"); - RustcCfgConfig::Discover + let sysroot_ref = sysroot.as_ref().ok(); + let cfg_config = RustcCfgConfig::Rustc(sysroot_ref); + let data_layout_config = RustcDataLayoutConfig::Rustc(sysroot_ref); + let toolchain = match get_toolchain_version( + project_json.path(), + sysroot_ref, + toolchain::Tool::Rustc, + extra_env, + "rustc ", + ) { + Ok(it) => it, + Err(e) => { + tracing::error!("{e}"); + None } }; - let rustc_cfg = rustc_cfg::get(target, extra_env, config); - ProjectWorkspace::Json { project: project_json, sysroot, rustc_cfg, toolchain } + let rustc_cfg = rustc_cfg::get(target, extra_env, cfg_config); + let data_layout = target_data_layout::get(data_layout_config, target, extra_env); + ProjectWorkspace::Json { + project: project_json, + sysroot, + rustc_cfg, + toolchain, + target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())), + } } pub fn load_detached_files( @@ -373,18 +423,11 @@ impl ProjectWorkspace { } None => Err(None), }; - let rustc_config = match &sysroot { - Ok(sysroot) => { - tracing::info!(src_root = %sysroot.src_root(), root = %sysroot.root(), "Using sysroot"); - RustcCfgConfig::Explicit(sysroot) - } - Err(_) => { - tracing::info!("discovering sysroot"); - RustcCfgConfig::Discover - } - }; - - let rustc_cfg = rustc_cfg::get(None, &FxHashMap::default(), rustc_config); + let rustc_cfg = rustc_cfg::get( + None, + &FxHashMap::default(), + RustcCfgConfig::Rustc(sysroot.as_ref().ok()), + ); Ok(ProjectWorkspace::DetachedFiles { files: detached_files, sysroot, rustc_cfg }) } @@ -395,11 +438,17 @@ impl ProjectWorkspace { progress: &dyn Fn(String), ) -> anyhow::Result { match self { - ProjectWorkspace::Cargo { cargo, toolchain, .. } => { - WorkspaceBuildScripts::run_for_workspace(config, cargo, progress, toolchain) - .with_context(|| { - format!("Failed to run build scripts for {}", cargo.workspace_root()) - }) + ProjectWorkspace::Cargo { cargo, toolchain, sysroot, .. } => { + WorkspaceBuildScripts::run_for_workspace( + config, + cargo, + progress, + toolchain, + sysroot.as_ref().ok(), + ) + .with_context(|| { + format!("Failed to run build scripts for {}", cargo.workspace_root()) + }) } ProjectWorkspace::Json { .. } | ProjectWorkspace::DetachedFiles { .. } => { Ok(WorkspaceBuildScripts::default()) @@ -472,18 +521,7 @@ impl ProjectWorkspace { ProjectWorkspace::Cargo { sysroot: Ok(sysroot), .. } | ProjectWorkspace::Json { sysroot: Ok(sysroot), .. } | ProjectWorkspace::DetachedFiles { sysroot: Ok(sysroot), .. } => { - let standalone_server_name = - format!("rust-analyzer-proc-macro-srv{}", std::env::consts::EXE_SUFFIX); - ["libexec", "lib"] - .into_iter() - .map(|segment| sysroot.root().join(segment).join(&standalone_server_name)) - .find(|server_path| std::fs::metadata(server_path).is_ok()) - .ok_or_else(|| { - anyhow::format_err!( - "cannot find proc-macro server in sysroot `{}`", - sysroot.root() - ) - }) + sysroot.discover_proc_macro_srv() } ProjectWorkspace::DetachedFiles { .. } => { Err(anyhow::format_err!("cannot find proc-macro server, no sysroot was found")) @@ -503,8 +541,7 @@ impl ProjectWorkspace { /// The return type contains the path and whether or not /// the root is a member of the current workspace pub fn to_roots(&self) -> Vec { - let mk_sysroot = |sysroot: Result<_, _>, project_root: Option<&AbsPath>| { - let project_root = project_root.map(ToOwned::to_owned); + let mk_sysroot = |sysroot: Result<_, _>| { sysroot.into_iter().flat_map(move |sysroot: &Sysroot| { let mut r = match sysroot.mode() { SysrootMode::Workspace(ws) => ws @@ -532,18 +569,21 @@ impl ProjectWorkspace { }; r.push(PackageRoot { - // mark the sysroot as mutable if it is located inside of the project - is_local: project_root - .as_ref() - .map_or(false, |project_root| sysroot.src_root().starts_with(project_root)), - include: vec![sysroot.src_root().to_path_buf()], + is_local: false, + include: sysroot.src_root().map(|it| it.to_path_buf()).into_iter().collect(), exclude: Vec::new(), }); r }) }; match self { - ProjectWorkspace::Json { project, sysroot, rustc_cfg: _, toolchain: _ } => project + ProjectWorkspace::Json { + project, + sysroot, + rustc_cfg: _, + toolchain: _, + target_layout: _, + } => project .crates() .map(|(_, krate)| PackageRoot { is_local: krate.is_workspace_member, @@ -552,7 +592,7 @@ impl ProjectWorkspace { }) .collect::>() .into_iter() - .chain(mk_sysroot(sysroot.as_ref(), Some(project.path()))) + .chain(mk_sysroot(sysroot.as_ref())) .collect::>(), ProjectWorkspace::Cargo { cargo, @@ -563,6 +603,7 @@ impl ProjectWorkspace { build_scripts, toolchain: _, target_layout: _, + cargo_config_extra_env: _, } => { cargo .packages() @@ -586,7 +627,7 @@ impl ProjectWorkspace { let extra_targets = cargo[pkg] .targets .iter() - .filter(|&&tgt| cargo[tgt].kind == TargetKind::Lib) + .filter(|&&tgt| matches!(cargo[tgt].kind, TargetKind::Lib { .. })) .filter_map(|&tgt| cargo[tgt].root.parent()) .map(|tgt| tgt.normalize().to_path_buf()) .filter(|path| !path.starts_with(&pkg_root)); @@ -602,7 +643,7 @@ impl ProjectWorkspace { } PackageRoot { is_local, include, exclude } }) - .chain(mk_sysroot(sysroot.as_ref(), Some(cargo.workspace_root()))) + .chain(mk_sysroot(sysroot.as_ref())) .chain(rustc.iter().map(|a| a.as_ref()).flat_map(|(rustc, _)| { rustc.packages().map(move |krate| PackageRoot { is_local: false, @@ -619,7 +660,7 @@ impl ProjectWorkspace { include: vec![detached_file.clone()], exclude: Vec::new(), }) - .chain(mk_sysroot(sysroot.as_ref(), None)) + .chain(mk_sysroot(sysroot.as_ref())) .collect(), } } @@ -651,17 +692,19 @@ impl ProjectWorkspace { let _p = tracing::span!(tracing::Level::INFO, "ProjectWorkspace::to_crate_graph").entered(); let (mut crate_graph, proc_macros) = match self { - ProjectWorkspace::Json { project, sysroot, rustc_cfg, toolchain } => { - project_json_to_crate_graph( - rustc_cfg.clone(), - load, - project, - sysroot.as_ref().ok(), - extra_env, - Err("rust-project.json projects have no target layout set".into()), - toolchain.clone(), - ) - } + ProjectWorkspace::Json { + project, + sysroot, + rustc_cfg, + toolchain: _, + target_layout: _, + } => project_json_to_crate_graph( + rustc_cfg.clone(), + load, + project, + sysroot.as_ref().ok(), + extra_env, + ), ProjectWorkspace::Cargo { cargo, sysroot, @@ -669,8 +712,9 @@ impl ProjectWorkspace { rustc_cfg, cfg_overrides, build_scripts, - toolchain, - target_layout, + toolchain: _, + target_layout: _, + cargo_config_extra_env: _, } => cargo_to_crate_graph( load, rustc.as_ref().map(|a| a.as_ref()).ok(), @@ -679,20 +723,9 @@ impl ProjectWorkspace { rustc_cfg.clone(), cfg_overrides, build_scripts, - match target_layout.as_ref() { - Ok(it) => Ok(Arc::from(it.as_str())), - Err(it) => Err(Arc::from(it.as_str())), - }, - toolchain.as_ref(), ), ProjectWorkspace::DetachedFiles { files, sysroot, rustc_cfg } => { - detached_files_to_crate_graph( - rustc_cfg.clone(), - load, - files, - sysroot.as_ref().ok(), - Err("detached file projects have no target layout set".into()), - ) + detached_files_to_crate_graph(rustc_cfg.clone(), load, files, sysroot.as_ref().ok()) } }; if crate_graph.patch_cfg_if() { @@ -713,6 +746,7 @@ impl ProjectWorkspace { rustc_cfg, cfg_overrides, toolchain, + cargo_config_extra_env, build_scripts: _, target_layout: _, }, @@ -723,6 +757,7 @@ impl ProjectWorkspace { rustc_cfg: o_rustc_cfg, cfg_overrides: o_cfg_overrides, toolchain: o_toolchain, + cargo_config_extra_env: o_cargo_config_extra_env, build_scripts: _, target_layout: _, }, @@ -733,14 +768,16 @@ impl ProjectWorkspace { && cfg_overrides == o_cfg_overrides && toolchain == o_toolchain && sysroot == o_sysroot + && cargo_config_extra_env == o_cargo_config_extra_env } ( - Self::Json { project, sysroot, rustc_cfg, toolchain }, + Self::Json { project, sysroot, rustc_cfg, toolchain, target_layout: _ }, Self::Json { project: o_project, sysroot: o_sysroot, rustc_cfg: o_rustc_cfg, toolchain: o_toolchain, + target_layout: _, }, ) => { project == o_project @@ -771,21 +808,12 @@ fn project_json_to_crate_graph( project: &ProjectJson, sysroot: Option<&Sysroot>, extra_env: &FxHashMap, - target_layout: TargetLayoutLoadResult, - toolchain: Option, ) -> (CrateGraph, ProcMacroPaths) { let mut res = (CrateGraph::default(), ProcMacroPaths::default()); let (crate_graph, proc_macros) = &mut res; - let sysroot_deps = sysroot.as_ref().map(|sysroot| { - sysroot_to_crate_graph( - crate_graph, - sysroot, - rustc_cfg.clone(), - target_layout.clone(), - load, - toolchain.as_ref(), - ) - }); + let sysroot_deps = sysroot + .as_ref() + .map(|sysroot| sysroot_to_crate_graph(crate_graph, sysroot, rustc_cfg.clone(), load)); let r_a_cfg_flag = CfgFlag::Atom("rust_analyzer".to_owned()); let mut cfg_cache: FxHashMap<&str, Vec> = FxHashMap::default(); @@ -813,12 +841,7 @@ fn project_json_to_crate_graph( let target_cfgs = match target.as_deref() { Some(target) => cfg_cache.entry(target).or_insert_with(|| { - let rustc_cfg = match sysroot { - Some(sysroot) => RustcCfgConfig::Explicit(sysroot), - None => RustcCfgConfig::Discover, - }; - - rustc_cfg::get(Some(target), extra_env, rustc_cfg) + rustc_cfg::get(Some(target), extra_env, RustcCfgConfig::Rustc(sysroot)) }), None => &rustc_cfg, }; @@ -845,8 +868,6 @@ fn project_json_to_crate_graph( } else { CrateOrigin::Local { repo: None, name: None } }, - target_layout.clone(), - toolchain.clone(), ); if *is_proc_macro { if let Some(path) = proc_macro_dylib_path.clone() { @@ -873,7 +894,7 @@ fn project_json_to_crate_graph( for dep in &krate.deps { if let Some(&to) = crates.get(&dep.crate_id) { - add_dep(crate_graph, from, dep.name.clone(), to, dep.kind().to_owned()) + add_dep(crate_graph, from, dep.name.clone(), to) } } } @@ -889,22 +910,13 @@ fn cargo_to_crate_graph( rustc_cfg: Vec, override_cfg: &CfgOverrides, build_scripts: &WorkspaceBuildScripts, - target_layout: TargetLayoutLoadResult, - toolchain: Option<&Version>, ) -> (CrateGraph, ProcMacroPaths) { let _p = tracing::span!(tracing::Level::INFO, "cargo_to_crate_graph").entered(); let mut res = (CrateGraph::default(), ProcMacroPaths::default()); let crate_graph = &mut res.0; let proc_macros = &mut res.1; let (public_deps, libproc_macro) = match sysroot { - Some(sysroot) => sysroot_to_crate_graph( - crate_graph, - sysroot, - rustc_cfg.clone(), - target_layout.clone(), - load, - toolchain, - ), + Some(sysroot) => sysroot_to_crate_graph(crate_graph, sysroot, rustc_cfg.clone(), load), None => (SysrootPublicDeps::default(), None), }; @@ -926,8 +938,6 @@ fn cargo_to_crate_graph( // Add test cfg for local crates if cargo[pkg].is_local { cfg_options.insert_atom("test".into()); - } - if cargo[pkg].is_member { cfg_options.insert_atom("rust_analyzer".into()); } @@ -949,7 +959,7 @@ fn cargo_to_crate_graph( let mut lib_tgt = None; for &tgt in cargo[pkg].targets.iter() { - if cargo[tgt].kind != TargetKind::Lib && !cargo[pkg].is_member { + if !matches!(cargo[tgt].kind, TargetKind::Lib { .. }) && !cargo[pkg].is_member { // For non-workspace-members, Cargo does not resolve dev-dependencies, so we don't // add any targets except the library target, since those will not work correctly if // they use dev-dependencies. @@ -957,46 +967,46 @@ fn cargo_to_crate_graph( // https://github.com/rust-lang/rust-analyzer/issues/11300 continue; } - let &TargetData { ref name, kind, is_proc_macro, ref root, .. } = &cargo[tgt]; - - if kind == TargetKind::Lib - && sysroot.map_or(false, |sysroot| root.starts_with(sysroot.src_root())) - { - if let Some(&(_, crate_id, _)) = - public_deps.deps.iter().find(|(dep_name, ..)| dep_name.as_smol_str() == name) - { - pkg_crates.entry(pkg).or_insert_with(Vec::new).push((crate_id, kind)); - - lib_tgt = Some((crate_id, name.clone())); - pkg_to_lib_crate.insert(pkg, crate_id); - // sysroot is inside the workspace, prevent the sysroot crates from being duplicated here - continue; - } - } + let &TargetData { ref name, kind, ref root, .. } = &cargo[tgt]; let Some(file_id) = load(root) else { continue }; + let build_data = build_scripts.get_output(pkg); + let pkg_data = &cargo[pkg]; let crate_id = add_target_crate_root( crate_graph, proc_macros, - &cargo[pkg], - build_scripts.get_output(pkg), + pkg_data, + build_data, cfg_options.clone(), file_id, name, - is_proc_macro, - target_layout.clone(), - false, - toolchain.cloned(), + kind, + if pkg_data.is_local { + CrateOrigin::Local { + repo: pkg_data.repository.clone(), + name: Some(pkg_data.name.clone()), + } + } else { + CrateOrigin::Library { + repo: pkg_data.repository.clone(), + name: pkg_data.name.clone(), + } + }, ); - if kind == TargetKind::Lib { + if let TargetKind::Lib { .. } = kind { lib_tgt = Some((crate_id, name.clone())); pkg_to_lib_crate.insert(pkg, crate_id); } // Even crates that don't set proc-macro = true are allowed to depend on proc_macro // (just none of the APIs work when called outside of a proc macro). if let Some(proc_macro) = libproc_macro { - add_proc_macro_dep(crate_graph, crate_id, proc_macro, is_proc_macro); + add_proc_macro_dep( + crate_graph, + crate_id, + proc_macro, + matches!(kind, TargetKind::Lib { is_proc_macro: true }), + ); } pkg_crates.entry(pkg).or_insert_with(Vec::new).push((crate_id, kind)); @@ -1016,7 +1026,7 @@ fn cargo_to_crate_graph( // cargo metadata does not do any normalization, // so we do it ourselves currently let name = CrateName::normalize_dashes(&name); - add_dep(crate_graph, from, name, to, DependencyKind::Normal); + add_dep(crate_graph, from, name, to); } } } @@ -1036,17 +1046,7 @@ fn cargo_to_crate_graph( continue; } - add_dep( - crate_graph, - from, - name.clone(), - to, - match dep.kind { - DepKind::Normal => DependencyKind::Normal, - DepKind::Dev => DependencyKind::Dev, - DepKind::Build => DependencyKind::Build, - }, - ) + add_dep(crate_graph, from, name.clone(), to) } } } @@ -1074,8 +1074,6 @@ fn cargo_to_crate_graph( } else { rustc_build_scripts }, - target_layout, - toolchain, ); } } @@ -1087,19 +1085,11 @@ fn detached_files_to_crate_graph( load: &mut dyn FnMut(&AbsPath) -> Option, detached_files: &[AbsPathBuf], sysroot: Option<&Sysroot>, - target_layout: TargetLayoutLoadResult, ) -> (CrateGraph, ProcMacroPaths) { let _p = tracing::span!(tracing::Level::INFO, "detached_files_to_crate_graph").entered(); let mut crate_graph = CrateGraph::default(); let (public_deps, _libproc_macro) = match sysroot { - Some(sysroot) => sysroot_to_crate_graph( - &mut crate_graph, - sysroot, - rustc_cfg.clone(), - target_layout.clone(), - load, - None, - ), + Some(sysroot) => sysroot_to_crate_graph(&mut crate_graph, sysroot, rustc_cfg.clone(), load), None => (SysrootPublicDeps::default(), None), }; @@ -1131,8 +1121,6 @@ fn detached_files_to_crate_graph( repo: None, name: display_name.map(|n| n.canonical_name().to_owned()), }, - target_layout.clone(), - None, ); public_deps.add_to_crate_graph(&mut crate_graph, detached_file_crate); @@ -1153,8 +1141,6 @@ fn handle_rustc_crates( cfg_options: &CfgOptions, override_cfg: &CfgOverrides, build_scripts: &WorkspaceBuildScripts, - target_layout: TargetLayoutLoadResult, - toolchain: Option<&Version>, ) { let mut rustc_pkg_crates = FxHashMap::default(); // The root package of the rustc-dev component is rustc_driver, so we match that @@ -1194,9 +1180,9 @@ fn handle_rustc_crates( }; for &tgt in rustc_workspace[pkg].targets.iter() { - if rustc_workspace[tgt].kind != TargetKind::Lib { + let kind @ TargetKind::Lib { is_proc_macro } = rustc_workspace[tgt].kind else { continue; - } + }; if let Some(file_id) = load(&rustc_workspace[tgt].root) { let crate_id = add_target_crate_root( crate_graph, @@ -1206,21 +1192,14 @@ fn handle_rustc_crates( cfg_options.clone(), file_id, &rustc_workspace[tgt].name, - rustc_workspace[tgt].is_proc_macro, - target_layout.clone(), - true, - toolchain.cloned(), + kind, + CrateOrigin::Rustc { name: rustc_workspace[pkg].name.clone() }, ); pkg_to_lib_crate.insert(pkg, crate_id); // Add dependencies on core / std / alloc for this crate public_deps.add_to_crate_graph(crate_graph, crate_id); if let Some(proc_macro) = libproc_macro { - add_proc_macro_dep( - crate_graph, - crate_id, - proc_macro, - rustc_workspace[tgt].is_proc_macro, - ); + add_proc_macro_dep(crate_graph, crate_id, proc_macro, is_proc_macro); } rustc_pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id); } @@ -1234,17 +1213,7 @@ fn handle_rustc_crates( let name = CrateName::new(&dep.name).unwrap(); if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) { for &from in rustc_pkg_crates.get(&pkg).into_iter().flatten() { - add_dep( - crate_graph, - from, - name.clone(), - to, - match dep.kind { - DepKind::Normal => DependencyKind::Normal, - DepKind::Dev => DependencyKind::Dev, - DepKind::Build => DependencyKind::Build, - }, - ); + add_dep(crate_graph, from, name.clone(), to); } } } @@ -1266,7 +1235,7 @@ fn handle_rustc_crates( // `rust_analyzer` thinks that it should use the one from the `rustc_source` // instead of the one from `crates.io` if !crate_graph[*from].dependencies.iter().any(|d| d.name == name) { - add_dep(crate_graph, *from, name.clone(), to, DependencyKind::Normal); + add_dep(crate_graph, *from, name.clone(), to); } } } @@ -1282,10 +1251,8 @@ fn add_target_crate_root( cfg_options: CfgOptions, file_id: FileId, cargo_name: &str, - is_proc_macro: bool, - target_layout: TargetLayoutLoadResult, - rustc_crate: bool, - toolchain: Option, + kind: TargetKind, + origin: CrateOrigin, ) -> CrateId { let edition = pkg.edition; let potential_cfg_options = if pkg.features.is_empty() { @@ -1332,18 +1299,10 @@ fn add_target_crate_root( cfg_options, potential_cfg_options, env, - is_proc_macro, - if rustc_crate { - CrateOrigin::Rustc { name: pkg.name.clone() } - } else if pkg.is_member { - CrateOrigin::Local { repo: pkg.repository.clone(), name: Some(pkg.name.clone()) } - } else { - CrateOrigin::Library { repo: pkg.repository.clone(), name: pkg.name.clone() } - }, - target_layout, - toolchain, + matches!(kind, TargetKind::Lib { is_proc_macro: true }), + origin, ); - if is_proc_macro { + if let TargetKind::Lib { is_proc_macro: true } = kind { let proc_macro = match build_data.as_ref().map(|it| it.proc_macro_dylib_path.as_ref()) { Some(it) => it.cloned().map(|path| Ok((Some(cargo_name.to_owned()), path))), None => Some(Err("crate has not yet been built".to_owned())), @@ -1365,14 +1324,7 @@ impl SysrootPublicDeps { /// Makes `from` depend on the public sysroot crates. fn add_to_crate_graph(&self, crate_graph: &mut CrateGraph, from: CrateId) { for (name, krate, prelude) in &self.deps { - add_dep_with_prelude( - crate_graph, - from, - name.clone(), - *krate, - *prelude, - DependencyKind::Normal, - ); + add_dep_with_prelude(crate_graph, from, name.clone(), *krate, *prelude); } } } @@ -1381,9 +1333,7 @@ fn sysroot_to_crate_graph( crate_graph: &mut CrateGraph, sysroot: &Sysroot, rustc_cfg: Vec, - target_layout: TargetLayoutLoadResult, load: &mut dyn FnMut(&AbsPath) -> Option, - toolchain: Option<&Version>, ) -> (SysrootPublicDeps, Option) { let _p = tracing::span!(tracing::Level::INFO, "sysroot_to_crate_graph").entered(); match sysroot.mode() { @@ -1396,8 +1346,6 @@ fn sysroot_to_crate_graph( rustc_cfg, &CfgOverrides::default(), &WorkspaceBuildScripts::default(), - target_layout, - toolchain, ); let mut pub_deps = vec![]; @@ -1440,17 +1388,16 @@ fn sysroot_to_crate_graph( // Remove all crates except the ones we are interested in to keep the sysroot graph small. let removed_mapping = cg.remove_crates_except(&marker_set); + let mapping = crate_graph.extend(cg, &mut pm, |(_, a), (_, b)| a == b); - crate_graph.extend(cg, &mut pm, |mapping| { - // Map the id through the removal mapping first, then through the crate graph extension mapping. - pub_deps.iter_mut().for_each(|(_, cid, _)| { - *cid = mapping[&removed_mapping[cid.into_raw().into_u32() as usize].unwrap()] - }); - if let Some(libproc_macro) = &mut libproc_macro { - *libproc_macro = mapping - [&removed_mapping[libproc_macro.into_raw().into_u32() as usize].unwrap()]; - } + // Map the id through the removal mapping first, then through the crate graph extension mapping. + pub_deps.iter_mut().for_each(|(_, cid, _)| { + *cid = mapping[&removed_mapping[cid.into_raw().into_u32() as usize].unwrap()] }); + if let Some(libproc_macro) = &mut libproc_macro { + *libproc_macro = mapping + [&removed_mapping[libproc_macro.into_raw().into_u32() as usize].unwrap()]; + } (SysrootPublicDeps { deps: pub_deps }, libproc_macro) } @@ -1474,8 +1421,6 @@ fn sysroot_to_crate_graph( env, false, CrateOrigin::Lang(LangCrateOrigin::from(&*stitched[krate].name)), - target_layout.clone(), - toolchain.cloned(), ); Some((krate, crate_id)) }) @@ -1487,7 +1432,7 @@ fn sysroot_to_crate_graph( if let (Some(&from), Some(&to)) = (sysroot_crates.get(&from), sysroot_crates.get(&to)) { - add_dep(crate_graph, from, name, to, DependencyKind::Normal); + add_dep(crate_graph, from, name, to); } } } @@ -1508,14 +1453,8 @@ fn sysroot_to_crate_graph( } } -fn add_dep( - graph: &mut CrateGraph, - from: CrateId, - name: CrateName, - to: CrateId, - kind: DependencyKind, -) { - add_dep_inner(graph, from, Dependency::new(name, to, kind)) +fn add_dep(graph: &mut CrateGraph, from: CrateId, name: CrateName, to: CrateId) { + add_dep_inner(graph, from, Dependency::new(name, to)) } fn add_dep_with_prelude( @@ -1524,20 +1463,12 @@ fn add_dep_with_prelude( name: CrateName, to: CrateId, prelude: bool, - kind: DependencyKind, ) { - add_dep_inner(graph, from, Dependency::with_prelude(name, to, prelude, kind)) + add_dep_inner(graph, from, Dependency::with_prelude(name, to, prelude)) } fn add_proc_macro_dep(crate_graph: &mut CrateGraph, from: CrateId, to: CrateId, prelude: bool) { - add_dep_with_prelude( - crate_graph, - from, - CrateName::new("proc_macro").unwrap(), - to, - prelude, - DependencyKind::Normal, - ); + add_dep_with_prelude(crate_graph, from, CrateName::new("proc_macro").unwrap(), to, prelude); } fn add_dep_inner(graph: &mut CrateGraph, from: CrateId, dep: Dependency) { @@ -1588,3 +1519,29 @@ fn create_cfg_options(rustc_cfg: Vec) -> CfgOptions { cfg_options.insert_atom("debug_assertions".into()); cfg_options } + +fn cargo_config_env( + cargo_toml: &ManifestPath, + extra_env: &FxHashMap, + sysroot: Option<&Sysroot>, +) -> FxHashMap { + let mut cargo_config = Command::new(Tool::Cargo.path()); + Sysroot::set_rustup_toolchain_env(&mut cargo_config, sysroot); + cargo_config.envs(extra_env); + cargo_config + .current_dir(cargo_toml.parent()) + .args(["-Z", "unstable-options", "config", "get", "env"]) + .env("RUSTC_BOOTSTRAP", "1"); + // if successful we receive `env.key.value = "value" per entry + tracing::debug!("Discovering cargo config env by {:?}", cargo_config); + utf8_stdout(cargo_config).map(parse_output_cargo_config_env).unwrap_or_default() +} + +fn parse_output_cargo_config_env(stdout: String) -> FxHashMap { + stdout + .lines() + .filter_map(|l| l.strip_prefix("env.")) + .filter_map(|l| l.split_once(".value = ")) + .map(|(key, value)| (key.to_owned(), value.trim_matches('"').to_owned())) + .collect() +} diff --git a/crates/project-model/test_data/output/cargo_hello_world_project_model.txt b/crates/project-model/test_data/output/cargo_hello_world_project_model.txt index d8d9e559e5c1d..0ad19ca9f759d 100644 --- a/crates/project-model/test_data/output/cargo_hello_world_project_model.txt +++ b/crates/project-model/test_data/output/cargo_hello_world_project_model.txt @@ -48,7 +48,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -59,10 +58,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 1: CrateData { root_file_id: FileId( @@ -113,7 +108,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -121,7 +115,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -132,10 +125,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 2: CrateData { root_file_id: FileId( @@ -186,7 +175,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -194,7 +182,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -205,10 +192,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 3: CrateData { root_file_id: FileId( @@ -259,7 +242,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -267,7 +249,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -278,10 +259,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 4: CrateData { root_file_id: FileId( @@ -347,9 +324,5 @@ name: "libc", }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, } \ No newline at end of file diff --git a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt index d8d9e559e5c1d..0ad19ca9f759d 100644 --- a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt +++ b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt @@ -48,7 +48,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -59,10 +58,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 1: CrateData { root_file_id: FileId( @@ -113,7 +108,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -121,7 +115,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -132,10 +125,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 2: CrateData { root_file_id: FileId( @@ -186,7 +175,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -194,7 +182,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -205,10 +192,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 3: CrateData { root_file_id: FileId( @@ -259,7 +242,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -267,7 +249,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -278,10 +259,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 4: CrateData { root_file_id: FileId( @@ -347,9 +324,5 @@ name: "libc", }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, } \ No newline at end of file diff --git a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt index e0ba5ed498fa8..e2334dca87579 100644 --- a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt +++ b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt @@ -47,7 +47,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -58,10 +57,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 1: CrateData { root_file_id: FileId( @@ -111,7 +106,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -119,7 +113,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -130,10 +123,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 2: CrateData { root_file_id: FileId( @@ -183,7 +172,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -191,7 +179,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -202,10 +189,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 3: CrateData { root_file_id: FileId( @@ -255,7 +238,6 @@ name: CrateName( "hello_world", ), - kind: Normal, prelude: true, }, Dependency { @@ -263,7 +245,6 @@ name: CrateName( "libc", ), - kind: Normal, prelude: true, }, ], @@ -274,10 +255,6 @@ ), }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, 4: CrateData { root_file_id: FileId( @@ -343,9 +320,5 @@ name: "libc", }, is_proc_macro: false, - target_layout: Err( - "target_data_layout not loaded", - ), - toolchain: None, }, } \ No newline at end of file diff --git a/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt b/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt index 0df99534c5bd9..ccaba963deda3 100644 --- a/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt +++ b/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt @@ -28,7 +28,6 @@ name: CrateName( "core", ), - kind: Normal, prelude: true, }, ], @@ -36,10 +35,6 @@ Alloc, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 1: CrateData { root_file_id: FileId( @@ -69,10 +64,6 @@ Core, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 2: CrateData { root_file_id: FileId( @@ -102,10 +93,6 @@ Other, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 3: CrateData { root_file_id: FileId( @@ -135,10 +122,6 @@ Other, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 4: CrateData { root_file_id: FileId( @@ -169,7 +152,6 @@ name: CrateName( "std", ), - kind: Normal, prelude: true, }, Dependency { @@ -177,7 +159,6 @@ name: CrateName( "core", ), - kind: Normal, prelude: true, }, ], @@ -185,10 +166,6 @@ ProcMacro, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 5: CrateData { root_file_id: FileId( @@ -218,10 +195,6 @@ Other, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 6: CrateData { root_file_id: FileId( @@ -252,7 +225,6 @@ name: CrateName( "alloc", ), - kind: Normal, prelude: true, }, Dependency { @@ -260,7 +232,6 @@ name: CrateName( "panic_unwind", ), - kind: Normal, prelude: true, }, Dependency { @@ -268,7 +239,6 @@ name: CrateName( "panic_abort", ), - kind: Normal, prelude: true, }, Dependency { @@ -276,7 +246,6 @@ name: CrateName( "core", ), - kind: Normal, prelude: true, }, Dependency { @@ -284,7 +253,6 @@ name: CrateName( "profiler_builtins", ), - kind: Normal, prelude: true, }, Dependency { @@ -292,7 +260,6 @@ name: CrateName( "unwind", ), - kind: Normal, prelude: true, }, Dependency { @@ -300,7 +267,6 @@ name: CrateName( "std_detect", ), - kind: Normal, prelude: true, }, Dependency { @@ -308,7 +274,6 @@ name: CrateName( "test", ), - kind: Normal, prelude: true, }, ], @@ -316,10 +281,6 @@ Std, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 7: CrateData { root_file_id: FileId( @@ -349,10 +310,6 @@ Other, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 8: CrateData { root_file_id: FileId( @@ -382,10 +339,6 @@ Test, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 9: CrateData { root_file_id: FileId( @@ -415,10 +368,6 @@ Other, ), is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, 10: CrateData { root_file_id: FileId( @@ -449,7 +398,6 @@ name: CrateName( "core", ), - kind: Normal, prelude: true, }, Dependency { @@ -457,7 +405,6 @@ name: CrateName( "alloc", ), - kind: Normal, prelude: true, }, Dependency { @@ -465,7 +412,6 @@ name: CrateName( "std", ), - kind: Normal, prelude: true, }, Dependency { @@ -473,7 +419,6 @@ name: CrateName( "test", ), - kind: Normal, prelude: false, }, Dependency { @@ -481,7 +426,6 @@ name: CrateName( "proc_macro", ), - kind: Normal, prelude: false, }, ], @@ -492,9 +436,5 @@ ), }, is_proc_macro: false, - target_layout: Err( - "rust-project.json projects have no target layout set", - ), - toolchain: None, }, } \ No newline at end of file diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 269dd3cfffe95..07e04a8366173 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -11,7 +11,7 @@ extern crate rustc_driver as _; mod rustc_wrapper; -use std::{env, fs, path::PathBuf, process, sync::Arc}; +use std::{env, fs, path::PathBuf, process::ExitCode, sync::Arc}; use anyhow::Context; use lsp_server::Connection; @@ -27,21 +27,15 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; -fn main() -> anyhow::Result<()> { +fn main() -> anyhow::Result { if std::env::var("RA_RUSTC_WRAPPER").is_ok() { - let mut args = std::env::args_os(); - let _me = args.next().unwrap(); - let rustc = args.next().unwrap(); - let code = match rustc_wrapper::run_rustc_skipping_cargo_checking(rustc, args.collect()) { - Ok(rustc_wrapper::ExitCode(code)) => code.unwrap_or(102), - Err(err) => { - eprintln!("{err}"); - 101 - } - }; - process::exit(code); + rustc_wrapper::main().map_err(Into::into) + } else { + actual_main() } +} +fn actual_main() -> anyhow::Result { let flags = flags::RustAnalyzer::from_env_or_exit(); #[cfg(debug_assertions)] @@ -58,14 +52,14 @@ fn main() -> anyhow::Result<()> { let verbosity = flags.verbosity(); match flags.subcommand { - flags::RustAnalyzerCmd::LspServer(cmd) => { + flags::RustAnalyzerCmd::LspServer(cmd) => 'lsp_server: { if cmd.print_config_schema { println!("{:#}", Config::json_schema()); - return Ok(()); + break 'lsp_server; } if cmd.version { println!("rust-analyzer {}", rust_analyzer::version()); - return Ok(()); + break 'lsp_server; } // rust-analyzer’s “main thread” is actually @@ -90,7 +84,7 @@ fn main() -> anyhow::Result<()> { flags::RustAnalyzerCmd::RunTests(cmd) => cmd.run()?, flags::RustAnalyzerCmd::RustcTests(cmd) => cmd.run()?, } - Ok(()) + Ok(ExitCode::SUCCESS) } fn setup_logging(log_file_flag: Option) -> anyhow::Result<()> { diff --git a/crates/rust-analyzer/src/bin/rustc_wrapper.rs b/crates/rust-analyzer/src/bin/rustc_wrapper.rs index 38e9c7dd7e11c..684b3f52afc86 100644 --- a/crates/rust-analyzer/src/bin/rustc_wrapper.rs +++ b/crates/rust-analyzer/src/bin/rustc_wrapper.rs @@ -7,13 +7,17 @@ use std::{ ffi::OsString, io, - process::{Command, Stdio}, + process::{Command, ExitCode, Stdio}, }; -/// ExitCode/ExitStatus are impossible to create :(. -pub(crate) struct ExitCode(pub(crate) Option); +pub(crate) fn main() -> io::Result { + let mut args = std::env::args_os(); + let _me = args.next().unwrap(); + let rustc = args.next().unwrap(); + run_rustc_skipping_cargo_checking(rustc, args.collect()) +} -pub(crate) fn run_rustc_skipping_cargo_checking( +fn run_rustc_skipping_cargo_checking( rustc_executable: OsString, args: Vec, ) -> io::Result { @@ -35,9 +39,10 @@ pub(crate) fn run_rustc_skipping_cargo_checking( arg.starts_with("--emit=") && arg.contains("metadata") && !arg.contains("link") }); if not_invoked_by_build_script && is_cargo_check { - return Ok(ExitCode(Some(0))); + Ok(ExitCode::from(0)) + } else { + run_rustc(rustc_executable, args) } - run_rustc(rustc_executable, args) } fn run_rustc(rustc_executable: OsString, args: Vec) -> io::Result { @@ -47,5 +52,5 @@ fn run_rustc(rustc_executable: OsString, args: Vec) -> io::Result { + TargetKind::Lib { is_proc_macro: _ } => { buf.push("--lib".to_owned()); } TargetKind::Other | TargetKind::BuildScript => (), diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 2741b45222569..ce7e3b3cd6a44 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -32,7 +32,7 @@ use oorandom::Rand32; use profile::{Bytes, StopWatch}; use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource}; use rayon::prelude::*; -use rustc_hash::FxHashSet; +use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{AstNode, SyntaxNode}; use vfs::{AbsPathBuf, FileId, Vfs, VfsPath}; @@ -91,7 +91,7 @@ impl flags::AnalysisStats { }; let (host, vfs, _proc_macro) = - load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?; + load_workspace(workspace.clone(), &cargo_config.extra_env, &load_cargo_config)?; let db = host.raw_database(); eprint!("{:<20} {}", "Database loaded:", db_load_sw.elapsed()); eprint!(" (metadata {metadata_time}"); @@ -232,7 +232,11 @@ impl flags::AnalysisStats { } if self.run_all_ide_things { - self.run_ide_things(host.analysis(), file_ids); + self.run_ide_things(host.analysis(), file_ids.clone()); + } + + if self.run_term_search { + self.run_term_search(&workspace, db, &vfs, file_ids, verbosity); } let total_span = analysis_sw.elapsed(); @@ -321,6 +325,212 @@ impl flags::AnalysisStats { report_metric("const eval time", const_eval_time.time.as_millis() as u64, "ms"); } + fn run_term_search( + &self, + ws: &ProjectWorkspace, + db: &RootDatabase, + vfs: &Vfs, + mut file_ids: Vec, + verbosity: Verbosity, + ) { + let cargo_config = CargoConfig { + sysroot: match self.no_sysroot { + true => None, + false => Some(RustLibSource::Discover), + }, + ..Default::default() + }; + + let mut bar = match verbosity { + Verbosity::Quiet | Verbosity::Spammy => ProgressReport::hidden(), + _ if self.parallel || self.output.is_some() => ProgressReport::hidden(), + _ => ProgressReport::new(file_ids.len() as u64), + }; + + file_ids.sort(); + file_ids.dedup(); + + #[derive(Debug, Default)] + struct Acc { + tail_expr_syntax_hits: u64, + tail_expr_no_term: u64, + total_tail_exprs: u64, + error_codes: FxHashMap, + syntax_errors: u32, + } + + let mut acc: Acc = Default::default(); + bar.tick(); + let mut sw = self.stop_watch(); + + for &file_id in &file_ids { + let sema = hir::Semantics::new(db); + let _ = db.parse(file_id); + + let parse = sema.parse(file_id); + let file_txt = db.file_text(file_id); + let path = vfs.file_path(file_id).as_path().unwrap().to_owned(); + + for node in parse.syntax().descendants() { + let expr = match syntax::ast::Expr::cast(node.clone()) { + Some(it) => it, + None => continue, + }; + let block = match syntax::ast::BlockExpr::cast(expr.syntax().clone()) { + Some(it) => it, + None => continue, + }; + let target_ty = match sema.type_of_expr(&expr) { + Some(it) => it.adjusted(), + None => continue, // Failed to infer type + }; + + let expected_tail = match block.tail_expr() { + Some(it) => it, + None => continue, + }; + + if expected_tail.is_block_like() { + continue; + } + + let range = sema.original_range(expected_tail.syntax()).range; + let original_text: String = db + .file_text(file_id) + .chars() + .skip(usize::from(range.start())) + .take(usize::from(range.end()) - usize::from(range.start())) + .collect(); + + let scope = match sema.scope(expected_tail.syntax()) { + Some(it) => it, + None => continue, + }; + + let ctx = hir::term_search::TermSearchCtx { + sema: &sema, + scope: &scope, + goal: target_ty, + config: hir::term_search::TermSearchConfig { + enable_borrowcheck: true, + ..Default::default() + }, + }; + let found_terms = hir::term_search::term_search(&ctx); + + if found_terms.is_empty() { + acc.tail_expr_no_term += 1; + acc.total_tail_exprs += 1; + // println!("\n{}\n", &original_text); + continue; + }; + + fn trim(s: &str) -> String { + s.chars().filter(|c| !c.is_whitespace()).collect() + } + + let todo = syntax::ast::make::ext::expr_todo().to_string(); + let mut formatter = |_: &hir::Type| todo.clone(); + let mut syntax_hit_found = false; + for term in found_terms { + let generated = + term.gen_source_code(&scope, &mut formatter, false, true).unwrap(); + syntax_hit_found |= trim(&original_text) == trim(&generated); + + // Validate if type-checks + let mut txt = file_txt.to_string(); + + let edit = ide::TextEdit::replace(range, generated.clone()); + edit.apply(&mut txt); + + if self.validate_term_search { + std::fs::write(&path, txt).unwrap(); + + let res = ws.run_build_scripts(&cargo_config, &|_| ()).unwrap(); + if let Some(err) = res.error() { + if err.contains("error: could not compile") { + if let Some(mut err_idx) = err.find("error[E") { + err_idx += 7; + let err_code = &err[err_idx..err_idx + 4]; + match err_code { + "0282" => continue, // Byproduct of testing method + "0277" if generated.contains(&todo) => continue, // See https://github.com/rust-lang/rust/issues/69882 + _ => (), + } + bar.println(err); + bar.println(generated); + acc.error_codes + .entry(err_code.to_owned()) + .and_modify(|n| *n += 1) + .or_insert(1); + } else { + acc.syntax_errors += 1; + bar.println(format!("Syntax error: \n{}", err)); + } + } + } + } + } + + if syntax_hit_found { + acc.tail_expr_syntax_hits += 1; + } + acc.total_tail_exprs += 1; + + let msg = move || { + format!( + "processing: {:<50}", + trim(&original_text).chars().take(50).collect::() + ) + }; + if verbosity.is_spammy() { + bar.println(msg()); + } + bar.set_message(msg); + } + // Revert file back to original state + if self.validate_term_search { + std::fs::write(&path, file_txt.to_string()).unwrap(); + } + + bar.inc(1); + } + let term_search_time = sw.elapsed(); + + bar.println(format!( + "Tail Expr syntactic hits: {}/{} ({}%)", + acc.tail_expr_syntax_hits, + acc.total_tail_exprs, + percentage(acc.tail_expr_syntax_hits, acc.total_tail_exprs) + )); + bar.println(format!( + "Tail Exprs found: {}/{} ({}%)", + acc.total_tail_exprs - acc.tail_expr_no_term, + acc.total_tail_exprs, + percentage(acc.total_tail_exprs - acc.tail_expr_no_term, acc.total_tail_exprs) + )); + if self.validate_term_search { + bar.println(format!( + "Tail Exprs total errors: {}, syntax errors: {}, error codes:", + acc.error_codes.values().sum::() + acc.syntax_errors, + acc.syntax_errors, + )); + for (err, count) in acc.error_codes { + bar.println(format!( + " E{err}: {count:>5} (https://doc.rust-lang.org/error_codes/E{err}.html)" + )); + } + } + bar.println(format!( + "Term search avg time: {}ms", + term_search_time.time.as_millis() as u64 / acc.total_tail_exprs + )); + bar.println(format!("{:<20} {}", "Term search:", term_search_time)); + report_metric("term search time", term_search_time.time.as_millis() as u64, "ms"); + + bar.finish_and_clear(); + } + fn run_mir_lowering(&self, db: &RootDatabase, bodies: &[DefWithBody], verbosity: Verbosity) { let mut sw = self.stop_watch(); let mut all = 0; diff --git a/crates/rust-analyzer/src/cli/flags.rs b/crates/rust-analyzer/src/cli/flags.rs index 252b1e1a48581..493e614dce682 100644 --- a/crates/rust-analyzer/src/cli/flags.rs +++ b/crates/rust-analyzer/src/cli/flags.rs @@ -93,6 +93,11 @@ xflags::xflags! { /// and annotations. This is useful for benchmarking the memory usage on a project that has /// been worked on for a bit in a longer running session. optional --run-all-ide-things + /// Run term search on all the tail expressions (of functions, block, if statements etc.) + optional --run-term-search + /// Validate term search by running `cargo check` on every response. + /// Note that this also temporarily modifies the files on disk, use with caution! + optional --validate-term-search } /// Run unit tests of the project using mir interpreter @@ -218,6 +223,8 @@ pub struct AnalysisStats { pub skip_data_layout: bool, pub skip_const_eval: bool, pub run_all_ide_things: bool, + pub run_term_search: bool, + pub validate_term_search: bool, } #[derive(Debug)] diff --git a/crates/rust-analyzer/src/cli/scip.rs b/crates/rust-analyzer/src/cli/scip.rs index f4aec288348f9..2d56830c87f30 100644 --- a/crates/rust-analyzer/src/cli/scip.rs +++ b/crates/rust-analyzer/src/cli/scip.rs @@ -135,12 +135,11 @@ impl flags::Scip { } if symbols_emitted.insert(id) { - let documentation = token - .hover - .as_ref() - .map(|hover| hover.markup.as_str()) - .filter(|it| !it.is_empty()) - .map(|it| vec![it.to_owned()]); + let documentation = match &token.documentation { + Some(doc) => vec![doc.as_str().to_owned()], + None => vec![], + }; + let position_encoding = scip_types::PositionEncoding::UTF8CodeUnitOffsetFromLineStart.into(); let signature_documentation = @@ -153,7 +152,7 @@ impl flags::Scip { }); let symbol_info = scip_types::SymbolInformation { symbol: symbol.clone(), - documentation: documentation.unwrap_or_default(), + documentation, relationships: Vec::new(), special_fields: Default::default(), kind: symbol_kind(token.kind).into(), @@ -599,4 +598,22 @@ pub mod example_mod { "rust-analyzer cargo main . MyTypeAlias#", ); } + + #[test] + fn documentation_matches_doc_comment() { + let s = "/// foo\nfn bar() {}"; + + let mut host = AnalysisHost::default(); + let change_fixture = ChangeFixture::parse(s); + host.raw_database_mut().apply_change(change_fixture.change); + + let analysis = host.analysis(); + let si = StaticIndex::compute(&analysis); + + let file = si.files.first().unwrap(); + let (_, token_id) = file.tokens.first().unwrap(); + let token = si.tokens.get(*token_id).unwrap(); + + assert_eq!(token.documentation.as_ref().map(|d| d.as_str()), Some("foo")); + } } diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 7bdd9ec866a5a..16e1a2f544907 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -112,7 +112,7 @@ config_data! { cargo_buildScripts_overrideCommand: Option> = "null", /// Rerun proc-macros building/build-scripts running when proc-macro /// or build-script sources change and are saved. - cargo_buildScripts_rebuildOnSave: bool = "false", + cargo_buildScripts_rebuildOnSave: bool = "true", /// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to /// avoid checking unnecessary things. cargo_buildScripts_useRustcWrapper: bool = "true", @@ -209,6 +209,11 @@ config_data! { /// by changing `#rust-analyzer.check.invocationStrategy#` and /// `#rust-analyzer.check.invocationLocation#`. /// + /// If `$saved_file` is part of the command, rust-analyzer will pass + /// the absolute path of the saved file to the provided command. This is + /// intended to be used with non-Cargo build systems. + /// Note that `$saved_file` is experimental and may be removed in the futureg. + /// /// An example command would be: /// /// ```bash @@ -286,6 +291,8 @@ config_data! { "scope": "expr" } }"#, + /// Whether to enable term search based snippets like `Some(foo.bar().baz())`. + completion_termSearch_enable: bool = "false", /// List of rust-analyzer diagnostics to disable. diagnostics_disabled: FxHashSet = "[]", @@ -504,9 +511,6 @@ config_data! { /// Exclude tests from find-all-references. references_excludeTests: bool = "false", - /// Allow renaming of items not belonging to the loaded workspaces. - rename_allowExternalItems: bool = "false", - /// Command to be executed instead of 'cargo' for runnables. runnables_command: Option = "null", @@ -1202,7 +1206,7 @@ impl Config { Some(AbsPathBuf::try_from(path).unwrap_or_else(|path| self.root_path.join(path))) } - pub fn dummy_replacements(&self) -> &FxHashMap, Box<[Box]>> { + pub fn ignored_proc_macros(&self) -> &FxHashMap, Box<[Box]>> { &self.data.procMacro_ignored } @@ -1535,6 +1539,7 @@ impl Config { && completion_item_edit_resolve(&self.caps), enable_self_on_the_fly: self.data.completion_autoself_enable, enable_private_editable: self.data.completion_privateEditable_enable, + enable_term_search: self.data.completion_termSearch_enable, full_function_signatures: self.data.completion_fullFunctionSignatures_enable, callable: match self.data.completion_callable_snippets { CallableCompletionDef::FillArguments => Some(CallableSnippets::FillArguments), @@ -1766,10 +1771,6 @@ impl Config { self.data.typing_autoClosingAngleBrackets_enable } - pub fn rename(&self) -> bool { - self.data.rename_allowExternalItems - } - // FIXME: VSCode seems to work wrong sometimes, see https://github.com/microsoft/vscode/issues/193124 // hence, distinguish it for now. pub fn is_visual_studio_code(&self) -> bool { diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index da4422a60a8a9..293807a383baa 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -9,7 +9,7 @@ use crossbeam_channel::{unbounded, Receiver, Sender}; use flycheck::FlycheckHandle; use hir::Change; use ide::{Analysis, AnalysisHost, Cancellable, FileId}; -use ide_db::base_db::{CrateId, FileLoader, ProcMacroPaths, SourceDatabase}; +use ide_db::base_db::{CrateId, ProcMacroPaths}; use load_cargo::SourceRootConfig; use lsp_types::{SemanticTokens, Url}; use nohash_hasher::IntMap; @@ -74,8 +74,8 @@ pub(crate) struct GlobalState { pub(crate) last_reported_status: Option, // proc macros - pub(crate) proc_macro_changed: bool, pub(crate) proc_macro_clients: Arc<[anyhow::Result]>, + pub(crate) build_deps_changed: bool, // Flycheck pub(crate) flycheck: Arc<[FlycheckHandle]>, @@ -203,9 +203,10 @@ impl GlobalState { source_root_config: SourceRootConfig::default(), config_errors: Default::default(), - proc_macro_changed: false, proc_macro_clients: Arc::from_iter([]), + build_deps_changed: false, + flycheck: Arc::from_iter([]), flycheck_sender, flycheck_receiver, @@ -300,12 +301,19 @@ impl GlobalState { if let Some(path) = vfs_path.as_path() { let path = path.to_path_buf(); if reload::should_refresh_for_change(&path, file.kind()) { - workspace_structure_change = Some((path.clone(), false)); + workspace_structure_change = Some(( + path.clone(), + false, + AsRef::::as_ref(&path).ends_with("build.rs"), + )); } if file.is_created_or_deleted() { has_structure_changes = true; - workspace_structure_change = - Some((path, self.crate_graph_file_dependencies.contains(vfs_path))); + workspace_structure_change = Some(( + path, + self.crate_graph_file_dependencies.contains(vfs_path), + false, + )); } else if path.extension() == Some("rs".as_ref()) { modified_rust_files.push(file.file_id); } @@ -346,23 +354,28 @@ impl GlobalState { }; self.analysis_host.apply_change(change); + { - let raw_database = self.analysis_host.raw_database(); + if !matches!(&workspace_structure_change, Some((.., true))) { + _ = self + .deferred_task_queue + .sender + .send(crate::main_loop::QueuedTask::CheckProcMacroSources(modified_rust_files)); + } // FIXME: ideally we should only trigger a workspace fetch for non-library changes // but something's going wrong with the source root business when we add a new local // crate see https://github.com/rust-lang/rust-analyzer/issues/13029 - if let Some((path, force_crate_graph_reload)) = workspace_structure_change { + if let Some((path, force_crate_graph_reload, build_scripts_touched)) = + workspace_structure_change + { self.fetch_workspaces_queue.request_op( format!("workspace vfs file change: {path}"), force_crate_graph_reload, ); + if build_scripts_touched { + self.fetch_build_data_queue.request_op(format!("build.rs changed: {path}"), ()); + } } - self.proc_macro_changed = modified_rust_files.into_iter().any(|file_id| { - let crates = raw_database.relevant_crates(file_id); - let crate_graph = raw_database.crate_graph(); - - crates.iter().any(|&krate| crate_graph[krate].is_proc_macro) - }); } true diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs index d3c2073f09d25..b13c709dbfe60 100644 --- a/crates/rust-analyzer/src/handlers/notification.rs +++ b/crates/rust-analyzer/src/handlers/notification.rs @@ -145,11 +145,11 @@ pub(crate) fn handle_did_save_text_document( state: &mut GlobalState, params: DidSaveTextDocumentParams, ) -> anyhow::Result<()> { - if state.config.script_rebuild_on_save() && state.proc_macro_changed { - // reset the flag - state.proc_macro_changed = false; - // rebuild the proc macros - state.fetch_build_data_queue.request_op("ScriptRebuildOnSave".to_owned(), ()); + if state.config.script_rebuild_on_save() && state.build_deps_changed { + state.build_deps_changed = false; + state + .fetch_build_data_queue + .request_op("build_deps_changed - save notification".to_owned(), ()); } if let Ok(vfs_path) = from_proto::vfs_path(¶ms.text_document.uri) { @@ -158,7 +158,7 @@ pub(crate) fn handle_did_save_text_document( if reload::should_refresh_for_change(abs_path, ChangeKind::Modify) { state .fetch_workspaces_queue - .request_op(format!("DidSaveTextDocument {abs_path}"), false); + .request_op(format!("workspace vfs file change saved {abs_path}"), false); } } @@ -168,7 +168,7 @@ pub(crate) fn handle_did_save_text_document( } else if state.config.check_on_save() { // No specific flycheck was triggered, so let's trigger all of them. for flycheck in state.flycheck.iter() { - flycheck.restart_workspace(); + flycheck.restart_workspace(None); } } Ok(()) @@ -314,6 +314,8 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { Some((idx, package)) }); + let saved_file = vfs_path.as_path().map(|p| p.to_owned()); + // Find and trigger corresponding flychecks for flycheck in world.flycheck.iter() { for (id, package) in workspace_ids.clone() { @@ -321,7 +323,7 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { updated = true; match package.filter(|_| !world.config.flycheck_workspace()) { Some(package) => flycheck.restart_for_package(package), - None => flycheck.restart_workspace(), + None => flycheck.restart_workspace(saved_file.clone()), } continue; } @@ -330,7 +332,7 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { // No specific flycheck was triggered, so let's trigger all of them. if !updated { for flycheck in world.flycheck.iter() { - flycheck.restart_workspace(); + flycheck.restart_workspace(saved_file.clone()); } } Ok(()) @@ -372,7 +374,7 @@ pub(crate) fn handle_run_flycheck( } // No specific flycheck was triggered, so let's trigger all of them. for flycheck in state.flycheck.iter() { - flycheck.restart_workspace(); + flycheck.restart_workspace(None); } Ok(()) } diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index 2a3633a48e9fa..eb9d4bf0f02d7 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -52,7 +52,7 @@ use crate::{ pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> anyhow::Result<()> { state.proc_macro_clients = Arc::from_iter([]); - state.proc_macro_changed = false; + state.build_deps_changed = false; state.fetch_workspaces_queue.request_op("reload workspace request".to_owned(), false); Ok(()) @@ -60,7 +60,7 @@ pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> anyhow: pub(crate) fn handle_proc_macros_rebuild(state: &mut GlobalState, _: ()) -> anyhow::Result<()> { state.proc_macro_clients = Arc::from_iter([]); - state.proc_macro_changed = false; + state.build_deps_changed = false; state.fetch_build_data_queue.request_op("rebuild proc macros request".to_owned(), ()); Ok(()) @@ -1017,10 +1017,8 @@ pub(crate) fn handle_rename( let _p = tracing::span!(tracing::Level::INFO, "handle_rename").entered(); let position = from_proto::file_position(&snap, params.text_document_position)?; - let mut change = snap - .analysis - .rename(position, ¶ms.new_name, snap.config.rename())? - .map_err(to_proto::rename_error)?; + let mut change = + snap.analysis.rename(position, ¶ms.new_name)?.map_err(to_proto::rename_error)?; // this is kind of a hack to prevent double edits from happening when moving files // When a module gets renamed by renaming the mod declaration this causes the file to move @@ -1937,6 +1935,7 @@ fn run_rustfmt( let mut command = match snap.config.rustfmt() { RustfmtConfig::Rustfmt { extra_args, enable_range_formatting } => { + // FIXME: Set RUSTUP_TOOLCHAIN let mut cmd = process::Command::new(toolchain::rustfmt()); cmd.envs(snap.config.extra_env()); cmd.args(extra_args); diff --git a/crates/rust-analyzer/src/integrated_benchmarks.rs b/crates/rust-analyzer/src/integrated_benchmarks.rs index acc02d6447c63..f0eee77aff592 100644 --- a/crates/rust-analyzer/src/integrated_benchmarks.rs +++ b/crates/rust-analyzer/src/integrated_benchmarks.rs @@ -132,6 +132,7 @@ fn integrated_completion_benchmark() { enable_imports_on_the_fly: true, enable_self_on_the_fly: true, enable_private_editable: true, + enable_term_search: true, full_function_signatures: false, callable: Some(CallableSnippets::FillArguments), snippet_cap: SnippetCap::new(true), @@ -175,6 +176,7 @@ fn integrated_completion_benchmark() { enable_imports_on_the_fly: true, enable_self_on_the_fly: true, enable_private_editable: true, + enable_term_search: true, full_function_signatures: false, callable: Some(CallableSnippets::FillArguments), snippet_cap: SnippetCap::new(true), @@ -216,6 +218,7 @@ fn integrated_completion_benchmark() { enable_imports_on_the_fly: true, enable_self_on_the_fly: true, enable_private_editable: true, + enable_term_search: true, full_function_signatures: false, callable: Some(CallableSnippets::FillArguments), snippet_cap: SnippetCap::new(true), diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index b1809f58ae700..473ca991ad9b0 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -47,7 +47,9 @@ mod integrated_benchmarks; use serde::de::DeserializeOwned; -pub use crate::{caps::server_capabilities, main_loop::main_loop, version::version}; +pub use crate::{ + caps::server_capabilities, main_loop::main_loop, reload::ws_to_crate_graph, version::version, +}; pub fn from_json( what: &'static str, diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index 64f19f0b32d7e..727007bba083a 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -123,6 +123,7 @@ pub(crate) fn completion_item_kind( CompletionItemKind::Method => lsp_types::CompletionItemKind::METHOD, CompletionItemKind::Snippet => lsp_types::CompletionItemKind::SNIPPET, CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::REFERENCE, + CompletionItemKind::Expression => lsp_types::CompletionItemKind::SNIPPET, CompletionItemKind::SymbolKind(symbol) => match symbol { SymbolKind::Attribute => lsp_types::CompletionItemKind::FUNCTION, SymbolKind::Const => lsp_types::CompletionItemKind::CONSTANT, @@ -929,6 +930,16 @@ fn merge_text_and_snippet_edits( let mut edits: Vec = vec![]; let mut snippets = snippet_edit.into_edit_ranges().into_iter().peekable(); let text_edits = edit.into_iter(); + // offset to go from the final source location to the original source location + let mut source_text_offset = 0i32; + + let offset_range = |range: TextRange, offset: i32| -> TextRange { + // map the snippet range from the target location into the original source location + let start = u32::from(range.start()).checked_add_signed(offset).unwrap_or(0); + let end = u32::from(range.end()).checked_add_signed(offset).unwrap_or(0); + + TextRange::new(start.into(), end.into()) + }; for current_indel in text_edits { let new_range = { @@ -937,10 +948,17 @@ fn merge_text_and_snippet_edits( TextRange::at(current_indel.delete.start(), insert_len) }; + // figure out how much this Indel will shift future ranges from the initial source + let offset_adjustment = + u32::from(current_indel.delete.len()) as i32 - u32::from(new_range.len()) as i32; + // insert any snippets before the text edit - for (snippet_index, snippet_range) in - snippets.take_while_ref(|(_, range)| range.end() < new_range.start()) - { + for (snippet_index, snippet_range) in snippets.peeking_take_while(|(_, range)| { + offset_range(*range, source_text_offset).end() < new_range.start() + }) { + // adjust the snippet range into the corresponding initial source location + let snippet_range = offset_range(snippet_range, source_text_offset); + let snippet_range = if !stdx::always!( snippet_range.is_empty(), "placeholder range {:?} is before current text edit range {:?}", @@ -953,22 +971,23 @@ fn merge_text_and_snippet_edits( snippet_range }; - let range = range(line_index, snippet_range); - let new_text = format!("${snippet_index}"); - - edits.push(SnippetTextEdit { - range, - new_text, - insert_text_format: Some(lsp_types::InsertTextFormat::SNIPPET), - annotation_id: None, - }) + edits.push(snippet_text_edit( + line_index, + true, + Indel { insert: format!("${snippet_index}"), delete: snippet_range }, + )) } - if snippets.peek().is_some_and(|(_, range)| new_range.intersect(*range).is_some()) { + if snippets.peek().is_some_and(|(_, range)| { + new_range.intersect(offset_range(*range, source_text_offset)).is_some() + }) { // at least one snippet edit intersects this text edit, // so gather all of the edits that intersect this text edit let mut all_snippets = snippets - .take_while_ref(|(_, range)| new_range.intersect(*range).is_some()) + .peeking_take_while(|(_, range)| { + new_range.intersect(offset_range(*range, source_text_offset)).is_some() + }) + .map(|(tabstop, range)| (tabstop, offset_range(range, source_text_offset))) .collect_vec(); // ensure all of the ranges are wholly contained inside of the new range @@ -979,40 +998,59 @@ fn merge_text_and_snippet_edits( ) }); - let mut text_edit = text_edit(line_index, current_indel); + let mut new_text = current_indel.insert; - // escape out snippet text - stdx::replace(&mut text_edit.new_text, '\\', r"\\"); - stdx::replace(&mut text_edit.new_text, '$', r"\$"); + // find which snippet bits need to be escaped + let escape_places = new_text + .rmatch_indices(['\\', '$', '{', '}']) + .map(|(insert, _)| insert) + .collect_vec(); + let mut escape_places = escape_places.into_iter().peekable(); + let mut escape_prior_bits = |new_text: &mut String, up_to: usize| { + for before in escape_places.peeking_take_while(|insert| *insert >= up_to) { + new_text.insert(before, '\\'); + } + }; - // ...and apply! + // insert snippets, and escaping any needed bits along the way for (index, range) in all_snippets.iter().rev() { - let start = (range.start() - new_range.start()).into(); - let end = (range.end() - new_range.start()).into(); + let text_range = range - new_range.start(); + let (start, end) = (text_range.start().into(), text_range.end().into()); if range.is_empty() { - text_edit.new_text.insert_str(start, &format!("${index}")); + escape_prior_bits(&mut new_text, start); + new_text.insert_str(start, &format!("${index}")); } else { - text_edit.new_text.insert(end, '}'); - text_edit.new_text.insert_str(start, &format!("${{{index}:")); + escape_prior_bits(&mut new_text, end); + new_text.insert(end, '}'); + escape_prior_bits(&mut new_text, start); + new_text.insert_str(start, &format!("${{{index}:")); } } - edits.push(SnippetTextEdit { - range: text_edit.range, - new_text: text_edit.new_text, - insert_text_format: Some(lsp_types::InsertTextFormat::SNIPPET), - annotation_id: None, - }) + // escape any remaining bits + escape_prior_bits(&mut new_text, 0); + + edits.push(snippet_text_edit( + line_index, + true, + Indel { insert: new_text, delete: current_indel.delete }, + )) } else { // snippet edit was beyond the current one // since it wasn't consumed, it's available for the next pass edits.push(snippet_text_edit(line_index, false, current_indel)); } + + // update the final source -> initial source mapping offset + source_text_offset += offset_adjustment; } // insert any remaining tabstops edits.extend(snippets.map(|(snippet_index, snippet_range)| { + // adjust the snippet range into the corresponding initial source location + let snippet_range = offset_range(snippet_range, source_text_offset); + let snippet_range = if !stdx::always!( snippet_range.is_empty(), "found placeholder snippet {:?} without a text edit", @@ -1023,15 +1061,11 @@ fn merge_text_and_snippet_edits( snippet_range }; - let range = range(line_index, snippet_range); - let new_text = format!("${snippet_index}"); - - SnippetTextEdit { - range, - new_text, - insert_text_format: Some(lsp_types::InsertTextFormat::SNIPPET), - annotation_id: None, - } + snippet_text_edit( + line_index, + true, + Indel { insert: format!("${snippet_index}"), delete: snippet_range }, + ) })); edits @@ -1658,15 +1692,44 @@ fn bar(_: usize) {} assert!(!docs.contains("use crate::bar")); } + #[track_caller] fn check_rendered_snippets(edit: TextEdit, snippets: SnippetEdit, expect: Expect) { - let text = r#"/* place to put all ranges in */"#; + check_rendered_snippets_in_source( + r"/* place to put all ranges in */", + edit, + snippets, + expect, + ); + } + + #[track_caller] + fn check_rendered_snippets_in_source( + ra_fixture: &str, + edit: TextEdit, + snippets: SnippetEdit, + expect: Expect, + ) { + let source = stdx::trim_indent(ra_fixture); + let endings = if source.contains('\r') { LineEndings::Dos } else { LineEndings::Unix }; let line_index = LineIndex { - index: Arc::new(ide::LineIndex::new(text)), - endings: LineEndings::Unix, + index: Arc::new(ide::LineIndex::new(&source)), + endings, encoding: PositionEncoding::Utf8, }; let res = merge_text_and_snippet_edits(&line_index, edit, snippets); + + // Ensure that none of the ranges overlap + { + let mut sorted = res.clone(); + sorted.sort_by_key(|edit| (edit.range.start, edit.range.end)); + let disjoint_ranges = sorted + .iter() + .zip(sorted.iter().skip(1)) + .all(|(l, r)| l.range.end <= r.range.start || l == r); + assert!(disjoint_ranges, "ranges overlap for {res:#?}"); + } + expect.assert_debug_eq(&res); } @@ -1811,7 +1874,8 @@ fn bar(_: usize) {} let mut edit = TextEdit::builder(); edit.insert(0.into(), "abc".to_owned()); let edit = edit.finish(); - let snippets = SnippetEdit::new(vec![Snippet::Tabstop(7.into())]); + // Note: tabstops are positioned in the source where all text edits have been applied + let snippets = SnippetEdit::new(vec![Snippet::Tabstop(10.into())]); check_rendered_snippets( edit, @@ -1928,8 +1992,9 @@ fn bar(_: usize) {} edit.insert(0.into(), "abc".to_owned()); edit.insert(7.into(), "abc".to_owned()); let edit = edit.finish(); + // Note: tabstops are positioned in the source where all text edits have been applied let snippets = - SnippetEdit::new(vec![Snippet::Tabstop(4.into()), Snippet::Tabstop(4.into())]); + SnippetEdit::new(vec![Snippet::Tabstop(7.into()), Snippet::Tabstop(7.into())]); check_rendered_snippets( edit, @@ -2085,13 +2150,502 @@ fn bar(_: usize) {} fn snippet_rendering_escape_snippet_bits() { // only needed for snippet formats let mut edit = TextEdit::builder(); - edit.insert(0.into(), r"abc\def$".to_owned()); - edit.insert(8.into(), r"ghi\jkl$".to_owned()); + edit.insert(0.into(), r"$ab{}$c\def".to_owned()); + edit.insert(8.into(), r"ghi\jk<-check_insert_here$".to_owned()); + edit.insert(10.into(), r"a\\b\\c{}$".to_owned()); let edit = edit.finish(); - let snippets = - SnippetEdit::new(vec![Snippet::Placeholder(TextRange::new(0.into(), 3.into()))]); + let snippets = SnippetEdit::new(vec![ + Snippet::Placeholder(TextRange::new(1.into(), 9.into())), + Snippet::Tabstop(25.into()), + ]); check_rendered_snippets( + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 0, + character: 0, + }, + end: Position { + line: 0, + character: 0, + }, + }, + new_text: "\\$${1:ab\\{\\}\\$c\\\\d}ef", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 0, + character: 8, + }, + end: Position { + line: 0, + character: 8, + }, + }, + new_text: "ghi\\\\jk$0<-check_insert_here\\$", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 0, + character: 10, + }, + end: Position { + line: 0, + character: 10, + }, + }, + new_text: "a\\\\b\\\\c{}$", + insert_text_format: None, + annotation_id: None, + }, + ] + "#]], + ); + } + + #[test] + fn snippet_rendering_tabstop_adjust_offset_deleted() { + // negative offset from inserting a smaller range + let mut edit = TextEdit::builder(); + edit.replace(TextRange::new(47.into(), 56.into()), "let".to_owned()); + edit.replace( + TextRange::new(57.into(), 89.into()), + "disabled = false;\n ProcMacro {\n disabled,\n }".to_owned(), + ); + let edit = edit.finish(); + let snippets = SnippetEdit::new(vec![Snippet::Tabstop(51.into())]); + + check_rendered_snippets_in_source( + r" +fn expander_to_proc_macro() -> ProcMacro { + ProcMacro { + disabled: false, + } +} + +struct ProcMacro { + disabled: bool, +}", + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 13, + }, + }, + new_text: "let", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 14, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + ] + "#]], + ); + } + + #[test] + fn snippet_rendering_tabstop_adjust_offset_added() { + // positive offset from inserting a larger range + let mut edit = TextEdit::builder(); + edit.replace(TextRange::new(39.into(), 40.into()), "let".to_owned()); + edit.replace( + TextRange::new(41.into(), 73.into()), + "disabled = false;\n ProcMacro {\n disabled,\n }".to_owned(), + ); + let edit = edit.finish(); + let snippets = SnippetEdit::new(vec![Snippet::Tabstop(43.into())]); + + check_rendered_snippets_in_source( + r" +fn expander_to_proc_macro() -> P { + P { + disabled: false, + } +} + +struct P { + disabled: bool, +}", + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 5, + }, + }, + new_text: "let", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 6, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + ] + "#]], + ); + } + + #[test] + fn snippet_rendering_placeholder_adjust_offset_deleted() { + // negative offset from inserting a smaller range + let mut edit = TextEdit::builder(); + edit.replace(TextRange::new(47.into(), 56.into()), "let".to_owned()); + edit.replace( + TextRange::new(57.into(), 89.into()), + "disabled = false;\n ProcMacro {\n disabled,\n }".to_owned(), + ); + let edit = edit.finish(); + let snippets = + SnippetEdit::new(vec![Snippet::Placeholder(TextRange::new(51.into(), 59.into()))]); + + check_rendered_snippets_in_source( + r" +fn expander_to_proc_macro() -> ProcMacro { + ProcMacro { + disabled: false, + } +} + +struct ProcMacro { + disabled: bool, +}", + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 13, + }, + }, + new_text: "let", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 14, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + ] + "#]], + ); + } + + #[test] + fn snippet_rendering_placeholder_adjust_offset_added() { + // positive offset from inserting a larger range + let mut edit = TextEdit::builder(); + edit.replace(TextRange::new(39.into(), 40.into()), "let".to_owned()); + edit.replace( + TextRange::new(41.into(), 73.into()), + "disabled = false;\n ProcMacro {\n disabled,\n }".to_owned(), + ); + let edit = edit.finish(); + let snippets = + SnippetEdit::new(vec![Snippet::Placeholder(TextRange::new(43.into(), 51.into()))]); + + check_rendered_snippets_in_source( + r" +fn expander_to_proc_macro() -> P { + P { + disabled: false, + } +} + +struct P { + disabled: bool, +}", + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 5, + }, + }, + new_text: "let", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 6, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + ] + "#]], + ); + } + + #[test] + fn snippet_rendering_tabstop_adjust_offset_between_text_edits() { + // inserting between edits, tabstop should be at (1, 14) + let mut edit = TextEdit::builder(); + edit.replace(TextRange::new(47.into(), 56.into()), "let".to_owned()); + edit.replace( + TextRange::new(58.into(), 90.into()), + "disabled = false;\n ProcMacro {\n disabled,\n }".to_owned(), + ); + let edit = edit.finish(); + let snippets = SnippetEdit::new(vec![Snippet::Tabstop(51.into())]); + + // add an extra space between `ProcMacro` and `{` to insert the tabstop at + check_rendered_snippets_in_source( + r" +fn expander_to_proc_macro() -> ProcMacro { + ProcMacro { + disabled: false, + } +} + +struct ProcMacro { + disabled: bool, +}", + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 13, + }, + }, + new_text: "let", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 14, + }, + end: Position { + line: 1, + character: 14, + }, + }, + new_text: "$0", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 15, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "disabled = false;\n ProcMacro {\n disabled,\n }", + insert_text_format: None, + annotation_id: None, + }, + ] +"#]], + ); + } + + #[test] + fn snippet_rendering_tabstop_adjust_offset_after_text_edits() { + // inserting after edits, tabstop should be before the closing curly of the fn + let mut edit = TextEdit::builder(); + edit.replace(TextRange::new(47.into(), 56.into()), "let".to_owned()); + edit.replace( + TextRange::new(57.into(), 89.into()), + "disabled = false;\n ProcMacro {\n disabled,\n }".to_owned(), + ); + let edit = edit.finish(); + let snippets = SnippetEdit::new(vec![Snippet::Tabstop(109.into())]); + + check_rendered_snippets_in_source( + r" +fn expander_to_proc_macro() -> ProcMacro { + ProcMacro { + disabled: false, + } +} + +struct ProcMacro { + disabled: bool, +}", + edit, + snippets, + expect![[r#" + [ + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 13, + }, + }, + new_text: "let", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 1, + character: 14, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "disabled = false;\n ProcMacro {\n disabled,\n }", + insert_text_format: None, + annotation_id: None, + }, + SnippetTextEdit { + range: Range { + start: Position { + line: 4, + character: 0, + }, + end: Position { + line: 4, + character: 0, + }, + }, + new_text: "$0", + insert_text_format: Some( + Snippet, + ), + annotation_id: None, + }, + ] +"#]], + ); + } + + #[test] + fn snippet_rendering_handle_dos_line_endings() { + // unix -> dos conversion should be handled after placing snippets + let mut edit = TextEdit::builder(); + edit.insert(6.into(), "\n\n->".to_owned()); + + let edit = edit.finish(); + let snippets = SnippetEdit::new(vec![Snippet::Tabstop(10.into())]); + + check_rendered_snippets_in_source( + "yeah\r\n<-tabstop here", edit, snippets, expect![[r#" @@ -2099,38 +2653,23 @@ fn bar(_: usize) {} SnippetTextEdit { range: Range { start: Position { - line: 0, + line: 1, character: 0, }, end: Position { - line: 0, + line: 1, character: 0, }, }, - new_text: "${0:abc}\\\\def\\$", + new_text: "\r\n\r\n->$0", insert_text_format: Some( Snippet, ), annotation_id: None, }, - SnippetTextEdit { - range: Range { - start: Position { - line: 0, - character: 8, - }, - end: Position { - line: 0, - character: 8, - }, - }, - new_text: "ghi\\jkl$", - insert_text_format: None, - annotation_id: None, - }, ] "#]], - ); + ) } // `Url` is not able to parse windows paths on unix machines. diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 88660db7e93b6..72f6d0fde5fe7 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -8,12 +8,10 @@ use std::{ use always_assert::always; use crossbeam_channel::{select, Receiver}; -use flycheck::FlycheckHandle; -use ide_db::base_db::{SourceDatabaseExt, VfsPath}; +use ide_db::base_db::{SourceDatabase, SourceDatabaseExt, VfsPath}; use lsp_server::{Connection, Notification, Request}; use lsp_types::notification::Notification as _; use stdx::thread::ThreadIntent; -use triomphe::Arc; use vfs::FileId; use crate::{ @@ -77,6 +75,7 @@ impl fmt::Display for Event { #[derive(Debug)] pub(crate) enum QueuedTask { CheckIfIndexed(lsp_types::Url), + CheckProcMacroSources(Vec), } #[derive(Debug)] @@ -89,6 +88,7 @@ pub(crate) enum Task { FetchWorkspace(ProjectWorkspaceProgress), FetchBuildData(BuildDataProgress), LoadProcMacros(ProcMacroProgress), + BuildDepsHaveChanged, } #[derive(Debug)] @@ -337,7 +337,7 @@ impl GlobalState { if became_quiescent { if self.config.check_on_save() { // Project has loaded properly, kick off initial flycheck - self.flycheck.iter().for_each(FlycheckHandle::restart_workspace); + self.flycheck.iter().for_each(|flycheck| flycheck.restart_workspace(None)); } if self.config.prefill_caches() { self.prime_caches_queue.request_op("became quiescent".to_owned(), ()); @@ -358,9 +358,7 @@ impl GlobalState { } // Refresh inlay hints if the client supports it. - if (self.send_hint_refresh_query || self.proc_macro_changed) - && self.config.inlay_hints_refresh() - { + if self.send_hint_refresh_query && self.config.inlay_hints_refresh() { self.send_request::((), |_, _| ()); self.send_hint_refresh_query = false; } @@ -555,16 +553,7 @@ impl GlobalState { if let Err(e) = self.fetch_workspace_error() { tracing::error!("FetchWorkspaceError:\n{e}"); } - - let old = Arc::clone(&self.workspaces); self.switch_workspaces("fetched workspace".to_owned()); - let workspaces_updated = !Arc::ptr_eq(&old, &self.workspaces); - - if self.config.run_build_scripts() && workspaces_updated { - self.fetch_build_data_queue - .request_op("workspace updated".to_owned(), ()); - } - (Progress::End, None) } }; @@ -608,6 +597,7 @@ impl GlobalState { self.report_progress("Loading", state, msg, None, None); } } + Task::BuildDepsHaveChanged => self.build_deps_changed = true, } } @@ -686,6 +676,25 @@ impl GlobalState { } }); } + QueuedTask::CheckProcMacroSources(modified_rust_files) => { + let crate_graph = self.analysis_host.raw_database().crate_graph(); + let snap = self.snapshot(); + self.task_pool.handle.spawn_with_sender(stdx::thread::ThreadIntent::Worker, { + move |sender| { + if modified_rust_files.into_iter().any(|file_id| { + // FIXME: Check whether these files could be build script related + match snap.analysis.crates_for(file_id) { + Ok(crates) => { + crates.iter().any(|&krate| crate_graph[krate].is_proc_macro) + } + _ => false, + } + }) { + sender.send(Task::BuildDepsHaveChanged).unwrap(); + } + } + }); + } } } diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 7bd2877b00cba..5895459d1fcf8 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -17,8 +17,9 @@ use std::{iter, mem}; use flycheck::{FlycheckConfig, FlycheckHandle}; use hir::{db::DefDatabase, Change, ProcMacros}; +use ide::CrateId; use ide_db::{ - base_db::{salsa::Durability, CrateGraph, ProcMacroPaths}, + base_db::{salsa::Durability, CrateGraph, ProcMacroPaths, Version}, FxHashMap, }; use itertools::Itertools; @@ -28,7 +29,7 @@ use project_model::{ProjectWorkspace, WorkspaceBuildScripts}; use rustc_hash::FxHashSet; use stdx::{format_to, thread::ThreadIntent}; use triomphe::Arc; -use vfs::{AbsPath, ChangeKind}; +use vfs::{AbsPath, AbsPathBuf, ChangeKind}; use crate::{ config::{Config, FilesWatcher, LinkedProject}, @@ -83,7 +84,7 @@ impl GlobalState { } if self.config.linked_or_discovered_projects() != old_config.linked_or_discovered_projects() { - self.fetch_workspaces_queue.request_op("linked projects changed".to_owned(), false) + self.fetch_workspaces_queue.request_op("discovered projects changed".to_owned(), false) } else if self.config.flycheck() != old_config.flycheck() { self.reload_flycheck(); } @@ -106,9 +107,11 @@ impl GlobalState { }; let mut message = String::new(); - if self.proc_macro_changed { + if self.build_deps_changed { status.health = lsp_ext::Health::Warning; - message.push_str("Proc-macros have changed and need to be rebuilt.\n\n"); + message.push_str( + "Proc-macros and/or build scripts have changed and need to be rebuilt.\n\n", + ); } if self.fetch_build_data_error().is_err() { status.health = lsp_ext::Health::Warning; @@ -234,7 +237,6 @@ impl GlobalState { it.clone(), cargo_config.target.as_deref(), &cargo_config.extra_env, - None, )) } }) @@ -300,13 +302,13 @@ impl GlobalState { pub(crate) fn fetch_proc_macros(&mut self, cause: Cause, paths: Vec) { tracing::info!(%cause, "will load proc macros"); - let dummy_replacements = self.config.dummy_replacements().clone(); + let ignored_proc_macros = self.config.ignored_proc_macros().clone(); let proc_macro_clients = self.proc_macro_clients.clone(); self.task_pool.handle.spawn_with_sender(ThreadIntent::Worker, move |sender| { sender.send(Task::LoadProcMacros(ProcMacroProgress::Begin)).unwrap(); - let dummy_replacements = &dummy_replacements; + let ignored_proc_macros = &ignored_proc_macros; let progress = { let sender = sender.clone(); &move |msg| { @@ -334,7 +336,12 @@ impl GlobalState { crate_name .as_deref() .and_then(|crate_name| { - dummy_replacements.get(crate_name).map(|v| &**v) + ignored_proc_macros.iter().find_map( + |(name, macros)| { + eq_ignore_underscore(name, crate_name) + .then_some(&**macros) + }, + ) }) .unwrap_or_default(), ) @@ -404,6 +411,10 @@ impl GlobalState { if *force_reload_crate_graph { self.recreate_crate_graph(cause); } + if self.build_deps_changed && self.config.run_build_scripts() { + self.build_deps_changed = false; + self.fetch_build_data_queue.request_op("build_deps_changed".to_owned(), ()); + } // Current build scripts do not match the version of the active // workspace, so there's nothing for us to update. return; @@ -415,6 +426,11 @@ impl GlobalState { // we don't care about build-script results, they are stale. // FIXME: can we abort the build scripts here? self.workspaces = Arc::new(workspaces); + + if self.config.run_build_scripts() { + self.build_deps_changed = false; + self.fetch_build_data_queue.request_op("workspace updated".to_owned(), ()); + } } if let FilesWatcher::Client = self.config.files().watcher { @@ -464,8 +480,23 @@ impl GlobalState { None => ws.find_sysroot_proc_macro_srv()?, }; + let env = + match ws { + ProjectWorkspace::Cargo { cargo_config_extra_env, sysroot, .. } => { + cargo_config_extra_env + .iter() + .chain(self.config.extra_env()) + .map(|(a, b)| (a.clone(), b.clone())) + .chain(sysroot.as_ref().map(|it| { + ("RUSTUP_TOOLCHAIN".to_owned(), it.root().to_string()) + })) + .collect() + } + _ => Default::default(), + }; tracing::info!("Using proc-macro server at {path}"); - ProcMacroServer::spawn(path.clone()).map_err(|err| { + + ProcMacroServer::spawn(path.clone(), &env).map_err(|err| { tracing::error!( "Failed to run proc-macro server from path {path}, error: {err:?}", ); @@ -494,15 +525,15 @@ impl GlobalState { } fn recreate_crate_graph(&mut self, cause: String) { - // Create crate graph from all the workspaces - let (crate_graph, proc_macro_paths, crate_graph_file_dependencies) = { + { + // Create crate graph from all the workspaces let vfs = &mut self.vfs.write().0; let loader = &mut self.loader; // crate graph construction relies on these paths, record them so when one of them gets // deleted or created we trigger a reconstruction of the crate graph let mut crate_graph_file_dependencies = FxHashSet::default(); - let mut load = |path: &AbsPath| { + let load = |path: &AbsPath| { let _p = tracing::span!(tracing::Level::DEBUG, "switch_workspaces::load").entered(); let vfs_path = vfs::VfsPath::from(path.to_path_buf()); crate_graph_file_dependencies.insert(vfs_path.clone()); @@ -517,32 +548,26 @@ impl GlobalState { } }; - let mut crate_graph = CrateGraph::default(); - let mut proc_macros = Vec::default(); - for ws in &**self.workspaces { - let (other, mut crate_proc_macros) = - ws.to_crate_graph(&mut load, self.config.extra_env()); - crate_graph.extend(other, &mut crate_proc_macros, |_| {}); - proc_macros.push(crate_proc_macros); - } - (crate_graph, proc_macros, crate_graph_file_dependencies) - }; + let (crate_graph, proc_macro_paths, layouts, toolchains) = + ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load); - let mut change = Change::new(); - if self.config.expand_proc_macros() { - change.set_proc_macros( - crate_graph - .iter() - .map(|id| (id, Err("Proc-macros have not been built yet".to_owned()))) - .collect(), - ); - self.fetch_proc_macros_queue.request_op(cause, proc_macro_paths); + let mut change = Change::new(); + if self.config.expand_proc_macros() { + change.set_proc_macros( + crate_graph + .iter() + .map(|id| (id, Err("Proc-macros have not been built yet".to_owned()))) + .collect(), + ); + self.fetch_proc_macros_queue.request_op(cause, proc_macro_paths); + } + change.set_crate_graph(crate_graph); + change.set_target_data_layouts(layouts); + change.set_toolchains(toolchains); + self.analysis_host.apply_change(change); + self.crate_graph_file_dependencies = crate_graph_file_dependencies; } - change.set_crate_graph(crate_graph); - self.analysis_host.apply_change(change); - self.crate_graph_file_dependencies = crate_graph_file_dependencies; self.process_changes(); - self.reload_flycheck(); } @@ -605,6 +630,7 @@ impl GlobalState { 0, Box::new(move |msg| sender.send(msg).unwrap()), config, + None, self.config.root_path().clone(), )], flycheck::InvocationStrategy::PerWorkspace => { @@ -612,23 +638,32 @@ impl GlobalState { .iter() .enumerate() .filter_map(|(id, w)| match w { - ProjectWorkspace::Cargo { cargo, .. } => Some((id, cargo.workspace_root())), - ProjectWorkspace::Json { project, .. } => { + ProjectWorkspace::Cargo { cargo, sysroot, .. } => Some(( + id, + cargo.workspace_root(), + sysroot.as_ref().ok().map(|sysroot| sysroot.root().to_owned()), + )), + ProjectWorkspace::Json { project, sysroot, .. } => { // Enable flychecks for json projects if a custom flycheck command was supplied // in the workspace configuration. match config { - FlycheckConfig::CustomCommand { .. } => Some((id, project.path())), + FlycheckConfig::CustomCommand { .. } => Some(( + id, + project.path(), + sysroot.as_ref().ok().map(|sysroot| sysroot.root().to_owned()), + )), _ => None, } } ProjectWorkspace::DetachedFiles { .. } => None, }) - .map(|(id, root)| { + .map(|(id, root, sysroot_root)| { let sender = sender.clone(); FlycheckHandle::spawn( id, Box::new(move |msg| sender.send(msg).unwrap()), config.clone(), + sysroot_root, root.to_path_buf(), ) }) @@ -639,6 +674,69 @@ impl GlobalState { } } +// FIXME: Move this into load-cargo? +pub fn ws_to_crate_graph( + workspaces: &[ProjectWorkspace], + extra_env: &FxHashMap, + mut load: impl FnMut(&AbsPath) -> Option, +) -> ( + CrateGraph, + Vec, AbsPathBuf), String>>>, + Vec, Arc>>, + Vec>, +) { + let mut crate_graph = CrateGraph::default(); + let mut proc_macro_paths = Vec::default(); + let mut layouts = Vec::default(); + let mut toolchains = Vec::default(); + let e = Err(Arc::from("missing layout")); + for ws in workspaces { + let (other, mut crate_proc_macros) = ws.to_crate_graph(&mut load, extra_env); + let num_layouts = layouts.len(); + let num_toolchains = toolchains.len(); + let (toolchain, layout) = match ws { + ProjectWorkspace::Cargo { toolchain, target_layout, .. } + | ProjectWorkspace::Json { toolchain, target_layout, .. } => { + (toolchain.clone(), target_layout.clone()) + } + ProjectWorkspace::DetachedFiles { .. } => { + (None, Err("detached files have no layout".into())) + } + }; + + let mapping = crate_graph.extend( + other, + &mut crate_proc_macros, + |(cg_id, cg_data), (_o_id, o_data)| { + // if the newly created crate graph's layout is equal to the crate of the merged graph, then + // we can merge the crates. + let id = cg_id.into_raw().into_u32() as usize; + layouts[id] == layout && toolchains[id] == toolchain && cg_data == o_data + }, + ); + // Populate the side tables for the newly merged crates + mapping.values().for_each(|val| { + let idx = val.into_raw().into_u32() as usize; + // we only need to consider crates that were not merged and remapped, as the + // ones that were remapped already have the correct layout and toolchain + if idx >= num_layouts { + if layouts.len() <= idx { + layouts.resize(idx + 1, e.clone()); + } + layouts[idx] = layout.clone(); + } + if idx >= num_toolchains { + if toolchains.len() <= idx { + toolchains.resize(idx + 1, None); + } + toolchains[idx] = toolchain.clone(); + } + }); + proc_macro_paths.push(crate_proc_macros); + } + (crate_graph, proc_macro_paths, layouts, toolchains) +} + pub(crate) fn should_refresh_for_change(path: &AbsPath, change_kind: ChangeKind) -> bool { const IMPLICIT_TARGET_FILES: &[&str] = &["build.rs", "src/main.rs", "src/lib.rs"]; const IMPLICIT_TARGET_DIRS: &[&str] = &["src/bin", "examples", "tests", "benches"]; @@ -683,3 +781,18 @@ pub(crate) fn should_refresh_for_change(path: &AbsPath, change_kind: ChangeKind) } false } + +/// Similar to [`str::eq_ignore_ascii_case`] but instead of ignoring +/// case, we say that `-` and `_` are equal. +fn eq_ignore_underscore(s1: &str, s2: &str) -> bool { + if s1.len() != s2.len() { + return false; + } + + s1.as_bytes().iter().zip(s2.as_bytes()).all(|(c1, c2)| { + let c1_underscore = c1 == &b'_' || c1 == &b'-'; + let c2_underscore = c2 == &b'_' || c2 == &b'-'; + + c1 == c2 || (c1_underscore && c2_underscore) + }) +} diff --git a/crates/rust-analyzer/tests/crate_graph.rs b/crates/rust-analyzer/tests/crate_graph.rs new file mode 100644 index 0000000000000..efd42fadf7e96 --- /dev/null +++ b/crates/rust-analyzer/tests/crate_graph.rs @@ -0,0 +1,118 @@ +use std::path::PathBuf; + +use project_model::{CargoWorkspace, ProjectWorkspace, Sysroot, WorkspaceBuildScripts}; +use rust_analyzer::ws_to_crate_graph; +use rustc_hash::FxHashMap; +use serde::de::DeserializeOwned; +use vfs::{AbsPathBuf, FileId}; + +fn load_cargo_with_fake_sysroot(file: &str) -> ProjectWorkspace { + let meta = get_test_json_file(file); + let cargo_workspace = CargoWorkspace::new(meta); + ProjectWorkspace::Cargo { + cargo: cargo_workspace, + build_scripts: WorkspaceBuildScripts::default(), + sysroot: Ok(get_fake_sysroot()), + rustc: Err(None), + rustc_cfg: Vec::new(), + cfg_overrides: Default::default(), + toolchain: None, + target_layout: Err("target_data_layout not loaded".into()), + cargo_config_extra_env: Default::default(), + } +} + +fn get_test_json_file(file: &str) -> T { + let base = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let file = base.join("tests/test_data").join(file); + let data = std::fs::read_to_string(file).unwrap(); + let mut json = data.parse::().unwrap(); + fixup_paths(&mut json); + return serde_json::from_value(json).unwrap(); + + fn fixup_paths(val: &mut serde_json::Value) { + match val { + serde_json::Value::String(s) => replace_root(s, true), + serde_json::Value::Array(vals) => vals.iter_mut().for_each(fixup_paths), + serde_json::Value::Object(kvals) => kvals.values_mut().for_each(fixup_paths), + serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_) => { + } + } + } +} + +fn replace_root(s: &mut String, direction: bool) { + if direction { + let root = if cfg!(windows) { r#"C:\\ROOT\"# } else { "/ROOT/" }; + *s = s.replace("$ROOT$", root) + } else { + let root = if cfg!(windows) { r#"C:\\\\ROOT\\"# } else { "/ROOT/" }; + *s = s.replace(root, "$ROOT$") + } +} + +fn get_fake_sysroot_path() -> PathBuf { + let base = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + base.join("../project-model/test_data/fake-sysroot") +} + +fn get_fake_sysroot() -> Sysroot { + let sysroot_path = get_fake_sysroot_path(); + // there's no `libexec/` directory with a `proc-macro-srv` binary in that + // fake sysroot, so we give them both the same path: + let sysroot_dir = AbsPathBuf::assert(sysroot_path); + let sysroot_src_dir = sysroot_dir.clone(); + Sysroot::load(sysroot_dir, Some(Ok(sysroot_src_dir)), false) +} + +#[test] +fn test_deduplicate_origin_dev() { + let path_map = &mut FxHashMap::default(); + let ws = load_cargo_with_fake_sysroot("deduplication_crate_graph_A.json"); + let ws2 = load_cargo_with_fake_sysroot("deduplication_crate_graph_B.json"); + + let (crate_graph, ..) = ws_to_crate_graph(&[ws, ws2], &Default::default(), |path| { + let len = path_map.len(); + Some(*path_map.entry(path.to_path_buf()).or_insert(FileId::from_raw(len as u32))) + }); + + let mut crates_named_p2 = vec![]; + for id in crate_graph.iter() { + let krate = &crate_graph[id]; + if let Some(name) = krate.display_name.as_ref() { + if name.to_string() == "p2" { + crates_named_p2.push(krate); + } + } + } + + assert!(crates_named_p2.len() == 1); + let p2 = crates_named_p2[0]; + assert!(p2.origin.is_local()); +} + +#[test] +fn test_deduplicate_origin_dev_rev() { + let path_map = &mut FxHashMap::default(); + let ws = load_cargo_with_fake_sysroot("deduplication_crate_graph_B.json"); + let ws2 = load_cargo_with_fake_sysroot("deduplication_crate_graph_A.json"); + + let (crate_graph, ..) = ws_to_crate_graph(&[ws, ws2], &Default::default(), |path| { + let len = path_map.len(); + Some(*path_map.entry(path.to_path_buf()).or_insert(FileId::from_raw(len as u32))) + }); + + let mut crates_named_p2 = vec![]; + for id in crate_graph.iter() { + let krate = &crate_graph[id]; + if let Some(name) = krate.display_name.as_ref() { + if name.to_string() == "p2" { + crates_named_p2.push(krate); + } + } + } + + assert!(crates_named_p2.len() == 1); + let p2 = crates_named_p2[0]; + assert!(p2.origin.is_local()); +} diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs index 79ae0c30cfc4c..960f5b531d44f 100644 --- a/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/crates/rust-analyzer/tests/slow-tests/main.rs @@ -911,20 +911,18 @@ fn root_contains_symlink_out_dirs_check() { #[cfg(any(feature = "sysroot-abi", rust_analyzer))] fn resolve_proc_macro() { use expect_test::expect; + use vfs::AbsPathBuf; if skip_slow_tests() { return; } - // skip using the sysroot config as to prevent us from loading the sysroot sources - let mut rustc = std::process::Command::new(toolchain::rustc()); - rustc.args(["--print", "sysroot"]); - let output = rustc.output().unwrap(); - let sysroot = - vfs::AbsPathBuf::try_from(std::str::from_utf8(&output.stdout).unwrap().trim()).unwrap(); + let sysroot = project_model::Sysroot::discover_no_source( + &AbsPathBuf::assert(std::env::current_dir().unwrap()), + &Default::default(), + ) + .unwrap(); - let standalone_server_name = - format!("rust-analyzer-proc-macro-srv{}", std::env::consts::EXE_SUFFIX); - let proc_macro_server_path = sysroot.join("libexec").join(&standalone_server_name); + let proc_macro_server_path = sysroot.discover_proc_macro_srv().unwrap(); let server = Project::with_fixture( r###" diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs index d02cb45b8e35f..392a71702070e 100644 --- a/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/crates/rust-analyzer/tests/slow-tests/support.rs @@ -101,8 +101,13 @@ impl Project<'_> { }; }); - let FixtureWithProjectMeta { fixture, mini_core, proc_macro_names, toolchain } = - FixtureWithProjectMeta::parse(self.fixture); + let FixtureWithProjectMeta { + fixture, + mini_core, + proc_macro_names, + toolchain, + target_data_layout: _, + } = FixtureWithProjectMeta::parse(self.fixture); assert!(proc_macro_names.is_empty()); assert!(mini_core.is_none()); assert!(toolchain.is_none()); diff --git a/crates/rust-analyzer/tests/slow-tests/tidy.rs b/crates/rust-analyzer/tests/slow-tests/tidy.rs index 3e38fc3ebcd7a..78da4487d4c9e 100644 --- a/crates/rust-analyzer/tests/slow-tests/tidy.rs +++ b/crates/rust-analyzer/tests/slow-tests/tidy.rs @@ -9,27 +9,6 @@ use xshell::Shell; #[cfg(not(feature = "in-rust-tree"))] use xshell::cmd; -#[cfg(not(feature = "in-rust-tree"))] -#[test] -fn check_code_formatting() { - let sh = &Shell::new().unwrap(); - sh.change_dir(sourcegen::project_root()); - - let out = cmd!(sh, "rustup run stable rustfmt --version").read().unwrap(); - if !out.contains("stable") { - panic!( - "Failed to run rustfmt from toolchain 'stable'. \ - Please run `rustup component add rustfmt --toolchain stable` to install it.", - ) - } - - let res = cmd!(sh, "rustup run stable cargo fmt -- --check").run(); - if res.is_err() { - let _ = cmd!(sh, "rustup run stable cargo fmt").run(); - } - res.unwrap() -} - #[test] fn check_lsp_extensions_docs() { let sh = &Shell::new().unwrap(); diff --git a/crates/project-model/test_data/deduplication_crate_graph_A.json b/crates/rust-analyzer/tests/test_data/deduplication_crate_graph_A.json similarity index 100% rename from crates/project-model/test_data/deduplication_crate_graph_A.json rename to crates/rust-analyzer/tests/test_data/deduplication_crate_graph_A.json diff --git a/crates/project-model/test_data/deduplication_crate_graph_B.json b/crates/rust-analyzer/tests/test_data/deduplication_crate_graph_B.json similarity index 100% rename from crates/project-model/test_data/deduplication_crate_graph_B.json rename to crates/rust-analyzer/tests/test_data/deduplication_crate_graph_B.json diff --git a/crates/salsa/src/doctest.rs b/crates/salsa/src/doctest.rs deleted file mode 100644 index 29a80663567fe..0000000000000 --- a/crates/salsa/src/doctest.rs +++ /dev/null @@ -1,115 +0,0 @@ -//! -#![allow(dead_code)] - -/// Test that a database with a key/value that is not `Send` will, -/// indeed, not be `Send`. -/// -/// ```compile_fail,E0277 -/// use std::rc::Rc; -/// -/// #[salsa::query_group(NoSendSyncStorage)] -/// trait NoSendSyncDatabase: salsa::Database { -/// fn no_send_sync_value(&self, key: bool) -> Rc; -/// fn no_send_sync_key(&self, key: Rc) -> bool; -/// } -/// -/// fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Rc { -/// Rc::new(key) -/// } -/// -/// fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Rc) -> bool { -/// *key -/// } -/// -/// #[salsa::database(NoSendSyncStorage)] -/// #[derive(Default)] -/// struct DatabaseImpl { -/// storage: salsa::Storage, -/// } -/// -/// impl salsa::Database for DatabaseImpl { -/// } -/// -/// fn is_send(_: T) { } -/// -/// fn assert_send() { -/// is_send(DatabaseImpl::default()); -/// } -/// ``` -fn test_key_not_send_db_not_send() {} - -/// Test that a database with a key/value that is not `Sync` will not -/// be `Send`. -/// -/// ```compile_fail,E0277 -/// use std::rc::Rc; -/// use std::cell::Cell; -/// -/// #[salsa::query_group(NoSendSyncStorage)] -/// trait NoSendSyncDatabase: salsa::Database { -/// fn no_send_sync_value(&self, key: bool) -> Cell; -/// fn no_send_sync_key(&self, key: Cell) -> bool; -/// } -/// -/// fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Cell { -/// Cell::new(key) -/// } -/// -/// fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Cell) -> bool { -/// *key -/// } -/// -/// #[salsa::database(NoSendSyncStorage)] -/// #[derive(Default)] -/// struct DatabaseImpl { -/// runtime: salsa::Storage, -/// } -/// -/// impl salsa::Database for DatabaseImpl { -/// } -/// -/// fn is_send(_: T) { } -/// -/// fn assert_send() { -/// is_send(DatabaseImpl::default()); -/// } -/// ``` -fn test_key_not_sync_db_not_send() {} - -/// Test that a database with a key/value that is not `Sync` will -/// not be `Sync`. -/// -/// ```compile_fail,E0277 -/// use std::cell::Cell; -/// use std::rc::Rc; -/// -/// #[salsa::query_group(NoSendSyncStorage)] -/// trait NoSendSyncDatabase: salsa::Database { -/// fn no_send_sync_value(&self, key: bool) -> Cell; -/// fn no_send_sync_key(&self, key: Cell) -> bool; -/// } -/// -/// fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Cell { -/// Cell::new(key) -/// } -/// -/// fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Cell) -> bool { -/// *key -/// } -/// -/// #[salsa::database(NoSendSyncStorage)] -/// #[derive(Default)] -/// struct DatabaseImpl { -/// runtime: salsa::Storage, -/// } -/// -/// impl salsa::Database for DatabaseImpl { -/// } -/// -/// fn is_sync(_: T) { } -/// -/// fn assert_send() { -/// is_sync(DatabaseImpl::default()); -/// } -/// ``` -fn test_key_not_sync_db_not_sync() {} diff --git a/crates/salsa/src/lib.rs b/crates/salsa/src/lib.rs index 2d58beafb2a0b..668dcfd925d8d 100644 --- a/crates/salsa/src/lib.rs +++ b/crates/salsa/src/lib.rs @@ -11,7 +11,6 @@ //! from previous invocations as appropriate. mod derived; -mod doctest; mod durability; mod hash; mod input; diff --git a/crates/syntax/rust.ungram b/crates/syntax/rust.ungram index c3010d090c6b9..c3d8e97c436cc 100644 --- a/crates/syntax/rust.ungram +++ b/crates/syntax/rust.ungram @@ -367,6 +367,7 @@ Expr = | RecordExpr | RefExpr | ReturnExpr +| BecomeExpr | TryExpr | TupleExpr | WhileExpr @@ -528,6 +529,9 @@ MatchGuard = ReturnExpr = Attr* 'return' Expr? +BecomeExpr = + Attr* 'become' Expr + YieldExpr = Attr* 'yield' Expr? @@ -610,7 +614,7 @@ TypeBoundList = TypeBound = Lifetime -| ('?' | '~' 'const')? Type +| ('~' 'const' | 'const')? 'async'? '?'? Type //************************// // Patterns // diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs index bc9c54d0b73ec..41d33c457ce70 100644 --- a/crates/syntax/src/ast/edit_in_place.rs +++ b/crates/syntax/src/ast/edit_in_place.rs @@ -1007,20 +1007,24 @@ impl ast::IdentPat { } pub trait HasVisibilityEdit: ast::HasVisibility { - fn set_visibility(&self, visibility: ast::Visibility) { - match self.visibility() { - Some(current_visibility) => { - ted::replace(current_visibility.syntax(), visibility.syntax()) - } - None => { - let vis_before = self - .syntax() - .children_with_tokens() - .find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR)) - .unwrap_or_else(|| self.syntax().first_child_or_token().unwrap()); - - ted::insert(ted::Position::before(vis_before), visibility.syntax()); + fn set_visibility(&self, visibility: Option) { + if let Some(visibility) = visibility { + match self.visibility() { + Some(current_visibility) => { + ted::replace(current_visibility.syntax(), visibility.syntax()) + } + None => { + let vis_before = self + .syntax() + .children_with_tokens() + .find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR)) + .unwrap_or_else(|| self.syntax().first_child_or_token().unwrap()); + + ted::insert(ted::Position::before(vis_before), visibility.syntax()); + } } + } else if let Some(visibility) = self.visibility() { + ted::remove(visibility.syntax()); } } } diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs index 6c86e591044a8..75971861aa80e 100644 --- a/crates/syntax/src/ast/generated/nodes.rs +++ b/crates/syntax/src/ast/generated/nodes.rs @@ -1095,6 +1095,16 @@ impl ReturnExpr { pub fn expr(&self) -> Option { support::child(&self.syntax) } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct BecomeExpr { + pub(crate) syntax: SyntaxNode, +} +impl ast::HasAttrs for BecomeExpr {} +impl BecomeExpr { + pub fn become_token(&self) -> Option { support::token(&self.syntax, T![become]) } + pub fn expr(&self) -> Option { support::child(&self.syntax) } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TryExpr { pub(crate) syntax: SyntaxNode, @@ -1400,9 +1410,10 @@ pub struct TypeBound { } impl TypeBound { pub fn lifetime(&self) -> Option { support::child(&self.syntax) } - pub fn question_mark_token(&self) -> Option { support::token(&self.syntax, T![?]) } pub fn tilde_token(&self) -> Option { support::token(&self.syntax, T![~]) } pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } + pub fn async_token(&self) -> Option { support::token(&self.syntax, T![async]) } + pub fn question_mark_token(&self) -> Option { support::token(&self.syntax, T![?]) } pub fn ty(&self) -> Option { support::child(&self.syntax) } } @@ -1633,6 +1644,7 @@ pub enum Expr { RecordExpr(RecordExpr), RefExpr(RefExpr), ReturnExpr(ReturnExpr), + BecomeExpr(BecomeExpr), TryExpr(TryExpr), TupleExpr(TupleExpr), WhileExpr(WhileExpr), @@ -2792,6 +2804,17 @@ impl AstNode for ReturnExpr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for BecomeExpr { + fn can_cast(kind: SyntaxKind) -> bool { kind == BECOME_EXPR } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for TryExpr { fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR } fn cast(syntax: SyntaxNode) -> Option { @@ -3540,6 +3563,9 @@ impl From for Expr { impl From for Expr { fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) } } +impl From for Expr { + fn from(node: BecomeExpr) -> Expr { Expr::BecomeExpr(node) } +} impl From for Expr { fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) } } @@ -3593,6 +3619,7 @@ impl AstNode for Expr { | RECORD_EXPR | REF_EXPR | RETURN_EXPR + | BECOME_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR @@ -3632,6 +3659,7 @@ impl AstNode for Expr { RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }), REF_EXPR => Expr::RefExpr(RefExpr { syntax }), RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), + BECOME_EXPR => Expr::BecomeExpr(BecomeExpr { syntax }), TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), @@ -3673,6 +3701,7 @@ impl AstNode for Expr { Expr::RecordExpr(it) => &it.syntax, Expr::RefExpr(it) => &it.syntax, Expr::ReturnExpr(it) => &it.syntax, + Expr::BecomeExpr(it) => &it.syntax, Expr::TryExpr(it) => &it.syntax, Expr::TupleExpr(it) => &it.syntax, Expr::WhileExpr(it) => &it.syntax, @@ -4150,6 +4179,7 @@ impl AstNode for AnyHasAttrs { | RANGE_EXPR | REF_EXPR | RETURN_EXPR + | BECOME_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR @@ -4851,6 +4881,11 @@ impl std::fmt::Display for ReturnExpr { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for BecomeExpr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for TryExpr { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 120d801c8d17e..02246fc3291d3 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -1147,7 +1147,7 @@ pub mod tokens { pub(super) static SOURCE_FILE: Lazy> = Lazy::new(|| { SourceFile::parse( - "const C: <()>::Item = ( true && true , true || true , 1 != 1, 2 == 2, 3 < 3, 4 <= 4, 5 > 5, 6 >= 6, !true, *p, &p , &mut p, { let a @ [] })\n;\n\n", + "const C: <()>::Item = ( true && true , true || true , 1 != 1, 2 == 2, 3 < 3, 4 <= 4, 5 > 5, 6 >= 6, !true, *p, &p , &mut p, { let a @ [] })\n;\n\nimpl A for B where: {}", ) }); diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 6e5e4127f4d43..1bc1ef8434fc7 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -569,6 +569,26 @@ impl fmt::Display for NameOrNameRef { } } +impl ast::AstNode for NameOrNameRef { + fn can_cast(kind: SyntaxKind) -> bool { + matches!(kind, SyntaxKind::NAME | SyntaxKind::NAME_REF) + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + SyntaxKind::NAME => NameOrNameRef::Name(ast::Name { syntax }), + SyntaxKind::NAME_REF => NameOrNameRef::NameRef(ast::NameRef { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + NameOrNameRef::NameRef(it) => it.syntax(), + NameOrNameRef::Name(it) => it.syntax(), + } + } +} + impl NameOrNameRef { pub fn text(&self) -> TokenText<'_> { match self { diff --git a/crates/syntax/src/ast/prec.rs b/crates/syntax/src/ast/prec.rs index 9ddf5a0a9804c..9131cd2f17993 100644 --- a/crates/syntax/src/ast/prec.rs +++ b/crates/syntax/src/ast/prec.rs @@ -130,8 +130,8 @@ impl Expr { // ContinueExpr(_) => (0, 0), - ClosureExpr(_) | ReturnExpr(_) | YieldExpr(_) | YeetExpr(_) | BreakExpr(_) - | OffsetOfExpr(_) | FormatArgsExpr(_) | AsmExpr(_) => (0, 1), + ClosureExpr(_) | ReturnExpr(_) | BecomeExpr(_) | YieldExpr(_) | YeetExpr(_) + | BreakExpr(_) | OffsetOfExpr(_) | FormatArgsExpr(_) | AsmExpr(_) => (0, 1), RangeExpr(_) => (5, 5), @@ -288,6 +288,7 @@ impl Expr { PrefixExpr(e) => e.op_token(), RefExpr(e) => e.amp_token(), ReturnExpr(e) => e.return_token(), + BecomeExpr(e) => e.become_token(), TryExpr(e) => e.question_mark_token(), YieldExpr(e) => e.yield_token(), YeetExpr(e) => e.do_token(), @@ -316,7 +317,8 @@ impl Expr { // For BinExpr and RangeExpr this is technically wrong -- the child can be on the left... BinExpr(_) | RangeExpr(_) | BreakExpr(_) | ContinueExpr(_) | PrefixExpr(_) - | RefExpr(_) | ReturnExpr(_) | YieldExpr(_) | YeetExpr(_) | LetExpr(_) => self + | RefExpr(_) | ReturnExpr(_) | BecomeExpr(_) | YieldExpr(_) | YeetExpr(_) + | LetExpr(_) => self .syntax() .parent() .and_then(Expr::cast) diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index 960889b742112..b755de86d32c5 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -27,11 +27,6 @@ extern crate ra_ap_rustc_lexer as rustc_lexer; #[cfg(feature = "in-rust-tree")] extern crate rustc_lexer; -#[allow(unused)] -macro_rules! eprintln { - ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; -} - mod parsing; mod ptr; mod syntax_error; diff --git a/crates/syntax/src/tests/ast_src.rs b/crates/syntax/src/tests/ast_src.rs index 341bda892ba1c..8221c577892de 100644 --- a/crates/syntax/src/tests/ast_src.rs +++ b/crates/syntax/src/tests/ast_src.rs @@ -67,8 +67,9 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc { keywords: &[ "as", "async", "await", "box", "break", "const", "continue", "crate", "do", "dyn", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "macro", - "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", - "super", "trait", "true", "try", "type", "unsafe", "use", "where", "while", "yield", + "match", "mod", "move", "mut", "pub", "ref", "return", "become", "self", "Self", "static", + "struct", "super", "trait", "true", "try", "type", "unsafe", "use", "where", "while", + "yield", ], contextual_keywords: &[ "auto", @@ -154,6 +155,7 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc { "BLOCK_EXPR", "STMT_LIST", "RETURN_EXPR", + "BECOME_EXPR", "YIELD_EXPR", "YEET_EXPR", "LET_EXPR", diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs index 28e757e81bb2c..e118262b4edd9 100644 --- a/crates/test-fixture/src/lib.rs +++ b/crates/test-fixture/src/lib.rs @@ -1,10 +1,9 @@ //! A set of high-level utility fixture methods to use in tests. -use std::{mem, ops::Not, str::FromStr, sync}; +use std::{iter, mem, ops::Not, str::FromStr, sync}; use base_db::{ - CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, DependencyKind, - Edition, Env, FileChange, FileSet, LangCrateOrigin, SourceDatabaseExt, SourceRoot, Version, - VfsPath, + CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env, + FileChange, FileSet, LangCrateOrigin, SourceDatabaseExt, SourceRoot, Version, VfsPath, }; use cfg::CfgOptions; use hir_expand::{ @@ -118,8 +117,14 @@ impl ChangeFixture { ra_fixture: &str, mut proc_macro_defs: Vec<(String, ProcMacro)>, ) -> ChangeFixture { - let FixtureWithProjectMeta { fixture, mini_core, proc_macro_names, toolchain } = - FixtureWithProjectMeta::parse(ra_fixture); + let FixtureWithProjectMeta { + fixture, + mini_core, + proc_macro_names, + toolchain, + target_data_layout, + } = FixtureWithProjectMeta::parse(ra_fixture); + let target_data_layout = Ok(target_data_layout.into()); let toolchain = Some({ let channel = toolchain.as_deref().unwrap_or("stable"); Version::parse(&format!("1.76.0-{channel}")).unwrap() @@ -131,7 +136,6 @@ impl ChangeFixture { let mut crates = FxHashMap::default(); let mut crate_deps = Vec::new(); let mut default_crate_root: Option = None; - let mut default_target_data_layout: Option = None; let mut default_cfg = CfgOptions::default(); let mut default_env = Env::new_for_test_fixture(); @@ -187,11 +191,6 @@ impl ChangeFixture { meta.env, false, origin, - meta.target_data_layout - .as_deref() - .map(From::from) - .ok_or_else(|| "target_data_layout unset".into()), - toolchain.clone(), ); let prev = crates.insert(crate_name.clone(), crate_id); assert!(prev.is_none(), "multiple crates with same name: {}", crate_name); @@ -205,7 +204,6 @@ impl ChangeFixture { default_crate_root = Some(file_id); default_cfg.extend(meta.cfg.into_iter()); default_env.extend(meta.env.iter().map(|(x, y)| (x.to_owned(), y.to_owned()))); - default_target_data_layout = meta.target_data_layout; } source_change.change_file(file_id, Some(text.into())); @@ -228,10 +226,6 @@ impl ChangeFixture { default_env, false, CrateOrigin::Local { repo: None, name: None }, - default_target_data_layout - .map(|it| it.into()) - .ok_or_else(|| "target_data_layout unset".into()), - toolchain.clone(), ); } else { for (from, to, prelude) in crate_deps { @@ -240,20 +234,11 @@ impl ChangeFixture { crate_graph .add_dep( from_id, - Dependency::with_prelude( - CrateName::new(&to).unwrap(), - to_id, - prelude, - DependencyKind::Normal, - ), + Dependency::with_prelude(CrateName::new(&to).unwrap(), to_id, prelude), ) .unwrap(); } } - let target_layout = crate_graph.iter().next().map_or_else( - || Err("target_data_layout unset".into()), - |it| crate_graph[it].target_layout.clone(), - ); if let Some(mini_core) = mini_core { let core_file = file_id; @@ -277,20 +262,11 @@ impl ChangeFixture { Env::new_for_test_fixture(), false, CrateOrigin::Lang(LangCrateOrigin::Core), - target_layout.clone(), - toolchain.clone(), ); for krate in all_crates { crate_graph - .add_dep( - krate, - Dependency::new( - CrateName::new("core").unwrap(), - core_crate, - DependencyKind::Normal, - ), - ) + .add_dep(krate, Dependency::new(CrateName::new("core").unwrap(), core_crate)) .unwrap(); } } @@ -322,8 +298,6 @@ impl ChangeFixture { Env::new_for_test_fixture(), true, CrateOrigin::Local { repo: None, name: None }, - target_layout, - toolchain, ); proc_macros.insert(proc_macros_crate, Ok(proc_macro)); @@ -331,11 +305,7 @@ impl ChangeFixture { crate_graph .add_dep( krate, - Dependency::new( - CrateName::new("proc_macros").unwrap(), - proc_macros_crate, - DependencyKind::Normal, - ), + Dependency::new(CrateName::new("proc_macros").unwrap(), proc_macros_crate), ) .unwrap(); } @@ -346,17 +316,20 @@ impl ChangeFixture { SourceRootKind::Library => SourceRoot::new_library(mem::take(&mut file_set)), }; roots.push(root); - source_change.set_roots(roots); - source_change.set_crate_graph(crate_graph); - - ChangeFixture { - file_position, - files, - change: Change { - source_change, - proc_macros: proc_macros.is_empty().not().then_some(proc_macros), - }, - } + + let mut change = Change { + source_change, + proc_macros: proc_macros.is_empty().not().then_some(proc_macros), + toolchains: Some(iter::repeat(toolchain).take(crate_graph.len()).collect()), + target_data_layouts: Some( + iter::repeat(target_data_layout).take(crate_graph.len()).collect(), + ), + }; + + change.source_change.set_roots(roots); + change.source_change.set_crate_graph(crate_graph); + + ChangeFixture { file_position, files, change } } } @@ -374,6 +347,7 @@ pub fn identity(_attr: TokenStream, item: TokenStream) -> TokenStream { name: "identity".into(), kind: ProcMacroKind::Attr, expander: sync::Arc::new(IdentityProcMacroExpander), + disabled: false, }, ), ( @@ -388,6 +362,7 @@ pub fn derive_identity(item: TokenStream) -> TokenStream { name: "DeriveIdentity".into(), kind: ProcMacroKind::CustomDerive, expander: sync::Arc::new(IdentityProcMacroExpander), + disabled: false, }, ), ( @@ -402,6 +377,7 @@ pub fn input_replace(attr: TokenStream, _item: TokenStream) -> TokenStream { name: "input_replace".into(), kind: ProcMacroKind::Attr, expander: sync::Arc::new(AttributeInputReplaceProcMacroExpander), + disabled: false, }, ), ( @@ -416,6 +392,7 @@ pub fn mirror(input: TokenStream) -> TokenStream { name: "mirror".into(), kind: ProcMacroKind::FuncLike, expander: sync::Arc::new(MirrorProcMacroExpander), + disabled: false, }, ), ( @@ -430,6 +407,7 @@ pub fn shorten(input: TokenStream) -> TokenStream { name: "shorten".into(), kind: ProcMacroKind::FuncLike, expander: sync::Arc::new(ShortenProcMacroExpander), + disabled: false, }, ), ] @@ -470,7 +448,6 @@ struct FileMeta { edition: Edition, env: Env, introduce_new_source_root: Option, - target_data_layout: Option, } impl FileMeta { @@ -502,7 +479,6 @@ impl FileMeta { edition: f.edition.map_or(Edition::CURRENT, |v| Edition::from_str(&v).unwrap()), env: f.env.into_iter().collect(), introduce_new_source_root, - target_data_layout: f.target_data_layout, } } } diff --git a/crates/test-utils/src/fixture.rs b/crates/test-utils/src/fixture.rs index 595281336d582..7e34c36189950 100644 --- a/crates/test-utils/src/fixture.rs +++ b/crates/test-utils/src/fixture.rs @@ -126,11 +126,6 @@ pub struct Fixture { /// /// Syntax: `library` pub library: bool, - /// Specifies LLVM data layout to be used. - /// - /// You probably don't want to manually specify this. See LLVM manual for the - /// syntax, if you must: https://llvm.org/docs/LangRef.html#data-layout - pub target_data_layout: Option, /// Actual file contents. All meta comments are stripped. pub text: String, } @@ -145,6 +140,11 @@ pub struct FixtureWithProjectMeta { pub mini_core: Option, pub proc_macro_names: Vec, pub toolchain: Option, + /// Specifies LLVM data layout to be used. + /// + /// You probably don't want to manually specify this. See LLVM manual for the + /// syntax, if you must: https://llvm.org/docs/LangRef.html#data-layout + pub target_data_layout: String, } impl FixtureWithProjectMeta { @@ -172,6 +172,8 @@ impl FixtureWithProjectMeta { let fixture = trim_indent(ra_fixture); let mut fixture = fixture.as_str(); let mut toolchain = None; + let mut target_data_layout = + "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128".to_owned(); let mut mini_core = None; let mut res: Vec = Vec::new(); let mut proc_macro_names = vec![]; @@ -182,6 +184,12 @@ impl FixtureWithProjectMeta { fixture = remain; } + if let Some(meta) = fixture.strip_prefix("//- target_data_layout:") { + let (meta, remain) = meta.split_once('\n').unwrap(); + target_data_layout = meta.trim().to_owned(); + fixture = remain; + } + if let Some(meta) = fixture.strip_prefix("//- proc_macros:") { let (meta, remain) = meta.split_once('\n').unwrap(); proc_macro_names = meta.split(',').map(|it| it.trim().to_owned()).collect(); @@ -225,7 +233,7 @@ impl FixtureWithProjectMeta { } } - Self { fixture: res, mini_core, proc_macro_names, toolchain } + Self { fixture: res, mini_core, proc_macro_names, toolchain, target_data_layout } } //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b env:OUTDIR=path/to,OTHER=foo @@ -245,9 +253,6 @@ impl FixtureWithProjectMeta { let mut env = FxHashMap::default(); let mut introduce_new_source_root = None; let mut library = false; - let mut target_data_layout = Some( - "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128".to_owned(), - ); for component in components { if component == "library" { library = true; @@ -284,7 +289,6 @@ impl FixtureWithProjectMeta { } } "new_source_root" => introduce_new_source_root = Some(value.to_owned()), - "target_data_layout" => target_data_layout = Some(value.to_owned()), _ => panic!("bad component: {component:?}"), } } @@ -307,7 +311,6 @@ impl FixtureWithProjectMeta { env, introduce_new_source_root, library, - target_data_layout, } } } @@ -476,16 +479,21 @@ fn parse_fixture_checks_further_indented_metadata() { #[test] fn parse_fixture_gets_full_meta() { - let FixtureWithProjectMeta { fixture: parsed, mini_core, proc_macro_names, toolchain } = - FixtureWithProjectMeta::parse( - r#" + let FixtureWithProjectMeta { + fixture: parsed, + mini_core, + proc_macro_names, + toolchain, + target_data_layout: _, + } = FixtureWithProjectMeta::parse( + r#" //- toolchain: nightly //- proc_macros: identity //- minicore: coerce_unsized //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo mod m; "#, - ); + ); assert_eq!(toolchain, Some("nightly".to_owned())); assert_eq!(proc_macro_names, vec!["identity".to_owned()]); assert_eq!(mini_core.unwrap().activated_flags, vec!["coerce_unsized".to_owned()]); diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs index 23a3a7e0afa49..f125792d12587 100644 --- a/crates/test-utils/src/minicore.rs +++ b/crates/test-utils/src/minicore.rs @@ -60,6 +60,8 @@ //! try: infallible //! unpin: sized //! unsize: sized +//! todo: panic +//! unimplemented: panic #![rustc_coherence_is_core] @@ -927,6 +929,10 @@ pub mod fmt { use crate::mem::transmute; unsafe { Argument { formatter: transmute(f), value: transmute(x) } } } + + pub fn new_display<'b, T: Display>(x: &'b T) -> Argument<'_> { + Self::new(x, Display::fmt) + } } #[lang = "format_alignment"] @@ -1438,6 +1444,33 @@ mod macros { // endregion:fmt + // region:todo + #[macro_export] + #[allow_internal_unstable(core_panic)] + macro_rules! todo { + () => { + $crate::panicking::panic("not yet implemented") + }; + ($($arg:tt)+) => { + $crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+)) + }; + } + // endregion:todo + + // region:unimplemented + #[macro_export] + #[allow_internal_unstable(core_panic)] + macro_rules! unimplemented { + () => { + $crate::panicking::panic("not implemented") + }; + ($($arg:tt)+) => { + $crate::panic!("not implemented: {}", $crate::format_args!($($arg)+)) + }; + } + // endregion:unimplemented + + // region:derive pub(crate) mod builtin { #[rustc_builtin_macro] diff --git a/crates/toolchain/src/lib.rs b/crates/toolchain/src/lib.rs index 997f339edc4d7..ae71b6700c0b2 100644 --- a/crates/toolchain/src/lib.rs +++ b/crates/toolchain/src/lib.rs @@ -2,7 +2,41 @@ #![warn(rust_2018_idioms, unused_lifetimes)] -use std::{env, iter, path::PathBuf}; +use std::{ + env, iter, + path::{Path, PathBuf}, +}; + +#[derive(Copy, Clone)] +pub enum Tool { + Cargo, + Rustc, + Rustup, + Rustfmt, +} + +impl Tool { + pub fn path(self) -> PathBuf { + get_path_for_executable(self.name()) + } + + pub fn path_in(self, path: &Path) -> Option { + probe_for_binary(path.join(self.name())) + } + + pub fn path_in_or_discover(self, path: &Path) -> PathBuf { + probe_for_binary(path.join(self.name())).unwrap_or_else(|| self.path()) + } + + pub fn name(self) -> &'static str { + match self { + Tool::Cargo => "cargo", + Tool::Rustc => "rustc", + Tool::Rustup => "rustup", + Tool::Rustfmt => "rustfmt", + } + } +} pub fn cargo() -> PathBuf { get_path_for_executable("cargo") @@ -47,7 +81,7 @@ fn get_path_for_executable(executable_name: &'static str) -> PathBuf { if let Some(mut path) = get_cargo_home() { path.push("bin"); path.push(executable_name); - if let Some(path) = probe(path) { + if let Some(path) = probe_for_binary(path) { return path; } } @@ -57,7 +91,7 @@ fn get_path_for_executable(executable_name: &'static str) -> PathBuf { fn lookup_in_path(exec: &str) -> bool { let paths = env::var_os("PATH").unwrap_or_default(); - env::split_paths(&paths).map(|path| path.join(exec)).find_map(probe).is_some() + env::split_paths(&paths).map(|path| path.join(exec)).find_map(probe_for_binary).is_some() } fn get_cargo_home() -> Option { @@ -73,7 +107,7 @@ fn get_cargo_home() -> Option { None } -fn probe(path: PathBuf) -> Option { +pub fn probe_for_binary(path: PathBuf) -> Option { let with_extension = match env::consts::EXE_EXTENSION { "" => None, it => Some(path.with_extension(it)), diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs index 9004bff53a808..eec88f80688c7 100644 --- a/crates/tt/src/lib.rs +++ b/crates/tt/src/lib.rs @@ -152,6 +152,7 @@ pub struct Punct { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Spacing { Alone, + /// Whether the following token is joint to the current one. Joint, } diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index a86ef709411cc..da7654b0f6447 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -71,7 +71,7 @@ cargo check --quiet --workspace --message-format=json --all-targets ``` . -- -[[rust-analyzer.cargo.buildScripts.rebuildOnSave]]rust-analyzer.cargo.buildScripts.rebuildOnSave (default: `false`):: +[[rust-analyzer.cargo.buildScripts.rebuildOnSave]]rust-analyzer.cargo.buildScripts.rebuildOnSave (default: `true`):: + -- Rerun proc-macros building/build-scripts running when proc-macro @@ -234,6 +234,11 @@ each of them, with the working directory being the workspace root by changing `#rust-analyzer.check.invocationStrategy#` and `#rust-analyzer.check.invocationLocation#`. +If `$saved_file` is part of the command, rust-analyzer will pass +the absolute path of the saved file to the provided command. This is +intended to be used with non-Cargo build systems. +Note that `$saved_file` is experimental and may be removed in the futureg. + An example command would be: ```bash @@ -343,6 +348,11 @@ Default: ---- Custom completion snippets. +-- +[[rust-analyzer.completion.termSearch.enable]]rust-analyzer.completion.termSearch.enable (default: `false`):: ++ +-- +Whether to enable term search based snippets like `Some(foo.bar().baz())`. -- [[rust-analyzer.diagnostics.disabled]]rust-analyzer.diagnostics.disabled (default: `[]`):: + @@ -793,11 +803,6 @@ Exclude imports from find-all-references. -- Exclude tests from find-all-references. -- -[[rust-analyzer.rename.allowExternalItems]]rust-analyzer.rename.allowExternalItems (default: `false`):: -+ --- -Allow renaming of items not belonging to the loaded workspaces. --- [[rust-analyzer.runnables.command]]rust-analyzer.runnables.command (default: `null`):: + -- diff --git a/editors/code/.vscodeignore b/editors/code/.vscodeignore index 09dc27056b37a..5c48205694fe9 100644 --- a/editors/code/.vscodeignore +++ b/editors/code/.vscodeignore @@ -12,3 +12,6 @@ !ra_syntax_tree.tmGrammar.json !server !README.md +!language-configuration-rustdoc.json +!rustdoc-inject.json +!rustdoc.json diff --git a/editors/code/language-configuration-rustdoc.json b/editors/code/language-configuration-rustdoc.json new file mode 100644 index 0000000000000..c905d3b60674e --- /dev/null +++ b/editors/code/language-configuration-rustdoc.json @@ -0,0 +1,37 @@ +{ + "comments": { + "blockComment": [""] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "colorizedBracketPairs": [], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" } + ], + "surroundingPairs": [ + ["(", ")"], + ["[", "]"], + ["`", "`"], + ["_", "_"], + ["*", "*"], + ["{", "}"], + ["'", "'"], + ["\"", "\""] + ], + "folding": { + "offSide": true, + "markers": { + "start": "^\\s*", + "end": "^\\s*" + } + }, + "wordPattern": { + "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", + "flags": "ug" + } +} diff --git a/editors/code/package.json b/editors/code/package.json index b474471e5a4b3..3a1df5a2f901c 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -68,7 +68,9 @@ "typescript": "^5.1.6" }, "activationEvents": [ + "workspaceContains:Cargo.toml", "workspaceContains:*/Cargo.toml", + "workspaceContains:rust-project.json", "workspaceContains:*/rust-project.json" ], "main": "./out/main", @@ -588,7 +590,7 @@ }, "rust-analyzer.cargo.buildScripts.rebuildOnSave": { "markdownDescription": "Rerun proc-macros building/build-scripts running when proc-macro\nor build-script sources change and are saved.", - "default": false, + "default": true, "type": "boolean" }, "rust-analyzer.cargo.buildScripts.useRustcWrapper": { @@ -775,7 +777,7 @@ ] }, "rust-analyzer.check.overrideCommand": { - "markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.check.invocationStrategy#` and\n`#rust-analyzer.check.invocationLocation#`.\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n.", + "markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.check.invocationStrategy#` and\n`#rust-analyzer.check.invocationLocation#`.\n\nIf `$saved_file` is part of the command, rust-analyzer will pass\nthe absolute path of the saved file to the provided command. This is\nintended to be used with non-Cargo build systems.\nNote that `$saved_file` is experimental and may be removed in the futureg.\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n.", "default": null, "type": [ "null", @@ -902,6 +904,11 @@ }, "type": "object" }, + "rust-analyzer.completion.termSearch.enable": { + "markdownDescription": "Whether to enable term search based snippets like `Some(foo.bar().baz())`.", + "default": false, + "type": "boolean" + }, "rust-analyzer.diagnostics.disabled": { "markdownDescription": "List of rust-analyzer diagnostics to disable.", "default": [], @@ -1520,11 +1527,6 @@ "default": false, "type": "boolean" }, - "rust-analyzer.rename.allowExternalItems": { - "markdownDescription": "Allow renaming of items not belonging to the loaded workspaces.", - "default": false, - "type": "boolean" - }, "rust-analyzer.runnables.command": { "markdownDescription": "Command to be executed instead of 'cargo' for runnables.", "default": null, @@ -1756,6 +1758,13 @@ "rs" ], "configuration": "language-configuration.json" + }, + { + "id": "rustdoc", + "extensions": [ + ".rustdoc" + ], + "configuration": "./language-configuration-rustdoc.json" } ], "grammars": [ @@ -1763,6 +1772,27 @@ "language": "ra_syntax_tree", "scopeName": "source.ra_syntax_tree", "path": "ra_syntax_tree.tmGrammar.json" + }, + { + "language": "rustdoc", + "scopeName": "text.html.markdown.rustdoc", + "path": "rustdoc.json", + "embeddedLanguages": { + "meta.embedded.block.html": "html", + "meta.embedded.block.markdown": "markdown", + "meta.embedded.block.rust": "rust" + } + }, + { + "injectTo": [ + "source.rust" + ], + "scopeName": "comment.markdown-cell-inject.rustdoc", + "path": "rustdoc-inject.json", + "embeddedLanguages": { + "meta.embedded.block.rustdoc": "rustdoc", + "meta.embedded.block.rust": "rust" + } } ], "problemMatchers": [ diff --git a/editors/code/rustdoc-inject.json b/editors/code/rustdoc-inject.json new file mode 100644 index 0000000000000..7a4498fea9d07 --- /dev/null +++ b/editors/code/rustdoc-inject.json @@ -0,0 +1,93 @@ +{ + "injectionSelector": "L:source.rust -string -comment -meta.embedded.block.rustdoc.md", + "patterns": [ + { + "include": "#triple-slash" + }, + { + "include": "#double-slash-exclamation" + }, + { + "include": "#slash-start-exclamation" + }, + { + "include": "#slash-double-start" + } + ], + "repository": { + "triple-slash": { + "begin": "(^|\\G)\\s*(///) ?", + "captures": { + "2": { + "name": "comment.line.double-slash.rust" + } + }, + "name": "comment.quote_code.triple-slash.rust", + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "while": "(^|\\G)\\s*(///) ?" + }, + "double-slash-exclamation": { + "begin": "(^|\\G)\\s*(//!) ?", + "captures": { + "2": { + "name": "comment.line.double-slash.rust" + } + }, + "name": "comment.quote_code.double-slash-exclamation.rust", + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "while": "(^|\\G)\\s*(//!) ?" + }, + "slash-start-exclamation": { + "begin": "(^)(/\\*!) ?$", + "captures": { + "2": { + "name": "comment.block.rust" + } + }, + "name": "comment.quote_code.slash-start-exclamation.rust", + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "end": "( ?)(\\*/)" + }, + "slash-double-start": { + "name": "comment.quote_code.slash-double-start-quote-star.rust", + "begin": "(?:^)\\s*/\\*\\* ?$", + "end": "\\*/", + "patterns": [ + { + "include": "#quote-star" + } + ] + }, + "quote-star": { + "begin": "(^|\\G)\\s*(\\*(?!/)) ?", + "captures": { + "2": { + "name": "comment.punctuation.definition.quote_code.slash-star.MR" + } + }, + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "while": "(^|\\G)\\s*(\\*(?!/)) ?" + } + }, + "scopeName": "comment.markdown-cell-inject.rustdoc" +} diff --git a/editors/code/rustdoc.json b/editors/code/rustdoc.json new file mode 100644 index 0000000000000..cecfae9d753e2 --- /dev/null +++ b/editors/code/rustdoc.json @@ -0,0 +1,82 @@ +{ + "name": "rustdoc", + "patterns": [ + { + "include": "#fenced_code_block" + }, + { + "include": "#markdown" + } + ], + "scopeName": "text.html.markdown.rustdoc", + "repository": { + "markdown": { + "patterns": [ + { + "include": "text.html.markdown" + } + ] + }, + "fenced_code_block": { + "patterns": [ + { + "include": "#fenced_code_block_rust" + }, + { + "include": "#fenced_code_block_unknown" + } + ] + }, + "fenced_code_block_rust": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(rust|not run|not_run)?((\\s+|:|,|\\{|\\?)[^`~]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.rust", + "patterns": [ + { + "include": "source.rust" + } + ] + } + ] + }, + "fenced_code_block_unknown": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?=([^`~]+)?$)", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language" + } + }, + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "name": "markup.fenced_code.block.markdown" + } + } +} diff --git a/editors/code/src/rust_project.ts b/editors/code/src/rust_project.ts index bf65ad43ba596..c983874fc009f 100644 --- a/editors/code/src/rust_project.ts +++ b/editors/code/src/rust_project.ts @@ -1,7 +1,26 @@ export interface JsonProject { + /// Path to the sysroot directory. + /// + /// The sysroot is where rustc looks for the + /// crates that are built-in to rust, such as + /// std. + /// + /// https://doc.rust-lang.org/rustc/command-line-arguments.html#--sysroot-override-the-system-root + /// + /// To see the current value of sysroot, you + /// can query rustc: + /// + /// ``` + /// $ rustc --print sysroot + /// /Users/yourname/.rustup/toolchains/stable-x86_64-apple-darwin + /// ``` + sysroot?: string; /// Path to the directory with *source code* of /// sysroot crates. /// + /// By default, this is `lib/rustlib/src/rust/library` + /// relative to the sysroot. + /// /// It should point to the directory where std, /// core, and friends can be found: /// diff --git a/lib/lsp-server/LICENSE-APACHE b/lib/lsp-server/LICENSE-APACHE new file mode 120000 index 0000000000000..1cd601d0a3aff --- /dev/null +++ b/lib/lsp-server/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/lib/lsp-server/LICENSE-MIT b/lib/lsp-server/LICENSE-MIT new file mode 120000 index 0000000000000..b2cfbdc7b0b46 --- /dev/null +++ b/lib/lsp-server/LICENSE-MIT @@ -0,0 +1 @@ +../../LICENSE-MIT \ No newline at end of file diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs index 9bd3a661c24de..2efafa10a828e 100644 --- a/xtask/src/metrics.rs +++ b/xtask/src/metrics.rs @@ -117,8 +117,6 @@ impl Metrics { sh, "./target/release/rust-analyzer -q analysis-stats {path} --query-sysroot-metadata" ) - // the sysroot uses `public-dependency`, so we make cargo think it's a nightly - .env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly") .read()?; for (metric, value, unit) in parse_metrics(&output) { self.report(&format!("analysis-stats/{name}/{metric}"), value, unit.into()); From d88ad9e6b7b07d177c28bf7c65c3bf44759338b4 Mon Sep 17 00:00:00 2001 From: surechen Date: Fri, 10 Nov 2023 10:11:24 +0800 Subject: [PATCH 109/417] By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ``` --- src/driver.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/driver.rs b/src/driver.rs index bdf1cf0a2240c..85867d1511d93 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -28,7 +28,6 @@ use std::fs::read_to_string; use std::ops::Deref; use std::path::Path; use std::process::exit; -use std::string::ToString; use anstream::println; From d1e8a5956ffd73e65288b447c68ac11a7ac26577 Mon Sep 17 00:00:00 2001 From: Victor Song Date: Sat, 17 Feb 2024 17:19:19 -0600 Subject: [PATCH 110/417] fix: make `#[allow]` work on field for `pub_underscore_fields` Add test for future regression --- clippy_lints/src/pub_underscore_fields.rs | 10 ++++++---- .../pub_underscore_fields/pub_underscore_fields.rs | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/pub_underscore_fields.rs b/clippy_lints/src/pub_underscore_fields.rs index 88b5a6cfe2aa7..d20d4a605a2b1 100644 --- a/clippy_lints/src/pub_underscore_fields.rs +++ b/clippy_lints/src/pub_underscore_fields.rs @@ -1,6 +1,6 @@ use clippy_config::types::PubUnderscoreFieldsBehaviour; use clippy_utils::attrs::is_doc_hidden; -use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::is_path_lang_item; use rustc_hir::{FieldDef, Item, ItemKind, LangItem}; use rustc_lint::{LateContext, LateLintPass}; @@ -69,13 +69,15 @@ impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields { // We ignore fields that are `PhantomData`. && !is_path_lang_item(cx, field.ty, LangItem::PhantomData) { - span_lint_and_help( + span_lint_hir_and_then( cx, PUB_UNDERSCORE_FIELDS, + field.hir_id, field.vis_span.to(field.ident.span), "field marked as public but also inferred as unused because it's prefixed with `_`", - None, - "consider removing the underscore, or making the field private", + |diag| { + diag.help("consider removing the underscore, or making the field private"); + }, ); } } diff --git a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs index 1d8fee7daad2d..4ee8dbb883470 100644 --- a/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs +++ b/tests/ui-toml/pub_underscore_fields/pub_underscore_fields.rs @@ -63,4 +63,10 @@ fn main() { _pub: String, pub(crate) _mark: PhantomData, } + + // shouldn't warn when `#[allow]` is used on field level + pub struct AllowedViolations { + #[allow(clippy::pub_underscore_fields)] + pub _first: u32, + } } From 98e26b3483341e0d3121c13bbf70718965f90209 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 18 Feb 2024 15:18:21 -0500 Subject: [PATCH 111/417] Upgrade anstream to 0.6.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e8e932b24f92a..c83a2e349e46e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ rustc_tools_util = "0.3.0" tempfile = { version = "3.2", optional = true } termize = "0.1" color-print = "0.3.4" -anstream = "0.5.0" +anstream = "0.6.0" [dev-dependencies] ui_test = "0.22.1" From 6b6da93e51851d098574b5e6f39b6d187e78f34a Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Mon, 19 Feb 2024 05:05:10 +0000 Subject: [PATCH 112/417] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 921a55d48c6c1..715917e0f2fbb 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -1f8e824f111c972c9df8dbb378d87c33f67bbad4 +d5735645753e990a72446094f703df9b5e421555 From 591356738d397dc1d1f8a7b815ac374ede4a5cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 19 Feb 2024 08:32:33 +0200 Subject: [PATCH 113/417] Downgrade actions/checkout in release workflow --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index adb1c85051610..88adc3bc757e4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -59,7 +59,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: fetch-depth: ${{ env.FETCH_DEPTH }} From 8ca834c86b6fc2da539d079d62c5e6baf26f2ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 19 Feb 2024 08:55:37 +0200 Subject: [PATCH 114/417] Also downgrade actions/setup-node --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 88adc3bc757e4..147f516db9de9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -78,7 +78,7 @@ jobs: rustup component add rust-src - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: node-version: 18 From 8544e729f1f0de1a35f1d7b87e9ec4ab8c669af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 19 Feb 2024 09:25:25 +0200 Subject: [PATCH 115/417] Also downgrade node to 16 --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 147f516db9de9..ac536d0fddeae 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -80,7 +80,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 16 - name: Update apt repositories if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf' From 059138cd5835bb40decb35aef9909c762f6450d2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 30 Jan 2024 08:10:44 +0100 Subject: [PATCH 116/417] enable from_bitmask_vector test on little-endian targets --- src/tools/miri/tests/pass/portable-simd.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/tools/miri/tests/pass/portable-simd.rs b/src/tools/miri/tests/pass/portable-simd.rs index 57d0b6a87b22a..d4b3ab8ac0992 100644 --- a/src/tools/miri/tests/pass/portable-simd.rs +++ b/src/tools/miri/tests/pass/portable-simd.rs @@ -268,15 +268,11 @@ fn simd_mask() { } // This used to cause an ICE. It exercises simd_select_bitmask with an array as input. - if cfg!(target_endian = "little") { - // FIXME this test currently fails on big-endian: - // - let bitmask = u8x4::from_array([0b00001101, 0, 0, 0]); - assert_eq!( - mask32x4::from_bitmask_vector(bitmask), - mask32x4::from_array([true, false, true, true]), - ); - } + let bitmask = u8x4::from_array([0b00001101, 0, 0, 0]); + assert_eq!( + mask32x4::from_bitmask_vector(bitmask), + mask32x4::from_array([true, false, true, true]), + ); let bitmask = u8x8::from_array([0b01000101, 0, 0, 0, 0, 0, 0, 0]); assert_eq!( mask32x8::from_bitmask_vector(bitmask), From a16dbd7339b63ed3b6660117dfa51696712cd1b5 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 1 Feb 2024 10:13:24 +1100 Subject: [PATCH 117/417] Prefer `DiagnosticBuilder` over `Diagnostic` in diagnostic modifiers. There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`. --- clippy_lints/src/casts/cast_possible_truncation.rs | 4 ++-- clippy_lints/src/functions/result.rs | 4 ++-- clippy_lints/src/if_let_mutex.rs | 4 ++-- clippy_lints/src/implicit_hasher.rs | 4 ++-- clippy_lints/src/manual_clamp.rs | 4 ++-- .../src/matches/significant_drop_in_scrutinee.rs | 4 ++-- .../src/methods/suspicious_command_arg_space.rs | 4 ++-- clippy_lints/src/missing_asserts_for_indexing.rs | 4 ++-- clippy_lints/src/needless_pass_by_value.rs | 4 ++-- clippy_utils/src/diagnostics.rs | 12 ++++++------ 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index f99a51e2b88c5..1543ae8039968 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -4,7 +4,7 @@ use clippy_utils::expr_or_init; use clippy_utils::source::snippet; use clippy_utils::sugg::Sugg; use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize}; -use rustc_errors::{Applicability, Diagnostic, SuggestionStyle}; +use rustc_errors::{Applicability, DiagnosticBuilder, SuggestionStyle}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; @@ -177,7 +177,7 @@ fn offer_suggestion( expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to_span: Span, - diag: &mut Diagnostic, + diag: &mut DiagnosticBuilder<'_, ()>, ) { let cast_to_snip = snippet(cx, cast_to_span, ".."); let suggestion = if cast_to_snip == "_" { diff --git a/clippy_lints/src/functions/result.rs b/clippy_lints/src/functions/result.rs index f1200c2edc134..9505741e68ff9 100644 --- a/clippy_lints/src/functions/result.rs +++ b/clippy_lints/src/functions/result.rs @@ -1,4 +1,4 @@ -use rustc_errors::Diagnostic; +use rustc_errors::DiagnosticBuilder; use rustc_hir as hir; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; @@ -135,7 +135,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty RESULT_LARGE_ERR, hir_ty_span, "the `Err`-variant returned from this function is very large", - |diag: &mut Diagnostic| { + |diag: &mut DiagnosticBuilder<'_, ()>| { diag.span_label(hir_ty_span, format!("the `Err`-variant is at least {ty_size} bytes")); diag.help(format!("try reducing the size of `{err_ty}`, for example by boxing large elements or replacing it with `Box<{err_ty}>`")); }, diff --git a/clippy_lints/src/if_let_mutex.rs b/clippy_lints/src/if_let_mutex.rs index 5e354209cbfc2..61a322ea8812f 100644 --- a/clippy_lints/src/if_let_mutex.rs +++ b/clippy_lints/src/if_let_mutex.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{higher, SpanlessEq}; -use rustc_errors::Diagnostic; +use rustc_errors::DiagnosticBuilder; use rustc_hir::intravisit::{self as visit, Visitor}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for IfLetMutex { arm_visit.visit_expr(if_else); if let Some(arm_mutex) = arm_visit.found_mutex_if_same_as(op_mutex) { - let diag = |diag: &mut Diagnostic| { + let diag = |diag: &mut DiagnosticBuilder<'_, ()>| { diag.span_label( op_mutex.span, "this Mutex will remain locked for the entire `if let`-block...", diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index 87f6f5e7959e1..746de50c0fa79 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use std::collections::BTreeMap; -use rustc_errors::Diagnostic; +use rustc_errors::DiagnosticBuilder; use rustc_hir as hir; use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor}; use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind}; @@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher { fn suggestion( cx: &LateContext<'_>, - diag: &mut Diagnostic, + diag: &mut DiagnosticBuilder<'_, ()>, generics_span: Span, generics_suggestion_span: Span, target: &ImplicitHasherType<'_>, diff --git a/clippy_lints/src/manual_clamp.rs b/clippy_lints/src/manual_clamp.rs index 0da309f9531e0..12bb80dfde2c5 100644 --- a/clippy_lints/src/manual_clamp.rs +++ b/clippy_lints/src/manual_clamp.rs @@ -9,7 +9,7 @@ use clippy_utils::{ peel_blocks_with_stmt, MaybePath, }; use itertools::Itertools; -use rustc_errors::{Applicability, Diagnostic}; +use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir::def::Res; use rustc_hir::{Arm, BinOpKind, Block, Expr, ExprKind, HirId, PatKind, PathSegment, PrimTy, QPath, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -163,7 +163,7 @@ fn emit_suggestion<'tcx>(cx: &LateContext<'tcx>, suggestion: &ClampSuggestion<'t }; let suggestion = format!("{assignment}{input}.clamp({min}, {max}){semicolon}"); let msg = "clamp-like pattern without using clamp function"; - let lint_builder = |d: &mut Diagnostic| { + let lint_builder = |d: &mut DiagnosticBuilder<'_, ()>| { d.span_suggestion(*span, "replace with clamp", suggestion, Applicability::MaybeIncorrect); if *is_float { d.note("clamp will panic if max < min, min.is_nan(), or max.is_nan()") diff --git a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index ee0fdb35313d5..a7e42fd24059d 100644 --- a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -2,7 +2,7 @@ use crate::FxHashSet; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{indent_of, snippet}; use clippy_utils::{get_attr, is_lint_allowed}; -use rustc_errors::{Applicability, Diagnostic}; +use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{Arm, Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LintContext}; @@ -37,7 +37,7 @@ pub(super) fn check<'tcx>( } } -fn set_diagnostic<'tcx>(diag: &mut Diagnostic, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, found: FoundSigDrop) { +fn set_diagnostic<'tcx>(diag: &mut DiagnosticBuilder<'_, ()>, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, found: FoundSigDrop) { if found.lint_suggestion == LintSuggestion::MoveAndClone { // If our suggestion is to move and clone, then we want to leave it to the user to // decide how to address this lint, since it may be that cloning is inappropriate. diff --git a/clippy_lints/src/methods/suspicious_command_arg_space.rs b/clippy_lints/src/methods/suspicious_command_arg_space.rs index b2c5987e43d23..617d6d998fcc7 100644 --- a/clippy_lints/src/methods/suspicious_command_arg_space.rs +++ b/clippy_lints/src/methods/suspicious_command_arg_space.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; -use rustc_errors::{Applicability, Diagnostic}; +use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_lint::LateContext; use rustc_span::{sym, Span}; use {rustc_ast as ast, rustc_hir as hir}; @@ -22,7 +22,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx hir::Expr<'_>, arg SUSPICIOUS_COMMAND_ARG_SPACE, arg.span, "single argument that looks like it should be multiple arguments", - |diag: &mut Diagnostic| { + |diag: &mut DiagnosticBuilder<'_, ()>| { diag.multipart_suggestion_verbose( "consider splitting the argument", vec![(span, "args".to_string()), (arg.span, format!("[{arg1:?}, {arg2:?}]"))], diff --git a/clippy_lints/src/missing_asserts_for_indexing.rs b/clippy_lints/src/missing_asserts_for_indexing.rs index 0e4d39c999020..ab25dde7efee4 100644 --- a/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/clippy_lints/src/missing_asserts_for_indexing.rs @@ -9,7 +9,7 @@ use clippy_utils::{eq_expr_value, hash_expr, higher}; use rustc_ast::{LitKind, RangeLimits}; use rustc_data_structures::packed::Pu128; use rustc_data_structures::unhash::UnhashMap; -use rustc_errors::{Applicability, Diagnostic}; +use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir::{BinOp, Block, Body, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -67,7 +67,7 @@ declare_lint_pass!(MissingAssertsForIndexing => [MISSING_ASSERTS_FOR_INDEXING]); fn report_lint(cx: &LateContext<'_>, full_span: Span, msg: &str, indexes: &[Span], f: F) where - F: FnOnce(&mut Diagnostic), + F: FnOnce(&mut DiagnosticBuilder<'_, ()>), { span_lint_and_then(cx, MISSING_ASSERTS_FOR_INDEXING, full_span, msg, |diag| { f(diag); diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 384a402ce5b01..6252f91b25f8e 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -6,7 +6,7 @@ use clippy_utils::ty::{ implements_trait, implements_trait_with_env_from_iter, is_copy, is_type_diagnostic_item, is_type_lang_item, }; use rustc_ast::ast::Attribute; -use rustc_errors::{Applicability, Diagnostic}; +use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir::intravisit::FnKind; use rustc_hir::{ BindingAnnotation, Body, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, Node, PatKind, @@ -196,7 +196,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { && !moved_vars.contains(&canonical_id) { // Dereference suggestion - let sugg = |diag: &mut Diagnostic| { + let sugg = |diag: &mut DiagnosticBuilder<'_, ()>| { if let ty::Adt(def, ..) = ty.kind() { if let Some(span) = cx.tcx.hir().span_if_local(def.did()) { if type_allowed_to_implement_copy( diff --git a/clippy_utils/src/diagnostics.rs b/clippy_utils/src/diagnostics.rs index 5199959c0f2b3..db94b60dc9512 100644 --- a/clippy_utils/src/diagnostics.rs +++ b/clippy_utils/src/diagnostics.rs @@ -8,13 +8,13 @@ //! Thank you! //! ~The `INTERNAL_METADATA_COLLECTOR` lint -use rustc_errors::{Applicability, Diagnostic, MultiSpan}; +use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan}; use rustc_hir::HirId; use rustc_lint::{LateContext, Lint, LintContext}; use rustc_span::Span; use std::env; -fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) { +fn docs_link(diag: &mut DiagnosticBuilder<'_, ()>, lint: &'static Lint) { if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() { if let Some(lint) = lint.name_lower().strip_prefix("clippy::") { diag.help(format!( @@ -143,7 +143,7 @@ pub fn span_lint_and_then(cx: &C, lint: &'static Lint, sp: S, msg: &str where C: LintContext, S: Into, - F: FnOnce(&mut Diagnostic), + F: FnOnce(&mut DiagnosticBuilder<'_, ()>), { #[expect(clippy::disallowed_methods)] cx.span_lint(lint, sp, msg.to_string(), |diag| { @@ -165,7 +165,7 @@ pub fn span_lint_hir_and_then( hir_id: HirId, sp: impl Into, msg: &str, - f: impl FnOnce(&mut Diagnostic), + f: impl FnOnce(&mut DiagnosticBuilder<'_, ()>), ) { #[expect(clippy::disallowed_methods)] cx.tcx.node_span_lint(lint, hir_id, sp, msg.to_string(), |diag| { @@ -214,7 +214,7 @@ pub fn span_lint_and_sugg( /// appear once per /// replacement. In human-readable format though, it only appears once before /// the whole suggestion. -pub fn multispan_sugg(diag: &mut Diagnostic, help_msg: &str, sugg: I) +pub fn multispan_sugg(diag: &mut DiagnosticBuilder<'_, ()>, help_msg: &str, sugg: I) where I: IntoIterator, { @@ -227,7 +227,7 @@ where /// multiple spans. This is tracked in issue [rustfix#141](https://github.com/rust-lang/rustfix/issues/141). /// Suggestions with multiple spans will be silently ignored. pub fn multispan_sugg_with_applicability( - diag: &mut Diagnostic, + diag: &mut DiagnosticBuilder<'_, ()>, help_msg: &str, applicability: Applicability, sugg: I, From af174b9428fd4a80971b7bfc213f108facf62740 Mon Sep 17 00:00:00 2001 From: Young-Flash Date: Mon, 19 Feb 2024 18:09:33 +0800 Subject: [PATCH 118/417] internal: checkout repo before run typos --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62fbd57abc165..5a8b18e3fe1b3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -226,6 +226,11 @@ jobs: - name: download typos run: curl -LsSf https://github.com/crate-ci/typos/releases/download/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: check for typos run: typos From f3d84e86c8e5490e2ac96c0fcd0de179d9f4aa22 Mon Sep 17 00:00:00 2001 From: Young-Flash Date: Mon, 19 Feb 2024 18:12:08 +0800 Subject: [PATCH 119/417] minor: fix typo --- crates/hir/src/term_search/tactics.rs | 6 +++--- crates/ide-completion/src/item.rs | 2 +- crates/rust-analyzer/tests/slow-tests/support.rs | 2 +- crates/salsa/src/lib.rs | 4 ++-- crates/salsa/src/lru.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/hir/src/term_search/tactics.rs b/crates/hir/src/term_search/tactics.rs index 666d63ac1558b..edbf75affe64c 100644 --- a/crates/hir/src/term_search/tactics.rs +++ b/crates/hir/src/term_search/tactics.rs @@ -281,14 +281,14 @@ pub(super) fn type_constructor<'a, DB: HirDatabase>( if ctx.config.enable_borrowcheck && struct_ty.contains_reference(db) { return None; } - let fileds = it.fields(db); + let fields = it.fields(db); // Check if all fields are visible, otherwise we cannot fill them - if fileds.iter().any(|it| !it.is_visible_from(db, module)) { + if fields.iter().any(|it| !it.is_visible_from(db, module)) { return None; } // Early exit if some param cannot be filled from lookup - let param_exprs: Vec> = fileds + let param_exprs: Vec> = fields .into_iter() .map(|field| lookup.find(db, &field.ty(db))) .collect::>()?; diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs index c2c0641961a6a..4bab2886851a0 100644 --- a/crates/ide-completion/src/item.rs +++ b/crates/ide-completion/src/item.rs @@ -308,7 +308,7 @@ impl CompletionRelevance { // When a fn is bumped due to return type: // Bump Constructor or Builder methods with no arguments, - // over them tha with self arguments + // over them than with self arguments if fn_score > 0 { if !asf.has_params { // bump associated functions diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs index 392a71702070e..dfd25abc70f6e 100644 --- a/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/crates/rust-analyzer/tests/slow-tests/support.rs @@ -243,7 +243,7 @@ impl Server { to_string_pretty(actual_part).unwrap(), ); } else { - tracing::debug!("sucessfully matched notification"); + tracing::debug!("successfully matched notification"); return; } } else { diff --git a/crates/salsa/src/lib.rs b/crates/salsa/src/lib.rs index 668dcfd925d8d..48b5d633bd672 100644 --- a/crates/salsa/src/lib.rs +++ b/crates/salsa/src/lib.rs @@ -456,12 +456,12 @@ pub trait Query: Debug + Default + Sized + for<'d> QueryDb<'d> { /// Name of the query method (e.g., `foo`) const QUERY_NAME: &'static str; - /// Extact storage for this query from the storage for its group. + /// Extract storage for this query from the storage for its group. fn query_storage<'a>( group_storage: &'a >::GroupStorage, ) -> &'a std::sync::Arc; - /// Extact storage for this query from the storage for its group. + /// Extract storage for this query from the storage for its group. fn query_storage_mut<'a>( group_storage: &'a >::GroupStorage, ) -> &'a std::sync::Arc; diff --git a/crates/salsa/src/lru.rs b/crates/salsa/src/lru.rs index c6b9778f20ad0..1ff85a3ea4585 100644 --- a/crates/salsa/src/lru.rs +++ b/crates/salsa/src/lru.rs @@ -40,7 +40,7 @@ pub(crate) trait LruNode: Sized + Debug { #[derive(Debug)] pub(crate) struct LruIndex { - /// Index in the approprate LRU list, or std::usize::MAX if not a + /// Index in the appropriate LRU list, or std::usize::MAX if not a /// member. index: AtomicUsize, } From 385479c0cd5519ae2ee5c273a333c704817f5411 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 19 Feb 2024 11:21:51 +0100 Subject: [PATCH 120/417] tests/pass/concurrency/sync: try to make it less likely for the test to fail on macOS --- src/tools/miri/tests/pass/concurrency/sync.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/tests/pass/concurrency/sync.rs b/src/tools/miri/tests/pass/concurrency/sync.rs index 1d48e5312d496..a6c181098b74b 100644 --- a/src/tools/miri/tests/pass/concurrency/sync.rs +++ b/src/tools/miri/tests/pass/concurrency/sync.rs @@ -63,10 +63,10 @@ fn check_conditional_variables_timed_wait_timeout() { let cvar = Condvar::new(); let guard = lock.lock().unwrap(); let now = Instant::now(); - let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(100)).unwrap(); + let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(10)).unwrap(); assert!(timeout.timed_out()); let elapsed_time = now.elapsed().as_millis(); - assert!(100 <= elapsed_time && elapsed_time <= 1000); + assert!(10 <= elapsed_time && elapsed_time <= 1000); } /// Test that signaling a conditional variable when waiting with a timeout works @@ -79,7 +79,7 @@ fn check_conditional_variables_timed_wait_notimeout() { let guard = lock.lock().unwrap(); let handle = thread::spawn(move || { - thread::sleep(Duration::from_millis(100)); // Make sure the other thread is waiting by the time we call `notify`. + thread::sleep(Duration::from_millis(1)); // Make sure the other thread is waiting by the time we call `notify`. let (_lock, cvar) = &*pair2; cvar.notify_one(); }); From 30b992e95a1e437b3e96b0e86373427f0fe2b121 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 14 Jan 2024 08:48:41 +0100 Subject: [PATCH 121/417] Deduplicate references to macro argument Commit 6a06f6f72 (Deduplicate reference search results, 2022-11-07) deduplicates references within each definition. There is an edge case when requesting references of a macro argument. Apparently, our descend_into_macros() stanza in references.rs produces a cartesian product of - references inside the macro times - times references outside the macro. Since the above deduplication only applies to the references within a single definition, we return them all, leading to many redundant references. Work around this by deduplicating definitions as well. Perhaps there is a better fix to not produce this cartesian product in the first place; but I think at least for definitions the problem would remain; a macro can contain multiple definitions of the same name, but since the navigation target will be the unresolved location, it's the same for all of them. We can't use unique() because we don't want to drop references that don't have a declaration (though I dont' have an example for this case). I discovered this working with the "bitflags" macro from the crate of the same name. Fixes #16357 --- crates/rust-analyzer/src/handlers/request.rs | 28 ++++++++++++++++---- crates/stdx/src/lib.rs | 16 +++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index eb9d4bf0f02d7..a677cea31b505 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -2,6 +2,7 @@ //! Protocol. This module specifically handles requests. use std::{ + collections::HashSet, fs, io::Write as _, path::PathBuf, @@ -13,7 +14,8 @@ use anyhow::Context; use ide::{ AnnotationConfig, AssistKind, AssistResolveStrategy, Cancellable, FilePosition, FileRange, HoverAction, HoverGotoTypeData, InlayFieldsToResolve, Query, RangeInfo, RangeLimit, - ReferenceCategory, Runnable, RunnableKind, SingleResolve, SourceChange, TextEdit, + ReferenceCategory, ReferenceSearchResult, Runnable, RunnableKind, SingleResolve, SourceChange, + TextEdit, }; use ide_db::SymbolKind; use lsp_server::ErrorCode; @@ -28,6 +30,8 @@ use lsp_types::{ }; use project_model::{ManifestPath, ProjectWorkspace, TargetKind}; use serde_json::json; +#[allow(unused_imports)] +use stdx::IsNoneOr; use stdx::{format_to, never}; use syntax::{algo, ast, AstNode, TextRange, TextSize}; use triomphe::Arc; @@ -1055,10 +1059,10 @@ pub(crate) fn handle_references( let exclude_imports = snap.config.find_all_refs_exclude_imports(); let exclude_tests = snap.config.find_all_refs_exclude_tests(); - let refs = match snap.analysis.find_all_refs(position, None)? { - None => return Ok(None), - Some(refs) => refs, + let Some(mut refs) = snap.analysis.find_all_refs(position, None)? else { + return Ok(None); }; + deduplicate_declarations(&mut refs); let include_declaration = params.context.include_declaration; let locations = refs @@ -1090,6 +1094,17 @@ pub(crate) fn handle_references( Ok(Some(locations)) } +fn deduplicate_declarations(refs: &mut Vec) { + if refs.iter().filter(|decl| decl.declaration.is_some()).take(2).count() > 1 { + let mut seen_navigation_targets = HashSet::new(); + refs.retain(|res| { + res.declaration + .as_ref() + .is_none_or(|decl| seen_navigation_targets.insert(decl.nav.clone())) + }); + } +} + pub(crate) fn handle_formatting( snap: GlobalStateSnapshot, params: lsp_types::DocumentFormattingParams, @@ -1794,7 +1809,10 @@ fn show_ref_command_link( position: &FilePosition, ) -> Option { if snap.config.hover_actions().references && snap.config.client_commands().show_reference { - if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) { + if let Some(mut ref_search_res) = + snap.analysis.find_all_refs(*position, None).unwrap_or(None) + { + deduplicate_declarations(&mut ref_search_res); let uri = to_proto::url(snap, position.file_id); let line_index = snap.file_line_index(position.file_id).ok()?; let position = to_proto::position(&line_index, position.offset); diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 9a9ebae74e8c1..0504ca50b8828 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -302,6 +302,22 @@ pub fn slice_tails(this: &[T]) -> impl Iterator { (0..this.len()).map(|i| &this[i..]) } +pub trait IsNoneOr { + type Type; + #[allow(clippy::wrong_self_convention)] + fn is_none_or(self, s: impl FnOnce(Self::Type) -> bool) -> bool; +} +#[allow(unstable_name_collisions)] +impl IsNoneOr for Option { + type Type = T; + fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool { + match self { + Some(v) => f(v), + None => true, + } + } +} + #[cfg(test)] mod tests { use super::*; From 91a8f34aeed075427ad4f6c0c6f58f247ac7de42 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 19 Feb 2024 12:22:27 +0100 Subject: [PATCH 122/417] Deduplicate lsp locations --- crates/rust-analyzer/src/handlers/request.rs | 33 +++++--------------- crates/rust-analyzer/src/lsp/to_proto.rs | 7 +++-- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index a677cea31b505..04a043954299a 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -2,7 +2,6 @@ //! Protocol. This module specifically handles requests. use std::{ - collections::HashSet, fs, io::Write as _, path::PathBuf, @@ -14,10 +13,10 @@ use anyhow::Context; use ide::{ AnnotationConfig, AssistKind, AssistResolveStrategy, Cancellable, FilePosition, FileRange, HoverAction, HoverGotoTypeData, InlayFieldsToResolve, Query, RangeInfo, RangeLimit, - ReferenceCategory, ReferenceSearchResult, Runnable, RunnableKind, SingleResolve, SourceChange, - TextEdit, + ReferenceCategory, Runnable, RunnableKind, SingleResolve, SourceChange, TextEdit, }; use ide_db::SymbolKind; +use itertools::Itertools; use lsp_server::ErrorCode; use lsp_types::{ CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem, @@ -30,8 +29,6 @@ use lsp_types::{ }; use project_model::{ManifestPath, ProjectWorkspace, TargetKind}; use serde_json::json; -#[allow(unused_imports)] -use stdx::IsNoneOr; use stdx::{format_to, never}; use syntax::{algo, ast, AstNode, TextRange, TextSize}; use triomphe::Arc; @@ -1059,10 +1056,9 @@ pub(crate) fn handle_references( let exclude_imports = snap.config.find_all_refs_exclude_imports(); let exclude_tests = snap.config.find_all_refs_exclude_tests(); - let Some(mut refs) = snap.analysis.find_all_refs(position, None)? else { + let Some(refs) = snap.analysis.find_all_refs(position, None)? else { return Ok(None); }; - deduplicate_declarations(&mut refs); let include_declaration = params.context.include_declaration; let locations = refs @@ -1088,23 +1084,13 @@ pub(crate) fn handle_references( }) .chain(decl) }) + .unique() .filter_map(|frange| to_proto::location(&snap, frange).ok()) .collect(); Ok(Some(locations)) } -fn deduplicate_declarations(refs: &mut Vec) { - if refs.iter().filter(|decl| decl.declaration.is_some()).take(2).count() > 1 { - let mut seen_navigation_targets = HashSet::new(); - refs.retain(|res| { - res.declaration - .as_ref() - .is_none_or(|decl| seen_navigation_targets.insert(decl.nav.clone())) - }); - } -} - pub(crate) fn handle_formatting( snap: GlobalStateSnapshot, params: lsp_types::DocumentFormattingParams, @@ -1809,10 +1795,7 @@ fn show_ref_command_link( position: &FilePosition, ) -> Option { if snap.config.hover_actions().references && snap.config.client_commands().show_reference { - if let Some(mut ref_search_res) = - snap.analysis.find_all_refs(*position, None).unwrap_or(None) - { - deduplicate_declarations(&mut ref_search_res); + if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) { let uri = to_proto::url(snap, position.file_id); let line_index = snap.file_line_index(position.file_id).ok()?; let position = to_proto::position(&line_index, position.offset); @@ -1820,10 +1803,10 @@ fn show_ref_command_link( .into_iter() .flat_map(|res| res.references) .flat_map(|(file_id, ranges)| { - ranges.into_iter().filter_map(move |(range, _)| { - to_proto::location(snap, FileRange { file_id, range }).ok() - }) + ranges.into_iter().map(move |(range, _)| FileRange { file_id, range }) }) + .unique() + .filter_map(|range| to_proto::location(snap, range).ok()) .collect(); let title = to_proto::reference_title(locations.len()); let command = to_proto::command::show_references(title, &uri, position, locations); diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index 727007bba083a..4101d476cd308 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -904,15 +904,16 @@ pub(crate) fn goto_definition_response( if snap.config.location_link() { let links = targets .into_iter() + .unique_by(|nav| (nav.file_id, nav.full_range, nav.focus_range)) .map(|nav| location_link(snap, src, nav)) .collect::>>()?; Ok(links.into()) } else { let locations = targets .into_iter() - .map(|nav| { - location(snap, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }) - }) + .map(|nav| FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }) + .unique() + .map(|range| location(snap, range)) .collect::>>()?; Ok(locations.into()) } From 6e16edb3bfc641b2a9a17b2fa66da05fc3d368e8 Mon Sep 17 00:00:00 2001 From: UserIsntAvailable Date: Sun, 4 Feb 2024 08:17:02 -0500 Subject: [PATCH 123/417] feat: append `as ` when renaming inside an "UseTree". test: include `rename_path_inside_use_tree`. Keeps tracks the progress of the changes. 3 other tests broke with the changes of this. feat: rename all other usages within the current file. feat: fix most of the implementation problems. test: `rename_path_inside_use_tree` tests a more complicated scenario. --- crates/ide/src/rename.rs | 120 ++++++++++++++++++++++++++++++++++----- 1 file changed, 106 insertions(+), 14 deletions(-) diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs index f2eedfa431693..c128fa5f41a2a 100644 --- a/crates/ide/src/rename.rs +++ b/crates/ide/src/rename.rs @@ -9,6 +9,7 @@ use ide_db::{ base_db::{FileId, FileRange}, defs::{Definition, NameClass, NameRefClass}, rename::{bail, format_err, source_edit_from_references, IdentifierKind}, + source_change::SourceChangeBuilder, RootDatabase, }; use itertools::Itertools; @@ -90,24 +91,60 @@ pub(crate) fn rename( let syntax = source_file.syntax(); let defs = find_definitions(&sema, syntax, position)?; + let alias_fallback = alias_fallback(syntax, position, new_name); + + let ops: RenameResult> = match alias_fallback { + Some(_) => defs + // FIXME: This can use the `ide_db::rename_reference` (or def.rename) method once we can + // properly find "direct" usages/references. + .map(|(.., def)| { + match IdentifierKind::classify(new_name)? { + IdentifierKind::Ident => (), + IdentifierKind::Lifetime => { + bail!("Cannot alias reference to a lifetime identifier") + } + IdentifierKind::Underscore => bail!("Cannot alias reference to `_`"), + }; - let ops: RenameResult> = defs - .map(|(.., def)| { - if let Definition::Local(local) = def { - if let Some(self_param) = local.as_self_param(sema.db) { - cov_mark::hit!(rename_self_to_param); - return rename_self_to_param(&sema, local, self_param, new_name); - } - if new_name == "self" { - cov_mark::hit!(rename_to_self); - return rename_to_self(&sema, local); + let mut usages = def.usages(&sema).all(); + + // FIXME: hack - removes the usage that triggered this rename operation. + match usages.references.get_mut(&position.file_id).and_then(|refs| { + refs.iter() + .position(|ref_| ref_.range.contains_inclusive(position.offset)) + .map(|idx| refs.remove(idx)) + }) { + Some(_) => (), + None => never!(), + }; + + let mut source_change = SourceChange::default(); + source_change.extend(usages.iter().map(|(&file_id, refs)| { + (file_id, source_edit_from_references(refs, def, new_name)) + })); + + Ok(source_change) + }) + .collect(), + None => defs + .map(|(.., def)| { + if let Definition::Local(local) = def { + if let Some(self_param) = local.as_self_param(sema.db) { + cov_mark::hit!(rename_self_to_param); + return rename_self_to_param(&sema, local, self_param, new_name); + } + if new_name == "self" { + cov_mark::hit!(rename_to_self); + return rename_to_self(&sema, local); + } } - } - def.rename(&sema, new_name) - }) - .collect(); + def.rename(&sema, new_name, rename_external) + }) + .collect(), + }; ops?.into_iter() + .chain(alias_fallback) .reduce(|acc, elem| acc.merge(elem)) .ok_or_else(|| format_err!("No references found at position")) } @@ -130,6 +167,38 @@ pub(crate) fn will_rename_file( Some(change) } +// FIXME: Should support `extern crate`. +fn alias_fallback( + syntax: &SyntaxNode, + FilePosition { file_id, offset }: FilePosition, + new_name: &str, +) -> Option { + let use_tree = syntax + .token_at_offset(offset) + .flat_map(|syntax| syntax.parent_ancestors()) + .find_map(ast::UseTree::cast)?; + + let last_path_segment = use_tree.path()?.segments().last()?.name_ref()?; + if !last_path_segment.syntax().text_range().contains_inclusive(offset) { + return None; + }; + + let mut builder = SourceChangeBuilder::new(file_id); + + match use_tree.rename() { + Some(rename) => { + let offset = rename.syntax().text_range(); + builder.replace(offset, format!("as {new_name}")); + } + None => { + let offset = use_tree.syntax().text_range().end(); + builder.insert(offset, format!(" as {new_name}")); + } + } + + Some(builder.finish()) +} + fn find_definitions( sema: &Semantics<'_, RootDatabase>, syntax: &SyntaxNode, @@ -2686,4 +2755,27 @@ fn test() { "#, ); } + + #[test] + fn rename_path_inside_use_tree() { + check( + "Baz", + r#" +mod foo { pub struct Foo; } +mod bar { use super::Foo; } + +use foo::Foo$0; + +fn main() { let _: Foo; } +"#, + r#" +mod foo { pub struct Foo; } +mod bar { use super::Baz; } + +use foo::Foo as Baz; + +fn main() { let _: Baz; } +"#, + ) + } } From 69c25327f48aa6e0297bff6249fb027c7b836eea Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Sun, 14 Jan 2024 15:19:20 +0000 Subject: [PATCH 124/417] internal: reduce body lookups in expr diagnostics --- crates/hir-ty/src/diagnostics/expr.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index c4329a7b82bf8..afb80e1f4450e 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -57,7 +57,8 @@ impl BodyValidationDiagnostic { let _p = tracing::span!(tracing::Level::INFO, "BodyValidationDiagnostic::collect").entered(); let infer = db.infer(owner); - let mut validator = ExprValidator::new(owner, infer); + let body = db.body(owner); + let mut validator = ExprValidator { owner, body, infer, diagnostics: Vec::new() }; validator.validate_body(db); validator.diagnostics } @@ -65,18 +66,16 @@ impl BodyValidationDiagnostic { struct ExprValidator { owner: DefWithBodyId, + body: Arc, infer: Arc, pub(super) diagnostics: Vec, } impl ExprValidator { - fn new(owner: DefWithBodyId, infer: Arc) -> ExprValidator { - ExprValidator { owner, infer, diagnostics: Vec::new() } - } - fn validate_body(&mut self, db: &dyn HirDatabase) { - let body = db.body(self.owner); let mut filter_map_next_checker = None; + // we'll pass &mut self while iterating over body.exprs, so they need to be disjoint + let body = Arc::clone(&self.body); if matches!(self.owner, DefWithBodyId::FunctionId(_)) { self.check_for_trailing_return(body.body_expr, &body); @@ -162,8 +161,6 @@ impl ExprValidator { arms: &[MatchArm], db: &dyn HirDatabase, ) { - let body = db.body(self.owner); - let scrut_ty = &self.infer[scrutinee_expr]; if scrut_ty.is_unknown() { return; @@ -191,12 +188,12 @@ impl ExprValidator { .as_reference() .map(|(match_expr_ty, ..)| match_expr_ty == pat_ty) .unwrap_or(false)) - && types_of_subpatterns_do_match(arm.pat, &body, &self.infer) + && types_of_subpatterns_do_match(arm.pat, &self.body, &self.infer) { // If we had a NotUsefulMatchArm diagnostic, we could // check the usefulness of each pattern as we added it // to the matrix here. - let pat = self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors); + let pat = self.lower_pattern(&cx, arm.pat, db, &mut has_lowering_errors); let m_arm = pat_analysis::MatchArm { pat: pattern_arena.alloc(pat), has_guard: arm.guard.is_some(), @@ -244,10 +241,9 @@ impl ExprValidator { cx: &MatchCheckCtx<'p>, pat: PatId, db: &dyn HirDatabase, - body: &Body, have_errors: &mut bool, ) -> DeconstructedPat<'p> { - let mut patcx = match_check::PatCtxt::new(db, &self.infer, body); + let mut patcx = match_check::PatCtxt::new(db, &self.infer, &self.body); let pattern = patcx.lower_pattern(pat); let pattern = cx.lower_pat(&pattern); if !patcx.errors.is_empty() { From 5390e4ce9bdb822ea4899e2df4383a7076d820cf Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Fri, 5 Jan 2024 17:38:29 +0000 Subject: [PATCH 125/417] feat: add non-exhaustive-let diagnostic --- crates/hir-ty/src/diagnostics/expr.rs | 60 +++++++++++++++++-- crates/hir/src/diagnostics.rs | 23 +++++++ .../src/handlers/mutability_errors.rs | 2 +- .../src/handlers/non_exhaustive_let.rs | 47 +++++++++++++++ crates/ide-diagnostics/src/lib.rs | 2 + 5 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index afb80e1f4450e..0c5d6399619a6 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -12,6 +12,7 @@ use hir_expand::name; use itertools::Itertools; use rustc_hash::FxHashSet; use rustc_pattern_analysis::usefulness::{compute_match_usefulness, ValidityConstraint}; +use tracing::debug; use triomphe::Arc; use typed_arena::Arena; @@ -44,6 +45,10 @@ pub enum BodyValidationDiagnostic { match_expr: ExprId, uncovered_patterns: String, }, + NonExhaustiveLet { + pat: PatId, + uncovered_patterns: String, + }, RemoveTrailingReturn { return_expr: ExprId, }, @@ -68,7 +73,7 @@ struct ExprValidator { owner: DefWithBodyId, body: Arc, infer: Arc, - pub(super) diagnostics: Vec, + diagnostics: Vec, } impl ExprValidator { @@ -105,6 +110,9 @@ impl ExprValidator { Expr::If { .. } => { self.check_for_unnecessary_else(id, expr, &body); } + Expr::Block { .. } => { + self.validate_block(db, expr); + } _ => {} } } @@ -231,11 +239,55 @@ impl ExprValidator { if !witnesses.is_empty() { self.diagnostics.push(BodyValidationDiagnostic::MissingMatchArms { match_expr, - uncovered_patterns: missing_match_arms(&cx, scrut_ty, witnesses, arms), + uncovered_patterns: missing_match_arms(&cx, scrut_ty, witnesses, m_arms.is_empty()), }); } } + fn validate_block(&mut self, db: &dyn HirDatabase, expr: &Expr) { + let Expr::Block { statements, .. } = expr else { return }; + let pattern_arena = Arena::new(); + let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db); + for stmt in &**statements { + let &Statement::Let { pat, initializer, else_branch: None, .. } = stmt else { + continue; + }; + let Some(initializer) = initializer else { continue }; + let ty = &self.infer[initializer]; + + let mut have_errors = false; + let deconstructed_pat = self.lower_pattern(&cx, pat, db, &mut have_errors); + let match_arm = rustc_pattern_analysis::MatchArm { + pat: pattern_arena.alloc(deconstructed_pat), + has_guard: false, + arm_data: (), + }; + if have_errors { + continue; + } + + let report = match compute_match_usefulness( + &cx, + &[match_arm], + ty.clone(), + ValidityConstraint::ValidOnly, + ) { + Ok(v) => v, + Err(e) => { + debug!(?e, "match usefulness error"); + continue; + } + }; + let witnesses = report.non_exhaustiveness_witnesses; + if !witnesses.is_empty() { + self.diagnostics.push(BodyValidationDiagnostic::NonExhaustiveLet { + pat, + uncovered_patterns: missing_match_arms(&cx, ty, witnesses, false), + }); + } + } + } + fn lower_pattern<'p>( &self, cx: &MatchCheckCtx<'p>, @@ -444,7 +496,7 @@ fn missing_match_arms<'p>( cx: &MatchCheckCtx<'p>, scrut_ty: &Ty, witnesses: Vec>, - arms: &[MatchArm], + arms_is_empty: bool, ) -> String { struct DisplayWitness<'a, 'p>(&'a WitnessPat<'p>, &'a MatchCheckCtx<'p>); impl fmt::Display for DisplayWitness<'_, '_> { @@ -459,7 +511,7 @@ fn missing_match_arms<'p>( Some((AdtId::EnumId(e), _)) => !cx.db.enum_data(e).variants.is_empty(), _ => false, }; - if arms.is_empty() && !non_empty_enum { + if arms_is_empty && !non_empty_enum { format!("type `{}` is non-empty", scrut_ty.display(cx.db)) } else { let pat_display = |witness| DisplayWitness(witness, cx); diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 08843a6c99941..d351e257d2e7c 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -64,6 +64,7 @@ diagnostics![ MissingUnsafe, MovedOutOfRef, NeedMut, + NonExhaustiveLet, NoSuchField, PrivateAssocItem, PrivateField, @@ -280,6 +281,12 @@ pub struct MissingMatchArms { pub uncovered_patterns: String, } +#[derive(Debug)] +pub struct NonExhaustiveLet { + pub pat: InFile>, + pub uncovered_patterns: String, +} + #[derive(Debug)] pub struct TypeMismatch { pub expr_or_pat: InFile>>, @@ -456,6 +463,22 @@ impl AnyDiagnostic { Err(SyntheticSyntax) => (), } } + BodyValidationDiagnostic::NonExhaustiveLet { pat, uncovered_patterns } => { + match source_map.pat_syntax(pat) { + Ok(source_ptr) => { + if let Some(ast_pat) = source_ptr.value.cast::() { + return Some( + NonExhaustiveLet { + pat: InFile::new(source_ptr.file_id, ast_pat), + uncovered_patterns, + } + .into(), + ); + } + } + Err(SyntheticSyntax) => {} + } + } BodyValidationDiagnostic::RemoveTrailingReturn { return_expr } => { if let Ok(source_ptr) = source_map.expr_syntax(return_expr) { // Filters out desugared return expressions (e.g. desugared try operators). diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs index bdb55a9d98a27..3c71f84dc4852 100644 --- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs +++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs @@ -817,7 +817,7 @@ fn f() { //- minicore: option fn f(_: i32) {} fn main() { - let ((Some(mut x), None) | (_, Some(mut x))) = (None, Some(7)); + let ((Some(mut x), None) | (_, Some(mut x))) = (None, Some(7)) else { return }; //^^^^^ 💡 warn: variable does not need to be mutable f(x); } diff --git a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs new file mode 100644 index 0000000000000..1a4d2877ef25f --- /dev/null +++ b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs @@ -0,0 +1,47 @@ +use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext}; + +// Diagnostic: non-exhaustive-let +// +// This diagnostic is triggered if a `let` statement without an `else` branch has a non-exhaustive +// pattern. +pub(crate) fn non_exhaustive_let( + ctx: &DiagnosticsContext<'_>, + d: &hir::NonExhaustiveLet, +) -> Diagnostic { + Diagnostic::new_with_syntax_node_ptr( + ctx, + DiagnosticCode::RustcHardError("E0005"), + format!("non-exhaustive pattern: {}", d.uncovered_patterns), + d.pat.map(Into::into), + ) +} + +#[cfg(test)] +mod tests { + use crate::tests::check_diagnostics; + + #[test] + fn option_nonexhaustive() { + check_diagnostics( + r#" +//- minicore: option +fn main() { + let None = Some(5); + //^^^^ error: non-exhaustive pattern: `Some(_)` not covered +} +"#, + ); + } + + #[test] + fn option_exhaustive() { + check_diagnostics( + r#" +//- minicore: option +fn main() { + let Some(_) | None = Some(5); +} +"#, + ); + } +} diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index 9d21bb4cd9fb6..3a3888011d75e 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -41,6 +41,7 @@ mod handlers { pub(crate) mod moved_out_of_ref; pub(crate) mod mutability_errors; pub(crate) mod no_such_field; + pub(crate) mod non_exhaustive_let; pub(crate) mod private_assoc_item; pub(crate) mod private_field; pub(crate) mod remove_trailing_return; @@ -359,6 +360,7 @@ pub fn diagnostics( AnyDiagnostic::MissingUnsafe(d) => handlers::missing_unsafe::missing_unsafe(&ctx, &d), AnyDiagnostic::MovedOutOfRef(d) => handlers::moved_out_of_ref::moved_out_of_ref(&ctx, &d), AnyDiagnostic::NeedMut(d) => handlers::mutability_errors::need_mut(&ctx, &d), + AnyDiagnostic::NonExhaustiveLet(d) => handlers::non_exhaustive_let::non_exhaustive_let(&ctx, &d), AnyDiagnostic::NoSuchField(d) => handlers::no_such_field::no_such_field(&ctx, &d), AnyDiagnostic::PrivateAssocItem(d) => handlers::private_assoc_item::private_assoc_item(&ctx, &d), AnyDiagnostic::PrivateField(d) => handlers::private_field::private_field(&ctx, &d), From 6dd5dc10ef2a7e305045657a9b71662a53884f9f Mon Sep 17 00:00:00 2001 From: UserIsntAvailable Date: Mon, 5 Feb 2024 13:26:47 -0500 Subject: [PATCH 126/417] test: fix `disallow_renaming_for_non_local_definition` to follow PR changes. --- crates/ide/src/rename.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs index c128fa5f41a2a..f78153df38bd6 100644 --- a/crates/ide/src/rename.rs +++ b/crates/ide/src/rename.rs @@ -138,7 +138,7 @@ pub(crate) fn rename( return rename_to_self(&sema, local); } } - def.rename(&sema, new_name, rename_external) + def.rename(&sema, new_name) }) .collect(), }; @@ -2695,7 +2695,8 @@ use qux as frob; //- /lib.rs crate:lib new_source_root:library pub struct S; //- /main.rs crate:main deps:lib new_source_root:local -use lib::S$0; +use lib::S; +fn main() { let _: S$0; } "#, "error: Cannot rename a non-local definition", ); From e9c80a9c256677d85398d93880eec1e54e226d2a Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Thu, 15 Feb 2024 00:59:13 +0900 Subject: [PATCH 127/417] fix: False positive diagnostic for necessary `else` --- crates/hir-ty/src/diagnostics/expr.rs | 8 ++++++- .../src/handlers/remove_unnecessary_else.rs | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index 0c5d6399619a6..571f01dde2ef9 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -338,7 +338,13 @@ impl ExprValidator { fn check_for_unnecessary_else(&mut self, id: ExprId, expr: &Expr, body: &Body) { if let Expr::If { condition: _, then_branch, else_branch } = expr { - if else_branch.is_none() { + if let Some(else_branch) = else_branch { + // If else branch has a tail, it is an "expression" that produces a value, + // e.g. `let a = if { ... } else { ... };` and this `else` is not unnecessary + if let Expr::Block { tail: Some(_), .. } = body.exprs[*else_branch] { + return; + } + } else { return; } if let Expr::Block { statements, tail, .. } = &body.exprs[*then_branch] { diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index ae8241ec2c695..813c07a505db2 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -384,6 +384,29 @@ fn test() { return bar; } } +"#, + ); + } + + #[test] + fn no_diagnostic_if_tail_exists_in_else_branch() { + check_diagnostics_with_needless_return_disabled( + r#" +fn test1(a: bool) { + let _x = if a { + return; + } else { + 1 + }; +} + +fn test2(a: bool) -> i32 { + if a { + return 1; + } else { + 0 + } +} "#, ); } From d14b22863bd58e78a8e9193db987ae22ba1e57e1 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Thu, 15 Feb 2024 01:29:48 +0900 Subject: [PATCH 128/417] Handle cases for `else if` --- crates/hir-ty/src/diagnostics/expr.rs | 19 +++++++++++++++++-- .../src/handlers/remove_unnecessary_else.rs | 12 ++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index 571f01dde2ef9..ff70618ca129c 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -341,8 +341,23 @@ impl ExprValidator { if let Some(else_branch) = else_branch { // If else branch has a tail, it is an "expression" that produces a value, // e.g. `let a = if { ... } else { ... };` and this `else` is not unnecessary - if let Expr::Block { tail: Some(_), .. } = body.exprs[*else_branch] { - return; + let mut branch = *else_branch; + loop { + match body.exprs[branch] { + Expr::Block { tail: Some(_), .. } => return, + Expr::If { then_branch, else_branch, .. } => { + if let Expr::Block { tail: Some(_), .. } = body.exprs[then_branch] { + return; + } + if let Some(else_branch) = else_branch { + // Continue checking for branches like `if { ... } else if { ... } else...` + branch = else_branch; + continue; + } + } + _ => break, + } + break; } } else { return; diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 813c07a505db2..bbc10e96cef84 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -407,6 +407,18 @@ fn test2(a: bool) -> i32 { 0 } } + +fn test3(a: bool, b: bool, c: bool) { + let _x = if a { + return; + } else if b { + return; + } else if c { + 1 + } else { + return; + }; +} "#, ); } From 21f4ff03516eebb3cbdd8947ad3a7a00c980a692 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Fri, 16 Feb 2024 23:53:00 +0900 Subject: [PATCH 129/417] Check for let expr ancestors instead of tail expr --- crates/hir-ty/src/diagnostics/expr.rs | 52 ++++++++++--------- .../src/handlers/remove_unnecessary_else.rs | 10 +--- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index ff70618ca129c..718409e15997d 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -12,6 +12,7 @@ use hir_expand::name; use itertools::Itertools; use rustc_hash::FxHashSet; use rustc_pattern_analysis::usefulness::{compute_match_usefulness, ValidityConstraint}; +use syntax::{ast, AstNode}; use tracing::debug; use triomphe::Arc; use typed_arena::Arena; @@ -108,7 +109,7 @@ impl ExprValidator { self.check_for_trailing_return(*body_expr, &body); } Expr::If { .. } => { - self.check_for_unnecessary_else(id, expr, &body); + self.check_for_unnecessary_else(id, expr, db); } Expr::Block { .. } => { self.validate_block(db, expr); @@ -336,31 +337,34 @@ impl ExprValidator { } } - fn check_for_unnecessary_else(&mut self, id: ExprId, expr: &Expr, body: &Body) { + fn check_for_unnecessary_else(&mut self, id: ExprId, expr: &Expr, db: &dyn HirDatabase) { if let Expr::If { condition: _, then_branch, else_branch } = expr { - if let Some(else_branch) = else_branch { - // If else branch has a tail, it is an "expression" that produces a value, - // e.g. `let a = if { ... } else { ... };` and this `else` is not unnecessary - let mut branch = *else_branch; - loop { - match body.exprs[branch] { - Expr::Block { tail: Some(_), .. } => return, - Expr::If { then_branch, else_branch, .. } => { - if let Expr::Block { tail: Some(_), .. } = body.exprs[then_branch] { - return; - } - if let Some(else_branch) = else_branch { - // Continue checking for branches like `if { ... } else if { ... } else...` - branch = else_branch; - continue; - } - } - _ => break, - } - break; - } - } else { + if else_branch.is_none() { + return; + } + let (body, source_map) = db.body_with_source_map(self.owner); + let Ok(source_ptr) = source_map.expr_syntax(id) else { return; + }; + let root = source_ptr.file_syntax(db.upcast()); + let ast::Expr::IfExpr(if_expr) = source_ptr.value.to_node(&root) else { + return; + }; + let mut top_if_expr = if_expr; + loop { + let parent = top_if_expr.syntax().parent(); + let has_parent_let_stmt = + parent.as_ref().map_or(false, |node| ast::LetStmt::can_cast(node.kind())); + if has_parent_let_stmt { + // Bail if parent or direct ancestor is a let stmt. + return; + } + let Some(parent_if_expr) = parent.and_then(ast::IfExpr::cast) else { + // Parent is neither an if expr nor a let stmt. + break; + }; + // Check parent if expr. + top_if_expr = parent_if_expr; } if let Expr::Block { statements, tail, .. } = &body.exprs[*then_branch] { let last_then_expr = tail.or_else(|| match statements.last()? { diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index bbc10e96cef84..351f728747efa 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -400,15 +400,7 @@ fn test1(a: bool) { }; } -fn test2(a: bool) -> i32 { - if a { - return 1; - } else { - 0 - } -} - -fn test3(a: bool, b: bool, c: bool) { +fn test2(a: bool, b: bool, c: bool) { let _x = if a { return; } else if b { From 8f6e2127c3a1537298cbda11a8f261875edd6659 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Fri, 16 Feb 2024 23:54:01 +0900 Subject: [PATCH 130/417] Fix the remove unnecessary else action to preserve block tail expr --- .../src/handlers/remove_unnecessary_else.rs | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 351f728747efa..289ce64035432 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -41,9 +41,11 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option { - block.statements().map(|stmt| format!("\n{indent}{stmt}")).join("") - } + ast::ElseBranch::Block(ref block) => block + .statements() + .map(|stmt| format!("\n{indent}{stmt}")) + .chain(block.tail_expr().map(|tail| format!("\n{indent}{tail}"))) + .join(""), ast::ElseBranch::IfExpr(ref nested_if_expr) => { format!("\n{indent}{nested_if_expr}") } @@ -171,6 +173,41 @@ fn test() { ); } + #[test] + fn remove_unnecessary_else_for_return3() { + check_diagnostics_with_needless_return_disabled( + r#" +fn test(a: bool) -> i32 { + if a { + return 1; + } else { + //^^^^ 💡 weak: remove unnecessary else block + 0 + } +} +"#, + ); + check_fix( + r#" +fn test(a: bool) -> i32 { + if a { + return 1; + } else$0 { + 0 + } +} +"#, + r#" +fn test(a: bool) -> i32 { + if a { + return 1; + } + 0 +} +"#, + ); + } + #[test] fn remove_unnecessary_else_for_return_in_child_if_expr() { check_diagnostics_with_needless_return_disabled( From 1205853c3689a69e81578dfd066b17e3ebe376cf Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Sat, 17 Feb 2024 00:55:45 +0900 Subject: [PATCH 131/417] Apply indent fix in #16575 --- .../src/handlers/remove_unnecessary_else.rs | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 289ce64035432..9564807a334e4 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -2,7 +2,10 @@ use hir::{db::ExpandDatabase, diagnostics::RemoveUnnecessaryElse, HirFileIdExt}; use ide_db::{assists::Assist, source_change::SourceChange}; use itertools::Itertools; use syntax::{ - ast::{self, edit::IndentLevel}, + ast::{ + self, + edit::{AstNodeEdit, IndentLevel}, + }, AstNode, SyntaxToken, TextRange, }; use text_edit::TextEdit; @@ -41,12 +44,15 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option block + ast::ElseBranch::Block(block) => block .statements() .map(|stmt| format!("\n{indent}{stmt}")) .chain(block.tail_expr().map(|tail| format!("\n{indent}{tail}"))) .join(""), - ast::ElseBranch::IfExpr(ref nested_if_expr) => { + ast::ElseBranch::IfExpr(mut nested_if_expr) => { + if has_parent_if_expr { + nested_if_expr = nested_if_expr.indent(IndentLevel(1)) + } format!("\n{indent}{nested_if_expr}") } }; @@ -251,6 +257,41 @@ fn test() { ); } + #[test] + fn remove_unnecessary_else_for_return_in_child_if_expr2() { + check_fix( + r#" +fn test() { + if foo { + do_something(); + } else if qux { + return bar; + } else$0 if quux { + do_something_else(); + } else { + do_something_else2(); + } +} +"#, + r#" +fn test() { + if foo { + do_something(); + } else { + if qux { + return bar; + } + if quux { + do_something_else(); + } else { + do_something_else2(); + } + } +} +"#, + ); + } + #[test] fn remove_unnecessary_else_for_break() { check_diagnostics( From ff7031008651021c330b93d4bd502810022b045d Mon Sep 17 00:00:00 2001 From: davidsemakula Date: Fri, 16 Feb 2024 20:39:52 +0300 Subject: [PATCH 132/417] fix: only emit "unnecessary else" diagnostic for expr stmts --- crates/hir-ty/src/diagnostics/expr.rs | 64 +++++++++++-------- .../src/handlers/remove_unnecessary_else.rs | 14 +++- 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index 718409e15997d..4fe75f24b80c8 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -109,7 +109,7 @@ impl ExprValidator { self.check_for_trailing_return(*body_expr, &body); } Expr::If { .. } => { - self.check_for_unnecessary_else(id, expr, db); + self.check_for_unnecessary_else(id, expr, &body, db); } Expr::Block { .. } => { self.validate_block(db, expr); @@ -337,35 +337,17 @@ impl ExprValidator { } } - fn check_for_unnecessary_else(&mut self, id: ExprId, expr: &Expr, db: &dyn HirDatabase) { + fn check_for_unnecessary_else( + &mut self, + id: ExprId, + expr: &Expr, + body: &Body, + db: &dyn HirDatabase, + ) { if let Expr::If { condition: _, then_branch, else_branch } = expr { if else_branch.is_none() { return; } - let (body, source_map) = db.body_with_source_map(self.owner); - let Ok(source_ptr) = source_map.expr_syntax(id) else { - return; - }; - let root = source_ptr.file_syntax(db.upcast()); - let ast::Expr::IfExpr(if_expr) = source_ptr.value.to_node(&root) else { - return; - }; - let mut top_if_expr = if_expr; - loop { - let parent = top_if_expr.syntax().parent(); - let has_parent_let_stmt = - parent.as_ref().map_or(false, |node| ast::LetStmt::can_cast(node.kind())); - if has_parent_let_stmt { - // Bail if parent or direct ancestor is a let stmt. - return; - } - let Some(parent_if_expr) = parent.and_then(ast::IfExpr::cast) else { - // Parent is neither an if expr nor a let stmt. - break; - }; - // Check parent if expr. - top_if_expr = parent_if_expr; - } if let Expr::Block { statements, tail, .. } = &body.exprs[*then_branch] { let last_then_expr = tail.or_else(|| match statements.last()? { Statement::Expr { expr, .. } => Some(*expr), @@ -374,6 +356,36 @@ impl ExprValidator { if let Some(last_then_expr) = last_then_expr { let last_then_expr_ty = &self.infer[last_then_expr]; if last_then_expr_ty.is_never() { + // Only look at sources if the then branch diverges and we have an else branch. + let (_, source_map) = db.body_with_source_map(self.owner); + let Ok(source_ptr) = source_map.expr_syntax(id) else { + return; + }; + let root = source_ptr.file_syntax(db.upcast()); + let ast::Expr::IfExpr(if_expr) = source_ptr.value.to_node(&root) else { + return; + }; + let mut top_if_expr = if_expr; + loop { + let parent = top_if_expr.syntax().parent(); + let has_parent_expr_stmt_or_stmt_list = + parent.as_ref().map_or(false, |node| { + ast::ExprStmt::can_cast(node.kind()) + | ast::StmtList::can_cast(node.kind()) + }); + if has_parent_expr_stmt_or_stmt_list { + // Only emit diagnostic if parent or direct ancestor is either + // an expr stmt or a stmt list. + break; + } + let Some(parent_if_expr) = parent.and_then(ast::IfExpr::cast) else { + // Bail if parent is neither an if expr, an expr stmt nor a stmt list. + return; + }; + // Check parent if expr. + top_if_expr = parent_if_expr; + } + self.diagnostics .push(BodyValidationDiagnostic::RemoveUnnecessaryElse { if_expr: id }) } diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 9564807a334e4..7bfd64596ed2f 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -467,10 +467,10 @@ fn test() { } #[test] - fn no_diagnostic_if_tail_exists_in_else_branch() { + fn no_diagnostic_if_not_expr_stmt() { check_diagnostics_with_needless_return_disabled( r#" -fn test1(a: bool) { +fn test1() { let _x = if a { return; } else { @@ -478,7 +478,7 @@ fn test1(a: bool) { }; } -fn test2(a: bool, b: bool, c: bool) { +fn test2() { let _x = if a { return; } else if b { @@ -491,5 +491,13 @@ fn test2(a: bool, b: bool, c: bool) { } "#, ); + check_diagnostics_with_disabled( + r#" +fn test3() { + foo(if a { return 1 } else { 0 }) +} +"#, + std::iter::once("E0308".to_owned()), + ); } } From 7dfeb2cdcc2a899f929bb3da1c2db7fe6725fb47 Mon Sep 17 00:00:00 2001 From: davidsemakula Date: Mon, 19 Feb 2024 14:43:43 +0300 Subject: [PATCH 133/417] refactor "unnecessary else" diagnostic test --- .../ide-diagnostics/src/handlers/remove_unnecessary_else.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 7bfd64596ed2f..9c63d79d91033 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -491,13 +491,12 @@ fn test2() { } "#, ); - check_diagnostics_with_disabled( + check_diagnostics( r#" -fn test3() { +fn test3() -> u8 { foo(if a { return 1 } else { 0 }) } "#, - std::iter::once("E0308".to_owned()), ); } } From f2218e727840ec0286d89ecc758322674e1efb6d Mon Sep 17 00:00:00 2001 From: davidsemakula Date: Mon, 19 Feb 2024 15:35:47 +0300 Subject: [PATCH 134/417] refactor: remove body parameter for "unnecessary else" diagnostic --- crates/hir-ty/src/diagnostics/expr.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index 4fe75f24b80c8..6c8a187516575 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -109,7 +109,7 @@ impl ExprValidator { self.check_for_trailing_return(*body_expr, &body); } Expr::If { .. } => { - self.check_for_unnecessary_else(id, expr, &body, db); + self.check_for_unnecessary_else(id, expr, db); } Expr::Block { .. } => { self.validate_block(db, expr); @@ -337,18 +337,12 @@ impl ExprValidator { } } - fn check_for_unnecessary_else( - &mut self, - id: ExprId, - expr: &Expr, - body: &Body, - db: &dyn HirDatabase, - ) { + fn check_for_unnecessary_else(&mut self, id: ExprId, expr: &Expr, db: &dyn HirDatabase) { if let Expr::If { condition: _, then_branch, else_branch } = expr { if else_branch.is_none() { return; } - if let Expr::Block { statements, tail, .. } = &body.exprs[*then_branch] { + if let Expr::Block { statements, tail, .. } = &self.body.exprs[*then_branch] { let last_then_expr = tail.or_else(|| match statements.last()? { Statement::Expr { expr, .. } => Some(*expr), _ => None, From d818b531c98d5361310e43127e05f5fe02d88013 Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Fri, 16 Feb 2024 14:54:58 +0000 Subject: [PATCH 135/417] internal: make check_diagnostics_with_disabled more ergonomic --- .../src/handlers/incorrect_case.rs | 2 +- .../src/handlers/mutability_errors.rs | 4 ++-- .../src/handlers/remove_trailing_return.rs | 2 +- .../src/handlers/remove_unnecessary_else.rs | 16 ++++++++-------- .../src/handlers/type_mismatch.rs | 2 +- crates/ide-diagnostics/src/tests.rs | 7 ++----- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/crates/ide-diagnostics/src/handlers/incorrect_case.rs b/crates/ide-diagnostics/src/handlers/incorrect_case.rs index 5e2541795ca1c..db28928a24ea2 100644 --- a/crates/ide-diagnostics/src/handlers/incorrect_case.rs +++ b/crates/ide-diagnostics/src/handlers/incorrect_case.rs @@ -512,7 +512,7 @@ impl BAD_TRAIT for () { fn BadFunction() {} } "#, - std::iter::once("unused_variables".to_owned()), + &["unused_variables"], ); } diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs index 3c71f84dc4852..91f1058d65bbc 100644 --- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs +++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs @@ -448,7 +448,7 @@ fn main(b: bool) { &mut x; } "#, - std::iter::once("remove-unnecessary-else".to_owned()), + &["remove-unnecessary-else"], ); check_diagnostics_with_disabled( r#" @@ -463,7 +463,7 @@ fn main(b: bool) { &mut x; } "#, - std::iter::once("remove-unnecessary-else".to_owned()), + &["remove-unnecessary-else"], ); } diff --git a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs index b7667dc318f0c..7a040e46e3386 100644 --- a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs +++ b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs @@ -140,7 +140,7 @@ fn foo(x: usize) -> u8 { } //^^^^^^^^^ 💡 weak: replace return ; with } "#, - std::iter::once("remove-unnecessary-else".to_owned()), + &["remove-unnecessary-else"], ); } diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 9c63d79d91033..8310af0f524c8 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -97,13 +97,9 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option i32 { #[test] fn remove_unnecessary_else_for_return_in_child_if_expr() { - check_diagnostics_with_needless_return_disabled( + check_diagnostics_with_disabled( r#" fn test() { if foo { @@ -229,6 +227,7 @@ fn test() { } } "#, + &["needless_return"], ); check_fix( r#" @@ -453,7 +452,7 @@ fn test() { #[test] fn no_diagnostic_if_no_divergence_in_else_branch() { - check_diagnostics_with_needless_return_disabled( + check_diagnostics_with_disabled( r#" fn test() { if foo { @@ -463,6 +462,7 @@ fn test() { } } "#, + &["needless_return"], ); } diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs index 8c97281b78328..4c255322280fc 100644 --- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs +++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs @@ -730,7 +730,7 @@ fn f() -> i32 { } fn g() { return; } "#, - std::iter::once("needless_return".to_owned()), + &["needless_return"], ); } diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs index 4e4a851f67e0a..9e134620ee3f1 100644 --- a/crates/ide-diagnostics/src/tests.rs +++ b/crates/ide-diagnostics/src/tests.rs @@ -198,12 +198,9 @@ pub(crate) fn check_diagnostics(ra_fixture: &str) { } #[track_caller] -pub(crate) fn check_diagnostics_with_disabled( - ra_fixture: &str, - disabled: impl Iterator, -) { +pub(crate) fn check_diagnostics_with_disabled(ra_fixture: &str, disabled: &[&str]) { let mut config = DiagnosticsConfig::test_sample(); - config.disabled.extend(disabled); + config.disabled.extend(disabled.into_iter().map(|&s| s.to_owned())); check_diagnostics_with_config(config, ra_fixture) } From a492d9d16489e2801fc0933f969cf3d3a2f88206 Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Sun, 11 Feb 2024 15:34:52 +0000 Subject: [PATCH 136/417] feat: add unresolved-ident diagnostic --- crates/hir-ty/src/infer.rs | 3 ++ crates/hir-ty/src/infer/expr.rs | 14 +++++- crates/hir/src/diagnostics.rs | 10 ++++ .../src/handlers/inactive_code.rs | 1 + .../src/handlers/missing_fields.rs | 3 +- .../src/handlers/missing_match_arms.rs | 16 ++++--- .../src/handlers/remove_unnecessary_else.rs | 25 ++++++---- .../src/handlers/undeclared_label.rs | 8 ++-- .../src/handlers/unresolved_field.rs | 7 ++- .../src/handlers/unresolved_ident.rs | 46 +++++++++++++++++++ .../src/handlers/unresolved_method.rs | 4 +- crates/ide-diagnostics/src/lib.rs | 2 + 12 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 crates/ide-diagnostics/src/handlers/unresolved_ident.rs diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index 1977f00517cd1..9cea414e1a009 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -221,6 +221,9 @@ pub enum InferenceDiagnostic { UnresolvedAssocItem { id: ExprOrPatId, }, + UnresolvedIdent { + expr: ExprId, + }, // FIXME: This should be emitted in body lowering BreakOutsideOfLoop { expr: ExprId, diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs index 428ed6748c6c2..c377a51e7d3b7 100644 --- a/crates/hir-ty/src/infer/expr.rs +++ b/crates/hir-ty/src/infer/expr.rs @@ -13,7 +13,7 @@ use hir_def::{ ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp, }, lang_item::{LangItem, LangItemTarget}, - path::{GenericArg, GenericArgs}, + path::{GenericArg, GenericArgs, Path}, BlockId, ConstParamId, FieldId, ItemContainerId, Lookup, TupleFieldId, TupleId, }; use hir_expand::name::{name, Name}; @@ -439,7 +439,17 @@ impl InferenceContext<'_> { } Expr::Path(p) => { let g = self.resolver.update_to_inner_scope(self.db.upcast(), self.owner, tgt_expr); - let ty = self.infer_path(p, tgt_expr.into()).unwrap_or_else(|| self.err_ty()); + let ty = match self.infer_path(p, tgt_expr.into()) { + Some(ty) => ty, + None => { + if matches!(p, Path::Normal { mod_path, .. } if mod_path.is_ident()) { + self.push_diagnostic(InferenceDiagnostic::UnresolvedIdent { + expr: tgt_expr, + }); + } + self.err_ty() + } + }; self.resolver.reset_to_guard(g); ty } diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index d351e257d2e7c..80cd0c9c794b6 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -87,6 +87,7 @@ diagnostics![ UnresolvedMacroCall, UnresolvedMethodCall, UnresolvedModule, + UnresolvedIdent, UnresolvedProcMacro, UnusedMut, UnusedVariable, @@ -242,6 +243,11 @@ pub struct UnresolvedAssocItem { pub expr_or_pat: InFile>>>, } +#[derive(Debug)] +pub struct UnresolvedIdent { + pub expr: InFile>, +} + #[derive(Debug)] pub struct PrivateField { pub expr: InFile>, @@ -588,6 +594,10 @@ impl AnyDiagnostic { }; UnresolvedAssocItem { expr_or_pat }.into() } + &InferenceDiagnostic::UnresolvedIdent { expr } => { + let expr = expr_syntax(expr); + UnresolvedIdent { expr }.into() + } &InferenceDiagnostic::BreakOutsideOfLoop { expr, is_break, bad_value_break } => { let expr = expr_syntax(expr); BreakOutsideOfLoop { expr, is_break, bad_value_break }.into() diff --git a/crates/ide-diagnostics/src/handlers/inactive_code.rs b/crates/ide-diagnostics/src/handlers/inactive_code.rs index 7db5ea04fbd06..785a42352bfab 100644 --- a/crates/ide-diagnostics/src/handlers/inactive_code.rs +++ b/crates/ide-diagnostics/src/handlers/inactive_code.rs @@ -60,6 +60,7 @@ fn f() { #[cfg(a)] let x = 0; // let statement //^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled + fn abc() {} abc(#[cfg(a)] 0); //^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled let x = Struct { diff --git a/crates/ide-diagnostics/src/handlers/missing_fields.rs b/crates/ide-diagnostics/src/handlers/missing_fields.rs index c70f39eb286f9..09daefd084dc2 100644 --- a/crates/ide-diagnostics/src/handlers/missing_fields.rs +++ b/crates/ide-diagnostics/src/handlers/missing_fields.rs @@ -634,7 +634,8 @@ struct TestStruct { one: i32, two: i64 } fn test_fn() { let one = 1; - let s = TestStruct{ ..a }; + let a = TestStruct{ one, two: 2 }; + let _ = TestStruct{ ..a }; } "#, ); diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs index 7632fdf1d090e..8596f5792e0fb 100644 --- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs +++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs @@ -18,7 +18,9 @@ pub(crate) fn missing_match_arms( #[cfg(test)] mod tests { use crate::{ - tests::{check_diagnostics, check_diagnostics_with_config}, + tests::{ + check_diagnostics, check_diagnostics_with_config, check_diagnostics_with_disabled, + }, DiagnosticsConfig, }; @@ -282,7 +284,7 @@ fn main() { cov_mark::check_count!(validate_match_bailed_out, 4); // Match statements with arms that don't match the // expression pattern do not fire this diagnostic. - check_diagnostics( + check_diagnostics_with_disabled( r#" enum Either { A, B } enum Either2 { C, D } @@ -307,6 +309,7 @@ fn main() { match Unresolved::Bar { Unresolved::Baz => () } } "#, + &["E0425"], ); } @@ -397,11 +400,11 @@ fn main() { match loop {} { Either::A => (), } - match loop { break Foo::A } { - //^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `B` not covered + match loop { break Either::A } { + //^^^^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `B` not covered Either::A => (), } - match loop { break Foo::A } { + match loop { break Either::A } { Either::A => (), Either::B => (), } @@ -977,7 +980,7 @@ fn f(ty: Enum) { #[test] fn unexpected_ty_fndef() { cov_mark::check!(validate_match_bailed_out); - check_diagnostics( + check_diagnostics_with_disabled( r" enum Exp { Tuple(()), @@ -987,6 +990,7 @@ fn f() { Exp::Tuple => {} } }", + &["E0425"], ); } diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index 8310af0f524c8..d5095b754696a 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -95,7 +95,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option ! { loop {} } "#, + &["E0425"], ); check_fix( r#" @@ -422,7 +425,7 @@ fn never() -> ! { #[test] fn no_diagnostic_if_no_else_branch() { - check_diagnostics( + check_diagnostics_with_disabled( r#" fn test() { if foo { @@ -432,12 +435,13 @@ fn test() { do_something_else(); } "#, + &["E0425"], ); } #[test] fn no_diagnostic_if_no_divergence() { - check_diagnostics( + check_diagnostics_with_disabled( r#" fn test() { if foo { @@ -447,6 +451,7 @@ fn test() { } } "#, + &["E0425"], ); } @@ -462,7 +467,7 @@ fn test() { } } "#, - &["needless_return"], + &["needless_return", "E0425"], ); } diff --git a/crates/ide-diagnostics/src/handlers/undeclared_label.rs b/crates/ide-diagnostics/src/handlers/undeclared_label.rs index a6a0fdc655fb2..97943b7e8b347 100644 --- a/crates/ide-diagnostics/src/handlers/undeclared_label.rs +++ b/crates/ide-diagnostics/src/handlers/undeclared_label.rs @@ -38,10 +38,12 @@ fn foo() { fn while_let_loop_with_label_in_condition() { check_diagnostics( r#" +//- minicore: option + fn foo() { let mut optional = Some(0); - 'my_label: while let Some(a) = match optional { + 'my_label: while let Some(_) = match optional { None => break 'my_label, Some(val) => Some(val), } { @@ -59,8 +61,8 @@ fn foo() { r#" //- minicore: iterator fn foo() { - 'xxx: for _ in unknown { - 'yyy: for _ in unknown { + 'xxx: for _ in [] { + 'yyy: for _ in [] { break 'xxx; continue 'yyy; break 'zzz; diff --git a/crates/ide-diagnostics/src/handlers/unresolved_field.rs b/crates/ide-diagnostics/src/handlers/unresolved_field.rs index 65abfd8a294b2..4c01a2d155a2f 100644 --- a/crates/ide-diagnostics/src/handlers/unresolved_field.rs +++ b/crates/ide-diagnostics/src/handlers/unresolved_field.rs @@ -78,7 +78,9 @@ fn method_fix( #[cfg(test)] mod tests { use crate::{ - tests::{check_diagnostics, check_diagnostics_with_config}, + tests::{ + check_diagnostics, check_diagnostics_with_config, check_diagnostics_with_disabled, + }, DiagnosticsConfig, }; @@ -148,7 +150,7 @@ fn foo() { #[test] fn no_diagnostic_on_unknown() { - check_diagnostics( + check_diagnostics_with_disabled( r#" fn foo() { x.foo; @@ -156,6 +158,7 @@ fn foo() { (&((x,),),).foo; } "#, + &["E0425"], ); } diff --git a/crates/ide-diagnostics/src/handlers/unresolved_ident.rs b/crates/ide-diagnostics/src/handlers/unresolved_ident.rs new file mode 100644 index 0000000000000..295c8a2c615fd --- /dev/null +++ b/crates/ide-diagnostics/src/handlers/unresolved_ident.rs @@ -0,0 +1,46 @@ +use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext}; + +// Diagnostic: unresolved-ident +// +// This diagnostic is triggered if an expr-position ident is invalid. +pub(crate) fn unresolved_ident( + ctx: &DiagnosticsContext<'_>, + d: &hir::UnresolvedIdent, +) -> Diagnostic { + Diagnostic::new_with_syntax_node_ptr( + ctx, + DiagnosticCode::RustcHardError("E0425"), + "no such value in this scope", + d.expr.map(Into::into), + ) + .experimental() +} + +#[cfg(test)] +mod tests { + use crate::tests::check_diagnostics; + + #[test] + fn missing() { + check_diagnostics( + r#" +fn main() { + let _ = x; + //^ error: no such value in this scope +} +"#, + ); + } + + #[test] + fn present() { + check_diagnostics( + r#" +fn main() { + let x = 5; + let _ = x; +} +"#, + ); + } +} diff --git a/crates/ide-diagnostics/src/handlers/unresolved_method.rs b/crates/ide-diagnostics/src/handlers/unresolved_method.rs index 648d081898ceb..0614fdc5514aa 100644 --- a/crates/ide-diagnostics/src/handlers/unresolved_method.rs +++ b/crates/ide-diagnostics/src/handlers/unresolved_method.rs @@ -335,8 +335,8 @@ fn main() { r#" struct Foo { bar: i32 } fn foo() { - Foo { bar: i32 }.bar(); - // ^^^ error: no method `bar` on type `Foo`, but a field with a similar name exists + Foo { bar: 0 }.bar(); + // ^^^ error: no method `bar` on type `Foo`, but a field with a similar name exists } "#, ); diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index 3a3888011d75e..4428b8baafbdb 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -59,6 +59,7 @@ mod handlers { pub(crate) mod unresolved_assoc_item; pub(crate) mod unresolved_extern_crate; pub(crate) mod unresolved_field; + pub(crate) mod unresolved_ident; pub(crate) mod unresolved_import; pub(crate) mod unresolved_macro_call; pub(crate) mod unresolved_method; @@ -377,6 +378,7 @@ pub fn diagnostics( AnyDiagnostic::UnresolvedAssocItem(d) => handlers::unresolved_assoc_item::unresolved_assoc_item(&ctx, &d), AnyDiagnostic::UnresolvedExternCrate(d) => handlers::unresolved_extern_crate::unresolved_extern_crate(&ctx, &d), AnyDiagnostic::UnresolvedField(d) => handlers::unresolved_field::unresolved_field(&ctx, &d), + AnyDiagnostic::UnresolvedIdent(d) => handlers::unresolved_ident::unresolved_ident(&ctx, &d), AnyDiagnostic::UnresolvedImport(d) => handlers::unresolved_import::unresolved_import(&ctx, &d), AnyDiagnostic::UnresolvedMacroCall(d) => handlers::unresolved_macro_call::unresolved_macro_call(&ctx, &d), AnyDiagnostic::UnresolvedMethodCall(d) => handlers::unresolved_method::unresolved_method(&ctx, &d), From 087c7c828d5e5730fbf8cfe4cbc398e27c66a60e Mon Sep 17 00:00:00 2001 From: roife Date: Sat, 30 Dec 2023 21:31:19 +0800 Subject: [PATCH 137/417] Add check for same guards in match_same_arms --- .../src/casts/cast_possible_truncation.rs | 3 +- clippy_lints/src/matches/match_same_arms.rs | 66 +++++++++++-------- tests/ui/match_same_arms2.rs | 14 ++++ tests/ui/match_same_arms2.stderr | 51 +++++++++----- 4 files changed, 87 insertions(+), 47 deletions(-) diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index f99a51e2b88c5..fbbb559319ed5 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -131,8 +131,7 @@ pub(super) fn check( let cast_from_ptr_size = def.repr().int.map_or(true, |ty| matches!(ty, IntegerType::Pointer(_),)); let suffix = match (cast_from_ptr_size, is_isize_or_usize(cast_to)) { - (false, false) if from_nbits > to_nbits => "", - (true, false) if from_nbits > to_nbits => "", + (_, false) if from_nbits > to_nbits => "", (false, true) if from_nbits > 64 => "", (false, true) if from_nbits > 32 => " on targets with 32-bit wide pointers", _ => return, diff --git a/clippy_lints/src/matches/match_same_arms.rs b/clippy_lints/src/matches/match_same_arms.rs index d645e6c6c05c9..ae302f0f0758a 100644 --- a/clippy_lints/src/matches/match_same_arms.rs +++ b/clippy_lints/src/matches/match_same_arms.rs @@ -64,38 +64,50 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>]) { let min_index = usize::min(lindex, rindex); let max_index = usize::max(lindex, rindex); - let mut local_map: HirIdMap = HirIdMap::default(); - let eq_fallback = |a: &Expr<'_>, b: &Expr<'_>| { - if let Some(a_id) = path_to_local(a) - && let Some(b_id) = path_to_local(b) - && let entry = match local_map.entry(a_id) { - HirIdMapEntry::Vacant(entry) => entry, - // check if using the same bindings as before - HirIdMapEntry::Occupied(entry) => return *entry.get() == b_id, - } + let check_eq_with_pat = |expr_a: &Expr<'_>, expr_b: &Expr<'_>| { + let mut local_map: HirIdMap = HirIdMap::default(); + let eq_fallback = |a: &Expr<'_>, b: &Expr<'_>| { + if let Some(a_id) = path_to_local(a) + && let Some(b_id) = path_to_local(b) + && let entry = match local_map.entry(a_id) { + HirIdMapEntry::Vacant(entry) => entry, + // check if using the same bindings as before + HirIdMapEntry::Occupied(entry) => return *entry.get() == b_id, + } // the names technically don't have to match; this makes the lint more conservative && cx.tcx.hir().name(a_id) == cx.tcx.hir().name(b_id) - && cx.typeck_results().expr_ty(a) == cx.typeck_results().expr_ty(b) - && pat_contains_local(lhs.pat, a_id) - && pat_contains_local(rhs.pat, b_id) - { - entry.insert(b_id); - true - } else { - false - } - }; - // Arms with a guard are ignored, those can’t always be merged together - // If both arms overlap with an arm in between then these can't be merged either. - !(backwards_blocking_idxs[max_index] > min_index && forwards_blocking_idxs[min_index] < max_index) - && lhs.guard.is_none() - && rhs.guard.is_none() - && SpanlessEq::new(cx) - .expr_fallback(eq_fallback) - .eq_expr(lhs.body, rhs.body) + && cx.typeck_results().expr_ty(a) == cx.typeck_results().expr_ty(b) + && pat_contains_local(lhs.pat, a_id) + && pat_contains_local(rhs.pat, b_id) + { + entry.insert(b_id); + true + } else { + false + } + }; + + SpanlessEq::new(cx) + .expr_fallback(eq_fallback) + .eq_expr(expr_a, expr_b) // these checks could be removed to allow unused bindings && bindings_eq(lhs.pat, local_map.keys().copied().collect()) && bindings_eq(rhs.pat, local_map.values().copied().collect()) + }; + + let check_same_guard = || match (&lhs.guard, &rhs.guard) { + (None, None) => true, + (Some(lhs_guard), Some(rhs_guard)) => check_eq_with_pat(lhs_guard, rhs_guard), + _ => false, + }; + + let check_same_body = || check_eq_with_pat(lhs.body, rhs.body); + + // Arms with different guard are ignored, those can’t always be merged together + // If both arms overlap with an arm in between then these can't be merged either. + !(backwards_blocking_idxs[max_index] > min_index && forwards_blocking_idxs[min_index] < max_index) + && check_same_guard() + && check_same_body() }; let indexed_arms: Vec<(usize, &Arm<'_>)> = arms.iter().enumerate().collect(); diff --git a/tests/ui/match_same_arms2.rs b/tests/ui/match_same_arms2.rs index 3428ff4590602..85ad0962eb4bf 100644 --- a/tests/ui/match_same_arms2.rs +++ b/tests/ui/match_same_arms2.rs @@ -67,6 +67,20 @@ fn match_same_arms() { _ => (), } + // No warning because guards are different + let _ = match Some(42) { + Some(a) if a == 42 => a, + Some(a) if a == 24 => a, + Some(_) => 24, + None => 0, + }; + + let _ = match (Some(42), Some(42)) { + (Some(a), None) if a == 42 => a, + (None, Some(a)) if a == 42 => a, //~ ERROR: this match arm has an identical body to another arm + _ => 0, + }; + match (Some(42), Some(42)) { (Some(a), ..) => bar(a), //~ ERROR: this match arm has an identical body to another arm (.., Some(a)) => bar(a), diff --git a/tests/ui/match_same_arms2.stderr b/tests/ui/match_same_arms2.stderr index 6abbb582763d4..f4c38c1af8975 100644 --- a/tests/ui/match_same_arms2.stderr +++ b/tests/ui/match_same_arms2.stderr @@ -71,7 +71,22 @@ LL | (Some(a), None) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:71:9 + --> tests/ui/match_same_arms2.rs:80:9 + | +LL | (None, Some(a)) if a == 42 => a, + | ---------------^^^^^^^^^^^^^^^^ + | | + | help: try merging the arm patterns: `(None, Some(a)) | (Some(a), None)` + | + = help: or try changing either arm body +note: other arm here + --> tests/ui/match_same_arms2.rs:79:9 + | +LL | (Some(a), None) if a == 42 => a, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this match arm has an identical body to another arm + --> tests/ui/match_same_arms2.rs:85:9 | LL | (Some(a), ..) => bar(a), | -------------^^^^^^^^^^ @@ -80,13 +95,13 @@ LL | (Some(a), ..) => bar(a), | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:72:9 + --> tests/ui/match_same_arms2.rs:86:9 | LL | (.., Some(a)) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:105:9 + --> tests/ui/match_same_arms2.rs:119:9 | LL | (Ok(x), Some(_)) => println!("ok {}", x), | ----------------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,13 +110,13 @@ LL | (Ok(x), Some(_)) => println!("ok {}", x), | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:106:9 + --> tests/ui/match_same_arms2.rs:120:9 | LL | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:121:9 + --> tests/ui/match_same_arms2.rs:135:9 | LL | Ok(_) => println!("ok"), | -----^^^^^^^^^^^^^^^^^^ @@ -110,13 +125,13 @@ LL | Ok(_) => println!("ok"), | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:120:9 + --> tests/ui/match_same_arms2.rs:134:9 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:148:9 + --> tests/ui/match_same_arms2.rs:162:9 | LL | 1 => { | ^ help: try merging the arm patterns: `1 | 0` @@ -128,7 +143,7 @@ LL | | }, | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:145:9 + --> tests/ui/match_same_arms2.rs:159:9 | LL | / 0 => { LL | | empty!(0); @@ -136,7 +151,7 @@ LL | | }, | |_________^ error: match expression looks like `matches!` macro - --> tests/ui/match_same_arms2.rs:167:16 + --> tests/ui/match_same_arms2.rs:181:16 | LL | let _ans = match x { | ________________^ @@ -150,7 +165,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:199:9 + --> tests/ui/match_same_arms2.rs:213:9 | LL | Foo::X(0) => 1, | ---------^^^^^ @@ -159,13 +174,13 @@ LL | Foo::X(0) => 1, | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:201:9 + --> tests/ui/match_same_arms2.rs:215:9 | LL | Foo::Z(_) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:209:9 + --> tests/ui/match_same_arms2.rs:223:9 | LL | Foo::Z(_) => 1, | ---------^^^^^ @@ -174,13 +189,13 @@ LL | Foo::Z(_) => 1, | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:207:9 + --> tests/ui/match_same_arms2.rs:221:9 | LL | Foo::X(0) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:232:9 + --> tests/ui/match_same_arms2.rs:246:9 | LL | Some(Bar { y: 0, x: 5, .. }) => 1, | ----------------------------^^^^^ @@ -189,13 +204,13 @@ LL | Some(Bar { y: 0, x: 5, .. }) => 1, | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:229:9 + --> tests/ui/match_same_arms2.rs:243:9 | LL | Some(Bar { x: 0, y: 5, .. }) => 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:246:9 + --> tests/ui/match_same_arms2.rs:260:9 | LL | 1 => cfg!(not_enable), | -^^^^^^^^^^^^^^^^^^^^ @@ -204,10 +219,10 @@ LL | 1 => cfg!(not_enable), | = help: or try changing either arm body note: other arm here - --> tests/ui/match_same_arms2.rs:245:9 + --> tests/ui/match_same_arms2.rs:259:9 | LL | 0 => cfg!(not_enable), | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 13 previous errors +error: aborting due to 14 previous errors From f67c3f4bd88f4a35fe48e45dc4fca7e3985447f2 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Mon, 19 Feb 2024 14:20:11 +0000 Subject: [PATCH 138/417] Default test output conflict handling to error --- tests/compile-test.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 09f7badcd2022..a088896b6b007 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -5,7 +5,7 @@ #![allow(unused_extern_crates)] use ui_test::spanned::Spanned; -use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, Mode}; +use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, Mode, OutputConflictHandling}; use std::collections::BTreeMap; use std::env::{self, set_var, var_os}; @@ -113,6 +113,7 @@ fn base_config(test_dir: &str) -> (Config, Args) { let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into())); let mut config = Config { + output_conflict_handling: OutputConflictHandling::Error, filter_files: env::var("TESTNAME") .map(|filters| filters.split(',').map(str::to_string).collect()) .unwrap_or_default(), From 1e448f84c3a05350af700de7903083572bba34fc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 19 Feb 2024 13:53:29 +0100 Subject: [PATCH 139/417] Clippy --- .../src/handlers/remove_unnecessary_else.rs | 9 ++++++--- crates/ide-diagnostics/src/tests.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs index d5095b754696a..47844876dc540 100644 --- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs +++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs @@ -179,7 +179,7 @@ fn test() { #[test] fn remove_unnecessary_else_for_return3() { - check_diagnostics_with_needless_return_disabled( + check_diagnostics_with_disabled( r#" fn test(a: bool) -> i32 { if a { @@ -190,6 +190,7 @@ fn test(a: bool) -> i32 { } } "#, + &["needless_return", "E0425"], ); check_fix( r#" @@ -473,7 +474,7 @@ fn test() { #[test] fn no_diagnostic_if_not_expr_stmt() { - check_diagnostics_with_needless_return_disabled( + check_diagnostics_with_disabled( r#" fn test1() { let _x = if a { @@ -495,13 +496,15 @@ fn test2() { }; } "#, + &["needless_return", "E0425"], ); - check_diagnostics( + check_diagnostics_with_disabled( r#" fn test3() -> u8 { foo(if a { return 1 } else { 0 }) } "#, + &["E0425"], ); } } diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs index 9e134620ee3f1..901ceffbb266d 100644 --- a/crates/ide-diagnostics/src/tests.rs +++ b/crates/ide-diagnostics/src/tests.rs @@ -200,7 +200,7 @@ pub(crate) fn check_diagnostics(ra_fixture: &str) { #[track_caller] pub(crate) fn check_diagnostics_with_disabled(ra_fixture: &str, disabled: &[&str]) { let mut config = DiagnosticsConfig::test_sample(); - config.disabled.extend(disabled.into_iter().map(|&s| s.to_owned())); + config.disabled.extend(disabled.iter().map(|&s| s.to_owned())); check_diagnostics_with_config(config, ra_fixture) } From d2b27d09ea075b36bac166e7ac029742510e8662 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 19 Feb 2024 16:46:09 +0100 Subject: [PATCH 140/417] Don't populate rust_ir::AdtVariantDatum::fields for now due to perf --- crates/hir-ty/src/chalk_db.rs | 3 +++ crates/hir-ty/src/tests/coercion.rs | 4 +++- crates/hir-ty/src/tests/traits.rs | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index 49393f05a1ab9..40a195f7d95a7 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -742,6 +742,8 @@ pub(crate) fn adt_datum_query( phantom_data, }; + #[cfg(FALSE)] + // this slows down rust-analyzer by quite a bit unfortunately, so enabling this is currently not worth it let variant_id_to_fields = |id: VariantId| { let variant_data = &id.variant_data(db.upcast()); let fields = if variant_data.fields().is_empty() { @@ -757,6 +759,7 @@ pub(crate) fn adt_datum_query( }; rust_ir::AdtVariantDatum { fields } }; + let variant_id_to_fields = |_: VariantId| rust_ir::AdtVariantDatum { fields: vec![] }; let (kind, variants) = match adt_id { hir_def::AdtId::StructId(id) => { diff --git a/crates/hir-ty/src/tests/coercion.rs b/crates/hir-ty/src/tests/coercion.rs index bfb8df61a3330..d56b15b9b741e 100644 --- a/crates/hir-ty/src/tests/coercion.rs +++ b/crates/hir-ty/src/tests/coercion.rs @@ -536,7 +536,7 @@ fn test() { #[test] fn coerce_unsize_generic() { - check_no_mismatches( + check( r#" //- minicore: coerce_unsized struct Foo { t: T }; @@ -544,7 +544,9 @@ struct Bar(Foo); fn test() { let _: &Foo<[usize]> = &Foo { t: [1, 2, 3] }; + //^^^^^^^^^^^^^^^^^^^^^ expected &Foo<[usize]>, got &Foo<[i32; 3]> let _: &Bar<[usize]> = &Bar(Foo { t: [1, 2, 3] }); + //^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &Bar<[usize]>, got &Bar<[i32; 3]> } "#, ); diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs index 68cd6071ec79b..879c69c758fcd 100644 --- a/crates/hir-ty/src/tests/traits.rs +++ b/crates/hir-ty/src/tests/traits.rs @@ -4583,21 +4583,21 @@ fn f() { Struct::::IS_SEND; //^^^^^^^^^^^^^^^^^^^^Yes Struct::::IS_SEND; - //^^^^^^^^^^^^^^^^^^^^{unknown} + //^^^^^^^^^^^^^^^^^^^^Yes Struct::<*const T>::IS_SEND; - //^^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + //^^^^^^^^^^^^^^^^^^^^^^^^^^^Yes Enum::::IS_SEND; //^^^^^^^^^^^^^^^^^^Yes Enum::::IS_SEND; - //^^^^^^^^^^^^^^^^^^{unknown} + //^^^^^^^^^^^^^^^^^^Yes Enum::<*const T>::IS_SEND; - //^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + //^^^^^^^^^^^^^^^^^^^^^^^^^Yes Union::::IS_SEND; //^^^^^^^^^^^^^^^^^^^Yes Union::::IS_SEND; - //^^^^^^^^^^^^^^^^^^^{unknown} + //^^^^^^^^^^^^^^^^^^^Yes Union::<*const T>::IS_SEND; - //^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown} + //^^^^^^^^^^^^^^^^^^^^^^^^^^Yes PhantomData::::IS_SEND; //^^^^^^^^^^^^^^^^^^^^^^^^^Yes PhantomData::::IS_SEND; From a822291a025f495aacef9201807fce77971e8097 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 19 Feb 2024 18:00:50 +0100 Subject: [PATCH 141/417] Infallible definition hovers --- crates/ide-db/src/defs.rs | 13 ++-- crates/ide/src/hover.rs | 37 ++++++------ crates/ide/src/hover/render.rs | 14 ++--- crates/ide/src/hover/tests.rs | 105 +++++++++++++++++++++++++++++++-- crates/ide/src/static_index.rs | 4 +- 5 files changed, 135 insertions(+), 38 deletions(-) diff --git a/crates/ide-db/src/defs.rs b/crates/ide-db/src/defs.rs index d95d94ec72e2c..747c90561deea 100644 --- a/crates/ide-db/src/defs.rs +++ b/crates/ide-db/src/defs.rs @@ -213,8 +213,8 @@ impl Definition { }) } - pub fn label(&self, db: &RootDatabase) -> Option { - let label = match *self { + pub fn label(&self, db: &RootDatabase) -> String { + match *self { Definition::Macro(it) => it.display(db).to_string(), Definition::Field(it) => it.display(db).to_string(), Definition::TupleField(it) => it.display(db).to_string(), @@ -241,7 +241,11 @@ impl Definition { } } Definition::SelfType(impl_def) => { - impl_def.self_ty(db).as_adt().and_then(|adt| Definition::Adt(adt).label(db))? + let self_ty = &impl_def.self_ty(db); + match self_ty.as_adt() { + Some(it) => it.display(db).to_string(), + None => self_ty.display(db).to_string(), + } } Definition::GenericParam(it) => it.display(db).to_string(), Definition::Label(it) => it.name(db).display(db).to_string(), @@ -249,8 +253,7 @@ impl Definition { Definition::BuiltinAttr(it) => format!("#[{}]", it.name(db)), Definition::ToolModule(it) => it.name(db).to_string(), Definition::DeriveHelper(it) => format!("derive_helper {}", it.name(db).display(db)), - }; - Some(label) + } } } diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 19b181ae3b61e..4a7350feb385e 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -147,7 +147,7 @@ fn hover_simple( if let Some(doc_comment) = token_as_doc_comment(&original_token) { cov_mark::hit!(no_highlight_on_comment_hover); return doc_comment.get_definition_with_descend_at(sema, offset, |def, node, range| { - let res = hover_for_definition(sema, file_id, def, &node, config)?; + let res = hover_for_definition(sema, file_id, def, &node, config); Some(RangeInfo::new(range, res)) }); } @@ -161,7 +161,7 @@ fn hover_simple( Definition::from(resolution?), &original_token.parent()?, config, - )?; + ); return Some(RangeInfo::new(range, res)); } @@ -215,7 +215,7 @@ fn hover_simple( }) .flatten() .unique_by(|&(def, _)| def) - .filter_map(|(def, node)| hover_for_definition(sema, file_id, def, &node, config)) + .map(|(def, node)| hover_for_definition(sema, file_id, def, &node, config)) .reduce(|mut acc: HoverResult, HoverResult { markup, actions }| { acc.actions.extend(actions); acc.markup = Markup::from(format!("{}\n---\n{markup}", acc.markup)); @@ -373,9 +373,9 @@ pub(crate) fn hover_for_definition( def: Definition, scope_node: &SyntaxNode, config: &HoverConfig, -) -> Option { +) -> HoverResult { let famous_defs = match &def { - Definition::BuiltinType(_) => Some(FamousDefs(sema, sema.scope(scope_node)?.krate())), + Definition::BuiltinType(_) => sema.scope(scope_node).map(|it| FamousDefs(sema, it.krate())), _ => None, }; @@ -396,20 +396,19 @@ pub(crate) fn hover_for_definition( }; let notable_traits = def_ty.map(|ty| notable_traits(db, &ty)).unwrap_or_default(); - render::definition(sema.db, def, famous_defs.as_ref(), ¬able_traits, config).map(|markup| { - HoverResult { - markup: render::process_markup(sema.db, def, &markup, config), - actions: [ - show_implementations_action(sema.db, def), - show_fn_references_action(sema.db, def), - runnable_action(sema, def, file_id), - goto_type_action_for_def(sema.db, def, ¬able_traits), - ] - .into_iter() - .flatten() - .collect(), - } - }) + let markup = render::definition(sema.db, def, famous_defs.as_ref(), ¬able_traits, config); + HoverResult { + markup: render::process_markup(sema.db, def, &markup, config), + actions: [ + show_implementations_action(sema.db, def), + show_fn_references_action(sema.db, def), + runnable_action(sema, def, file_id), + goto_type_action_for_def(sema.db, def, ¬able_traits), + ] + .into_iter() + .flatten() + .collect(), + } } fn notable_traits( diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs index eff055c959926..42342d94b6d13 100644 --- a/crates/ide/src/hover/render.rs +++ b/crates/ide/src/hover/render.rs @@ -264,7 +264,7 @@ pub(super) fn keyword( let markup = process_markup( sema.db, Definition::Module(doc_owner), - &markup(Some(docs.into()), description, None)?, + &markup(Some(docs.into()), description, None), config, ); Some(HoverResult { markup, actions }) @@ -396,11 +396,11 @@ pub(super) fn definition( famous_defs: Option<&FamousDefs<'_, '_>>, notable_traits: &[(Trait, Vec<(Option, Name)>)], config: &HoverConfig, -) -> Option { +) -> Markup { let mod_path = definition_mod_path(db, &def); - let label = def.label(db)?; + let label = def.label(db); let docs = def.docs(db, famous_defs); - let value = match def { + let value = (|| match def { Definition::Variant(it) => { if !it.parent_enum(db).is_data_carrying(db) { match it.eval(db) { @@ -436,7 +436,7 @@ pub(super) fn definition( Some(body.to_string()) } _ => None, - }; + })(); let layout_info = match def { Definition::Field(it) => render_memory_layout( @@ -683,7 +683,7 @@ fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option { def.module(db).map(|module| path(db, module, definition_owner_name(db, def))) } -fn markup(docs: Option, desc: String, mod_path: Option) -> Option { +fn markup(docs: Option, desc: String, mod_path: Option) -> Markup { let mut buf = String::new(); if let Some(mod_path) = mod_path { @@ -696,7 +696,7 @@ fn markup(docs: Option, desc: String, mod_path: Option) -> Optio if let Some(doc) = docs { format_to!(buf, "\n___\n\n{}", doc); } - Some(buf.into()) + buf.into() } fn find_std_module(famous_defs: &FamousDefs<'_, '_>, name: &str) -> Option { diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 69ddc1e45efbd..157f8ff371ef2 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -1279,11 +1279,11 @@ impl Thing { ); check( r#" - enum Thing { A } - impl Thing { - pub fn thing(a: Self$0) {} - } - "#, +enum Thing { A } +impl Thing { + pub fn thing(a: Self$0) {} +} +"#, expect![[r#" *Self* @@ -1298,6 +1298,42 @@ impl Thing { ``` "#]], ); + check( + r#" +impl usize { + pub fn thing(a: Self$0) {} +} +"#, + expect![[r#" + *Self* + + ```rust + test + ``` + + ```rust + usize + ``` + "#]], + ); + check( + r#" +impl fn() -> usize { + pub fn thing(a: Self$0) {} +} +"#, + expect![[r#" + *Self* + + ```rust + test + ``` + + ```rust + fn() -> usize + ``` + "#]], + ); } #[test] @@ -7201,6 +7237,65 @@ impl Iterator for S { ); } +#[test] +fn extern_items() { + check( + r#" +extern "C" { + static STATIC$0: (); +} +"#, + expect![[r#" + *STATIC* + + ```rust + test + ``` + + ```rust + static STATIC: () + ``` + "#]], + ); + check( + r#" +extern "C" { + fn fun$0(); +} +"#, + expect![[r#" + *fun* + + ```rust + test + ``` + + ```rust + unsafe fn fun() + ``` + "#]], + ); + check( + r#" +extern "C" { + type Ty$0; +} +"#, + expect![[r#" + *Ty* + + ```rust + test + ``` + + ```rust + // size = 0, align = 1 + type Ty + ``` + "#]], + ); +} + #[test] fn notable_ranged() { check_hover_range( diff --git a/crates/ide/src/static_index.rs b/crates/ide/src/static_index.rs index 5feaf21aa9795..2929a7522e591 100644 --- a/crates/ide/src/static_index.rs +++ b/crates/ide/src/static_index.rs @@ -186,7 +186,7 @@ impl StaticIndex<'_> { } else { let it = self.tokens.insert(TokenStaticData { documentation: documentation_for_definition(&sema, def, &node), - hover: hover_for_definition(&sema, file_id, def, &node, &hover_config), + hover: Some(hover_for_definition(&sema, file_id, def, &node, &hover_config)), definition: def.try_to_nav(self.db).map(UpmappingResult::call_site).map(|it| { FileRange { file_id: it.file_id, range: it.focus_or_full_range() } }), @@ -196,7 +196,7 @@ impl StaticIndex<'_> { enclosing_moniker: current_crate .zip(def.enclosing_definition(self.db)) .and_then(|(cc, enclosing_def)| def_to_moniker(self.db, enclosing_def, cc)), - signature: def.label(self.db), + signature: Some(def.label(self.db)), kind: def_to_kind(self.db, def), }); self.def_map.insert(def, it); From 16d5a2be3d938cc3a8263a88fe2229758115dbb2 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 19 Feb 2024 17:39:25 -0300 Subject: [PATCH 142/417] Remove suspicious auto trait lint --- tests/ui/non_send_fields_in_send_ty.rs | 1 - tests/ui/non_send_fields_in_send_ty.stderr | 52 +++++++++++----------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/tests/ui/non_send_fields_in_send_ty.rs b/tests/ui/non_send_fields_in_send_ty.rs index c6855a0969681..046ea70b08f16 100644 --- a/tests/ui/non_send_fields_in_send_ty.rs +++ b/tests/ui/non_send_fields_in_send_ty.rs @@ -1,5 +1,4 @@ #![warn(clippy::non_send_fields_in_send_ty)] -#![allow(suspicious_auto_trait_impls)] #![feature(extern_types)] use std::cell::UnsafeCell; diff --git a/tests/ui/non_send_fields_in_send_ty.stderr b/tests/ui/non_send_fields_in_send_ty.stderr index 1ea76196af938..99fd4ea60b608 100644 --- a/tests/ui/non_send_fields_in_send_ty.stderr +++ b/tests/ui/non_send_fields_in_send_ty.stderr @@ -1,11 +1,11 @@ error: some fields in `RingBuffer` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:17:1 + --> $DIR/non_send_fields_in_send_ty.rs:16:1 | LL | unsafe impl Send for RingBuffer {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `data` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:12:5 + --> $DIR/non_send_fields_in_send_ty.rs:11:5 | LL | data: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,155 +14,155 @@ LL | data: Vec>, = help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]` error: some fields in `MvccRwLock` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:26:1 + --> $DIR/non_send_fields_in_send_ty.rs:25:1 | LL | unsafe impl Send for MvccRwLock {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `lock` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:23:5 + --> $DIR/non_send_fields_in_send_ty.rs:22:5 | LL | lock: Mutex>, | ^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Mutex>: Send` error: some fields in `ArcGuard` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:35:1 + --> $DIR/non_send_fields_in_send_ty.rs:34:1 | LL | unsafe impl Send for ArcGuard {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `head` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:32:5 + --> $DIR/non_send_fields_in_send_ty.rs:31:5 | LL | head: Arc, | ^^^^^^^^^^^^^ = help: add bounds on type parameter `RC` that satisfy `Arc: Send` error: some fields in `DeviceHandle` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:52:1 + --> $DIR/non_send_fields_in_send_ty.rs:51:1 | LL | unsafe impl Send for DeviceHandle {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `context` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:48:5 + --> $DIR/non_send_fields_in_send_ty.rs:47:5 | LL | context: T, | ^^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `NoGeneric` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:60:1 + --> $DIR/non_send_fields_in_send_ty.rs:59:1 | LL | unsafe impl Send for NoGeneric {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `rc_is_not_send` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:57:5 + --> $DIR/non_send_fields_in_send_ty.rs:56:5 | LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: some fields in `MultiField` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:69:1 + --> $DIR/non_send_fields_in_send_ty.rs:68:1 | LL | unsafe impl Send for MultiField {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:64:5 + --> $DIR/non_send_fields_in_send_ty.rs:63:5 | LL | field1: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field2` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:65:5 + --> $DIR/non_send_fields_in_send_ty.rs:64:5 | LL | field2: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field3` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:66:5 + --> $DIR/non_send_fields_in_send_ty.rs:65:5 | LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `MyOption` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:77:1 + --> $DIR/non_send_fields_in_send_ty.rs:76:1 | LL | unsafe impl Send for MyOption {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:73:12 + --> $DIR/non_send_fields_in_send_ty.rs:72:12 | LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `MultiParam` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:90:1 + --> $DIR/non_send_fields_in_send_ty.rs:89:1 | LL | unsafe impl Send for MultiParam {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `vec` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:87:5 + --> $DIR/non_send_fields_in_send_ty.rs:86:5 | LL | vec: Vec<(A, B)>, | ^^^^^^^^^^^^^^^^ = help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send` error: some fields in `HeuristicTest` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:109:1 + --> $DIR/non_send_fields_in_send_ty.rs:108:1 | LL | unsafe impl Send for HeuristicTest {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field4` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:104:5 + --> $DIR/non_send_fields_in_send_ty.rs:103:5 | LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: some fields in `AttrTest3` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:129:1 + --> $DIR/non_send_fields_in_send_ty.rs:128:1 | LL | unsafe impl Send for AttrTest3 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:124:11 + --> $DIR/non_send_fields_in_send_ty.rs:123:11 | LL | Enum2(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `Complex` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:138:1 + --> $DIR/non_send_fields_in_send_ty.rs:137:1 | LL | unsafe impl

Send for Complex {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:134:5 + --> $DIR/non_send_fields_in_send_ty.rs:133:5 | LL | field1: A, | ^^^^^^^^^ = help: add `P: Send` bound in `Send` impl error: some fields in `Complex>` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:142:1 + --> $DIR/non_send_fields_in_send_ty.rs:141:1 | LL | unsafe impl Send for Complex> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field2` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:135:5 + --> $DIR/non_send_fields_in_send_ty.rs:134:5 | LL | field2: B, | ^^^^^^^^^ From ee8fd82f4ca18d154522f65cafd808c8de1ecd9c Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 11 Jan 2024 20:26:07 +1000 Subject: [PATCH 143/417] Fix uncertain sign and remainder op handling in cast_sign_loss.rs --- clippy_lints/src/casts/cast_sign_loss.rs | 90 ++++++++++++++++-------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 1df5a25f674d7..1b907d8257018 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -7,7 +7,12 @@ use rustc_middle::ty::{self, Ty, UintTy}; use super::CAST_SIGN_LOSS; -const METHODS_RET_POSITIVE: &[&str] = &["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"]; +/// A list of methods that can never return a negative value. +/// Includes methods that panic rather than returning a negative value. +/// +/// Methods that can overflow and return a negative value must not be included in this list, +/// because checking for negative return values from those functions can be useful. +const METHODS_RET_POSITIVE: &[&str] = &["checked_abs", "rem_euclid", "checked_rem_euclid"]; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { if should_lint(cx, cast_op, cast_from, cast_to) { @@ -27,13 +32,15 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast return false; } - // Don't lint if `cast_op` is known to be positive. + // Don't lint if `cast_op` is known to be positive, ignoring overflow. if let Sign::ZeroOrPositive = expr_sign(cx, cast_op, cast_from) { return false; } let (mut uncertain_count, mut negative_count) = (0, 0); - // Peel off possible binary expressions, e.g. x * x * y => [x, x, y] + // Peel off possible binary expressions, for example: + // x * x * y => [x, x, y] + // a % b => [a] let Some(exprs) = exprs_with_selected_binop_peeled(cast_op) else { // Assume cast sign lose if we cannot determine the sign of `cast_op` return true; @@ -47,8 +54,9 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast }; } - // Lint if there are odd number of uncertain or negative results - uncertain_count % 2 == 1 || negative_count % 2 == 1 + // Lint if there are any uncertain results (because they could be negative or positive), + // or an odd number of negative results. + uncertain_count > 0 || negative_count % 2 == 1 }, (false, true) => !cast_to.is_signed(), @@ -87,6 +95,12 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { { method_name = inner_path.ident.name.as_str(); } + if method_name == "expect" + && let Some(arglist) = method_chain_args(expr, &["expect"]) + && let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind + { + method_name = inner_path.ident.name.as_str(); + } if method_name == "pow" && let [arg] = args @@ -100,53 +114,69 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { Sign::Uncertain } -/// Return the sign of the `pow` call's result. +/// Return the sign of the `pow` call's result, ignoring overflow. +/// +/// If the base is positive, the result is always positive. +/// If the base is negative, and the exponent is a even number, the result is always positive, +/// otherwise if the exponent is an odd number, the result is always negative. /// -/// If the caller is a positive number, the result is always positive, -/// If the `power_of` is a even number, the result is always positive as well, -/// Otherwise a [`Sign::Uncertain`] will be returned. +/// If either value can't be evaluated, [`Sign::Uncertain`] will be returned. fn pow_call_result_sign(cx: &LateContext<'_>, caller: &Expr<'_>, power_of: &Expr<'_>) -> Sign { let caller_ty = cx.typeck_results().expr_ty(caller); - if let Some(caller_val) = get_const_int_eval(cx, caller, caller_ty) - && caller_val >= 0 - { + let Some(caller_val) = get_const_int_eval(cx, caller, caller_ty) else { + return Sign::Uncertain; + } + // Non-negative values raised to non-negative exponents are always non-negative, ignoring overflow. + // (Rust's integer pow() function takes an unsigned exponent.) + if caller_val >= 0 { return Sign::ZeroOrPositive; } - if let Some(Constant::Int(n)) = constant(cx, cx.typeck_results(), power_of) - && clip(cx.tcx, n, UintTy::U32) % 2 == 0 - { + let Some(Constant::Int(n)) = constant(cx, cx.typeck_results(), power_of) else { + return Sign::Uncertain; + } + // A negative value raised to an even exponent is non-negative, and an odd exponent + // is negative, ignoring overflow. + if clip(cx.tcx, n, UintTy::U32) % 2 == 0 0 { return Sign::ZeroOrPositive; + } else { + return Sign::Negative; } - - Sign::Uncertain } /// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`], -/// which the result could always be positive under certain condition. +/// which the result could always be positive under certain conditions, ignoring overflow. /// -/// Other operators such as `+`/`-` causing the result's sign hard to determine, which we will -/// return `None` -fn exprs_with_selected_binop_peeled<'a>(expr: &'a Expr<'_>) -> Option>> { +/// Expressions using other operators are preserved, so we can try to evaluate them later. +fn exprs_with_selected_binop_peeled<'a>(expr: &'a Expr<'_>) -> Vec<&'a Expr<'a>> { #[inline] - fn collect_operands<'a>(expr: &'a Expr<'a>, operands: &mut Vec<&'a Expr<'a>>) -> Option<()> { + fn collect_operands<'a>(expr: &'a Expr<'a>, operands: &mut Vec<&'a Expr<'a>>) { match expr.kind { ExprKind::Binary(op, lhs, rhs) => { - if matches!(op.node, BinOpKind::Mul | BinOpKind::Div | BinOpKind::Rem) { + if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { + // For binary operators which both contribute to the sign of the result, + // collect all their operands, recursively. This ignores overflow. + collect_operands(lhs, operands); + collect_operands(rhs, operands); + } else if matches!(op.node, BinOpKind::Rem) { + // For binary operators where the left hand side determines the sign of the result, + // only collect that side, recursively. Overflow panics, so this always holds. + // + // > Given remainder = dividend % divisor, the remainder will have the same sign as the dividend + // https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators collect_operands(lhs, operands); - operands.push(rhs); } else { - // Things are complicated when there are other binary ops exist, - // abort checking by returning `None` for now. - return None; + // The sign of the result of other binary operators depends on the values of the operands, + // so try to evaluate the expression. + operands.push(expr); } }, + // For other expressions, including unary operators and constants, try to evaluate the expression. _ => operands.push(expr), } - Some(()) } let mut res = vec![]; - collect_operands(expr, &mut res)?; - Some(res) + collect_operands(expr, &mut res); + res } From 02214f2ac00986f84fa32e136f0ba81c1f85a495 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 16:40:32 +1000 Subject: [PATCH 144/417] Expand method lists --- clippy_lints/src/casts/cast_sign_loss.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 1b907d8257018..be8f524317aee 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -11,8 +11,28 @@ use super::CAST_SIGN_LOSS; /// Includes methods that panic rather than returning a negative value. /// /// Methods that can overflow and return a negative value must not be included in this list, -/// because checking for negative return values from those functions can be useful. -const METHODS_RET_POSITIVE: &[&str] = &["checked_abs", "rem_euclid", "checked_rem_euclid"]; +/// because casting their return values can still result in sign loss. +const METHODS_RET_POSITIVE: &[&str] = &[ + "checked_abs", + "saturating_abs", + "isqrt", + "checked_isqrt", + "rem_euclid", + "checked_rem_euclid", + "wrapping_rem_euclid", +]; + +/// A list of methods that act like `pow()`, and can never return: +/// - a negative value from a non-negative base +/// - a negative value from a negative base and even exponent +/// - a non-negative value from a negative base and odd exponent +/// +/// Methods that can overflow and return a negative value must not be included in this list, +/// because casting their return values can still result in sign loss. +const METHODS_POW: &[&str] = &["pow", "saturating_pow", "checked_pow"]; + +/// A list of methods that act like `unwrap()`, and don't change the sign of the inner value. +const METHODS_UNWRAP: &[&str] = &["unwrap", "unwrap_unchecked", "expect", "into_ok"]; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { if should_lint(cx, cast_op, cast_from, cast_to) { From e51fcd03dc6a5b61f98289825961be1bdbb3dd64 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 16:40:49 +1000 Subject: [PATCH 145/417] Make pow_call_result_sign compile --- clippy_lints/src/casts/cast_sign_loss.rs | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index be8f524317aee..241f523769cc6 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -59,12 +59,9 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast let (mut uncertain_count, mut negative_count) = (0, 0); // Peel off possible binary expressions, for example: - // x * x * y => [x, x, y] + // x * x / y => [x, x, y] // a % b => [a] - let Some(exprs) = exprs_with_selected_binop_peeled(cast_op) else { - // Assume cast sign lose if we cannot determine the sign of `cast_op` - return true; - }; + let exprs = exprs_with_selected_binop_peeled(cast_op); for expr in exprs { let ty = cx.typeck_results().expr_ty(expr); match expr_sign(cx, expr, ty) { @@ -141,23 +138,24 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { /// otherwise if the exponent is an odd number, the result is always negative. /// /// If either value can't be evaluated, [`Sign::Uncertain`] will be returned. -fn pow_call_result_sign(cx: &LateContext<'_>, caller: &Expr<'_>, power_of: &Expr<'_>) -> Sign { - let caller_ty = cx.typeck_results().expr_ty(caller); - let Some(caller_val) = get_const_int_eval(cx, caller, caller_ty) else { +fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<'_>) -> Sign { + let base_ty = cx.typeck_results().expr_ty(base); + let Some(base_val) = get_const_int_eval(cx, base, base_ty) else { return Sign::Uncertain; - } - // Non-negative values raised to non-negative exponents are always non-negative, ignoring overflow. + }; + // Non-negative bases raised to non-negative exponents are always non-negative, ignoring overflow. // (Rust's integer pow() function takes an unsigned exponent.) - if caller_val >= 0 { + if base_val >= 0 { return Sign::ZeroOrPositive; } - let Some(Constant::Int(n)) = constant(cx, cx.typeck_results(), power_of) else { + let Some(Constant::Int(n)) = constant(cx, cx.typeck_results(), exponent) else { return Sign::Uncertain; - } + }; + // A negative value raised to an even exponent is non-negative, and an odd exponent // is negative, ignoring overflow. - if clip(cx.tcx, n, UintTy::U32) % 2 == 0 0 { + if clip(cx.tcx, n, UintTy::U32) % 2 == 0 { return Sign::ZeroOrPositive; } else { return Sign::Negative; From 28f247e16ce6e311cbbb7208373f27c14a85e97f Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 16:50:16 +1000 Subject: [PATCH 146/417] Use the expanded method lists --- clippy_lints/src/casts/cast_sign_loss.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 241f523769cc6..690fd6a97118c 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -102,24 +102,20 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { if let Some(val) = get_const_int_eval(cx, expr, ty) { return if val >= 0 { Sign::ZeroOrPositive } else { Sign::Negative }; } + // Calling on methods that always return non-negative values. if let ExprKind::MethodCall(path, caller, args, ..) = expr.kind { let mut method_name = path.ident.name.as_str(); - if method_name == "unwrap" - && let Some(arglist) = method_chain_args(expr, &["unwrap"]) - && let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind - { - method_name = inner_path.ident.name.as_str(); - } - if method_name == "expect" - && let Some(arglist) = method_chain_args(expr, &["expect"]) + // Peel unwrap(), expect(), etc. + while let Some(&found_name) = METHODS_UNWRAP.iter().find(|&name| &method_name == name) + && let Some(arglist) = method_chain_args(expr, &[found_name]) && let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind { method_name = inner_path.ident.name.as_str(); } - if method_name == "pow" + if METHODS_POW.iter().any(|&name| method_name == name) && let [arg] = args { return pow_call_result_sign(cx, caller, arg); From 47339d01f8e22df7b25d7ac92f3628f4cdc982af Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 16:53:34 +1000 Subject: [PATCH 147/417] Bless fixed cast_sign_loss false negatives --- tests/ui/cast.stderr | 86 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index e2bcf94734e9a..0eb3b95733a77 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -321,6 +321,36 @@ error: casting `isize` to `usize` may lose the sign of the value LL | -1isize as usize; | ^^^^^^^^^^^^^^^^ +error: casting `i8` to `u8` may lose the sign of the value + --> tests/ui/cast.rs:119:5 + | +LL | (-1i8).abs() as u8; + | ^^^^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:120:5 + | +LL | (-1i16).abs() as u16; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:121:5 + | +LL | (-1i32).abs() as u32; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `i64` to `u64` may lose the sign of the value + --> tests/ui/cast.rs:122:5 + | +LL | (-1i64).abs() as u64; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `isize` to `usize` may lose the sign of the value + --> tests/ui/cast.rs:123:5 + | +LL | (-1isize).abs() as usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i64` to `i8` may truncate the value --> tests/ui/cast.rs:179:5 | @@ -444,12 +474,36 @@ help: ... or use `try_from` and handle the error accordingly LL | let c = u8::try_from(q / 1000); | ~~~~~~~~~~~~~~~~~~~~~~ +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:372:9 + | +LL | (x * x) as u32; + | ^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:373:9 + | +LL | x.pow(2) as u32; + | ^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:377:32 + | +LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 }; + | ^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value --> tests/ui/cast.rs:379:5 | LL | (-2_i32).pow(3) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:383:5 + | +LL | (x * x) as u32; + | ^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value --> tests/ui/cast.rs:384:5 | @@ -462,6 +516,12 @@ error: casting `i16` to `u16` may lose the sign of the value LL | (y * y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:390:5 + | +LL | (y * y * y * y * 2) as u16; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i16` to `u16` may lose the sign of the value --> tests/ui/cast.rs:391:5 | @@ -474,6 +534,12 @@ error: casting `i16` to `u16` may lose the sign of the value LL | (y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^ +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:397:9 + | +LL | (a * a * b * b * c * c) as u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value --> tests/ui/cast.rs:398:9 | @@ -486,6 +552,12 @@ error: casting `i32` to `u32` may lose the sign of the value LL | (a * -b * c) as u32; | ^^^^^^^^^^^^^^^^^^^ +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:402:9 + | +LL | (a * b * c * c) as u32; + | ^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value --> tests/ui/cast.rs:403:9 | @@ -498,6 +570,12 @@ error: casting `i32` to `u32` may lose the sign of the value LL | (a * b * c * -2) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:407:9 + | +LL | (a / b) as u32; + | ^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value --> tests/ui/cast.rs:408:9 | @@ -516,5 +594,11 @@ error: casting `i32` to `u32` may lose the sign of the value LL | a.pow(3) as u32; | ^^^^^^^^^^^^^^^ -error: aborting due to 63 previous errors +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:414:9 + | +LL | (a.abs() * b.pow(2) / c.abs()) as u32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 77 previous errors From c5e8487d63290fc38e6261c45425662be9279a36 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 17:43:57 +1000 Subject: [PATCH 148/417] Fix pow() to return more known signs --- clippy_lints/src/casts/cast_sign_loss.rs | 69 +++++++++++++----------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 690fd6a97118c..ba8222fc0cd5f 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -1,9 +1,9 @@ use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; -use clippy_utils::{clip, method_chain_args, sext}; +use clippy_utils::{method_chain_args, sext}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; -use rustc_middle::ty::{self, Ty, UintTy}; +use rustc_middle::ty::{self, Ty}; use super::CAST_SIGN_LOSS; @@ -22,10 +22,7 @@ const METHODS_RET_POSITIVE: &[&str] = &[ "wrapping_rem_euclid", ]; -/// A list of methods that act like `pow()`, and can never return: -/// - a negative value from a non-negative base -/// - a negative value from a negative base and even exponent -/// - a non-negative value from a negative base and odd exponent +/// A list of methods that act like `pow()`. See `pow_call_result_sign()` for details. /// /// Methods that can overflow and return a negative value must not be included in this list, /// because casting their return values can still result in sign loss. @@ -34,7 +31,13 @@ const METHODS_POW: &[&str] = &["pow", "saturating_pow", "checked_pow"]; /// A list of methods that act like `unwrap()`, and don't change the sign of the inner value. const METHODS_UNWRAP: &[&str] = &["unwrap", "unwrap_unchecked", "expect", "into_ok"]; -pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { +pub(super) fn check<'cx>( + cx: &LateContext<'cx>, + expr: &Expr<'_>, + cast_op: &Expr<'_>, + cast_from: Ty<'cx>, + cast_to: Ty<'_>, +) { if should_lint(cx, cast_op, cast_from, cast_to) { span_lint( cx, @@ -45,7 +48,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, c } } -fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) -> bool { +fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx>, cast_to: Ty<'_>) -> bool { match (cast_from.is_integral(), cast_to.is_integral()) { (true, true) => { if !cast_from.is_signed() || cast_to.is_signed() { @@ -82,7 +85,9 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast } } -fn get_const_int_eval(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Option { +fn get_const_int_eval<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into>>) -> Option { + let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); + if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? && let ty::Int(ity) = *ty.kind() { @@ -97,7 +102,7 @@ enum Sign { Uncertain, } -fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { +fn expr_sign<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into>>) -> Sign { // Try evaluate this expr first to see if it's positive if let Some(val) = get_const_int_eval(cx, expr, ty) { return if val >= 0 { Sign::ZeroOrPositive } else { Sign::Negative }; @@ -112,6 +117,8 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { && let Some(arglist) = method_chain_args(expr, &[found_name]) && let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind { + // The original type has changed, but we can't use `ty` here anyway, because it has been + // moved. method_name = inner_path.ident.name.as_str(); } @@ -130,31 +137,31 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { /// Return the sign of the `pow` call's result, ignoring overflow. /// /// If the base is positive, the result is always positive. -/// If the base is negative, and the exponent is a even number, the result is always positive, -/// otherwise if the exponent is an odd number, the result is always negative. +/// If the exponent is a even number, the result is always positive, +/// Otherwise, if the base is negative, and the exponent is an odd number, the result is always +/// negative. /// -/// If either value can't be evaluated, [`Sign::Uncertain`] will be returned. +/// Otherwise, returns [`Sign::Uncertain`]. fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<'_>) -> Sign { - let base_ty = cx.typeck_results().expr_ty(base); - let Some(base_val) = get_const_int_eval(cx, base, base_ty) else { - return Sign::Uncertain; - }; - // Non-negative bases raised to non-negative exponents are always non-negative, ignoring overflow. - // (Rust's integer pow() function takes an unsigned exponent.) - if base_val >= 0 { - return Sign::ZeroOrPositive; - } + let base_sign = expr_sign(cx, base, None); + let exponent_val = get_const_int_eval(cx, exponent, None); + let exponent_is_even = exponent_val.map(|val| val % 2 == 0); + + match (base_sign, exponent_is_even) { + // Non-negative bases always return non-negative results, ignoring overflow. + // This is because Rust's integer pow() functions take an unsigned exponent. + (Sign::ZeroOrPositive, _) => Sign::ZeroOrPositive, + + // Any base raised to an even exponent is non-negative. + // This is true even if we don't know the value of the base. + (_, Some(true)) => Sign::ZeroOrPositive, - let Some(Constant::Int(n)) = constant(cx, cx.typeck_results(), exponent) else { - return Sign::Uncertain; - }; + // A negative base raised to an odd exponent is non-negative. + (Sign::Negative, Some(false)) => Sign::Negative, - // A negative value raised to an even exponent is non-negative, and an odd exponent - // is negative, ignoring overflow. - if clip(cx.tcx, n, UintTy::U32) % 2 == 0 { - return Sign::ZeroOrPositive; - } else { - return Sign::Negative; + // Negative or unknown base to an unknown exponent, or an unknown base to an odd exponent. + (Sign::Negative | Sign::Uncertain, None) => Sign::Uncertain, + (Sign::Uncertain, Some(false)) => Sign::Uncertain, } } From e74fe4362ac6b79751aa1ddd72dfb256b006fff6 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 18:03:35 +1000 Subject: [PATCH 149/417] Check for both signed and unsigned constant expressions --- clippy_lints/src/casts/cast_sign_loss.rs | 35 ++++++++++++++++++++---- tests/ui/cast.stderr | 2 +- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index ba8222fc0cd5f..530fb0dcde037 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -66,8 +66,7 @@ fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx // a % b => [a] let exprs = exprs_with_selected_binop_peeled(cast_op); for expr in exprs { - let ty = cx.typeck_results().expr_ty(expr); - match expr_sign(cx, expr, ty) { + match expr_sign(cx, expr, None) { Sign::Negative => negative_count += 1, Sign::Uncertain => uncertain_count += 1, Sign::ZeroOrPositive => (), @@ -85,7 +84,11 @@ fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx } } -fn get_const_int_eval<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into>>) -> Option { +fn get_const_signed_int_eval<'cx>( + cx: &LateContext<'cx>, + expr: &Expr<'_>, + ty: impl Into>>, +) -> Option { let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? @@ -96,6 +99,22 @@ fn get_const_int_eval<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into None } +fn get_const_unsigned_int_eval<'cx>( + cx: &LateContext<'cx>, + expr: &Expr<'_>, + ty: impl Into>>, +) -> Option { + let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); + + if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? + && let ty::Uint(_ity) = *ty.kind() + { + return Some(n); + } + None +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] enum Sign { ZeroOrPositive, Negative, @@ -104,9 +123,12 @@ enum Sign { fn expr_sign<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into>>) -> Sign { // Try evaluate this expr first to see if it's positive - if let Some(val) = get_const_int_eval(cx, expr, ty) { + if let Some(val) = get_const_signed_int_eval(cx, expr, ty) { return if val >= 0 { Sign::ZeroOrPositive } else { Sign::Negative }; } + if let Some(_val) = get_const_unsigned_int_eval(cx, expr, None) { + return Sign::ZeroOrPositive; + } // Calling on methods that always return non-negative values. if let ExprKind::MethodCall(path, caller, args, ..) = expr.kind { @@ -144,12 +166,13 @@ fn expr_sign<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into, base: &Expr<'_>, exponent: &Expr<'_>) -> Sign { let base_sign = expr_sign(cx, base, None); - let exponent_val = get_const_int_eval(cx, exponent, None); + + // Rust's integer pow() functions take an unsigned exponent. + let exponent_val = get_const_unsigned_int_eval(cx, exponent, None); let exponent_is_even = exponent_val.map(|val| val % 2 == 0); match (base_sign, exponent_is_even) { // Non-negative bases always return non-negative results, ignoring overflow. - // This is because Rust's integer pow() functions take an unsigned exponent. (Sign::ZeroOrPositive, _) => Sign::ZeroOrPositive, // Any base raised to an even exponent is non-negative. diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 0eb3b95733a77..aaa6b4183e95c 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -600,5 +600,5 @@ error: casting `i32` to `u32` may lose the sign of the value LL | (a.abs() * b.pow(2) / c.abs()) as u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 77 previous errors +error: aborting due to 76 previous errors From 8b615af7608c243a2be777d36df59e75e2b553df Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 18:09:16 +1000 Subject: [PATCH 150/417] Fix clippy_dogfood --- clippy_lints/src/casts/cast_sign_loss.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 530fb0dcde037..b1a0f46bb02f7 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -173,17 +173,18 @@ fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<' match (base_sign, exponent_is_even) { // Non-negative bases always return non-negative results, ignoring overflow. - (Sign::ZeroOrPositive, _) => Sign::ZeroOrPositive, - + (Sign::ZeroOrPositive, _) | // Any base raised to an even exponent is non-negative. - // This is true even if we don't know the value of the base. - (_, Some(true)) => Sign::ZeroOrPositive, + // These both hold even if we don't know the value of the base. + (_, Some(true)) + => Sign::ZeroOrPositive, // A negative base raised to an odd exponent is non-negative. (Sign::Negative, Some(false)) => Sign::Negative, - // Negative or unknown base to an unknown exponent, or an unknown base to an odd exponent. - (Sign::Negative | Sign::Uncertain, None) => Sign::Uncertain, + // Negative/unknown base to an unknown exponent, or unknown base to an odd exponent. + // Could be negative or positive depending on the actual values. + (Sign::Negative | Sign::Uncertain, None) | (Sign::Uncertain, Some(false)) => Sign::Uncertain, } } From 11e0d6acca95e3db70ff0cbd474cb3bacd5ad1a7 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 18:25:38 +1000 Subject: [PATCH 151/417] Move muldiv peeling into expr_sign --- clippy_lints/src/casts/cast_sign_loss.rs | 50 +++++++++++++----------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index b1a0f46bb02f7..7e4efbbc03d67 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -56,26 +56,7 @@ fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx } // Don't lint if `cast_op` is known to be positive, ignoring overflow. - if let Sign::ZeroOrPositive = expr_sign(cx, cast_op, cast_from) { - return false; - } - - let (mut uncertain_count, mut negative_count) = (0, 0); - // Peel off possible binary expressions, for example: - // x * x / y => [x, x, y] - // a % b => [a] - let exprs = exprs_with_selected_binop_peeled(cast_op); - for expr in exprs { - match expr_sign(cx, expr, None) { - Sign::Negative => negative_count += 1, - Sign::Uncertain => uncertain_count += 1, - Sign::ZeroOrPositive => (), - }; - } - - // Lint if there are any uncertain results (because they could be negative or positive), - // or an odd number of negative results. - uncertain_count > 0 || negative_count % 2 == 1 + expr_sign(cx, cast_op, cast_from) == Sign::ZeroOrPositive }, (false, true) => !cast_to.is_signed(), @@ -153,7 +134,32 @@ fn expr_sign<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into [x, x, y] + // a % b => [a] + let exprs = exprs_with_muldiv_binop_peeled(expr); + for expr in exprs { + match expr_sign(cx, expr, None) { + Sign::Negative => negative_count += 1, + Sign::Uncertain => uncertain_count += 1, + Sign::ZeroOrPositive => (), + }; + } + + // A mul/div is: + // - uncertain if there are any uncertain values (because they could be negative or positive), + // - negative if there are an odd number of negative values, + // - positive or zero otherwise. + if uncertain_count > 0 { + Sign::Uncertain + } else if negative_count % 2 == 1 { + Sign::Negative + } else { + Sign::ZeroOrPositive + } } /// Return the sign of the `pow` call's result, ignoring overflow. @@ -193,7 +199,7 @@ fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<' /// which the result could always be positive under certain conditions, ignoring overflow. /// /// Expressions using other operators are preserved, so we can try to evaluate them later. -fn exprs_with_selected_binop_peeled<'a>(expr: &'a Expr<'_>) -> Vec<&'a Expr<'a>> { +fn exprs_with_muldiv_binop_peeled<'a>(expr: &'a Expr<'_>) -> Vec<&'a Expr<'a>> { #[inline] fn collect_operands<'a>(expr: &'a Expr<'a>, operands: &mut Vec<&'a Expr<'a>>) { match expr.kind { From 4ab2ed33a07c9b2c76430b8221f78b6efd9fde79 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 18:33:20 +1000 Subject: [PATCH 152/417] Put muldiv peeling in its own method --- clippy_lints/src/casts/cast_sign_loss.rs | 74 ++++++++++++++---------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 7e4efbbc03d67..db7121928fe80 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -56,7 +56,15 @@ fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx } // Don't lint if `cast_op` is known to be positive, ignoring overflow. - expr_sign(cx, cast_op, cast_from) == Sign::ZeroOrPositive + if let Sign::ZeroOrPositive = expr_sign(cx, cast_op, cast_from) { + return false; + } + + if let Sign::ZeroOrPositive = expr_muldiv_sign(cx, cast_op) { + return false; + } + + true }, (false, true) => !cast_to.is_signed(), @@ -134,32 +142,7 @@ fn expr_sign<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into [x, x, y] - // a % b => [a] - let exprs = exprs_with_muldiv_binop_peeled(expr); - for expr in exprs { - match expr_sign(cx, expr, None) { - Sign::Negative => negative_count += 1, - Sign::Uncertain => uncertain_count += 1, - Sign::ZeroOrPositive => (), - }; - } - - // A mul/div is: - // - uncertain if there are any uncertain values (because they could be negative or positive), - // - negative if there are an odd number of negative values, - // - positive or zero otherwise. - if uncertain_count > 0 { - Sign::Uncertain - } else if negative_count % 2 == 1 { - Sign::Negative - } else { - Sign::ZeroOrPositive - } + Sign::Uncertain } /// Return the sign of the `pow` call's result, ignoring overflow. @@ -195,13 +178,46 @@ fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<' } } +/// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`], +/// which the result could always be positive under certain conditions, ignoring overflow. +/// +/// Returns the sign of the list of peeled expressions. +fn expr_muldiv_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { + let mut uncertain_count = 0; + let mut negative_count = 0; + + // Peel off possible binary expressions, for example: + // x * x / y => [x, x, y] + // a % b => [a] + let exprs = exprs_with_muldiv_binop_peeled(expr); + for expr in exprs { + match expr_sign(cx, expr, None) { + Sign::Negative => negative_count += 1, + Sign::Uncertain => uncertain_count += 1, + Sign::ZeroOrPositive => (), + }; + } + + // A mul/div is: + // - uncertain if there are any uncertain values (because they could be negative or positive), + // - negative if there are an odd number of negative values, + // - positive or zero otherwise. + if uncertain_count > 0 { + Sign::Uncertain + } else if negative_count % 2 == 1 { + Sign::Negative + } else { + Sign::ZeroOrPositive + } +} + /// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`], /// which the result could always be positive under certain conditions, ignoring overflow. /// /// Expressions using other operators are preserved, so we can try to evaluate them later. -fn exprs_with_muldiv_binop_peeled<'a>(expr: &'a Expr<'_>) -> Vec<&'a Expr<'a>> { +fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { #[inline] - fn collect_operands<'a>(expr: &'a Expr<'a>, operands: &mut Vec<&'a Expr<'a>>) { + fn collect_operands<'e>(expr: &'e Expr<'e>, operands: &mut Vec<&'e Expr<'e>>) { match expr.kind { ExprKind::Binary(op, lhs, rhs) => { if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { From 740441fd98090cde764a360587d380dbd66a69f0 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 18:56:51 +1000 Subject: [PATCH 153/417] Use the visitor pattern instead of recusive functions --- clippy_lints/src/casts/cast_sign_loss.rs | 30 ++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index db7121928fe80..20a7cbd4a1ba1 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -1,5 +1,8 @@ +use std::ops::ControlFlow; + use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::visitors::{for_each_expr, Descend}; use clippy_utils::{method_chain_args, sext}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; @@ -216,34 +219,37 @@ fn expr_muldiv_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { /// /// Expressions using other operators are preserved, so we can try to evaluate them later. fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { - #[inline] - fn collect_operands<'e>(expr: &'e Expr<'e>, operands: &mut Vec<&'e Expr<'e>>) { - match expr.kind { - ExprKind::Binary(op, lhs, rhs) => { + let mut res = vec![]; + + for_each_expr(expr, |sub_expr| { + match sub_expr.kind { + ExprKind::Binary(op, lhs, _rhs) => { if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { // For binary operators which both contribute to the sign of the result, // collect all their operands, recursively. This ignores overflow. - collect_operands(lhs, operands); - collect_operands(rhs, operands); + ControlFlow::Continue(Descend::Yes) } else if matches!(op.node, BinOpKind::Rem) { // For binary operators where the left hand side determines the sign of the result, // only collect that side, recursively. Overflow panics, so this always holds. // // > Given remainder = dividend % divisor, the remainder will have the same sign as the dividend // https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators - collect_operands(lhs, operands); + res.push(lhs); + ControlFlow::Break(()) } else { // The sign of the result of other binary operators depends on the values of the operands, // so try to evaluate the expression. - operands.push(expr); + res.push(expr); + ControlFlow::Continue(Descend::No) } }, // For other expressions, including unary operators and constants, try to evaluate the expression. - _ => operands.push(expr), + _ => { + res.push(expr); + ControlFlow::Continue(Descend::No) + }, } - } + }); - let mut res = vec![]; - collect_operands(expr, &mut res); res } From 6dfff19090e544c58a9bbb6caaf406da7db3d427 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 19:00:32 +1000 Subject: [PATCH 154/417] clippy_dogfood --- clippy_lints/src/casts/cast_sign_loss.rs | 45 +++++++++++------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 20a7cbd4a1ba1..1d71545913a4a 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -222,32 +222,29 @@ fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { let mut res = vec![]; for_each_expr(expr, |sub_expr| { - match sub_expr.kind { - ExprKind::Binary(op, lhs, _rhs) => { - if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { - // For binary operators which both contribute to the sign of the result, - // collect all their operands, recursively. This ignores overflow. - ControlFlow::Continue(Descend::Yes) - } else if matches!(op.node, BinOpKind::Rem) { - // For binary operators where the left hand side determines the sign of the result, - // only collect that side, recursively. Overflow panics, so this always holds. - // - // > Given remainder = dividend % divisor, the remainder will have the same sign as the dividend - // https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators - res.push(lhs); - ControlFlow::Break(()) - } else { - // The sign of the result of other binary operators depends on the values of the operands, - // so try to evaluate the expression. - res.push(expr); - ControlFlow::Continue(Descend::No) - } - }, - // For other expressions, including unary operators and constants, try to evaluate the expression. - _ => { + if let ExprKind::Binary(op, lhs, _rhs) = sub_expr.kind { + if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { + // For binary operators which both contribute to the sign of the result, + // collect all their operands, recursively. This ignores overflow. + ControlFlow::Continue(Descend::Yes) + } else if matches!(op.node, BinOpKind::Rem) { + // For binary operators where the left hand side determines the sign of the result, + // only collect that side, recursively. Overflow panics, so this always holds. + // + // > Given remainder = dividend % divisor, the remainder will have the same sign as the dividend + // https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators + res.push(lhs); + ControlFlow::Break(()) + } else { + // The sign of the result of other binary operators depends on the values of the operands, + // so try to evaluate the expression. res.push(expr); ControlFlow::Continue(Descend::No) - }, + } + } else { + // For other expressions, including unary operators and constants, try to evaluate the expression. + res.push(expr); + ControlFlow::Continue(Descend::No) } }); From d109e681782d71c6426b155d225b816893538a9c Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 16 Jan 2024 19:04:22 +1000 Subject: [PATCH 155/417] Add some TODO comments --- clippy_lints/src/casts/cast_sign_loss.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 1d71545913a4a..1100625bc4a95 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -63,6 +63,7 @@ fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx return false; } + // We don't check for sums of all-positive or all-negative values, but we could. if let Sign::ZeroOrPositive = expr_muldiv_sign(cx, cast_op) { return false; } @@ -222,6 +223,7 @@ fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { let mut res = vec![]; for_each_expr(expr, |sub_expr| { + // We don't check for mul/div/rem methods here, but we could. if let ExprKind::Binary(op, lhs, _rhs) = sub_expr.kind { if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { // For binary operators which both contribute to the sign of the result, From 1cbb58bd061a72f07f087c7f0befad6b0b214538 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Jan 2024 12:22:23 +1000 Subject: [PATCH 156/417] Fix divmul peeling --- clippy_lints/src/casts/cast_sign_loss.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 1100625bc4a95..9c18989701e0c 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -229,23 +229,30 @@ fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { // For binary operators which both contribute to the sign of the result, // collect all their operands, recursively. This ignores overflow. ControlFlow::Continue(Descend::Yes) - } else if matches!(op.node, BinOpKind::Rem) { + } else if matches!(op.node, BinOpKind::Rem | BinOpKind::Shr) { // For binary operators where the left hand side determines the sign of the result, // only collect that side, recursively. Overflow panics, so this always holds. // + // Large left shifts turn negatives into zeroes, so we can't use it here. + // // > Given remainder = dividend % divisor, the remainder will have the same sign as the dividend + // > ... + // > Arithmetic right shift on signed integer types // https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators + + // We want to descend into the lhs, but skip the rhs. + // That's tricky to do using for_each_expr(), so we just keep the lhs intact. res.push(lhs); - ControlFlow::Break(()) + ControlFlow::Continue(Descend::No) } else { // The sign of the result of other binary operators depends on the values of the operands, // so try to evaluate the expression. - res.push(expr); + res.push(sub_expr); ControlFlow::Continue(Descend::No) } } else { // For other expressions, including unary operators and constants, try to evaluate the expression. - res.push(expr); + res.push(sub_expr); ControlFlow::Continue(Descend::No) } }); From 6670acd2878b2053b8118dcf65056f99d755fe5a Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Jan 2024 12:32:43 +1000 Subject: [PATCH 157/417] Check for all-positive or all-negative sums --- clippy_lints/src/casts/cast_sign_loss.rs | 90 ++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 9c18989701e0c..546cfca215664 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -1,3 +1,4 @@ +use std::convert::Infallible; use std::ops::ControlFlow; use clippy_utils::consts::{constant, Constant}; @@ -63,11 +64,14 @@ fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx return false; } - // We don't check for sums of all-positive or all-negative values, but we could. if let Sign::ZeroOrPositive = expr_muldiv_sign(cx, cast_op) { return false; } + if let Sign::ZeroOrPositive = expr_add_sign(cx, cast_op) { + return false; + } + true }, @@ -182,13 +186,13 @@ fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<' } } -/// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`], -/// which the result could always be positive under certain conditions, ignoring overflow. +/// Peels binary operators such as [`BinOpKind::Mul`] or [`BinOpKind::Rem`], +/// where the result could always be positive. See [`exprs_with_muldiv_binop_peeled()`] for details. /// /// Returns the sign of the list of peeled expressions. fn expr_muldiv_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { - let mut uncertain_count = 0; let mut negative_count = 0; + let mut uncertain_count = 0; // Peel off possible binary expressions, for example: // x * x / y => [x, x, y] @@ -215,18 +219,58 @@ fn expr_muldiv_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { } } +/// Peels binary operators such as [`BinOpKind::Add`], where the result could always be positive. +/// See [`exprs_with_add_binop_peeled()`] for details. +/// +/// Returns the sign of the list of peeled expressions. +fn expr_add_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { + let mut negative_count = 0; + let mut uncertain_count = 0; + let mut positive_count = 0; + + // Peel off possible binary expressions, for example: + // a + b + c => [a, b, c] + let exprs = exprs_with_add_binop_peeled(expr); + for expr in exprs { + match expr_sign(cx, expr, None) { + Sign::Negative => negative_count += 1, + Sign::Uncertain => uncertain_count += 1, + Sign::ZeroOrPositive => positive_count += 1, + }; + } + + // A sum is: + // - uncertain if there are any uncertain values (because they could be negative or positive), + // - positive or zero if there are only positive (or zero) values, + // - negative if there are only negative (or zero) values. + // We could split Zero out into its own variant, but we don't yet. + if uncertain_count > 0 { + Sign::Uncertain + } else if negative_count == 0 { + Sign::ZeroOrPositive + } else if positive_count == 0 { + Sign::Negative + } else { + Sign::Uncertain + } +} + /// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`], -/// which the result could always be positive under certain conditions, ignoring overflow. +/// where the result depends on: +/// - the number of negative values in the entire expression, or +/// - the number of negative values on the left hand side of the expression. +/// Ignores overflow. +/// /// /// Expressions using other operators are preserved, so we can try to evaluate them later. fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { let mut res = vec![]; - for_each_expr(expr, |sub_expr| { + for_each_expr(expr, |sub_expr| -> ControlFlow { // We don't check for mul/div/rem methods here, but we could. if let ExprKind::Binary(op, lhs, _rhs) = sub_expr.kind { if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { - // For binary operators which both contribute to the sign of the result, + // For binary operators where both sides contribute to the sign of the result, // collect all their operands, recursively. This ignores overflow. ControlFlow::Continue(Descend::Yes) } else if matches!(op.node, BinOpKind::Rem | BinOpKind::Shr) { @@ -259,3 +303,35 @@ fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { res } + +/// Peels binary operators such as [`BinOpKind::Add`], where the result depends on: +/// - all the expressions being positive, or +/// - all the expressions being negative. +/// Ignores overflow. +/// +/// Expressions using other operators are preserved, so we can try to evaluate them later. +fn exprs_with_add_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { + let mut res = vec![]; + + for_each_expr(expr, |sub_expr| -> ControlFlow { + // We don't check for add methods here, but we could. + if let ExprKind::Binary(op, _lhs, _rhs) = sub_expr.kind { + if matches!(op.node, BinOpKind::Add) { + // For binary operators where both sides contribute to the sign of the result, + // collect all their operands, recursively. This ignores overflow. + ControlFlow::Continue(Descend::Yes) + } else { + // The sign of the result of other binary operators depends on the values of the operands, + // so try to evaluate the expression. + res.push(sub_expr); + ControlFlow::Continue(Descend::No) + } + } else { + // For other expressions, including unary operators and constants, try to evaluate the expression. + res.push(sub_expr); + ControlFlow::Continue(Descend::No) + } + }); + + res +} From f40279ff7dd7e2abaa6d3be3b647a911153c6411 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Jan 2024 12:55:38 +1000 Subject: [PATCH 158/417] Add some more test cases --- tests/ui/cast.stderr | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index aaa6b4183e95c..458b2736866b0 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -480,12 +480,6 @@ error: casting `i32` to `u32` may lose the sign of the value LL | (x * x) as u32; | ^^^^^^^^^^^^^^ -error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:373:9 - | -LL | x.pow(2) as u32; - | ^^^^^^^^^^^^^^^ - error: casting `i32` to `u32` may lose the sign of the value --> tests/ui/cast.rs:377:32 | From 367a403367566d1ec8d9721c160585f3ebf042d1 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Jan 2024 12:56:11 +1000 Subject: [PATCH 159/417] Add test coverage for cast_sign_loss changes --- tests/ui/cast.rs | 68 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index e9476c80ccb81..6973a574942f0 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -116,21 +116,41 @@ fn main() { i64::MAX as u64; i128::MAX as u128; - (-1i8).abs() as u8; - (-1i16).abs() as u16; - (-1i32).abs() as u32; + (-1i8).saturating_abs() as u8; + // abs() can return a negative value in release builds + (i8::MIN).abs() as u8; + //~^ ERROR: casting `i8` to `u8` may lose the sign of the value + (-1i16).saturating_abs() as u16; + (-1i32).saturating_abs() as u32; (-1i64).abs() as u64; (-1isize).abs() as usize; (-1i8).checked_abs().unwrap() as u8; + (i8::MIN).checked_abs().unwrap() as u8; (-1i16).checked_abs().unwrap() as u16; (-1i32).checked_abs().unwrap() as u32; - (-1i64).checked_abs().unwrap() as u64; - (-1isize).checked_abs().unwrap() as usize; + // SAFETY: -1 is a small number which will always return Some + (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64; + (-1isize).checked_abs().expect("-1 is a small number") as usize; + + (-1i8).isqrt() as u8; + (i8::MIN).isqrt() as u8; + (-1i16).isqrt() as u16; + (-1i32).isqrt() as u32; + (-1i64).isqrt() as u64; + (-1isize).isqrt() as usize; + + (-1i8).checked_isqrt().unwrap() as u8; + (i8::MIN).checked_isqrt().unwrap() as u8; + (-1i16).checked_isqrt().unwrap() as u16; + (-1i32).checked_isqrt().unwrap() as u32; + // SAFETY: -1 is a small number which will always return Some + (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64; + (-1isize).checked_isqrt().expect("-1 is a small number") as usize; (-1i8).rem_euclid(1i8) as u8; - (-1i8).rem_euclid(1i8) as u16; - (-1i16).rem_euclid(1i16) as u16; + (-1i8).wrapping_rem_euclid(1i8).unwrap() as u16; + (-1i16).rem_euclid(1i16).unwrap() as u16; (-1i16).rem_euclid(1i16) as u32; (-1i32).rem_euclid(1i32) as u32; (-1i32).rem_euclid(1i32) as u64; @@ -138,7 +158,7 @@ fn main() { (-1i64).rem_euclid(1i64) as u128; (-1isize).rem_euclid(1isize) as usize; (1i8).rem_euclid(-1i8) as u8; - (1i8).rem_euclid(-1i8) as u16; + (1i8).wrapping_rem_euclid(-1i8) as u16; (1i16).rem_euclid(-1i16) as u16; (1i16).rem_euclid(-1i16) as u32; (1i32).rem_euclid(-1i32) as u32; @@ -371,14 +391,25 @@ fn issue11642() { let x = x as i32; (x * x) as u32; x.pow(2) as u32; - (-2_i32).pow(2) as u32 + (-2_i32).saturating_pow(2) as u32 } let _a = |x: i32| -> u32 { (x * x * x * x) as u32 }; + (2_i32).checked_pow(3).unwrap() as u32; (-2_i32).pow(3) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + (2_i32 % 1) as u32; + (2_i32 % -1) as u32; + (-2_i32 % 1) as u32; + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + (-2_i32 % -1) as u32; + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + (2_i32 >> 1) as u32; + (-2_i32 >> 1) as u32; + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + let x: i32 = 10; (x * x) as u32; (x * x * x) as u32; @@ -387,12 +418,22 @@ fn issue11642() { let y: i16 = -2; (y * y * y * y * -2) as u16; //~^ ERROR: casting `i16` to `u16` may lose the sign of the value - (y * y * y * y * 2) as u16; - (y * y * y * 2) as u16; + (y * y * y / y * 2) as u16; + (y * y / y * 2) as u16; //~^ ERROR: casting `i16` to `u16` may lose the sign of the value - (y * y * y * -2) as u16; + (y / y * y * -2) as u16; //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + (y + y + y + -2) as u16; + //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + (y + y + y + 2) as u16; + //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + + let z: i16 = 2; + (z + -2) as u16; + //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + (z + z + 2) as u16; + fn foo(a: i32, b: i32, c: i32) -> u32 { (a * a * b * b * c * c) as u32; (a * b * c) as u32; @@ -409,8 +450,9 @@ fn issue11642() { //~^ ERROR: casting `i32` to `u32` may lose the sign of the value (a / b + b * c) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value - a.pow(3) as u32; + a.saturating_pow(3) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value (a.abs() * b.pow(2) / c.abs()) as u32 + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value } } From 6bc7c96bb39b4e29c6195e1c24bda1dc97888702 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Jan 2024 13:02:58 +1000 Subject: [PATCH 160/417] cargo bless --- tests/ui/cast.rs | 13 +-- tests/ui/cast.stderr | 244 ++++++++++++++++++++++++++----------------- 2 files changed, 157 insertions(+), 100 deletions(-) diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 6973a574942f0..a7331ddc7d0e7 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -1,6 +1,7 @@ //@no-rustfix #![feature(repr128)] +#![feature(isqrt)] #![allow(incomplete_features)] #![warn( clippy::cast_precision_loss, @@ -149,8 +150,8 @@ fn main() { (-1isize).checked_isqrt().expect("-1 is a small number") as usize; (-1i8).rem_euclid(1i8) as u8; - (-1i8).wrapping_rem_euclid(1i8).unwrap() as u16; - (-1i16).rem_euclid(1i16).unwrap() as u16; + (-1i8).wrapping_rem_euclid(1i8) as u16; + (-1i16).rem_euclid(1i16) as u16; (-1i16).rem_euclid(1i16) as u32; (-1i32).rem_euclid(1i32) as u32; (-1i32).rem_euclid(1i32) as u64; @@ -400,11 +401,11 @@ fn issue11642() { (-2_i32).pow(3) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value - (2_i32 % 1) as u32; - (2_i32 % -1) as u32; - (-2_i32 % 1) as u32; + (3_i32 % 2) as u32; + (3_i32 % -2) as u32; + (-5_i32 % 2) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value - (-2_i32 % -1) as u32; + (-5_i32 % -2) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value (2_i32 >> 1) as u32; (-2_i32 >> 1) as u32; diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 458b2736866b0..dd5d339b81b2a 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,5 +1,5 @@ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:16:5 + --> tests/ui/cast.rs:17:5 | LL | x0 as f32; | ^^^^^^^^^ @@ -8,37 +8,37 @@ LL | x0 as f32; = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:20:5 + --> tests/ui/cast.rs:21:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> tests/ui/cast.rs:22:5 + --> tests/ui/cast.rs:23:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:25:5 + --> tests/ui/cast.rs:26:5 | LL | x2 as f32; | ^^^^^^^^^ error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:28:5 + --> tests/ui/cast.rs:29:5 | LL | x3 as f32; | ^^^^^^^^^ error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> tests/ui/cast.rs:30:5 + --> tests/ui/cast.rs:31:5 | LL | x3 as f64; | ^^^^^^^^^ error: casting `f32` to `i32` may truncate the value - --> tests/ui/cast.rs:33:5 + --> tests/ui/cast.rs:34:5 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | 1f32 as i32; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]` error: casting `f32` to `u32` may truncate the value - --> tests/ui/cast.rs:35:5 + --> tests/ui/cast.rs:36:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | 1f32 as u32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:35:5 + --> tests/ui/cast.rs:36:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | 1f32 as u32; = help: to override `-D warnings` add `#[allow(clippy::cast_sign_loss)]` error: casting `f64` to `f32` may truncate the value - --> tests/ui/cast.rs:39:5 + --> tests/ui/cast.rs:40:5 | LL | 1f64 as f32; | ^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | 1f64 as f32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `i32` to `i8` may truncate the value - --> tests/ui/cast.rs:41:5 + --> tests/ui/cast.rs:42:5 | LL | 1i32 as i8; | ^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | i8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u8` may truncate the value - --> tests/ui/cast.rs:43:5 + --> tests/ui/cast.rs:44:5 | LL | 1i32 as u8; | ^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | u8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `f64` to `isize` may truncate the value - --> tests/ui/cast.rs:45:5 + --> tests/ui/cast.rs:46:5 | LL | 1f64 as isize; | ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 1f64 as isize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may truncate the value - --> tests/ui/cast.rs:47:5 + --> tests/ui/cast.rs:48:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ @@ -113,13 +113,13 @@ LL | 1f64 as usize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:47:5 + --> tests/ui/cast.rs:48:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting `u32` to `u16` may truncate the value - --> tests/ui/cast.rs:50:5 + --> tests/ui/cast.rs:51:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL | u16::try_from(1f32 as u32); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `f32` to `u32` may truncate the value - --> tests/ui/cast.rs:50:5 + --> tests/ui/cast.rs:51:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | 1f32 as u32 as u16; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:50:5 + --> tests/ui/cast.rs:51:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ error: casting `i32` to `i8` may truncate the value - --> tests/ui/cast.rs:55:22 + --> tests/ui/cast.rs:56:22 | LL | let _x: i8 = 1i32 as _; | ^^^^^^^^^ @@ -157,7 +157,7 @@ LL | let _x: i8 = 1i32.try_into(); | ~~~~~~~~~~~~~~~ error: casting `f32` to `i32` may truncate the value - --> tests/ui/cast.rs:57:9 + --> tests/ui/cast.rs:58:9 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | 1f32 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `i32` may truncate the value - --> tests/ui/cast.rs:59:9 + --> tests/ui/cast.rs:60:9 | LL | 1f64 as i32; | ^^^^^^^^^^^ @@ -173,7 +173,7 @@ LL | 1f64 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may truncate the value - --> tests/ui/cast.rs:61:9 + --> tests/ui/cast.rs:62:9 | LL | 1f32 as u8; | ^^^^^^^^^^ @@ -181,13 +181,13 @@ LL | 1f32 as u8; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may lose the sign of the value - --> tests/ui/cast.rs:61:9 + --> tests/ui/cast.rs:62:9 | LL | 1f32 as u8; | ^^^^^^^^^^ error: casting `u8` to `i8` may wrap around the value - --> tests/ui/cast.rs:66:5 + --> tests/ui/cast.rs:67:5 | LL | 1u8 as i8; | ^^^^^^^^^ @@ -196,31 +196,31 @@ LL | 1u8 as i8; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `u16` to `i16` may wrap around the value - --> tests/ui/cast.rs:69:5 + --> tests/ui/cast.rs:70:5 | LL | 1u16 as i16; | ^^^^^^^^^^^ error: casting `u32` to `i32` may wrap around the value - --> tests/ui/cast.rs:71:5 + --> tests/ui/cast.rs:72:5 | LL | 1u32 as i32; | ^^^^^^^^^^^ error: casting `u64` to `i64` may wrap around the value - --> tests/ui/cast.rs:73:5 + --> tests/ui/cast.rs:74:5 | LL | 1u64 as i64; | ^^^^^^^^^^^ error: casting `usize` to `isize` may wrap around the value - --> tests/ui/cast.rs:75:5 + --> tests/ui/cast.rs:76:5 | LL | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting `usize` to `i8` may truncate the value - --> tests/ui/cast.rs:78:5 + --> tests/ui/cast.rs:79:5 | LL | 1usize as i8; | ^^^^^^^^^^^^ @@ -232,7 +232,7 @@ LL | i8::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may truncate the value - --> tests/ui/cast.rs:81:5 + --> tests/ui/cast.rs:82:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -244,7 +244,7 @@ LL | i16::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may wrap around the value on targets with 16-bit wide pointers - --> tests/ui/cast.rs:81:5 + --> tests/ui/cast.rs:82:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | 1usize as i16; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> tests/ui/cast.rs:86:5 + --> tests/ui/cast.rs:87:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -265,19 +265,19 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:86:5 + --> tests/ui/cast.rs:87:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ error: casting `usize` to `i64` may wrap around the value on targets with 64-bit wide pointers - --> tests/ui/cast.rs:90:5 + --> tests/ui/cast.rs:91:5 | LL | 1usize as i64; | ^^^^^^^^^^^^^ error: casting `u16` to `isize` may wrap around the value on targets with 16-bit wide pointers - --> tests/ui/cast.rs:95:5 + --> tests/ui/cast.rs:96:5 | LL | 1u16 as isize; | ^^^^^^^^^^^^^ @@ -286,13 +286,13 @@ LL | 1u16 as isize; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:99:5 + --> tests/ui/cast.rs:100:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:102:5 + --> tests/ui/cast.rs:103:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -304,55 +304,55 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> tests/ui/cast.rs:102:5 + --> tests/ui/cast.rs:103:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:107:5 + --> tests/ui/cast.rs:108:5 | LL | -1i32 as u32; | ^^^^^^^^^^^^ error: casting `isize` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:110:5 + --> tests/ui/cast.rs:111:5 | LL | -1isize as usize; | ^^^^^^^^^^^^^^^^ error: casting `i8` to `u8` may lose the sign of the value - --> tests/ui/cast.rs:119:5 - | -LL | (-1i8).abs() as u8; - | ^^^^^^^^^^^^^^^^^^ - -error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:120:5 - | -LL | (-1i16).abs() as u16; - | ^^^^^^^^^^^^^^^^^^^^ - -error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:121:5 + --> tests/ui/cast.rs:122:5 | -LL | (-1i32).abs() as u32; - | ^^^^^^^^^^^^^^^^^^^^ +LL | (i8::MIN).abs() as u8; + | ^^^^^^^^^^^^^^^^^^^^^ error: casting `i64` to `u64` may lose the sign of the value - --> tests/ui/cast.rs:122:5 + --> tests/ui/cast.rs:126:5 | LL | (-1i64).abs() as u64; | ^^^^^^^^^^^^^^^^^^^^ error: casting `isize` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:123:5 + --> tests/ui/cast.rs:127:5 | LL | (-1isize).abs() as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^ +error: casting `i64` to `u64` may lose the sign of the value + --> tests/ui/cast.rs:134:5 + | +LL | (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i64` to `u64` may lose the sign of the value + --> tests/ui/cast.rs:149:5 + | +LL | (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i64` to `i8` may truncate the value - --> tests/ui/cast.rs:179:5 + --> tests/ui/cast.rs:200:5 | LL | (-99999999999i64).min(1) as i8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -364,7 +364,7 @@ LL | i8::try_from((-99999999999i64).min(1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `u8` may truncate the value - --> tests/ui/cast.rs:193:5 + --> tests/ui/cast.rs:214:5 | LL | 999999u64.clamp(0, 256) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -376,7 +376,7 @@ LL | u8::try_from(999999u64.clamp(0, 256)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E2` to `u8` may truncate the value - --> tests/ui/cast.rs:216:21 + --> tests/ui/cast.rs:237:21 | LL | let _ = self as u8; | ^^^^^^^^^^ @@ -388,7 +388,7 @@ LL | let _ = u8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E2::B` to `u8` will truncate the value - --> tests/ui/cast.rs:218:21 + --> tests/ui/cast.rs:239:21 | LL | let _ = Self::B as u8; | ^^^^^^^^^^^^^ @@ -397,7 +397,7 @@ LL | let _ = Self::B as u8; = help: to override `-D warnings` add `#[allow(clippy::cast_enum_truncation)]` error: casting `main::E5` to `i8` may truncate the value - --> tests/ui/cast.rs:260:21 + --> tests/ui/cast.rs:281:21 | LL | let _ = self as i8; | ^^^^^^^^^^ @@ -409,13 +409,13 @@ LL | let _ = i8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E5::A` to `i8` will truncate the value - --> tests/ui/cast.rs:262:21 + --> tests/ui/cast.rs:283:21 | LL | let _ = Self::A as i8; | ^^^^^^^^^^^^^ error: casting `main::E6` to `i16` may truncate the value - --> tests/ui/cast.rs:279:21 + --> tests/ui/cast.rs:300:21 | LL | let _ = self as i16; | ^^^^^^^^^^^ @@ -427,7 +427,7 @@ LL | let _ = i16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:298:21 + --> tests/ui/cast.rs:319:21 | LL | let _ = self as usize; | ^^^^^^^^^^^^^ @@ -439,7 +439,7 @@ LL | let _ = usize::try_from(self); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E10` to `u16` may truncate the value - --> tests/ui/cast.rs:345:21 + --> tests/ui/cast.rs:366:21 | LL | let _ = self as u16; | ^^^^^^^^^^^ @@ -451,7 +451,7 @@ LL | let _ = u16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> tests/ui/cast.rs:356:13 + --> tests/ui/cast.rs:377:13 | LL | let c = (q >> 16) as u8; | ^^^^^^^^^^^^^^^ @@ -463,7 +463,7 @@ LL | let c = u8::try_from(q >> 16); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> tests/ui/cast.rs:360:13 + --> tests/ui/cast.rs:381:13 | LL | let c = (q / 1000) as u8; | ^^^^^^^^^^^^^^^^ @@ -475,124 +475,180 @@ LL | let c = u8::try_from(q / 1000); | ~~~~~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:372:9 + --> tests/ui/cast.rs:393:9 | LL | (x * x) as u32; | ^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:377:32 + --> tests/ui/cast.rs:398:32 | LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 }; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:379:5 + --> tests/ui/cast.rs:400:5 + | +LL | (2_i32).checked_pow(3).unwrap() as u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:401:5 | LL | (-2_i32).pow(3) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:383:5 + --> tests/ui/cast.rs:406:5 + | +LL | (-5_i32 % 2) as u32; + | ^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:408:5 + | +LL | (-5_i32 % -2) as u32; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:411:5 + | +LL | (-2_i32 >> 1) as u32; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:415:5 | LL | (x * x) as u32; | ^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:384:5 + --> tests/ui/cast.rs:416:5 | LL | (x * x * x) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:388:5 + --> tests/ui/cast.rs:420:5 | LL | (y * y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:390:5 + --> tests/ui/cast.rs:422:5 | -LL | (y * y * y * y * 2) as u16; +LL | (y * y * y / y * 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:391:5 + --> tests/ui/cast.rs:423:5 | -LL | (y * y * y * 2) as u16; +LL | (y * y / y * 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:393:5 + --> tests/ui/cast.rs:425:5 | -LL | (y * y * y * -2) as u16; +LL | (y / y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^ +error: equal expressions as operands to `/` + --> tests/ui/cast.rs:425:6 + | +LL | (y / y * y * -2) as u16; + | ^^^^^ + | + = note: `#[deny(clippy::eq_op)]` on by default + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:428:5 + | +LL | (y + y + y + -2) as u16; + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:430:5 + | +LL | (y + y + y + 2) as u16; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:434:5 + | +LL | (z + -2) as u16; + | ^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:436:5 + | +LL | (z + z + 2) as u16; + | ^^^^^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:397:9 + --> tests/ui/cast.rs:439:9 | LL | (a * a * b * b * c * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:398:9 + --> tests/ui/cast.rs:440:9 | LL | (a * b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:400:9 + --> tests/ui/cast.rs:442:9 | LL | (a * -b * c) as u32; | ^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:402:9 + --> tests/ui/cast.rs:444:9 | LL | (a * b * c * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:403:9 + --> tests/ui/cast.rs:445:9 | LL | (a * -2) as u32; | ^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:405:9 + --> tests/ui/cast.rs:447:9 | LL | (a * b * c * -2) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:407:9 + --> tests/ui/cast.rs:449:9 | LL | (a / b) as u32; | ^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:408:9 + --> tests/ui/cast.rs:450:9 | LL | (a / b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:410:9 + --> tests/ui/cast.rs:452:9 | LL | (a / b + b * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:412:9 + --> tests/ui/cast.rs:454:9 | -LL | a.pow(3) as u32; - | ^^^^^^^^^^^^^^^ +LL | a.saturating_pow(3) as u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:414:9 + --> tests/ui/cast.rs:456:9 | LL | (a.abs() * b.pow(2) / c.abs()) as u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 76 previous errors +error: aborting due to 85 previous errors From d136b05c1be89db5bce650b6ef5e3ae3f521bf86 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 14 Feb 2024 12:28:07 +0000 Subject: [PATCH 161/417] Always evaluate free constants and statics, even if previous errors occurred --- tests/ui-toml/suppress_lint_in_const/test.rs | 5 -- .../suppress_lint_in_const/test.stderr | 33 +++---------- tests/ui/indexing_slicing_index.rs | 2 - tests/ui/indexing_slicing_index.stderr | 47 +++++++------------ 4 files changed, 23 insertions(+), 64 deletions(-) diff --git a/tests/ui-toml/suppress_lint_in_const/test.rs b/tests/ui-toml/suppress_lint_in_const/test.rs index 3edb3a10b7695..4ae75544c60c4 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.rs +++ b/tests/ui-toml/suppress_lint_in_const/test.rs @@ -13,8 +13,6 @@ const ARR: [i32; 2] = [1, 2]; const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. -const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. -//~^ ERROR: failed const fn idx() -> usize { 1 @@ -35,9 +33,6 @@ fn main() { x[const { idx() }]; // Ok, should not produce stderr. x[const { idx4() }]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays. const { &ARR[idx()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - // - //~^^ ERROR: failed let y = &x; y[0]; // Ok, referencing shouldn't affect this lint. See the issue 6021 diff --git a/tests/ui-toml/suppress_lint_in_const/test.stderr b/tests/ui-toml/suppress_lint_in_const/test.stderr index 84e7eff45573e..d5ce891b6805a 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -1,17 +1,5 @@ -error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/test.rs:38:14 - | -LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 - -note: erroneous constant encountered - --> $DIR/test.rs:38:5 - | -LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - | ^^^^^^^^^^^^^^^^^^^^^^ - error: indexing may panic - --> $DIR/test.rs:29:5 + --> $DIR/test.rs:27:5 | LL | x[index]; | ^^^^^^^^ @@ -21,7 +9,7 @@ LL | x[index]; = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic - --> $DIR/test.rs:47:5 + --> $DIR/test.rs:42:5 | LL | v[0]; | ^^^^ @@ -29,7 +17,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:48:5 + --> $DIR/test.rs:43:5 | LL | v[10]; | ^^^^^ @@ -37,7 +25,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:49:5 + --> $DIR/test.rs:44:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -45,7 +33,7 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:55:5 + --> $DIR/test.rs:50:5 | LL | v[N]; | ^^^^ @@ -53,19 +41,12 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:56:5 + --> $DIR/test.rs:51:5 | LL | v[M]; | ^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error[E0080]: evaluation of constant value failed - --> $DIR/test.rs:16:24 - | -LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. - | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 - -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/indexing_slicing_index.rs b/tests/ui/indexing_slicing_index.rs index 1ac0bb11014aa..2ababad7fc758 100644 --- a/tests/ui/indexing_slicing_index.rs +++ b/tests/ui/indexing_slicing_index.rs @@ -13,8 +13,6 @@ const ARR: [i32; 2] = [1, 2]; const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false. //~^ ERROR: indexing may panic -const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. -//~^ ERROR: indexing may panic const fn idx() -> usize { 1 diff --git a/tests/ui/indexing_slicing_index.stderr b/tests/ui/indexing_slicing_index.stderr index 6d64fa1e6cf89..2996e31a1aa26 100644 --- a/tests/ui/indexing_slicing_index.stderr +++ b/tests/ui/indexing_slicing_index.stderr @@ -9,29 +9,20 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re = note: `-D clippy::indexing-slicing` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:16:24 - | -LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. - | ^^^^^^^^^^^ - | - = help: consider using `.get(n)` or `.get_mut(n)` instead - = note: the suggestion might not be applicable in constant blocks - error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/indexing_slicing_index.rs:48:14 + --> $DIR/indexing_slicing_index.rs:46:14 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant encountered - --> $DIR/indexing_slicing_index.rs:48:5 + --> $DIR/indexing_slicing_index.rs:46:5 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^^^^^^^^^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:29:5 + --> $DIR/indexing_slicing_index.rs:27:5 | LL | x[index]; | ^^^^^^^^ @@ -39,7 +30,7 @@ LL | x[index]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:32:5 + --> $DIR/indexing_slicing_index.rs:30:5 | LL | x[4]; | ^^^^ @@ -48,13 +39,13 @@ LL | x[4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:34:5 + --> $DIR/indexing_slicing_index.rs:32:5 | LL | x[1 << 3]; | ^^^^^^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:45:14 + --> $DIR/indexing_slicing_index.rs:43:14 | LL | const { &ARR[idx()] }; | ^^^^^^^^^^ @@ -63,7 +54,7 @@ LL | const { &ARR[idx()] }; = note: the suggestion might not be applicable in constant blocks error: indexing may panic - --> $DIR/indexing_slicing_index.rs:48:14 + --> $DIR/indexing_slicing_index.rs:46:14 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^ @@ -72,13 +63,13 @@ LL | const { &ARR[idx4()] }; = note: the suggestion might not be applicable in constant blocks error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:55:5 + --> $DIR/indexing_slicing_index.rs:53:5 | LL | y[4]; | ^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:58:5 + --> $DIR/indexing_slicing_index.rs:56:5 | LL | v[0]; | ^^^^ @@ -86,7 +77,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:60:5 + --> $DIR/indexing_slicing_index.rs:58:5 | LL | v[10]; | ^^^^^ @@ -94,7 +85,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:62:5 + --> $DIR/indexing_slicing_index.rs:60:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -102,13 +93,13 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:70:5 + --> $DIR/indexing_slicing_index.rs:68:5 | LL | x[N]; | ^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:73:5 + --> $DIR/indexing_slicing_index.rs:71:5 | LL | v[N]; | ^^^^ @@ -116,7 +107,7 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:75:5 + --> $DIR/indexing_slicing_index.rs:73:5 | LL | v[M]; | ^^^^ @@ -124,17 +115,11 @@ LL | v[M]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:79:13 + --> $DIR/indexing_slicing_index.rs:77:13 | LL | let _ = x[4]; | ^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/indexing_slicing_index.rs:16:24 - | -LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. - | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 - -error: aborting due to 17 previous errors +error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0080`. From 86cb711b9647827783c4c0dd699d5ae835b2dc40 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 6 Feb 2024 16:44:30 +1100 Subject: [PATCH 162/417] Reduce capabilities of `Diagnostic`. Currently many diagnostic modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`. This commit removes most of them from `Diagnostic`. To minimize the diff size, it keeps them within `diagnostic.rs` but changes the surrounding `impl Diagnostic` block to `impl DiagnosticBuilder`. (I intend to move things around later, to give a more sensible code layout.) `Diagnostic` keeps a few methods that it still needs, like `sub`, `arg`, and `replace_args`. The `forward!` macro, which defined two additional methods per call (e.g. `note` and `with_note`), is replaced by the `with_fn!` macro, which defines one additional method per call (e.g. `with_note`). It's now also only used when necessary -- not all modifier methods currently need a `with_*` form. (New ones can be easily added as necessary.) All this also requires changing `trait AddToDiagnostic` so its methods take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`. There are three subdiagnostics -- `DelayedAtWithoutNewline`, `DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` -- that are created within the diagnostics machinery and appended to external diagnostics. These are handled at the `Diagnostic` level, which means it's now hard to construct them via `derive(Diagnostic)`, so instead we construct them by hand. This has no effect on what they look like when printed. There are lots of new `allow` markers for `untranslatable_diagnostics` and `diagnostics_outside_of_impl`. This is because `#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic` modifier methods, but missing from the `DiagnosticBuilder` modifier methods. They're now present. --- clippy_utils/src/sugg.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_utils/src/sugg.rs b/clippy_utils/src/sugg.rs index c86362c427ce2..b355e66b7b12a 100644 --- a/clippy_utils/src/sugg.rs +++ b/clippy_utils/src/sugg.rs @@ -683,7 +683,7 @@ fn indentation(cx: &T, span: Span) -> Option { }) } -/// Convenience extension trait for `Diagnostic`. +/// Convenience extension trait for `DiagnosticBuilder`. pub trait DiagnosticExt { /// Suggests to add an attribute to an item. /// @@ -731,7 +731,7 @@ pub trait DiagnosticExt { fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability); } -impl DiagnosticExt for rustc_errors::Diagnostic { +impl DiagnosticExt for rustc_errors::DiagnosticBuilder<'_, ()> { fn suggest_item_with_attr( &mut self, cx: &T, From 47b21730c4bf6ff2a93929e58009646fd022e3c8 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 31 Jan 2024 03:24:24 +0100 Subject: [PATCH 163/417] Factor out unspecialization --- .../rustc_pattern_analysis/src/usefulness.rs | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index d35b0248e415c..ffea76e4d53f7 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -1118,6 +1118,25 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> { } Ok(matrix) } + + /// Recover row usefulness and intersection information from a processed specialized matrix. + /// `specialized` must come from `self.specialize_constructor`. + fn unspecialize(&mut self, specialized: Self) { + for child_row in specialized.rows() { + let parent_row_id = child_row.parent_row; + let parent_row = &mut self.rows[parent_row_id]; + // A parent row is useful if any of its children is. + parent_row.useful |= child_row.useful; + for child_intersection in child_row.intersects.iter() { + // Convert the intersecting ids into ids for the parent matrix. + let parent_intersection = specialized.rows[child_intersection].parent_row; + // Note: self-intersection can happen with or-patterns. + if parent_intersection != parent_row_id { + parent_row.intersects.insert(parent_intersection); + } + } + } + } } /// Pretty-printer for matrices of patterns, example: @@ -1542,21 +1561,6 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>( // Accumulate the found witnesses. ret.extend(witnesses); - for child_row in spec_matrix.rows() { - let parent_row_id = child_row.parent_row; - let parent_row = &mut matrix.rows[parent_row_id]; - // A parent row is useful if any of its children is. - parent_row.useful |= child_row.useful; - for child_intersection in child_row.intersects.iter() { - // Convert the intersecting ids into ids for the parent matrix. - let parent_intersection = spec_matrix.rows[child_intersection].parent_row; - // Note: self-intersection can happen with or-patterns. - if parent_intersection != parent_row_id { - parent_row.intersects.insert(parent_intersection); - } - } - } - // Detect ranges that overlap on their endpoints. if let Constructor::IntRange(overlap_range) = ctor { if overlap_range.is_singleton() @@ -1566,6 +1570,8 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>( collect_overlapping_range_endpoints(mcx, overlap_range, matrix, &spec_matrix); } } + + matrix.unspecialize(spec_matrix); } // Record usefulness in the patterns. From d93096ecc0cb530d851ebbd58dce6cd2e68c850f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 20 Feb 2024 10:40:39 +0100 Subject: [PATCH 164/417] internal: Fetch toolchain and datalayout for DetachedFiles --- crates/hir-def/src/body/pretty.rs | 4 +- crates/hir-def/src/import_map.rs | 4 +- crates/hir-def/src/item_tree.rs | 6 +- crates/hir-def/src/item_tree/lower.rs | 26 ++++- crates/hir-def/src/item_tree/pretty.rs | 9 +- crates/hir-def/src/nameres.rs | 2 +- crates/hir-def/src/nameres/collector.rs | 2 +- crates/hir-def/src/nameres/tests/macros.rs | 3 - .../src/diagnostics/match_check/pat_util.rs | 2 +- crates/hir-ty/src/mir/eval/shim.rs | 8 +- crates/hir-ty/src/mir/eval/shim/simd.rs | 1 + crates/hir-ty/src/mir/lower.rs | 10 +- .../hir-ty/src/mir/lower/pattern_matching.rs | 13 ++- .../src/handlers/generate_delegate_methods.rs | 2 +- .../src/completions/item_list/trait_impl.rs | 2 +- crates/ide-db/src/imports/insert_use/tests.rs | 1 - crates/ide-db/src/symbol_index.rs | 3 +- crates/ide/src/join_lines.rs | 1 - crates/load-cargo/src/lib.rs | 15 ++- crates/project-model/src/workspace.rs | 96 ++++++++++++++----- crates/rust-analyzer/src/cargo_target_spec.rs | 3 +- crates/rust-analyzer/src/cli/lsif.rs | 2 +- crates/rust-analyzer/src/cli/rustc_tests.rs | 22 +++-- crates/rust-analyzer/src/cli/scip.rs | 2 +- crates/salsa/salsa-macros/src/query_group.rs | 1 - crates/salsa/src/debug.rs | 1 - crates/salsa/src/derived.rs | 1 - crates/salsa/src/input.rs | 1 - crates/salsa/src/interned.rs | 1 - 29 files changed, 164 insertions(+), 80 deletions(-) diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs index 7007dea638ef9..cd14f7b855a81 100644 --- a/crates/hir-def/src/body/pretty.rs +++ b/crates/hir-def/src/body/pretty.rs @@ -6,8 +6,8 @@ use itertools::Itertools; use crate::{ hir::{ - Array, BindingAnnotation, BindingId, CaptureBy, ClosureKind, Literal, LiteralOrConst, - Movability, Statement, + Array, BindingAnnotation, CaptureBy, ClosureKind, Literal, LiteralOrConst, Movability, + Statement, }, pretty::{print_generic_args, print_path, print_type_ref}, type_ref::TypeRef, diff --git a/crates/hir-def/src/import_map.rs b/crates/hir-def/src/import_map.rs index 98982c7db8406..faa1eed15a45a 100644 --- a/crates/hir-def/src/import_map.rs +++ b/crates/hir-def/src/import_map.rs @@ -3,7 +3,7 @@ use std::{fmt, hash::BuildHasherDefault}; use base_db::CrateId; -use fst::{self, raw::IndexedValue, Automaton, Streamer}; +use fst::{raw::IndexedValue, Automaton, Streamer}; use hir_expand::name::Name; use indexmap::IndexMap; use itertools::Itertools; @@ -477,7 +477,7 @@ mod tests { use expect_test::{expect, Expect}; use test_fixture::WithFixture; - use crate::{db::DefDatabase, test_db::TestDB, ItemContainerId, Lookup}; + use crate::{test_db::TestDB, ItemContainerId, Lookup}; use super::*; diff --git a/crates/hir-def/src/item_tree.rs b/crates/hir-def/src/item_tree.rs index be16a5e31a23c..bb36950f95acd 100644 --- a/crates/hir-def/src/item_tree.rs +++ b/crates/hir-def/src/item_tree.rs @@ -44,13 +44,13 @@ use std::{ ops::{Index, Range}, }; -use ast::{AstNode, HasName, StructKind}; +use ast::{AstNode, StructKind}; use base_db::CrateId; use either::Either; use hir_expand::{ ast_id_map::{AstIdNode, FileAstId}, attrs::RawAttrs, - name::{name, AsName, Name}, + name::Name, ExpandTo, HirFileId, InFile, }; use intern::Interned; @@ -67,7 +67,7 @@ use crate::{ attr::Attrs, db::DefDatabase, generics::{GenericParams, LifetimeParamData, TypeOrConstParamData}, - path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path, PathKind}, + path::{GenericArgs, ImportAlias, ModPath, Path, PathKind}, type_ref::{Mutability, TraitRef, TypeBound, TypeRef}, visibility::{RawVisibility, VisibilityExplicitness}, BlockId, Lookup, diff --git a/crates/hir-def/src/item_tree/lower.rs b/crates/hir-def/src/item_tree/lower.rs index e0aa3ae612352..37fdece876810 100644 --- a/crates/hir-def/src/item_tree/lower.rs +++ b/crates/hir-def/src/item_tree/lower.rs @@ -2,17 +2,33 @@ use std::collections::hash_map::Entry; -use hir_expand::{ast_id_map::AstIdMap, span_map::SpanMapRef, HirFileId}; -use syntax::ast::{self, HasModuleItem, HasTypeBounds, IsString}; +use hir_expand::{ + ast_id_map::AstIdMap, mod_path::path, name, name::AsName, span_map::SpanMapRef, HirFileId, +}; +use la_arena::Arena; +use syntax::{ + ast::{self, HasModuleItem, HasName, HasTypeBounds, IsString}, + AstNode, +}; +use triomphe::Arc; use crate::{ + db::DefDatabase, generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance}, - type_ref::{LifetimeRef, TraitBoundModifier, TraitRef}, + item_tree::{ + AssocItem, AttrOwner, Const, Either, Enum, ExternBlock, ExternCrate, Field, FieldAstId, + Fields, FileItemTreeId, FnFlags, Function, GenericArgs, Idx, IdxRange, Impl, ImportAlias, + Interned, ItemTree, ItemTreeData, ItemTreeNode, Macro2, MacroCall, MacroRules, Mod, + ModItem, ModKind, ModPath, Mutability, Name, Param, ParamAstId, Path, Range, RawAttrs, + RawIdx, RawVisibilityId, Static, Struct, StructKind, Trait, TraitAlias, TypeAlias, Union, + Use, UseTree, UseTreeKind, Variant, + }, + path::AssociatedTypeBinding, + type_ref::{LifetimeRef, TraitBoundModifier, TraitRef, TypeBound, TypeRef}, + visibility::RawVisibility, LocalLifetimeParamId, LocalTypeOrConstParamId, }; -use super::*; - fn id(index: Idx) -> FileItemTreeId { FileItemTreeId(index) } diff --git a/crates/hir-def/src/item_tree/pretty.rs b/crates/hir-def/src/item_tree/pretty.rs index 0086b7180b2bd..87c90a4c6ab94 100644 --- a/crates/hir-def/src/item_tree/pretty.rs +++ b/crates/hir-def/src/item_tree/pretty.rs @@ -6,12 +6,17 @@ use span::ErasedFileAstId; use crate::{ generics::{TypeOrConstParamData, WherePredicate, WherePredicateTypeTarget}, + item_tree::{ + AttrOwner, Const, DefDatabase, Enum, ExternBlock, ExternCrate, Field, FieldAstId, Fields, + FileItemTreeId, FnFlags, Function, GenericParams, Impl, Interned, ItemTree, Macro2, + MacroCall, MacroRules, Mod, ModItem, ModKind, Param, ParamAstId, Path, RawAttrs, + RawVisibilityId, Static, Struct, Trait, TraitAlias, TypeAlias, TypeBound, TypeRef, Union, + Use, UseTree, UseTreeKind, Variant, + }, pretty::{print_path, print_type_bounds, print_type_ref}, visibility::RawVisibility, }; -use super::*; - pub(super) fn print_item_tree(db: &dyn DefDatabase, tree: &ItemTree) -> String { let mut p = Printer { db, tree, buf: String::new(), indent_level: 0, needs_indent: true }; diff --git a/crates/hir-def/src/nameres.rs b/crates/hir-def/src/nameres.rs index 2a9390e797808..a2eca066438af 100644 --- a/crates/hir-def/src/nameres.rs +++ b/crates/hir-def/src/nameres.rs @@ -57,7 +57,7 @@ pub mod proc_macro; #[cfg(test)] mod tests; -use std::{cmp::Ord, ops::Deref}; +use std::ops::Deref; use base_db::{CrateId, Edition, FileId}; use hir_expand::{ diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs index 88838f58fe787..32825406505de 100644 --- a/crates/hir-def/src/nameres/collector.rs +++ b/crates/hir-def/src/nameres/collector.rs @@ -2446,7 +2446,7 @@ mod tests { use base_db::SourceDatabase; use test_fixture::WithFixture; - use crate::{db::DefDatabase, test_db::TestDB}; + use crate::test_db::TestDB; use super::*; diff --git a/crates/hir-def/src/nameres/tests/macros.rs b/crates/hir-def/src/nameres/tests/macros.rs index bf89ea711a0a1..d278b75e8158a 100644 --- a/crates/hir-def/src/nameres/tests/macros.rs +++ b/crates/hir-def/src/nameres/tests/macros.rs @@ -1,10 +1,7 @@ use expect_test::expect; -use test_fixture::WithFixture; use itertools::Itertools; -use crate::nameres::tests::check; - use super::*; #[test] diff --git a/crates/hir-ty/src/diagnostics/match_check/pat_util.rs b/crates/hir-ty/src/diagnostics/match_check/pat_util.rs index 217454499ef6d..c6a26cdd1d0f8 100644 --- a/crates/hir-ty/src/diagnostics/match_check/pat_util.rs +++ b/crates/hir-ty/src/diagnostics/match_check/pat_util.rs @@ -2,7 +2,7 @@ //! //! Originates from `rustc_hir::pat_util` -use std::iter::{Enumerate, ExactSizeIterator}; +use std::iter::Enumerate; pub(crate) struct EnumerateAndAdjust { enumerate: Enumerate, diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs index d68803fe2801a..cd992d0760204 100644 --- a/crates/hir-ty/src/mir/eval/shim.rs +++ b/crates/hir-ty/src/mir/eval/shim.rs @@ -8,9 +8,13 @@ use hir_def::{ builtin_type::{BuiltinInt, BuiltinUint}, resolver::HasResolver, }; -use hir_expand::mod_path::ModPath; -use super::*; +use crate::mir::eval::{ + name, pad16, static_lifetime, Address, AdtId, Arc, BuiltinType, Evaluator, FunctionId, + HasModule, HirDisplay, Interned, InternedClosure, Interner, Interval, IntervalAndTy, + IntervalOrOwned, ItemContainerId, LangItem, Layout, Locals, Lookup, MirEvalError, MirSpan, + ModPath, Mutability, Result, Substitution, Ty, TyBuilder, TyExt, +}; mod simd; diff --git a/crates/hir-ty/src/mir/eval/shim/simd.rs b/crates/hir-ty/src/mir/eval/shim/simd.rs index eddfd0acfb98c..e229a4ab31727 100644 --- a/crates/hir-ty/src/mir/eval/shim/simd.rs +++ b/crates/hir-ty/src/mir/eval/shim/simd.rs @@ -2,6 +2,7 @@ use std::cmp::Ordering; +use crate::consteval::try_const_usize; use crate::TyKind; use super::*; diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index b038900cdacba..ed316f972689f 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -31,14 +31,20 @@ use crate::{ inhabitedness::is_ty_uninhabited_from, layout::LayoutError, mapping::ToChalk, + mir::{ + intern_const_scalar, return_slot, AggregateKind, Arena, BasicBlock, BasicBlockId, BinOp, + BorrowKind, CastKind, ClosureId, ConstScalar, Either, Expr, FieldId, Idx, InferenceResult, + Interner, Local, LocalId, MemoryMap, MirBody, MirSpan, Mutability, Operand, Place, + PlaceElem, PointerCast, ProjectionElem, ProjectionStore, RawIdx, Rvalue, Statement, + StatementKind, Substitution, SwitchTargets, Terminator, TerminatorKind, TupleFieldId, Ty, + UnOp, VariantId, + }, static_lifetime, traits::FnTrait, utils::{generics, ClosureSubst}, Adjust, Adjustment, AutoBorrow, CallableDefId, TyBuilder, TyExt, }; -use super::*; - mod as_place; mod pattern_matching; diff --git a/crates/hir-ty/src/mir/lower/pattern_matching.rs b/crates/hir-ty/src/mir/lower/pattern_matching.rs index 8202bac532f7a..85c8d1685b874 100644 --- a/crates/hir-ty/src/mir/lower/pattern_matching.rs +++ b/crates/hir-ty/src/mir/lower/pattern_matching.rs @@ -2,9 +2,16 @@ use hir_def::{hir::LiteralOrConst, resolver::HasResolver, AssocItemId}; -use crate::BindingMode; - -use super::*; +use crate::{ + mir::lower::{ + BasicBlockId, BinOp, BindingId, BorrowKind, Either, Expr, FieldId, Idx, Interner, + MemoryMap, MirLowerCtx, MirLowerError, MirSpan, Mutability, Operand, Pat, PatId, Place, + PlaceElem, ProjectionElem, RecordFieldPat, ResolveValueResult, Result, Rvalue, + Substitution, SwitchTargets, TerminatorKind, TupleFieldId, TupleId, TyBuilder, TyKind, + ValueNs, VariantData, VariantId, + }, + BindingMode, +}; macro_rules! not_supported { ($x: expr) => { diff --git a/crates/ide-assists/src/handlers/generate_delegate_methods.rs b/crates/ide-assists/src/handlers/generate_delegate_methods.rs index 4f2df5633c3cb..38f40b8d58b4c 100644 --- a/crates/ide-assists/src/handlers/generate_delegate_methods.rs +++ b/crates/ide-assists/src/handlers/generate_delegate_methods.rs @@ -1,4 +1,4 @@ -use hir::{self, HasCrate, HasVisibility}; +use hir::{HasCrate, HasVisibility}; use ide_db::{path_transform::PathTransform, FxHashSet}; use syntax::{ ast::{ diff --git a/crates/ide-completion/src/completions/item_list/trait_impl.rs b/crates/ide-completion/src/completions/item_list/trait_impl.rs index 3c4b89ca742ec..7394d63be5868 100644 --- a/crates/ide-completion/src/completions/item_list/trait_impl.rs +++ b/crates/ide-completion/src/completions/item_list/trait_impl.rs @@ -31,7 +31,7 @@ //! } //! ``` -use hir::{self, HasAttrs}; +use hir::HasAttrs; use ide_db::{ documentation::HasDocs, path_transform::PathTransform, syntax_helpers::insert_whitespace_into_node, traits::get_missing_assoc_items, SymbolKind, diff --git a/crates/ide-db/src/imports/insert_use/tests.rs b/crates/ide-db/src/imports/insert_use/tests.rs index 6b0fecae26758..10c285a13fbcc 100644 --- a/crates/ide-db/src/imports/insert_use/tests.rs +++ b/crates/ide-db/src/imports/insert_use/tests.rs @@ -1,4 +1,3 @@ -use hir::PrefixKind; use stdx::trim_indent; use test_fixture::WithFixture; use test_utils::{assert_eq_text, CURSOR_MARKER}; diff --git a/crates/ide-db/src/symbol_index.rs b/crates/ide-db/src/symbol_index.rs index 92c09089e1f13..c65467a43249b 100644 --- a/crates/ide-db/src/symbol_index.rs +++ b/crates/ide-db/src/symbol_index.rs @@ -31,7 +31,7 @@ use base_db::{ salsa::{self, ParallelDatabase}, SourceDatabaseExt, SourceRootId, Upcast, }; -use fst::{self, raw::IndexedValue, Automaton, Streamer}; +use fst::{raw::IndexedValue, Automaton, Streamer}; use hir::{ db::HirDatabase, import_map::{AssocSearchMode, SearchMode}, @@ -394,7 +394,6 @@ impl Query { mod tests { use expect_test::expect_file; - use hir::symbols::SymbolCollector; use test_fixture::WithFixture; use super::*; diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index fef0ec35ba091..815a4ba7fd702 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs @@ -303,7 +303,6 @@ fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { #[cfg(test)] mod tests { - use syntax::SourceFile; use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range}; use super::*; diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs index 8c5592da63ecd..830d19a709c42 100644 --- a/crates/load-cargo/src/lib.rs +++ b/crates/load-cargo/src/lib.rs @@ -309,6 +309,10 @@ fn load_crate_graph( vfs: &mut vfs::Vfs, receiver: &Receiver, ) -> AnalysisHost { + let (ProjectWorkspace::Cargo { toolchain, target_layout, .. } + | ProjectWorkspace::Json { toolchain, target_layout, .. } + | ProjectWorkspace::DetachedFiles { toolchain, target_layout, .. }) = ws; + let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::().ok()); let mut host = AnalysisHost::new(lru_cap); let mut analysis_change = Change::new(); @@ -344,14 +348,9 @@ fn load_crate_graph( let num_crates = crate_graph.len(); analysis_change.set_crate_graph(crate_graph); analysis_change.set_proc_macros(proc_macros); - if let ProjectWorkspace::Cargo { toolchain, target_layout, .. } - | ProjectWorkspace::Json { toolchain, target_layout, .. } = ws - { - analysis_change.set_target_data_layouts( - iter::repeat(target_layout.clone()).take(num_crates).collect(), - ); - analysis_change.set_toolchains(iter::repeat(toolchain.clone()).take(num_crates).collect()); - } + analysis_change + .set_target_data_layouts(iter::repeat(target_layout.clone()).take(num_crates).collect()); + analysis_change.set_toolchains(iter::repeat(toolchain.clone()).take(num_crates).collect()); host.apply_change(analysis_change); host diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index b7ae76be8cec0..bcb5dcadb5b99 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -100,6 +100,8 @@ pub enum ProjectWorkspace { /// Holds cfg flags for the current target. We get those by running /// `rustc --print cfg`. rustc_cfg: Vec, + toolchain: Option, + target_layout: TargetLayoutLoadResult, }, } @@ -145,16 +147,24 @@ impl fmt::Debug for ProjectWorkspace { debug_struct.field("n_sysroot_crates", &sysroot.num_packages()); } debug_struct - .field("toolchain", &toolchain) .field("n_rustc_cfg", &rustc_cfg.len()) + .field("toolchain", &toolchain) .field("data_layout", &data_layout); debug_struct.finish() } - ProjectWorkspace::DetachedFiles { files, sysroot, rustc_cfg } => f + ProjectWorkspace::DetachedFiles { + files, + sysroot, + rustc_cfg, + toolchain, + target_layout, + } => f .debug_struct("DetachedFiles") .field("n_files", &files.len()) .field("sysroot", &sysroot.is_ok()) .field("n_rustc_cfg", &rustc_cfg.len()) + .field("toolchain", &toolchain) + .field("data_layout", &target_layout) .finish(), } } @@ -403,32 +413,54 @@ impl ProjectWorkspace { detached_files: Vec, config: &CargoConfig, ) -> anyhow::Result { + let dir = detached_files + .first() + .and_then(|it| it.parent()) + .ok_or_else(|| format_err!("No detached files to load"))?; let sysroot = match &config.sysroot { Some(RustLibSource::Path(path)) => { Sysroot::with_sysroot_dir(path.clone(), config.sysroot_query_metadata) .map_err(|e| Some(format!("Failed to find sysroot at {path}:{e}"))) } - Some(RustLibSource::Discover) => { - let dir = &detached_files - .first() - .and_then(|it| it.parent()) - .ok_or_else(|| format_err!("No detached files to load"))?; - Sysroot::discover(dir, &config.extra_env, config.sysroot_query_metadata).map_err( - |e| { - Some(format!( - "Failed to find sysroot for {dir}. Is rust-src installed? {e}" - )) - }, - ) - } + Some(RustLibSource::Discover) => Sysroot::discover( + dir, + &config.extra_env, + config.sysroot_query_metadata, + ) + .map_err(|e| { + Some(format!("Failed to find sysroot for {dir}. Is rust-src installed? {e}")) + }), None => Err(None), }; - let rustc_cfg = rustc_cfg::get( + + let sysroot_ref = sysroot.as_ref().ok(); + let toolchain = match get_toolchain_version( + dir, + sysroot_ref, + toolchain::Tool::Rustc, + &config.extra_env, + "rustc ", + ) { + Ok(it) => it, + Err(e) => { + tracing::error!("{e}"); + None + } + }; + + let rustc_cfg = rustc_cfg::get(None, &config.extra_env, RustcCfgConfig::Rustc(sysroot_ref)); + let data_layout = target_data_layout::get( + RustcDataLayoutConfig::Rustc(sysroot_ref), None, - &FxHashMap::default(), - RustcCfgConfig::Rustc(sysroot.as_ref().ok()), + &config.extra_env, ); - Ok(ProjectWorkspace::DetachedFiles { files: detached_files, sysroot, rustc_cfg }) + Ok(ProjectWorkspace::DetachedFiles { + files: detached_files, + sysroot, + rustc_cfg, + toolchain, + target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())), + }) } /// Runs the build scripts for this [`ProjectWorkspace`]. @@ -724,7 +756,13 @@ impl ProjectWorkspace { cfg_overrides, build_scripts, ), - ProjectWorkspace::DetachedFiles { files, sysroot, rustc_cfg } => { + ProjectWorkspace::DetachedFiles { + files, + sysroot, + rustc_cfg, + toolchain: _, + target_layout: _, + } => { detached_files_to_crate_graph(rustc_cfg.clone(), load, files, sysroot.as_ref().ok()) } }; @@ -786,9 +824,21 @@ impl ProjectWorkspace { && toolchain == o_toolchain } ( - Self::DetachedFiles { files, sysroot, rustc_cfg }, - Self::DetachedFiles { files: o_files, sysroot: o_sysroot, rustc_cfg: o_rustc_cfg }, - ) => files == o_files && sysroot == o_sysroot && rustc_cfg == o_rustc_cfg, + Self::DetachedFiles { files, sysroot, rustc_cfg, toolchain, target_layout }, + Self::DetachedFiles { + files: o_files, + sysroot: o_sysroot, + rustc_cfg: o_rustc_cfg, + toolchain: o_toolchain, + target_layout: o_target_layout, + }, + ) => { + files == o_files + && sysroot == o_sysroot + && rustc_cfg == o_rustc_cfg + && toolchain == o_toolchain + && target_layout == o_target_layout + } _ => false, } } diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index 9a9357a539897..815a98980b93b 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -4,7 +4,7 @@ use std::mem; use cfg::{CfgAtom, CfgExpr}; use ide::{Cancellable, CrateId, FileId, RunnableKind, TestId}; -use project_model::{self, CargoFeatures, ManifestPath, TargetKind}; +use project_model::{CargoFeatures, ManifestPath, TargetKind}; use rustc_hash::FxHashSet; use vfs::AbsPathBuf; @@ -208,7 +208,6 @@ fn required_features(cfg_expr: &CfgExpr, features: &mut Vec) { mod tests { use super::*; - use cfg::CfgExpr; use mbe::{syntax_node_to_token_tree, DummyTestSpanMap, DUMMY}; use syntax::{ ast::{self, AstNode}, diff --git a/crates/rust-analyzer/src/cli/lsif.rs b/crates/rust-analyzer/src/cli/lsif.rs index 1424a775777fd..5e810463db6cb 100644 --- a/crates/rust-analyzer/src/cli/lsif.rs +++ b/crates/rust-analyzer/src/cli/lsif.rs @@ -13,7 +13,7 @@ use ide_db::{ LineIndexDatabase, }; use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice}; -use lsp_types::{self, lsif}; +use lsp_types::lsif; use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource}; use rustc_hash::FxHashMap; use vfs::{AbsPathBuf, Vfs}; diff --git a/crates/rust-analyzer/src/cli/rustc_tests.rs b/crates/rust-analyzer/src/cli/rustc_tests.rs index 64ea246a45872..25f84d770bfb3 100644 --- a/crates/rust-analyzer/src/cli/rustc_tests.rs +++ b/crates/rust-analyzer/src/cli/rustc_tests.rs @@ -5,7 +5,8 @@ use std::{cell::RefCell, fs::read_to_string, panic::AssertUnwindSafe, path::Path use hir::{Change, Crate}; use ide::{AnalysisHost, DiagnosticCode, DiagnosticsConfig}; use profile::StopWatch; -use project_model::{CargoConfig, ProjectWorkspace, RustLibSource, Sysroot}; +use project_model::target_data_layout::RustcDataLayoutConfig; +use project_model::{target_data_layout, CargoConfig, ProjectWorkspace, RustLibSource, Sysroot}; use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice}; use rustc_hash::FxHashMap; @@ -60,15 +61,22 @@ impl Tester { std::fs::write(&tmp_file, "")?; let cargo_config = CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() }; + + let sysroot = + Ok(Sysroot::discover(tmp_file.parent().unwrap(), &cargo_config.extra_env, false) + .unwrap()); + let data_layout = target_data_layout::get( + RustcDataLayoutConfig::Rustc(sysroot.as_ref().ok()), + None, + &cargo_config.extra_env, + ); + let workspace = ProjectWorkspace::DetachedFiles { files: vec![tmp_file.clone()], - sysroot: Ok(Sysroot::discover( - tmp_file.parent().unwrap(), - &cargo_config.extra_env, - false, - ) - .unwrap()), + sysroot, rustc_cfg: vec![], + toolchain: None, + target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())), }; let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check: false, diff --git a/crates/rust-analyzer/src/cli/scip.rs b/crates/rust-analyzer/src/cli/scip.rs index 2d56830c87f30..27869a5a7e63d 100644 --- a/crates/rust-analyzer/src/cli/scip.rs +++ b/crates/rust-analyzer/src/cli/scip.rs @@ -324,7 +324,7 @@ fn moniker_to_symbol(moniker: &MonikerResult) -> scip_types::Symbol { #[cfg(test)] mod test { use super::*; - use ide::{AnalysisHost, FilePosition, StaticIndex, TextSize}; + use ide::{AnalysisHost, FilePosition, TextSize}; use scip::symbol::format_symbol; use test_fixture::ChangeFixture; diff --git a/crates/salsa/salsa-macros/src/query_group.rs b/crates/salsa/salsa-macros/src/query_group.rs index e535d7ed0438a..5d1678ef12006 100644 --- a/crates/salsa/salsa-macros/src/query_group.rs +++ b/crates/salsa/salsa-macros/src/query_group.rs @@ -1,5 +1,4 @@ //! -use std::{convert::TryFrom, iter::FromIterator}; use crate::parenthesized::Parenthesized; use heck::ToUpperCamelCase; diff --git a/crates/salsa/src/debug.rs b/crates/salsa/src/debug.rs index 0925ddb3d85bb..5f113541f04cf 100644 --- a/crates/salsa/src/debug.rs +++ b/crates/salsa/src/debug.rs @@ -5,7 +5,6 @@ use crate::durability::Durability; use crate::plumbing::QueryStorageOps; use crate::Query; use crate::QueryTable; -use std::iter::FromIterator; /// Additional methods on queries that can be used to "peek into" /// their current state. These methods are meant for debugging and diff --git a/crates/salsa/src/derived.rs b/crates/salsa/src/derived.rs index c381e66e087bc..d631671005816 100644 --- a/crates/salsa/src/derived.rs +++ b/crates/salsa/src/derived.rs @@ -13,7 +13,6 @@ use crate::Runtime; use crate::{Database, DatabaseKeyIndex, QueryDb, Revision}; use parking_lot::RwLock; use std::borrow::Borrow; -use std::convert::TryFrom; use std::hash::Hash; use std::marker::PhantomData; use triomphe::Arc; diff --git a/crates/salsa/src/input.rs b/crates/salsa/src/input.rs index 4e8fca6149b7e..c2539570e0f9f 100644 --- a/crates/salsa/src/input.rs +++ b/crates/salsa/src/input.rs @@ -14,7 +14,6 @@ use crate::Runtime; use crate::{DatabaseKeyIndex, QueryDb}; use indexmap::map::Entry; use parking_lot::RwLock; -use std::convert::TryFrom; use std::iter; use tracing::debug; diff --git a/crates/salsa/src/interned.rs b/crates/salsa/src/interned.rs index 731839e9598c0..822219f51859c 100644 --- a/crates/salsa/src/interned.rs +++ b/crates/salsa/src/interned.rs @@ -13,7 +13,6 @@ use crate::{Database, DatabaseKeyIndex, QueryDb}; use parking_lot::RwLock; use rustc_hash::FxHashMap; use std::collections::hash_map::Entry; -use std::convert::From; use std::fmt::Debug; use std::hash::Hash; use triomphe::Arc; From 85203d97216e88f1bc2df9eb5e8d1d0bd9d93118 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 19 Feb 2024 18:14:48 +0100 Subject: [PATCH 165/417] Render assoc item owner in hover for items other than functions --- crates/hir/src/lib.rs | 88 ++++++++++++++++++++++++++++++++++ crates/ide-db/src/defs.rs | 21 ++++++-- crates/ide/src/hover/render.rs | 22 ++++++--- crates/ide/src/hover/tests.rs | 32 ++++++------- 4 files changed, 135 insertions(+), 28 deletions(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index beaa6dd4d67cb..2d8811cf5ebeb 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2653,6 +2653,37 @@ impl ItemInNs { } } +/// Invariant: `inner.as_extern_assoc_item(db).is_some()` +/// We do not actively enforce this invariant. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum ExternAssocItem { + Function(Function), + Static(Static), + TypeAlias(TypeAlias), +} + +pub trait AsExternAssocItem { + fn as_extern_assoc_item(self, db: &dyn HirDatabase) -> Option; +} + +impl AsExternAssocItem for Function { + fn as_extern_assoc_item(self, db: &dyn HirDatabase) -> Option { + as_extern_assoc_item(db, ExternAssocItem::Function, self.id) + } +} + +impl AsExternAssocItem for Static { + fn as_extern_assoc_item(self, db: &dyn HirDatabase) -> Option { + as_extern_assoc_item(db, ExternAssocItem::Static, self.id) + } +} + +impl AsExternAssocItem for TypeAlias { + fn as_extern_assoc_item(self, db: &dyn HirDatabase) -> Option { + as_extern_assoc_item(db, ExternAssocItem::TypeAlias, self.id) + } +} + /// Invariant: `inner.as_assoc_item(db).is_some()` /// We do not actively enforce this invariant. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -2727,6 +2758,63 @@ where } } +fn as_extern_assoc_item<'db, ID, DEF, LOC>( + db: &(dyn HirDatabase + 'db), + ctor: impl FnOnce(DEF) -> ExternAssocItem, + id: ID, +) -> Option +where + ID: Lookup = dyn DefDatabase + 'db, Data = AssocItemLoc>, + DEF: From, + LOC: ItemTreeNode, +{ + match id.lookup(db.upcast()).container { + ItemContainerId::ExternBlockId(_) => Some(ctor(DEF::from(id))), + ItemContainerId::TraitId(_) | ItemContainerId::ImplId(_) | ItemContainerId::ModuleId(_) => { + None + } + } +} + +impl ExternAssocItem { + pub fn name(self, db: &dyn HirDatabase) -> Name { + match self { + Self::Function(it) => it.name(db), + Self::Static(it) => it.name(db), + Self::TypeAlias(it) => it.name(db), + } + } + + pub fn module(self, db: &dyn HirDatabase) -> Module { + match self { + Self::Function(f) => f.module(db), + Self::Static(c) => c.module(db), + Self::TypeAlias(t) => t.module(db), + } + } + + pub fn as_function(self) -> Option { + match self { + Self::Function(v) => Some(v), + _ => None, + } + } + + pub fn as_static(self) -> Option { + match self { + Self::Static(v) => Some(v), + _ => None, + } + } + + pub fn as_type_alias(self) -> Option { + match self { + Self::TypeAlias(v) => Some(v), + _ => None, + } + } +} + impl AssocItem { pub fn name(self, db: &dyn HirDatabase) -> Option { match self { diff --git a/crates/ide-db/src/defs.rs b/crates/ide-db/src/defs.rs index 747c90561deea..1b6ff8bad53c5 100644 --- a/crates/ide-db/src/defs.rs +++ b/crates/ide-db/src/defs.rs @@ -8,11 +8,11 @@ use arrayvec::ArrayVec; use either::Either; use hir::{ - Adt, AsAssocItem, AssocItem, AttributeTemplate, BuiltinAttr, BuiltinType, Const, Crate, - DefWithBody, DeriveHelper, DocLinkDef, ExternCrateDecl, Field, Function, GenericParam, - HasVisibility, HirDisplay, Impl, Label, Local, Macro, Module, ModuleDef, Name, PathResolution, - Semantics, Static, ToolModule, Trait, TraitAlias, TupleField, TypeAlias, Variant, VariantDef, - Visibility, + Adt, AsAssocItem, AsExternAssocItem, AssocItem, AttributeTemplate, BuiltinAttr, BuiltinType, + Const, Crate, DefWithBody, DeriveHelper, DocLinkDef, ExternAssocItem, ExternCrateDecl, Field, + Function, GenericParam, HasVisibility, HirDisplay, Impl, Label, Local, Macro, Module, + ModuleDef, Name, PathResolution, Semantics, Static, ToolModule, Trait, TraitAlias, TupleField, + TypeAlias, Variant, VariantDef, Visibility, }; use stdx::{format_to, impl_from}; use syntax::{ @@ -742,6 +742,17 @@ impl AsAssocItem for Definition { } } +impl AsExternAssocItem for Definition { + fn as_extern_assoc_item(self, db: &dyn hir::db::HirDatabase) -> Option { + match self { + Definition::Function(it) => it.as_extern_assoc_item(db), + Definition::Static(it) => it.as_extern_assoc_item(db), + Definition::TypeAlias(it) => it.as_extern_assoc_item(db), + _ => None, + } + } +} + impl From for Definition { fn from(assoc_item: AssocItem) -> Self { match assoc_item { diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs index 42342d94b6d13..563e78253a8ae 100644 --- a/crates/ide/src/hover/render.rs +++ b/crates/ide/src/hover/render.rs @@ -3,8 +3,8 @@ use std::{mem, ops::Not}; use either::Either; use hir::{ - Adt, AsAssocItem, CaptureKind, HasCrate, HasSource, HirDisplay, Layout, LayoutError, Name, - Semantics, Trait, Type, TypeInfo, + Adt, AsAssocItem, AsExternAssocItem, CaptureKind, HasCrate, HasSource, HirDisplay, Layout, + LayoutError, Name, Semantics, Trait, Type, TypeInfo, }; use ide_db::{ base_db::SourceDatabase, @@ -369,12 +369,20 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option match def { Definition::Field(f) => Some(f.parent_def(db).name(db)), Definition::Local(l) => l.parent(db).name(db), - Definition::Function(f) => match f.as_assoc_item(db)?.container(db) { - hir::AssocItemContainer::Trait(t) => Some(t.name(db)), - hir::AssocItemContainer::Impl(i) => i.self_ty(db).as_adt().map(|adt| adt.name(db)), - }, Definition::Variant(e) => Some(e.parent_enum(db).name(db)), - _ => None, + + d => { + if let Some(assoc_item) = d.as_assoc_item(db) { + match assoc_item.container(db) { + hir::AssocItemContainer::Trait(t) => Some(t.name(db)), + hir::AssocItemContainer::Impl(i) => { + i.self_ty(db).as_adt().map(|adt| adt.name(db)) + } + } + } else { + return d.as_extern_assoc_item(db).map(|_| "".to_owned()); + } + } } .map(|name| name.display(db).to_string()) } diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 157f8ff371ef2..ead4f91595f0e 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -1202,7 +1202,7 @@ fn main() { *C* ```rust - test + test::X ``` ```rust @@ -2277,7 +2277,7 @@ fn main() { let foo_test = unsafe { fo$0o(1, 2, 3); } } *foo* ```rust - test + test:: ``` ```rust @@ -4266,7 +4266,7 @@ fn main() { *B* ```rust - test + test::T ``` ```rust @@ -4295,7 +4295,7 @@ fn main() { *B* ```rust - test + test::T ``` ```rust @@ -4327,7 +4327,7 @@ fn main() { *B* ```rust - test + test::T ``` ```rust @@ -4919,7 +4919,7 @@ fn test() { *FOO* ```rust - test + test::S ``` ```rust @@ -5284,7 +5284,7 @@ impl T1 for Foo { *Bar* ```rust - test::t2 + test::t2::T2 ``` ```rust @@ -5306,7 +5306,7 @@ trait A { *Assoc* ```rust - test + test::A ``` ```rust @@ -5327,7 +5327,7 @@ trait A { *Assoc* ```rust - test + test::A ``` ```rust @@ -5346,7 +5346,7 @@ trait A where *Assoc* ```rust - test + test::A ``` ```rust @@ -6632,7 +6632,7 @@ fn test() { *A* ```rust - test + test::S ``` ```rust @@ -6661,7 +6661,7 @@ fn test() { *A* ```rust - test + test::S ``` ```rust @@ -6691,7 +6691,7 @@ mod m { *A* ```rust - test + test::S ``` ```rust @@ -7249,7 +7249,7 @@ extern "C" { *STATIC* ```rust - test + test:: ``` ```rust @@ -7267,7 +7267,7 @@ extern "C" { *fun* ```rust - test + test:: ``` ```rust @@ -7285,7 +7285,7 @@ extern "C" { *Ty* ```rust - test + test:: ``` ```rust From 06d6c62f80c2729f2ba3129c43c2cd3417b50251 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 13 Feb 2024 23:28:27 +0000 Subject: [PATCH 166/417] Add newtype for raw idents --- compiler/rustc_ast/src/token.rs | 38 +++++++++++++----- compiler/rustc_ast/src/tokenstream.rs | 2 +- compiler/rustc_ast_pretty/src/pprust/state.rs | 8 ++-- compiler/rustc_builtin_macros/src/asm.rs | 3 +- .../src/assert/context.rs | 8 ++-- compiler/rustc_expand/src/mbe/macro_check.rs | 4 +- compiler/rustc_expand/src/mbe/macro_rules.rs | 14 +++++-- compiler/rustc_expand/src/mbe/metavar_expr.rs | 4 +- compiler/rustc_expand/src/mbe/quoted.rs | 4 +- compiler/rustc_expand/src/parse/tests.rs | 40 ++++++++++++++----- .../rustc_expand/src/proc_macro_server.rs | 13 +++--- .../rustc_expand/src/tokenstream/tests.rs | 5 ++- compiler/rustc_lint/src/builtin.rs | 2 +- compiler/rustc_parse/src/lexer/mod.rs | 8 ++-- .../rustc_parse/src/lexer/unicode_chars.rs | 2 +- .../rustc_parse/src/parser/diagnostics.rs | 13 +++--- compiler/rustc_parse/src/parser/expr.rs | 38 ++++++++++-------- compiler/rustc_parse/src/parser/item.rs | 7 ++-- compiler/rustc_parse/src/parser/mod.rs | 9 +++-- .../rustc_parse/src/parser/nonterminal.rs | 2 +- compiler/rustc_parse/src/parser/pat.rs | 2 +- compiler/rustc_parse/src/parser/path.rs | 3 +- compiler/rustc_parse/src/parser/stmt.rs | 2 +- src/librustdoc/clean/render_macro_matchers.rs | 4 +- 24 files changed, 148 insertions(+), 87 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 50fe37dcdb6fc..5ccc7d51066d9 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -107,7 +107,7 @@ impl Lit { /// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation. pub fn from_token(token: &Token) -> Option { match token.uninterpolate().kind { - Ident(name, false) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)), + Ident(name, IdentIsRaw::No) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)), Literal(token_lit) => Some(token_lit), Interpolated(ref nt) if let NtExpr(expr) | NtLiteral(expr) = &nt.0 @@ -183,7 +183,7 @@ impl LitKind { } } -pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool { +pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool { let ident_token = Token::new(Ident(name, is_raw), span); !ident_token.is_reserved_ident() @@ -214,7 +214,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool { .contains(&name) } -fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool { +fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool { let ident_token = Token::new(Ident(name, is_raw), span); !ident_token.is_reserved_ident() @@ -223,6 +223,24 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool { .contains(&name) } +#[derive(PartialEq, Encodable, Decodable, Debug, Copy, Clone, HashStable_Generic)] +pub enum IdentIsRaw { + No, + Yes, +} + +impl From for IdentIsRaw { + fn from(b: bool) -> Self { + if b { Self::Yes } else { Self::No } + } +} + +impl From for bool { + fn from(is_raw: IdentIsRaw) -> bool { + matches!(is_raw, IdentIsRaw::Yes) + } +} + // SAFETY: due to the `Clone` impl below, all fields of all variants other than // `Interpolated` must impl `Copy`. #[derive(PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] @@ -298,7 +316,7 @@ pub enum TokenKind { /// Do not forget about `NtIdent` when you want to match on identifiers. /// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to /// treat regular and interpolated identifiers in the same way. - Ident(Symbol, /* is_raw */ bool), + Ident(Symbol, IdentIsRaw), /// Lifetime identifier token. /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers. /// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to @@ -411,7 +429,7 @@ impl Token { /// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary. pub fn from_ast_ident(ident: Ident) -> Self { - Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span) + Token::new(Ident(ident.name, ident.is_raw_guess().into()), ident.span) } /// For interpolated tokens, returns a span of the fragment to which the interpolated @@ -567,7 +585,7 @@ impl Token { pub fn can_begin_literal_maybe_minus(&self) -> bool { match self.uninterpolate().kind { Literal(..) | BinOp(Minus) => true, - Ident(name, false) if name.is_bool_lit() => true, + Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true, Interpolated(ref nt) => match &nt.0 { NtLiteral(_) => true, NtExpr(e) => match &e.kind { @@ -602,7 +620,7 @@ impl Token { /// Returns an identifier if this token is an identifier. #[inline] - pub fn ident(&self) -> Option<(Ident, /* is_raw */ bool)> { + pub fn ident(&self) -> Option<(Ident, IdentIsRaw)> { // We avoid using `Token::uninterpolate` here because it's slow. match &self.kind { &Ident(name, is_raw) => Some((Ident::new(name, self.span), is_raw)), @@ -755,7 +773,7 @@ impl Token { /// Returns `true` if the token is a non-raw identifier for which `pred` holds. pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool { match self.ident() { - Some((id, false)) => pred(id), + Some((id, IdentIsRaw::No)) => pred(id), _ => false, } } @@ -806,7 +824,7 @@ impl Token { _ => return None, }, SingleQuote => match joint.kind { - Ident(name, false) => Lifetime(Symbol::intern(&format!("'{name}"))), + Ident(name, IdentIsRaw::No) => Lifetime(Symbol::intern(&format!("'{name}"))), _ => return None, }, @@ -836,7 +854,7 @@ pub enum Nonterminal { NtPat(P), NtExpr(P), NtTy(P), - NtIdent(Ident, /* is_raw */ bool), + NtIdent(Ident, IdentIsRaw), NtLifetime(Ident), NtLiteral(P), /// Stuff inside brackets for attributes diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 298c01a456740..adc3056cc2921 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -656,7 +656,7 @@ impl TokenStream { DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Bracket, [ - TokenTree::token_alone(token::Ident(sym::doc, false), span), + TokenTree::token_alone(token::Ident(sym::doc, token::IdentIsRaw::No), span), TokenTree::token_alone(token::Eq, span), TokenTree::token_alone( TokenKind::lit(token::StrRaw(num_of_hashes), data, None), diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 7ea0078ea3bb9..6e1974f48b26b 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -185,7 +185,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { // IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if` (Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Not, .. }, _)) - if !Ident::new(*sym, *span).is_reserved() || *is_raw => + if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, IdentIsRaw::Yes) => { false } @@ -197,7 +197,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { || *sym == kw::Fn || *sym == kw::SelfUpper || *sym == kw::Pub - || *is_raw => + || matches!(is_raw, IdentIsRaw::Yes) => { false } @@ -731,7 +731,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere token::NtBlock(e) => self.block_to_string(e), token::NtStmt(e) => self.stmt_to_string(e), token::NtPat(e) => self.pat_to_string(e), - token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(*e, *is_raw).to_string(), + &token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw.into()).to_string(), token::NtLifetime(e) => e.to_string(), token::NtLiteral(e) => self.expr_to_string(e), token::NtVis(e) => self.vis_to_string(e), @@ -795,7 +795,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere /* Name components */ token::Ident(s, is_raw) => { - IdentPrinter::new(s, is_raw, convert_dollar_crate).to_string().into() + IdentPrinter::new(s, is_raw.into(), convert_dollar_crate).to_string().into() } token::Lifetime(s) => s.to_string().into(), diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 0b2e63b403bf5..8489217ad931f 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -1,3 +1,4 @@ +use ast::token::IdentIsRaw; use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter}; @@ -416,7 +417,7 @@ fn parse_reg<'a>( ) -> PResult<'a, ast::InlineAsmRegOrRegClass> { p.expect(&token::OpenDelim(Delimiter::Parenthesis))?; let result = match p.token.uninterpolate().kind { - token::Ident(name, false) => ast::InlineAsmRegOrRegClass::RegClass(name), + token::Ident(name, IdentIsRaw::No) => ast::InlineAsmRegOrRegClass::RegClass(name), token::Literal(token::Lit { kind: token::LitKind::Str, symbol, suffix: _ }) => { *explicit_reg = true; ast::InlineAsmRegOrRegClass::Reg(symbol) diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index d244897f8a5de..01821ee833f1b 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -1,7 +1,6 @@ use rustc_ast::{ ptr::P, - token, - token::Delimiter, + token::{self, Delimiter, IdentIsRaw}, tokenstream::{DelimSpan, TokenStream, TokenTree}, BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID, @@ -170,7 +169,10 @@ impl<'cx, 'a> Context<'cx, 'a> { ]; let captures = self.capture_decls.iter().flat_map(|cap| { [ - TokenTree::token_joint_hidden(token::Ident(cap.ident.name, false), cap.ident.span), + TokenTree::token_joint_hidden( + token::Ident(cap.ident.name, IdentIsRaw::No), + cap.ident.span, + ), TokenTree::token_alone(token::Comma, self.span), ] }); diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index e66cfbe6fb689..ffc8f782fd344 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -107,7 +107,7 @@ use crate::errors; use crate::mbe::{KleeneToken, TokenTree}; -use rustc_ast::token::{Delimiter, Token, TokenKind}; +use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind}; use rustc_ast::{NodeId, DUMMY_NODE_ID}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{DiagnosticMessage, MultiSpan}; @@ -409,7 +409,7 @@ fn check_nested_occurrences( match (state, tt) { ( NestedMacroState::Empty, - &TokenTree::Token(Token { kind: TokenKind::Ident(name, false), .. }), + &TokenTree::Token(Token { kind: TokenKind::Ident(name, IdentIsRaw::No), .. }), ) => { if name == kw::MacroRules { state = NestedMacroState::MacroRules; diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index c82609503c18a..bf99e9e6d5cc8 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -8,6 +8,7 @@ use crate::mbe::macro_parser::{Error, ErrorReported, Failure, Success, TtParser} use crate::mbe::macro_parser::{MatchedSeq, MatchedTokenTree, MatcherLoc}; use crate::mbe::transcribe::transcribe; +use ast::token::IdentIsRaw; use rustc_ast as ast; use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind, TokenKind::*}; use rustc_ast::tokenstream::{DelimSpan, TokenStream}; @@ -1302,7 +1303,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { match tok { TokenTree::Token(token) => match token.kind { FatArrow | Comma | Eq | BinOp(token::Or) => IsInFollow::Yes, - Ident(name, false) if name == kw::If || name == kw::In => IsInFollow::Yes, + Ident(name, IdentIsRaw::No) if name == kw::If || name == kw::In => { + IsInFollow::Yes + } _ => IsInFollow::No(TOKENS), }, _ => IsInFollow::No(TOKENS), @@ -1313,7 +1316,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { match tok { TokenTree::Token(token) => match token.kind { FatArrow | Comma | Eq => IsInFollow::Yes, - Ident(name, false) if name == kw::If || name == kw::In => IsInFollow::Yes, + Ident(name, IdentIsRaw::No) if name == kw::If || name == kw::In => { + IsInFollow::Yes + } _ => IsInFollow::No(TOKENS), }, _ => IsInFollow::No(TOKENS), @@ -1336,7 +1341,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { | BinOp(token::Shr) | Semi | BinOp(token::Or) => IsInFollow::Yes, - Ident(name, false) if name == kw::As || name == kw::Where => { + Ident(name, IdentIsRaw::No) if name == kw::As || name == kw::Where => { IsInFollow::Yes } _ => IsInFollow::No(TOKENS), @@ -1364,7 +1369,8 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { match tok { TokenTree::Token(token) => match token.kind { Comma => IsInFollow::Yes, - Ident(name, is_raw) if is_raw || name != kw::Priv => IsInFollow::Yes, + Ident(_, IdentIsRaw::Yes) => IsInFollow::Yes, + Ident(name, _) if name != kw::Priv => IsInFollow::Yes, _ => { if token.can_begin_type() { IsInFollow::Yes diff --git a/compiler/rustc_expand/src/mbe/metavar_expr.rs b/compiler/rustc_expand/src/mbe/metavar_expr.rs index 3ca0787ce8e1f..84f7dc4771a9e 100644 --- a/compiler/rustc_expand/src/mbe/metavar_expr.rs +++ b/compiler/rustc_expand/src/mbe/metavar_expr.rs @@ -1,4 +1,4 @@ -use rustc_ast::token::{self, Delimiter}; +use rustc_ast::token::{self, Delimiter, IdentIsRaw}; use rustc_ast::tokenstream::{RefTokenTreeCursor, TokenStream, TokenTree}; use rustc_ast::{LitIntType, LitKind}; use rustc_ast_pretty::pprust; @@ -142,7 +142,7 @@ fn parse_ident<'sess>( if let Some(tt) = iter.next() && let TokenTree::Token(token, _) = tt { - if let Some((elem, false)) = token.ident() { + if let Some((elem, IdentIsRaw::No)) = token.ident() { return Ok(elem); } let token_str = pprust::token_to_string(token); diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 0fdfa5631389e..ec1dd807d1a4f 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -2,7 +2,7 @@ use crate::errors; use crate::mbe::macro_parser::count_metavar_decls; use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree}; -use rustc_ast::token::{self, Delimiter, Token}; +use rustc_ast::token::{self, Delimiter, IdentIsRaw, Token}; use rustc_ast::{tokenstream, NodeId}; use rustc_ast_pretty::pprust; use rustc_feature::Features; @@ -222,7 +222,7 @@ fn parse_tree<'a>( Some(tokenstream::TokenTree::Token(token, _)) if token.is_ident() => { let (ident, is_raw) = token.ident().unwrap(); let span = ident.span.with_lo(span.lo()); - if ident.name == kw::Crate && !is_raw { + if ident.name == kw::Crate && matches!(is_raw, IdentIsRaw::No) { TokenTree::token(token::Ident(kw::DollarCrate, is_raw), span) } else { TokenTree::MetaVar(span, ident) diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index 7a888250ca161..0e07b41b43c7d 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -2,6 +2,7 @@ use crate::tests::{ matches_codepattern, string_to_stream, with_error_checking_parse, with_expected_parse_error, }; +use ast::token::IdentIsRaw; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token}; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; @@ -74,9 +75,12 @@ fn string_to_tts_macro() { match tts { [ - TokenTree::Token(Token { kind: token::Ident(name_macro_rules, false), .. }, _), + TokenTree::Token( + Token { kind: token::Ident(name_macro_rules, IdentIsRaw::No), .. }, + _, + ), TokenTree::Token(Token { kind: token::Not, .. }, _), - TokenTree::Token(Token { kind: token::Ident(name_zip, false), .. }, _), + TokenTree::Token(Token { kind: token::Ident(name_zip, IdentIsRaw::No), .. }, _), TokenTree::Delimited(.., macro_delim, macro_tts), ] if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" => { let tts = ¯o_tts.trees().collect::>(); @@ -90,7 +94,10 @@ fn string_to_tts_macro() { match &tts[..] { [ TokenTree::Token(Token { kind: token::Dollar, .. }, _), - TokenTree::Token(Token { kind: token::Ident(name, false), .. }, _), + TokenTree::Token( + Token { kind: token::Ident(name, IdentIsRaw::No), .. }, + _, + ), ] if first_delim == &Delimiter::Parenthesis && name.as_str() == "a" => { } _ => panic!("value 3: {:?} {:?}", first_delim, first_tts), @@ -99,7 +106,10 @@ fn string_to_tts_macro() { match &tts[..] { [ TokenTree::Token(Token { kind: token::Dollar, .. }, _), - TokenTree::Token(Token { kind: token::Ident(name, false), .. }, _), + TokenTree::Token( + Token { kind: token::Ident(name, IdentIsRaw::No), .. }, + _, + ), ] if second_delim == &Delimiter::Parenthesis && name.as_str() == "a" => {} _ => panic!("value 4: {:?} {:?}", second_delim, second_tts), @@ -119,8 +129,11 @@ fn string_to_tts_1() { let tts = string_to_stream("fn a(b: i32) { b; }".to_string()); let expected = TokenStream::new(vec![ - TokenTree::token_alone(token::Ident(kw::Fn, false), sp(0, 2)), - TokenTree::token_joint_hidden(token::Ident(Symbol::intern("a"), false), sp(3, 4)), + TokenTree::token_alone(token::Ident(kw::Fn, IdentIsRaw::No), sp(0, 2)), + TokenTree::token_joint_hidden( + token::Ident(Symbol::intern("a"), IdentIsRaw::No), + sp(3, 4), + ), TokenTree::Delimited( DelimSpan::from_pair(sp(4, 5), sp(11, 12)), // `JointHidden` because the `(` is followed immediately by @@ -128,10 +141,16 @@ fn string_to_tts_1() { DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Parenthesis, TokenStream::new(vec![ - TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(5, 6)), + TokenTree::token_joint( + token::Ident(Symbol::intern("b"), IdentIsRaw::No), + sp(5, 6), + ), TokenTree::token_alone(token::Colon, sp(6, 7)), // `JointHidden` because the `i32` is immediately followed by the `)`. - TokenTree::token_joint_hidden(token::Ident(sym::i32, false), sp(8, 11)), + TokenTree::token_joint_hidden( + token::Ident(sym::i32, IdentIsRaw::No), + sp(8, 11), + ), ]) .into(), ), @@ -143,7 +162,10 @@ fn string_to_tts_1() { DelimSpacing::new(Spacing::Alone, Spacing::Alone), Delimiter::Brace, TokenStream::new(vec![ - TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(15, 16)), + TokenTree::token_joint( + token::Ident(Symbol::intern("b"), IdentIsRaw::No), + sp(15, 16), + ), // `Alone` because the `;` is followed by whitespace. TokenTree::token_alone(token::Semi, sp(16, 17)), ]) diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 8f31b5801da7f..b5595c01b877c 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -1,4 +1,5 @@ use crate::base::ExtCtxt; +use ast::token::IdentIsRaw; use pm::bridge::{ server, DelimSpan, Diagnostic, ExpnGlobals, Group, Ident, LitKind, Literal, Punct, TokenTree, }; @@ -216,7 +217,9 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec op("?"), SingleQuote => op("'"), - Ident(sym, is_raw) => trees.push(TokenTree::Ident(Ident { sym, is_raw, span })), + Ident(sym, is_raw) => { + trees.push(TokenTree::Ident(Ident { sym, is_raw: is_raw.into(), span })) + } Lifetime(name) => { let ident = symbol::Ident::new(name, span).without_first_quote(); trees.extend([ @@ -238,7 +241,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec)> for Vec { trees.push(TokenTree::Ident(Ident { sym: ident.name, - is_raw: *is_raw, + is_raw: matches!(is_raw, IdentIsRaw::Yes), span: ident.span, })) } @@ -352,7 +355,7 @@ impl ToInternal> } TokenTree::Ident(self::Ident { sym, is_raw, span }) => { rustc.sess().symbol_gallery.insert(sym, span); - smallvec![tokenstream::TokenTree::token_alone(Ident(sym, is_raw), span)] + smallvec![tokenstream::TokenTree::token_alone(Ident(sym, is_raw.into()), span)] } TokenTree::Literal(self::Literal { kind: self::LitKind::Integer, @@ -569,7 +572,7 @@ impl server::TokenStream for Rustc<'_, '_> { match &expr.kind { ast::ExprKind::Lit(token_lit) if token_lit.kind == token::Bool => { Ok(tokenstream::TokenStream::token_alone( - token::Ident(token_lit.symbol, false), + token::Ident(token_lit.symbol, IdentIsRaw::No), expr.span, )) } diff --git a/compiler/rustc_expand/src/tokenstream/tests.rs b/compiler/rustc_expand/src/tokenstream/tests.rs index 91c4dd732e3a5..78795e86fd5da 100644 --- a/compiler/rustc_expand/src/tokenstream/tests.rs +++ b/compiler/rustc_expand/src/tokenstream/tests.rs @@ -1,6 +1,6 @@ use crate::tests::string_to_stream; -use rustc_ast::token; +use rustc_ast::token::{self, IdentIsRaw}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_span::create_default_session_globals_then; use rustc_span::{BytePos, Span, Symbol}; @@ -86,7 +86,8 @@ fn test_diseq_1() { fn test_is_empty() { create_default_session_globals_then(|| { let test0 = TokenStream::default(); - let test1 = TokenStream::token_alone(token::Ident(Symbol::intern("a"), false), sp(0, 1)); + let test1 = + TokenStream::token_alone(token::Ident(Symbol::intern("a"), IdentIsRaw::No), sp(0, 1)); let test2 = string_to_ts("foo(bar::baz)"); assert_eq!(test0.is_empty(), true); diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index f9149f54e926c..30b9e64cb095c 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1821,7 +1821,7 @@ impl KeywordIdents { match tt { // Only report non-raw idents. TokenTree::Token(token, _) => { - if let Some((ident, false)) = token.ident() { + if let Some((ident, token::IdentIsRaw::No)) = token.ident() { self.check_ident_token(cx, UnderMacro(true), ident); } } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index c768ea93b5fec..dc9f5bad765fc 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -4,7 +4,7 @@ use crate::errors; use crate::lexer::unicode_chars::UNICODE_ARRAY; use crate::make_unclosed_delims_error; use rustc_ast::ast::{self, AttrStyle}; -use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind}; +use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::util::unicode::contains_text_flow_control_chars; use rustc_errors::{codes::*, Applicability, DiagCtxt, DiagnosticBuilder, StashKey}; @@ -181,7 +181,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> { self.dcx().emit_err(errors::CannotBeRawIdent { span, ident: sym }); } self.sess.raw_identifier_spans.push(span); - token::Ident(sym, true) + token::Ident(sym, IdentIsRaw::Yes) } rustc_lexer::TokenKind::UnknownPrefix => { self.report_unknown_prefix(start); @@ -201,7 +201,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> { let span = self.mk_sp(start, self.pos); self.sess.bad_unicode_identifiers.borrow_mut().entry(sym).or_default() .push(span); - token::Ident(sym, false) + token::Ident(sym, IdentIsRaw::No) } // split up (raw) c string literals to an ident and a string literal when edition < 2021. rustc_lexer::TokenKind::Literal { @@ -339,7 +339,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> { let sym = nfc_normalize(self.str_from(start)); let span = self.mk_sp(start, self.pos); self.sess.symbol_gallery.insert(sym, span); - token::Ident(sym, false) + token::Ident(sym, IdentIsRaw::No) } /// Detect usages of Unicode codepoints changing the direction of the text on screen and loudly diff --git a/compiler/rustc_parse/src/lexer/unicode_chars.rs b/compiler/rustc_parse/src/lexer/unicode_chars.rs index a136abaa28bb8..3b4e05332fac9 100644 --- a/compiler/rustc_parse/src/lexer/unicode_chars.rs +++ b/compiler/rustc_parse/src/lexer/unicode_chars.rs @@ -307,7 +307,7 @@ pub(crate) const UNICODE_ARRAY: &[(char, &str, &str)] = &[ // fancier error recovery to it, as there will be less overall work to do this way. const ASCII_ARRAY: &[(&str, &str, Option)] = &[ (" ", "Space", None), - ("_", "Underscore", Some(token::Ident(kw::Underscore, false))), + ("_", "Underscore", Some(token::Ident(kw::Underscore, token::IdentIsRaw::No))), ("-", "Minus/Hyphen", Some(token::BinOp(token::Minus))), (",", "Comma", Some(token::Comma)), (";", "Semicolon", Some(token::Semi)), diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 659716548d95d..7f5d604050dd0 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -21,6 +21,7 @@ use crate::errors::{ use crate::fluent_generated as fluent; use crate::parser; use crate::parser::attr::InnerAttrPolicy; +use ast::token::IdentIsRaw; use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Lit, LitKind, Token, TokenKind}; @@ -264,7 +265,7 @@ impl<'a> Parser<'a> { pub(super) fn expected_ident_found( &mut self, recover: bool, - ) -> PResult<'a, (Ident, /* is_raw */ bool)> { + ) -> PResult<'a, (Ident, IdentIsRaw)> { if let TokenKind::DocComment(..) = self.prev_token.kind { return Err(self.dcx().create_err(DocCommentDoesNotDocumentAnything { span: self.prev_token.span, @@ -290,11 +291,11 @@ impl<'a> Parser<'a> { let bad_token = self.token.clone(); // suggest prepending a keyword in identifier position with `r#` - let suggest_raw = if let Some((ident, false)) = self.token.ident() + let suggest_raw = if let Some((ident, IdentIsRaw::No)) = self.token.ident() && ident.is_raw_guess() && self.look_ahead(1, |t| valid_follow.contains(&t.kind)) { - recovered_ident = Some((ident, true)); + recovered_ident = Some((ident, IdentIsRaw::Yes)); // `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`, // which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#` @@ -320,7 +321,7 @@ impl<'a> Parser<'a> { let help_cannot_start_number = self.is_lit_bad_ident().map(|(len, valid_portion)| { let (invalid, valid) = self.token.span.split_at(len as u32); - recovered_ident = Some((Ident::new(valid_portion, valid), false)); + recovered_ident = Some((Ident::new(valid_portion, valid), IdentIsRaw::No)); HelpIdentifierStartsWithNumber { num_span: invalid } }); @@ -653,9 +654,9 @@ impl<'a> Parser<'a> { // positive for a `cr#` that wasn't intended to start a c-string literal, but identifying // that in the parser requires unbounded lookahead, so we only add a hint to the existing // error rather than replacing it entirely. - if ((self.prev_token.kind == TokenKind::Ident(sym::c, false) + if ((self.prev_token.kind == TokenKind::Ident(sym::c, IdentIsRaw::No) && matches!(&self.token.kind, TokenKind::Literal(token::Lit { kind: token::Str, .. }))) - || (self.prev_token.kind == TokenKind::Ident(sym::cr, false) + || (self.prev_token.kind == TokenKind::Ident(sym::cr, IdentIsRaw::No) && matches!( &self.token.kind, TokenKind::Literal(token::Lit { kind: token::Str, .. }) | token::Pound diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 20b9581f2ef27..455d9c3deb365 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -10,6 +10,7 @@ use super::{ use crate::errors; use crate::maybe_recover_from_interpolated_ty_qpath; use ast::mut_visit::{noop_visit_expr, MutVisitor}; +use ast::token::IdentIsRaw; use ast::{CoroutineKind, ForLoopKind, GenBlockKind, Pat, Path, PathSegment}; use core::mem; use rustc_ast::ptr::P; @@ -128,7 +129,7 @@ impl<'a> Parser<'a> { match self.parse_expr_res(restrictions, None) { Ok(expr) => Ok(expr), Err(err) => match self.token.ident() { - Some((Ident { name: kw::Underscore, .. }, false)) + Some((Ident { name: kw::Underscore, .. }, IdentIsRaw::No)) if self.may_recover() && self.look_ahead(1, |t| t == &token::Comma) => { // Special-case handling of `foo(_, _, _)` @@ -459,7 +460,9 @@ impl<'a> Parser<'a> { return None; } (Some(op), _) => (op, self.token.span), - (None, Some((Ident { name: sym::and, span }, false))) if self.may_recover() => { + (None, Some((Ident { name: sym::and, span }, IdentIsRaw::No))) + if self.may_recover() => + { self.dcx().emit_err(errors::InvalidLogicalOperator { span: self.token.span, incorrect: "and".into(), @@ -467,7 +470,7 @@ impl<'a> Parser<'a> { }); (AssocOp::LAnd, span) } - (None, Some((Ident { name: sym::or, span }, false))) if self.may_recover() => { + (None, Some((Ident { name: sym::or, span }, IdentIsRaw::No))) if self.may_recover() => { self.dcx().emit_err(errors::InvalidLogicalOperator { span: self.token.span, incorrect: "or".into(), @@ -744,7 +747,7 @@ impl<'a> Parser<'a> { ( // `foo: ` ExprKind::Path(None, ast::Path { segments, .. }), - token::Ident(kw::For | kw::Loop | kw::While, false), + token::Ident(kw::For | kw::Loop | kw::While, IdentIsRaw::No), ) if segments.len() == 1 => { let snapshot = self.create_snapshot_for_diagnostic(); let label = Label { @@ -957,19 +960,20 @@ impl<'a> Parser<'a> { fn parse_expr_dot_or_call_with_(&mut self, mut e: P, lo: Span) -> PResult<'a, P> { loop { - let has_question = if self.prev_token.kind == TokenKind::Ident(kw::Return, false) { - // we are using noexpect here because we don't expect a `?` directly after a `return` - // which could be suggested otherwise - self.eat_noexpect(&token::Question) - } else { - self.eat(&token::Question) - }; + let has_question = + if self.prev_token.kind == TokenKind::Ident(kw::Return, IdentIsRaw::No) { + // we are using noexpect here because we don't expect a `?` directly after a `return` + // which could be suggested otherwise + self.eat_noexpect(&token::Question) + } else { + self.eat(&token::Question) + }; if has_question { // `expr?` e = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Try(e)); continue; } - let has_dot = if self.prev_token.kind == TokenKind::Ident(kw::Return, false) { + let has_dot = if self.prev_token.kind == TokenKind::Ident(kw::Return, IdentIsRaw::No) { // we are using noexpect here because we don't expect a `.` directly after a `return` // which could be suggested otherwise self.eat_noexpect(&token::Dot) @@ -1128,19 +1132,19 @@ impl<'a> Parser<'a> { // 1. DestructuredFloat::TrailingDot(sym, ident_span, dot_span) => { assert!(suffix.is_none()); - self.token = Token::new(token::Ident(sym, false), ident_span); + self.token = Token::new(token::Ident(sym, IdentIsRaw::No), ident_span); let next_token = (Token::new(token::Dot, dot_span), self.token_spacing); self.parse_expr_tuple_field_access(lo, base, sym, None, Some(next_token)) } // 1.2 | 1.2e3 DestructuredFloat::MiddleDot(symbol1, ident1_span, dot_span, symbol2, ident2_span) => { - self.token = Token::new(token::Ident(symbol1, false), ident1_span); + self.token = Token::new(token::Ident(symbol1, IdentIsRaw::No), ident1_span); // This needs to be `Spacing::Alone` to prevent regressions. // See issue #76399 and PR #76285 for more details let next_token1 = (Token::new(token::Dot, dot_span), Spacing::Alone); let base1 = self.parse_expr_tuple_field_access(lo, base, symbol1, None, Some(next_token1)); - let next_token2 = Token::new(token::Ident(symbol2, false), ident2_span); + let next_token2 = Token::new(token::Ident(symbol2, IdentIsRaw::No), ident2_span); self.bump_with((next_token2, self.token_spacing)); // `.` self.parse_expr_tuple_field_access(lo, base1, symbol2, suffix, None) } @@ -1948,7 +1952,7 @@ impl<'a> Parser<'a> { self.bump(); // `builtin` self.bump(); // `#` - let Some((ident, false)) = self.token.ident() else { + let Some((ident, IdentIsRaw::No)) = self.token.ident() else { let err = self.dcx().create_err(errors::ExpectedBuiltinIdent { span: self.token.span }); return Err(err); }; @@ -3576,7 +3580,7 @@ impl<'a> Parser<'a> { fn find_struct_error_after_field_looking_code(&self) -> Option { match self.token.ident() { Some((ident, is_raw)) - if (is_raw || !ident.is_reserved()) + if (matches!(is_raw, IdentIsRaw::Yes) || !ident.is_reserved()) && self.look_ahead(1, |t| *t == token::Colon) => { Some(ast::ExprField { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index e7b9076bd3c8f..c6e80f3f07f37 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -3,6 +3,7 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken}; use crate::errors::{self, MacroExpandsToAdtField}; use crate::fluent_generated as fluent; +use ast::token::IdentIsRaw; use rustc_ast::ast::*; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, TokenKind}; @@ -1079,7 +1080,7 @@ impl<'a> Parser<'a> { fn parse_ident_or_underscore(&mut self) -> PResult<'a, Ident> { match self.token.ident() { - Some((ident @ Ident { name: kw::Underscore, .. }, false)) => { + Some((ident @ Ident { name: kw::Underscore, .. }, IdentIsRaw::No)) => { self.bump(); Ok(ident) } @@ -1965,7 +1966,7 @@ impl<'a> Parser<'a> { let (ident, is_raw) = self.ident_or_err(true)?; if ident.name == kw::Underscore { self.sess.gated_spans.gate(sym::unnamed_fields, lo); - } else if !is_raw && ident.is_reserved() { + } else if matches!(is_raw, IdentIsRaw::No) && ident.is_reserved() { let snapshot = self.create_snapshot_for_diagnostic(); let err = if self.check_fn_front_matter(false, Case::Sensitive) { let inherited_vis = Visibility { @@ -2743,7 +2744,7 @@ impl<'a> Parser<'a> { fn parse_self_param(&mut self) -> PResult<'a, Option> { // Extract an identifier *after* having confirmed that the token is one. let expect_self_ident = |this: &mut Self| match this.token.ident() { - Some((ident, false)) => { + Some((ident, IdentIsRaw::No)) => { this.bump(); ident } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index dea2b9e6ca70b..80f6a20b985b9 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -11,6 +11,7 @@ mod stmt; mod ty; use crate::lexer::UnmatchedDelim; +use ast::token::IdentIsRaw; pub use attr_wrapper::AttrWrapper; pub use diagnostics::AttemptLocalParseRecovery; pub(crate) use expr::ForbiddenLetReason; @@ -499,7 +500,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> { let (ident, is_raw) = self.ident_or_err(recover)?; - if !is_raw && ident.is_reserved() { + if matches!(is_raw, IdentIsRaw::No) && ident.is_reserved() { let err = self.expected_ident_found_err(); if recover { err.emit(); @@ -511,7 +512,7 @@ impl<'a> Parser<'a> { Ok(ident) } - fn ident_or_err(&mut self, recover: bool) -> PResult<'a, (Ident, /* is_raw */ bool)> { + fn ident_or_err(&mut self, recover: bool) -> PResult<'a, (Ident, IdentIsRaw)> { match self.token.ident() { Some(ident) => Ok(ident), None => self.expected_ident_found(recover), @@ -568,7 +569,7 @@ impl<'a> Parser<'a> { } if case == Case::Insensitive - && let Some((ident, /* is_raw */ false)) = self.token.ident() + && let Some((ident, IdentIsRaw::No)) = self.token.ident() && ident.as_str().to_lowercase() == kw.as_str().to_lowercase() { true @@ -598,7 +599,7 @@ impl<'a> Parser<'a> { } if case == Case::Insensitive - && let Some((ident, /* is_raw */ false)) = self.token.ident() + && let Some((ident, IdentIsRaw::No)) = self.token.ident() && ident.as_str().to_lowercase() == kw.as_str().to_lowercase() { self.dcx().emit_err(errors::KwBadCase { span: ident.span, kw: kw.as_str() }); diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 071d6b72f3b96..f1572a18a8be0 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -201,6 +201,6 @@ impl<'a> Parser<'a> { /// The token is an identifier, but not `_`. /// We prohibit passing `_` to macros expecting `ident` for now. -fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { +fn get_macro_ident(token: &Token) -> Option<(Ident, token::IdentIsRaw)> { token.ident().filter(|(ident, _)| ident.name != kw::Underscore) } diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 75fc013d3e6fe..072db24265eea 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -311,7 +311,7 @@ impl<'a> Parser<'a> { matches!( &token.uninterpolate().kind, token::FatArrow // e.g. `a | => 0,`. - | token::Ident(kw::If, false) // e.g. `a | if expr`. + | token::Ident(kw::If, token::IdentIsRaw::No) // e.g. `a | if expr`. | token::Eq // e.g. `let a | = 0`. | token::Semi // e.g. `let a |;`. | token::Colon // e.g. `let a | :`. diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 681039999a652..6e7bbe7e06d42 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -2,6 +2,7 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; use crate::errors::PathSingleColon; use crate::{errors, maybe_whole}; +use ast::token::IdentIsRaw; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; use rustc_ast::{ @@ -390,7 +391,7 @@ impl<'a> Parser<'a> { pub(super) fn parse_path_segment_ident(&mut self) -> PResult<'a, Ident> { match self.token.ident() { - Some((ident, false)) if ident.is_path_segment_keyword() => { + Some((ident, IdentIsRaw::No)) if ident.is_path_segment_keyword() => { self.bump(); Ok(ident) } diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 1bae5b3224035..5c2f0967b649d 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -691,7 +691,7 @@ impl<'a> Parser<'a> { token.kind, token::Ident( kw::For | kw::Loop | kw::While, - false + token::IdentIsRaw::No ) | token::OpenDelim(Delimiter::Brace) ) }) diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index b736f4a795614..b6880cfc60fbf 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -1,4 +1,4 @@ -use rustc_ast::token::{self, BinOpToken, Delimiter}; +use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast_pretty::pprust::state::State as Printer; use rustc_ast_pretty::pprust::PrintState; @@ -148,7 +148,7 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) { (false, Other) } (Pound, token::Not) => (false, PoundBang), - (_, token::Ident(symbol, /* is_raw */ false)) + (_, token::Ident(symbol, IdentIsRaw::No)) if !usually_needs_space_between_keyword_and_open_delim(*symbol, tt.span) => { (true, Ident) From f5d0d087ad310856f9ed32fdef01acc009a91ff7 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 13 Feb 2024 23:31:06 +0000 Subject: [PATCH 167/417] Add newtype for `IsTuple` --- .../rustc_builtin_macros/src/deriving/decodable.rs | 2 +- .../rustc_builtin_macros/src/deriving/default.rs | 4 ++-- .../src/deriving/generic/mod.rs | 13 +++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/deriving/decodable.rs b/compiler/rustc_builtin_macros/src/deriving/decodable.rs index 97d6b82de98c6..bf4693cd54198 100644 --- a/compiler/rustc_builtin_macros/src/deriving/decodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/decodable.rs @@ -198,7 +198,7 @@ where match fields { Unnamed(fields, is_tuple) => { let path_expr = cx.expr_path(outer_pat_path); - if !*is_tuple { + if matches!(is_tuple, IsTuple::No) { path_expr } else { let fields = fields diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs index d5a42566e1912..0bd2d423a294f 100644 --- a/compiler/rustc_builtin_macros/src/deriving/default.rs +++ b/compiler/rustc_builtin_macros/src/deriving/default.rs @@ -62,8 +62,8 @@ fn default_struct_substructure( let default_call = |span| cx.expr_call_global(span, default_ident.clone(), ThinVec::new()); let expr = match summary { - Unnamed(_, false) => cx.expr_ident(trait_span, substr.type_ident), - Unnamed(fields, true) => { + Unnamed(_, IsTuple::No) => cx.expr_ident(trait_span, substr.type_ident), + Unnamed(fields, IsTuple::Yes) => { let exprs = fields.iter().map(|sp| default_call(*sp)).collect(); cx.expr_call_ident(trait_span, substr.type_ident, exprs) } diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 6eeb028728c9d..3ee4fded74999 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -286,10 +286,16 @@ pub struct FieldInfo { pub other_selflike_exprs: Vec>, } +#[derive(Copy, Clone)] +pub enum IsTuple { + No, + Yes, +} + /// Fields for a static method pub enum StaticFields { /// Tuple and unit structs/enum variants like this. - Unnamed(Vec, bool /*is tuple*/), + Unnamed(Vec, IsTuple), /// Normal structs/struct variants. Named(Vec<(Ident, Span)>), } @@ -1439,7 +1445,10 @@ impl<'a> TraitDef<'a> { } } - let is_tuple = matches!(struct_def, ast::VariantData::Tuple(..)); + let is_tuple = match struct_def { + ast::VariantData::Tuple(..) => IsTuple::Yes, + _ => IsTuple::No, + }; match (just_spans.is_empty(), named_idents.is_empty()) { (false, false) => cx .dcx() From 4850ae84422569747901c14169b5ed6dfbfb96a3 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 13 Feb 2024 23:44:33 +0000 Subject: [PATCH 168/417] Add newtype for parser recovery --- compiler/rustc_builtin_macros/src/format.rs | 6 +-- .../rustc_parse/src/parser/diagnostics.rs | 18 ++++----- compiler/rustc_parse/src/parser/expr.rs | 8 ++-- compiler/rustc_parse/src/parser/item.rs | 26 +++++++------ compiler/rustc_parse/src/parser/mod.rs | 37 +++++++++++++------ compiler/rustc_parse/src/parser/stmt.rs | 6 +-- 6 files changed, 57 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index b66f7111ff006..3366378d38da8 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -10,6 +10,7 @@ use rustc_ast::{ use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan, PResult, SingleLabelManySpans}; use rustc_expand::base::{self, *}; +use rustc_parse::parser::Recovered; use rustc_parse_format as parse; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{BytePos, InnerSpan, Span}; @@ -111,9 +112,8 @@ fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult< _ => return Err(err), } } - Ok(recovered) => { - assert!(recovered); - } + Ok(Recovered::Yes) => (), + Ok(Recovered::No) => unreachable!(), } } first = false; diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 7f5d604050dd0..f4e7bb413ddff 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -22,6 +22,7 @@ use crate::fluent_generated as fluent; use crate::parser; use crate::parser::attr::InnerAttrPolicy; use ast::token::IdentIsRaw; +use parser::Recovered; use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Lit, LitKind, Token, TokenKind}; @@ -430,7 +431,7 @@ impl<'a> Parser<'a> { &mut self, edible: &[TokenKind], inedible: &[TokenKind], - ) -> PResult<'a, bool /* recovered */> { + ) -> PResult<'a, Recovered> { debug!("expected_one_of_not_found(edible: {:?}, inedible: {:?})", edible, inedible); fn tokens_to_string(tokens: &[TokenType]) -> String { let mut i = tokens.iter(); @@ -533,7 +534,7 @@ impl<'a> Parser<'a> { sugg: ExpectedSemiSugg::ChangeToSemi(self.token.span), }); self.bump(); - return Ok(true); + return Ok(Recovered::Yes); } else if self.look_ahead(0, |t| { t == &token::CloseDelim(Delimiter::Brace) || ((t.can_begin_expr() || t.can_begin_item()) @@ -557,7 +558,7 @@ impl<'a> Parser<'a> { unexpected_token_label: Some(self.token.span), sugg: ExpectedSemiSugg::AddSemi(span), }); - return Ok(true); + return Ok(Recovered::Yes); } } @@ -712,7 +713,7 @@ impl<'a> Parser<'a> { if self.check_too_many_raw_str_terminators(&mut err) { if expected.contains(&TokenType::Token(token::Semi)) && self.eat(&token::Semi) { err.emit(); - return Ok(true); + return Ok(Recovered::Yes); } else { return Err(err); } @@ -1224,7 +1225,7 @@ impl<'a> Parser<'a> { |p| p.parse_generic_arg(None), ); match x { - Ok((_, _, false)) => { + Ok((_, _, Recovered::No)) => { if self.eat(&token::Gt) { // We made sense of it. Improve the error message. e.span_suggestion_verbose( @@ -1248,7 +1249,7 @@ impl<'a> Parser<'a> { } } } - Ok((_, _, true)) => {} + Ok((_, _, Recovered::Yes)) => {} Err(err) => { err.cancel(); } @@ -1841,10 +1842,7 @@ impl<'a> Parser<'a> { /// Creates a `DiagnosticBuilder` for an unexpected token `t` and tries to recover if it is a /// closing delimiter. - pub(super) fn unexpected_try_recover( - &mut self, - t: &TokenKind, - ) -> PResult<'a, bool /* recovered */> { + pub(super) fn unexpected_try_recover(&mut self, t: &TokenKind) -> PResult<'a, Recovered> { let token_str = pprust::token_kind_to_string(t); let this_token_str = super::token_descr(&self.token); let (prev_sp, sp) = match (&self.token.kind, self.subparser_name) { diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 455d9c3deb365..081f30ef11a4c 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3,7 +3,7 @@ use super::diagnostics::SnapshotParser; use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{ - AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions, + AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Recovered, Restrictions, SemiColonMode, SeqSep, TokenExpectType, TokenType, TrailingToken, }; @@ -3093,10 +3093,10 @@ impl<'a> Parser<'a> { if !require_comma { arm_body = Some(expr); this.eat(&token::Comma); - Ok(false) + Ok(Recovered::No) } else if let Some(body) = this.parse_arm_body_missing_braces(&expr, arrow_span) { arm_body = Some(body); - Ok(true) + Ok(Recovered::Yes) } else { let expr_span = expr.span; arm_body = Some(expr); @@ -3177,7 +3177,7 @@ impl<'a> Parser<'a> { this.dcx().emit_err(errors::MissingCommaAfterMatchArm { span: arm_span.shrink_to_hi(), }); - return Ok(true); + return Ok(Recovered::Yes); } Err(err) }); diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index c6e80f3f07f37..6e9af1e15d8e6 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1,6 +1,8 @@ use super::diagnostics::{dummy_arg, ConsumeClosingDelim}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; -use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken}; +use super::{ + AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Recovered, TrailingToken, +}; use crate::errors::{self, MacroExpandsToAdtField}; use crate::fluent_generated as fluent; use ast::token::IdentIsRaw; @@ -1534,10 +1536,10 @@ impl<'a> Parser<'a> { err.span_label(span, "while parsing this enum"); err.help(help); err.emit(); - (thin_vec![], true) + (thin_vec![], Recovered::Yes) } }; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) { let body = match this.parse_tuple_struct_body() { Ok(body) => body, @@ -1622,7 +1624,7 @@ impl<'a> Parser<'a> { class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } // No `where` so: `struct Foo;` } else if self.eat(&token::Semi) { @@ -1634,7 +1636,7 @@ impl<'a> Parser<'a> { class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } // Tuple-style struct definition with optional where-clause. } else if self.token == token::OpenDelim(Delimiter::Parenthesis) { let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID); @@ -1663,14 +1665,14 @@ impl<'a> Parser<'a> { class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } else if self.token == token::OpenDelim(Delimiter::Brace) { let (fields, recovered) = self.parse_record_struct_body( "union", class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } else { let token_str = super::token_descr(&self.token); let msg = format!("expected `where` or `{{` after union name, found {token_str}"); @@ -1687,14 +1689,14 @@ impl<'a> Parser<'a> { adt_ty: &str, ident_span: Span, parsed_where: bool, - ) -> PResult<'a, (ThinVec, /* recovered */ bool)> { + ) -> PResult<'a, (ThinVec, Recovered)> { let mut fields = ThinVec::new(); - let mut recovered = false; + let mut recovered = Recovered::No; if self.eat(&token::OpenDelim(Delimiter::Brace)) { while self.token != token::CloseDelim(Delimiter::Brace) { let field = self.parse_field_def(adt_ty).map_err(|e| { self.consume_block(Delimiter::Brace, ConsumeClosingDelim::No); - recovered = true; + recovered = Recovered::Yes; e }); match field { @@ -2465,8 +2467,8 @@ impl<'a> Parser<'a> { // `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't // account for this. match self.expect_one_of(&[], &[]) { - Ok(true) => {} - Ok(false) => unreachable!(), + Ok(Recovered::Yes) => {} + Ok(Recovered::No) => unreachable!(), Err(mut err) => { // Qualifier keywords ordering check enum WrongKw { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 80f6a20b985b9..27e9fb10a9fcb 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -358,6 +358,19 @@ pub enum FollowedByType { No, } +/// Whether a function performed recovery +#[derive(Copy, Clone, Debug)] +pub enum Recovered { + No, + Yes, +} + +impl From for bool { + fn from(r: Recovered) -> bool { + matches!(r, Recovered::Yes) + } +} + #[derive(Clone, Copy, PartialEq, Eq)] pub enum TokenDescription { ReservedIdentifier, @@ -456,11 +469,11 @@ impl<'a> Parser<'a> { } /// Expects and consumes the token `t`. Signals an error if the next token is not `t`. - pub fn expect(&mut self, t: &TokenKind) -> PResult<'a, bool /* recovered */> { + pub fn expect(&mut self, t: &TokenKind) -> PResult<'a, Recovered> { if self.expected_tokens.is_empty() { if self.token == *t { self.bump(); - Ok(false) + Ok(Recovered::No) } else { self.unexpected_try_recover(t) } @@ -476,13 +489,13 @@ impl<'a> Parser<'a> { &mut self, edible: &[TokenKind], inedible: &[TokenKind], - ) -> PResult<'a, bool /* recovered */> { + ) -> PResult<'a, Recovered> { if edible.contains(&self.token.kind) { self.bump(); - Ok(false) + Ok(Recovered::No) } else if inedible.contains(&self.token.kind) { // leave it in the input - Ok(false) + Ok(Recovered::No) } else if self.token.kind != token::Eof && self.last_unexpected_token_span == Some(self.token.span) { @@ -784,9 +797,9 @@ impl<'a> Parser<'a> { sep: SeqSep, expect: TokenExpectType, mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */, bool /* recovered */)> { + ) -> PResult<'a, (ThinVec, bool /* trailing */, Recovered)> { let mut first = true; - let mut recovered = false; + let mut recovered = Recovered::No; let mut trailing = false; let mut v = ThinVec::new(); @@ -801,12 +814,12 @@ impl<'a> Parser<'a> { } else { // check for separator match self.expect(t) { - Ok(false) /* not recovered */ => { + Ok(Recovered::No) => { self.current_closure.take(); } - Ok(true) /* recovered */ => { + Ok(Recovered::Yes) => { self.current_closure.take(); - recovered = true; + recovered = Recovered::Yes; break; } Err(mut expect_err) => { @@ -979,7 +992,7 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */, bool /* recovered */)> { + ) -> PResult<'a, (ThinVec, bool /* trailing */, Recovered)> { self.parse_seq_to_before_tokens(&[ket], sep, TokenExpectType::Expect, f) } @@ -993,7 +1006,7 @@ impl<'a> Parser<'a> { f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, ) -> PResult<'a, (ThinVec, bool /* trailing */)> { let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?; - if !recovered { + if matches!(recovered, Recovered::No) { self.eat(ket); } Ok((val, trailing)) diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 5c2f0967b649d..ee02b69c6140d 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -11,6 +11,7 @@ use crate::errors; use crate::maybe_whole; use crate::errors::MalformedLoopLabel; +use crate::parser::Recovered; use ast::Label; use rustc_ast as ast; use rustc_ast::ptr::P; @@ -661,7 +662,6 @@ impl<'a> Parser<'a> { if self.token != token::Eof && classify::expr_requires_semi_to_be_stmt(expr) => { // Just check for errors and recover; do not eat semicolon yet. - // `expect_one_of` returns PResult<'a, bool /* recovered */> let expect_result = self.expect_one_of(&[], &[token::Semi, token::CloseDelim(Delimiter::Brace)]); @@ -669,7 +669,7 @@ impl<'a> Parser<'a> { let replace_with_err = 'break_recover: { match expect_result { // Recover from parser, skip type error to avoid extra errors. - Ok(true) => true, + Ok(Recovered::Yes) => true, Err(e) => { if self.recover_colon_as_semi() { // recover_colon_as_semi has already emitted a nicer error. @@ -735,7 +735,7 @@ impl<'a> Parser<'a> { true } - Ok(false) => false, + Ok(Recovered::No) => false, } }; From acb2cee618bca1be9a1d778a525c07d2792f0f91 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 13 Feb 2024 23:48:23 +0000 Subject: [PATCH 169/417] Add newtype for trailing in parser --- compiler/rustc_parse/src/parser/expr.rs | 4 ++-- compiler/rustc_parse/src/parser/item.rs | 5 +++-- compiler/rustc_parse/src/parser/mod.rs | 22 ++++++++++++++-------- compiler/rustc_parse/src/parser/pat.rs | 16 +++++++++------- compiler/rustc_parse/src/parser/ty.rs | 4 ++-- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 081f30ef11a4c..cb46eb25fa4c1 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -4,7 +4,7 @@ use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{ AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Recovered, Restrictions, - SemiColonMode, SeqSep, TokenExpectType, TokenType, TrailingToken, + SemiColonMode, SeqSep, TokenExpectType, TokenType, Trailing, TrailingToken, }; use crate::errors; @@ -1561,7 +1561,7 @@ impl<'a> Parser<'a> { return Ok(self.recover_seq_parse_error(Delimiter::Parenthesis, lo, err)); } }; - let kind = if es.len() == 1 && !trailing_comma { + let kind = if es.len() == 1 && matches!(trailing_comma, Trailing::No) { // `(e)` is parenthesized `e`. ExprKind::Paren(es.into_iter().next().unwrap()) } else { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 6e9af1e15d8e6..b9fbf1c576589 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1,7 +1,8 @@ use super::diagnostics::{dummy_arg, ConsumeClosingDelim}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{ - AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Recovered, TrailingToken, + AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Recovered, Trailing, + TrailingToken, }; use crate::errors::{self, MacroExpandsToAdtField}; use crate::fluent_generated as fluent; @@ -1459,7 +1460,7 @@ impl<'a> Parser<'a> { let (variants, _) = if self.token == TokenKind::Semi { self.dcx().emit_err(errors::UseEmptyBlockNotSemi { span: self.token.span }); self.bump(); - (thin_vec![], false) + (thin_vec![], Trailing::No) } else { self.parse_delim_comma_seq(Delimiter::Brace, |p| p.parse_enum_variant(id.span)) .map_err(|mut err| { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 27e9fb10a9fcb..29dd2eeb56aba 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -371,6 +371,12 @@ impl From for bool { } } +#[derive(Copy, Clone, Debug)] +pub enum Trailing { + No, + Yes, +} + #[derive(Clone, Copy, PartialEq, Eq)] pub enum TokenDescription { ReservedIdentifier, @@ -797,10 +803,10 @@ impl<'a> Parser<'a> { sep: SeqSep, expect: TokenExpectType, mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */, Recovered)> { + ) -> PResult<'a, (ThinVec, Trailing, Recovered)> { let mut first = true; let mut recovered = Recovered::No; - let mut trailing = false; + let mut trailing = Trailing::No; let mut v = ThinVec::new(); while !self.expect_any_with_type(kets, expect) { @@ -914,7 +920,7 @@ impl<'a> Parser<'a> { } } if sep.trailing_sep_allowed && self.expect_any_with_type(kets, expect) { - trailing = true; + trailing = Trailing::Yes; break; } @@ -992,7 +998,7 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */, Recovered)> { + ) -> PResult<'a, (ThinVec, Trailing, Recovered)> { self.parse_seq_to_before_tokens(&[ket], sep, TokenExpectType::Expect, f) } @@ -1004,7 +1010,7 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?; if matches!(recovered, Recovered::No) { self.eat(ket); @@ -1021,7 +1027,7 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { self.expect(bra)?; self.parse_seq_to_end(ket, sep, f) } @@ -1033,7 +1039,7 @@ impl<'a> Parser<'a> { &mut self, delim: Delimiter, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { self.parse_unspanned_seq( &token::OpenDelim(delim), &token::CloseDelim(delim), @@ -1048,7 +1054,7 @@ impl<'a> Parser<'a> { fn parse_paren_comma_seq( &mut self, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { self.parse_delim_comma_seq(Delimiter::Parenthesis, f) } diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 072db24265eea..2ede19b11e049 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -1,4 +1,4 @@ -use super::{ForceCollect, Parser, PathStyle, Restrictions, TrailingToken}; +use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing, TrailingToken}; use crate::errors::{ self, AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed, DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt, @@ -696,7 +696,9 @@ impl<'a> Parser<'a> { // Here, `(pat,)` is a tuple pattern. // For backward compatibility, `(..)` is a tuple pattern as well. - Ok(if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) { + let paren_pattern = + fields.len() == 1 && !(matches!(trailing_comma, Trailing::Yes) || fields[0].is_rest()); + if paren_pattern { let pat = fields.into_iter().next().unwrap(); let close_paren = self.prev_token.span; @@ -714,7 +716,7 @@ impl<'a> Parser<'a> { }, }); - self.parse_pat_range_begin_with(begin.clone(), form)? + self.parse_pat_range_begin_with(begin.clone(), form) } // recover ranges with parentheses around the `(start)..` PatKind::Err(_) @@ -729,15 +731,15 @@ impl<'a> Parser<'a> { }, }); - self.parse_pat_range_begin_with(self.mk_expr(pat.span, ExprKind::Err), form)? + self.parse_pat_range_begin_with(self.mk_expr(pat.span, ExprKind::Err), form) } // (pat) with optional parentheses - _ => PatKind::Paren(pat), + _ => Ok(PatKind::Paren(pat)), } } else { - PatKind::Tuple(fields) - }) + Ok(PatKind::Tuple(fields)) + } } /// Parse a mutable binding with the `mut` token already eaten. diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index f79f2a813b223..d65e06494fc7b 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -1,4 +1,4 @@ -use super::{Parser, PathStyle, TokenType}; +use super::{Parser, PathStyle, TokenType, Trailing}; use crate::errors::{ self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType, @@ -415,7 +415,7 @@ impl<'a> Parser<'a> { Ok(ty) })?; - if ts.len() == 1 && !trailing { + if ts.len() == 1 && matches!(trailing, Trailing::No) { let ty = ts.into_iter().next().unwrap().into_inner(); let maybe_bounds = allow_plus == AllowPlus::Yes && self.token.is_like_plus(); match ty.kind { From cb51c850232d8b98b37c0cde6090392b9f077939 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 13 Feb 2024 23:50:50 +0000 Subject: [PATCH 170/417] Use `Recovered` more --- .../rustc_parse/src/parser/diagnostics.rs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index f4e7bb413ddff..03a2b47683a14 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1288,7 +1288,7 @@ impl<'a> Parser<'a> { err: &mut ComparisonOperatorsCannotBeChained, inner_op: &Expr, outer_op: &Spanned, - ) -> bool /* advanced the cursor */ { + ) -> Recovered { if let ExprKind::Binary(op, l1, r1) = &inner_op.kind { if let ExprKind::Field(_, ident) = l1.kind && ident.as_str().parse::().is_err() @@ -1296,7 +1296,7 @@ impl<'a> Parser<'a> { { // The parser has encountered `foo.bar Parser<'a> { span: inner_op.span.shrink_to_hi(), middle_term: expr_to_str(r1), }); - false // Keep the current parse behavior, where the AST is `(x < y) < z`. + Recovered::No // Keep the current parse behavior, where the AST is `(x < y) < z`. } // `x == y < z` (BinOpKind::Eq, AssocOp::Less | AssocOp::LessEqual | AssocOp::Greater | AssocOp::GreaterEqual) => { @@ -1329,12 +1329,12 @@ impl<'a> Parser<'a> { left: r1.span.shrink_to_lo(), right: r2.span.shrink_to_hi(), }); - true + Recovered::Yes } Err(expr_err) => { expr_err.cancel(); self.restore_snapshot(snapshot); - false + Recovered::Yes } } } @@ -1349,19 +1349,19 @@ impl<'a> Parser<'a> { left: l1.span.shrink_to_lo(), right: r1.span.shrink_to_hi(), }); - true + Recovered::Yes } Err(expr_err) => { expr_err.cancel(); self.restore_snapshot(snapshot); - false + Recovered::No } } } - _ => false, + _ => Recovered::No, }; } - false + Recovered::No } /// Produces an error if comparison operators are chained (RFC #558). @@ -1489,8 +1489,9 @@ impl<'a> Parser<'a> { // If it looks like a genuine attempt to chain operators (as opposed to a // misformatted turbofish, for instance), suggest a correct form. - if self.attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op) - { + let recovered = self + .attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); + if matches!(recovered, Recovered::Yes) { self.dcx().emit_err(err); mk_err_expr(self, inner_op.span.to(self.prev_token.span)) } else { @@ -1502,7 +1503,7 @@ impl<'a> Parser<'a> { let recover = self.attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); self.dcx().emit_err(err); - if recover { + if matches!(recover, Recovered::Yes) { return mk_err_expr(self, inner_op.span.to(self.prev_token.span)); } } From cd45d5a81c239ccced418604c8f60a4e5338c1e0 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Tue, 20 Feb 2024 22:18:49 +0900 Subject: [PATCH 171/417] Be careful with expressions with attributes --- clippy_lints/src/unused_unit.rs | 1 + tests/ui/unused_unit.fixed | 7 +++++++ tests/ui/unused_unit.rs | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index 0a73da202ec6d..b70aa768b46b1 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -58,6 +58,7 @@ impl EarlyLintPass for UnusedUnit { && let ctxt = block.span.ctxt() && stmt.span.ctxt() == ctxt && expr.span.ctxt() == ctxt + && expr.attrs.is_empty() { let sp = expr.span; span_lint_and_sugg( diff --git a/tests/ui/unused_unit.fixed b/tests/ui/unused_unit.fixed index 16da9a25b2aa8..04fe2d3b7af18 100644 --- a/tests/ui/unused_unit.fixed +++ b/tests/ui/unused_unit.fixed @@ -94,3 +94,10 @@ mod issue9748 { let _ = for<'a> |_: &'a u32| -> () {}; } } + +mod issue9949 { + fn main() { + #[doc = "documentation"] + () + } +} diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index e374031436d5f..25c2ed59873ac 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -94,3 +94,10 @@ mod issue9748 { let _ = for<'a> |_: &'a u32| -> () {}; } } + +mod issue9949 { + fn main() { + #[doc = "documentation"] + () + } +} From 9bfc46c5d8cafda9b9fe4a5ce38f134edb37cf6f Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 13 Feb 2024 23:57:43 +0000 Subject: [PATCH 172/417] Add newtype for first input type --- .../src/coherence/orphan.rs | 10 ++++----- .../src/traits/coherence.rs | 21 ++++++++++++++++--- .../rustc_trait_selection/src/traits/mod.rs | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 07bbaa1926edf..b46a67d08eb03 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -1,14 +1,13 @@ //! Orphan checker: every impl either implements a trait defined in this //! crate or pertains to a type defined in this crate. +use crate::errors; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_middle::ty::{self, AliasKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::def_id::LocalDefId; use rustc_span::Span; -use rustc_trait_selection::traits; - -use crate::errors; +use rustc_trait_selection::traits::{self, IsFirstInputType}; #[instrument(skip(tcx), level = "debug")] pub(crate) fn orphan_check_impl( @@ -288,7 +287,7 @@ fn emit_orphan_check_error<'tcx>( (Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new()); let mut sugg = None; for &(mut ty, is_target_ty) in &tys { - let span = if is_target_ty { + let span = if matches!(is_target_ty, IsFirstInputType::Yes) { // Point at `D` in `impl for C in D` self_ty_span } else { @@ -321,7 +320,8 @@ fn emit_orphan_check_error<'tcx>( } } - let is_foreign = !trait_ref.def_id.is_local() && !is_target_ty; + let is_foreign = + !trait_ref.def_id.is_local() && matches!(is_target_ty, IsFirstInputType::No); match &ty.kind() { ty::Slice(_) => { diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index f663f02f87289..0d3169cec143c 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -598,9 +598,24 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>( trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental) } +#[derive(Debug, Copy, Clone)] +pub enum IsFirstInputType { + No, + Yes, +} + +impl From for IsFirstInputType { + fn from(b: bool) -> IsFirstInputType { + match b { + false => IsFirstInputType::No, + true => IsFirstInputType::Yes, + } + } +} + #[derive(Debug)] pub enum OrphanCheckErr<'tcx> { - NonLocalInputType(Vec<(Ty<'tcx>, bool /* Is this the first input type? */)>), + NonLocalInputType(Vec<(Ty<'tcx>, IsFirstInputType)>), UncoveredTy(Ty<'tcx>, Option>), } @@ -751,7 +766,7 @@ struct OrphanChecker<'tcx, F> { /// Ignore orphan check failures and exclusively search for the first /// local type. search_first_local_ty: bool, - non_local_tys: Vec<(Ty<'tcx>, bool)>, + non_local_tys: Vec<(Ty<'tcx>, IsFirstInputType)>, } impl<'tcx, F, E> OrphanChecker<'tcx, F> @@ -769,7 +784,7 @@ where } fn found_non_local_ty(&mut self, t: Ty<'tcx>) -> ControlFlow> { - self.non_local_tys.push((t, self.in_self_ty)); + self.non_local_tys.push((t, self.in_self_ty.into())); ControlFlow::Continue(()) } diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 9eec60ea06c21..32447aca390a4 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -42,7 +42,7 @@ use std::fmt::Debug; use std::ops::ControlFlow; pub use self::coherence::{add_placeholder_note, orphan_check, overlapping_impls}; -pub use self::coherence::{OrphanCheckErr, OverlapResult}; +pub use self::coherence::{IsFirstInputType, OrphanCheckErr, OverlapResult}; pub use self::engine::{ObligationCtxt, TraitEngineExt}; pub use self::fulfill::{FulfillmentContext, PendingPredicateObligation}; pub use self::normalize::NormalizeExt; From 3377dac31e5990a6fd65660f356806c82a8327c7 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Wed, 14 Feb 2024 00:01:08 +0000 Subject: [PATCH 173/417] Add newtype for signedness in LLVM SIMD --- compiler/rustc_codegen_llvm/src/intrinsic.rs | 55 +++++++++++--------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 4415c51acf684..574097e82dcc9 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -2094,9 +2094,16 @@ fn generic_simd_intrinsic<'ll, 'tcx>( return Ok(args[0].immediate()); } + #[derive(Copy, Clone)] + enum Sign { + Unsigned, + Signed, + } + use Sign::*; + enum Style { Float, - Int(/* is signed? */ bool), + Int(Sign), Unsupported, } @@ -2104,11 +2111,11 @@ fn generic_simd_intrinsic<'ll, 'tcx>( // vectors of pointer-sized integers should've been // disallowed before here, so this unwrap is safe. ty::Int(i) => ( - Style::Int(true), + Style::Int(Signed), i.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Uint(u) => ( - Style::Int(false), + Style::Int(Unsigned), u.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Float(f) => (Style::Float, f.bit_width()), @@ -2116,11 +2123,11 @@ fn generic_simd_intrinsic<'ll, 'tcx>( }; let (out_style, out_width) = match out_elem.kind() { ty::Int(i) => ( - Style::Int(true), + Style::Int(Signed), i.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Uint(u) => ( - Style::Int(false), + Style::Int(Unsigned), u.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Float(f) => (Style::Float, f.bit_width()), @@ -2128,31 +2135,31 @@ fn generic_simd_intrinsic<'ll, 'tcx>( }; match (in_style, out_style) { - (Style::Int(in_is_signed), Style::Int(_)) => { + (Style::Int(sign), Style::Int(_)) => { return Ok(match in_width.cmp(&out_width) { Ordering::Greater => bx.trunc(args[0].immediate(), llret_ty), Ordering::Equal => args[0].immediate(), - Ordering::Less => { - if in_is_signed { - bx.sext(args[0].immediate(), llret_ty) - } else { - bx.zext(args[0].immediate(), llret_ty) - } - } + Ordering::Less => match sign { + Sign::Signed => bx.sext(args[0].immediate(), llret_ty), + Sign::Unsigned => bx.zext(args[0].immediate(), llret_ty), + }, }); } - (Style::Int(in_is_signed), Style::Float) => { - return Ok(if in_is_signed { - bx.sitofp(args[0].immediate(), llret_ty) - } else { - bx.uitofp(args[0].immediate(), llret_ty) - }); + (Style::Int(Sign::Signed), Style::Float) => { + return Ok(bx.sitofp(args[0].immediate(), llret_ty)); } - (Style::Float, Style::Int(out_is_signed)) => { - return Ok(match (out_is_signed, name == sym::simd_as) { - (false, false) => bx.fptoui(args[0].immediate(), llret_ty), - (true, false) => bx.fptosi(args[0].immediate(), llret_ty), - (_, true) => bx.cast_float_to_int(out_is_signed, args[0].immediate(), llret_ty), + (Style::Int(Sign::Unsigned), Style::Float) => { + return Ok(bx.uitofp(args[0].immediate(), llret_ty)); + } + (Style::Float, Style::Int(sign)) => { + return Ok(match (sign, name == sym::simd_as) { + (Sign::Unsigned, false) => bx.fptoui(args[0].immediate(), llret_ty), + (Sign::Signed, false) => bx.fptosi(args[0].immediate(), llret_ty), + (_, true) => bx.cast_float_to_int( + matches!(sign, Sign::Signed), + args[0].immediate(), + llret_ty, + ), }); } (Style::Float, Style::Float) => { From 06e77397e18a8743087ef3f2b5546a148c0560ec Mon Sep 17 00:00:00 2001 From: clubby789 Date: Wed, 14 Feb 2024 00:04:54 +0000 Subject: [PATCH 174/417] Add newtype for using the prelude in resolution --- compiler/rustc_resolve/src/diagnostics.rs | 2 +- compiler/rustc_resolve/src/ident.rs | 24 ++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 4b978fefa107a..99ce47254328c 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1111,7 +1111,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { suggestions.extend( tmp_suggestions .into_iter() - .filter(|s| use_prelude || this.is_builtin_macro(s.res)), + .filter(|s| use_prelude.into() || this.is_builtin_macro(s.res)), ); } } diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 4583f991cabd5..7e7424be303ac 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -23,6 +23,18 @@ use Namespace::*; type Visibility = ty::Visibility; +#[derive(Copy, Clone)] +pub enum UsePrelude { + No, + Yes, +} + +impl From for bool { + fn from(up: UsePrelude) -> bool { + matches!(up, UsePrelude::Yes) + } +} + impl<'a, 'tcx> Resolver<'a, 'tcx> { /// A generic scope visitor. /// Visits scopes in order to resolve some identifier in them or perform other actions. @@ -32,12 +44,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { scope_set: ScopeSet<'a>, parent_scope: &ParentScope<'a>, ctxt: SyntaxContext, - mut visitor: impl FnMut( - &mut Self, - Scope<'a>, - /*use_prelude*/ bool, - SyntaxContext, - ) -> Option, + mut visitor: impl FnMut(&mut Self, Scope<'a>, UsePrelude, SyntaxContext) -> Option, ) -> Option { // General principles: // 1. Not controlled (user-defined) names should have higher priority than controlled names @@ -133,6 +140,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }; if visit { + let use_prelude = if use_prelude { UsePrelude::Yes } else { UsePrelude::No }; if let break_result @ Some(..) = visitor(self, scope, use_prelude, ctxt) { return break_result; } @@ -579,7 +587,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { None, ignore_binding, ) { - if use_prelude || this.is_builtin_macro(binding.res()) { + if matches!(use_prelude, UsePrelude::Yes) + || this.is_builtin_macro(binding.res()) + { result = Ok((binding, Flags::MISC_FROM_PRELUDE)); } } From 9dee352da09f53af244ecb651885dd0e62fc594d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 20 Feb 2024 15:55:17 +0100 Subject: [PATCH 175/417] fix: server hanging up on build script task --- crates/rust-analyzer/src/global_state.rs | 20 ++++---------------- crates/rust-analyzer/src/lsp/utils.rs | 1 + crates/rust-analyzer/src/reload.rs | 7 ++----- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 293807a383baa..b2d507491b177 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -301,19 +301,12 @@ impl GlobalState { if let Some(path) = vfs_path.as_path() { let path = path.to_path_buf(); if reload::should_refresh_for_change(&path, file.kind()) { - workspace_structure_change = Some(( - path.clone(), - false, - AsRef::::as_ref(&path).ends_with("build.rs"), - )); + workspace_structure_change = Some((path.clone(), false)); } if file.is_created_or_deleted() { has_structure_changes = true; - workspace_structure_change = Some(( - path, - self.crate_graph_file_dependencies.contains(vfs_path), - false, - )); + workspace_structure_change = + Some((path, self.crate_graph_file_dependencies.contains(vfs_path))); } else if path.extension() == Some("rs".as_ref()) { modified_rust_files.push(file.file_id); } @@ -365,16 +358,11 @@ impl GlobalState { // FIXME: ideally we should only trigger a workspace fetch for non-library changes // but something's going wrong with the source root business when we add a new local // crate see https://github.com/rust-lang/rust-analyzer/issues/13029 - if let Some((path, force_crate_graph_reload, build_scripts_touched)) = - workspace_structure_change - { + if let Some((path, force_crate_graph_reload)) = workspace_structure_change { self.fetch_workspaces_queue.request_op( format!("workspace vfs file change: {path}"), force_crate_graph_reload, ); - if build_scripts_touched { - self.fetch_build_data_queue.request_op(format!("build.rs changed: {path}"), ()); - } } } diff --git a/crates/rust-analyzer/src/lsp/utils.rs b/crates/rust-analyzer/src/lsp/utils.rs index 10335cb145335..800c0eee53a02 100644 --- a/crates/rust-analyzer/src/lsp/utils.rs +++ b/crates/rust-analyzer/src/lsp/utils.rs @@ -134,6 +134,7 @@ impl GlobalState { let token = lsp_types::ProgressToken::String( cancel_token.unwrap_or_else(|| format!("rustAnalyzer/{title}")), ); + tracing::debug!(?token, ?state, "report_progress {message:?}"); let work_done_progress = match state { Progress::Begin => { self.send_request::( diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 5895459d1fcf8..00494ca5ba090 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -411,10 +411,7 @@ impl GlobalState { if *force_reload_crate_graph { self.recreate_crate_graph(cause); } - if self.build_deps_changed && self.config.run_build_scripts() { - self.build_deps_changed = false; - self.fetch_build_data_queue.request_op("build_deps_changed".to_owned(), ()); - } + // Current build scripts do not match the version of the active // workspace, so there's nothing for us to update. return; @@ -424,7 +421,7 @@ impl GlobalState { // Here, we completely changed the workspace (Cargo.toml edit), so // we don't care about build-script results, they are stale. - // FIXME: can we abort the build scripts here? + // FIXME: can we abort the build scripts here if they are already running? self.workspaces = Arc::new(workspaces); if self.config.run_build_scripts() { From e59efe4d7e77bb498d32bc75b46fe7924c3f8270 Mon Sep 17 00:00:00 2001 From: Takashiidobe Date: Tue, 20 Feb 2024 09:02:49 -0500 Subject: [PATCH 176/417] Add examples for some methods on slices --- library/core/src/slice/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index c948337ba6c2d..ab43499f2689d 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -146,6 +146,9 @@ impl [T] { /// ``` /// let a = [1, 2, 3]; /// assert!(!a.is_empty()); + /// + /// let b: &[i32] = &[]; + /// assert!(b.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_slice_is_empty", since = "1.39.0")] @@ -185,6 +188,9 @@ impl [T] { /// *first = 5; /// } /// assert_eq!(x, &[5, 1, 2]); + /// + /// let y: &mut [i32] = &mut []; + /// assert_eq!(None, y.first_mut()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")] @@ -297,7 +303,7 @@ impl [T] { if let [.., last] = self { Some(last) } else { None } } - /// Returns a mutable reference to the last item in the slice. + /// Returns a mutable reference to the last item in the slice, or `None` if it is empty. /// /// # Examples /// @@ -308,6 +314,9 @@ impl [T] { /// *last = 10; /// } /// assert_eq!(x, &[0, 1, 10]); + /// + /// let y: &mut [i32] = &mut []; + /// assert_eq!(None, y.last_mut()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")] From 16b15a203ec888714ffbcc7168a259d18555caae Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 20 Feb 2024 17:02:59 +0100 Subject: [PATCH 177/417] internal: Attempt to add a timeout to rustc-tests --- .../src/handlers/useless_braces.rs | 4 +- crates/ide-diagnostics/src/lib.rs | 20 ++++-- crates/rust-analyzer/src/cli/rustc_tests.rs | 70 +++++++++++++++---- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/crates/ide-diagnostics/src/handlers/useless_braces.rs b/crates/ide-diagnostics/src/handlers/useless_braces.rs index 863a7ab783ec8..79bcaa0a9c4c9 100644 --- a/crates/ide-diagnostics/src/handlers/useless_braces.rs +++ b/crates/ide-diagnostics/src/handlers/useless_braces.rs @@ -4,7 +4,7 @@ use ide_db::{ source_change::SourceChange, }; use itertools::Itertools; -use syntax::{ast, AstNode, SyntaxNode}; +use syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr}; use text_edit::TextEdit; use crate::{fix, Diagnostic, DiagnosticCode}; @@ -43,7 +43,7 @@ pub(crate) fn useless_braces( "Unnecessary braces in use statement".to_owned(), FileRange { file_id, range: use_range }, ) - .with_main_node(InFile::new(file_id.into(), node.clone())) + .with_main_node(InFile::new(file_id.into(), SyntaxNodePtr::new(node))) .with_fixes(Some(vec![fix( "remove_braces", "Remove unnecessary braces", diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index 4428b8baafbdb..9f4368b04e79b 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -142,7 +142,7 @@ pub struct Diagnostic { pub experimental: bool, pub fixes: Option>, // The node that will be affected by `#[allow]` and similar attributes. - pub main_node: Option>, + pub main_node: Option>, } impl Diagnostic { @@ -174,9 +174,8 @@ impl Diagnostic { message: impl Into, node: InFile, ) -> Diagnostic { - let file_id = node.file_id; Diagnostic::new(code, message, ctx.sema.diagnostics_display_range(node)) - .with_main_node(node.map(|x| x.to_node(&ctx.sema.parse_or_expand(file_id)))) + .with_main_node(node) } fn experimental(mut self) -> Diagnostic { @@ -184,7 +183,7 @@ impl Diagnostic { self } - fn with_main_node(mut self, main_node: InFile) -> Diagnostic { + fn with_main_node(mut self, main_node: InFile) -> Diagnostic { self.main_node = Some(main_node); self } @@ -394,8 +393,17 @@ pub fn diagnostics( res.push(d) } - let mut diagnostics_of_range = - res.iter_mut().filter_map(|x| Some((x.main_node.clone()?, x))).collect::>(); + let mut diagnostics_of_range = res + .iter_mut() + .filter_map(|it| { + Some(( + it.main_node + .map(|ptr| ptr.map(|node| node.to_node(&ctx.sema.parse_or_expand(ptr.file_id)))) + .clone()?, + it, + )) + }) + .collect::>(); let mut rustc_stack: FxHashMap> = FxHashMap::default(); let mut clippy_stack: FxHashMap> = FxHashMap::default(); diff --git a/crates/rust-analyzer/src/cli/rustc_tests.rs b/crates/rust-analyzer/src/cli/rustc_tests.rs index 25f84d770bfb3..b3b6da1f698e8 100644 --- a/crates/rust-analyzer/src/cli/rustc_tests.rs +++ b/crates/rust-analyzer/src/cli/rustc_tests.rs @@ -1,9 +1,13 @@ //! Run all tests in a project, similar to `cargo test`, but using the mir interpreter. +use std::convert::identity; +use std::thread::Builder; +use std::time::{Duration, Instant}; use std::{cell::RefCell, fs::read_to_string, panic::AssertUnwindSafe, path::PathBuf}; use hir::{Change, Crate}; use ide::{AnalysisHost, DiagnosticCode, DiagnosticsConfig}; +use itertools::Either; use profile::StopWatch; use project_model::target_data_layout::RustcDataLayoutConfig; use project_model::{target_data_layout, CargoConfig, ProjectWorkspace, RustLibSource, Sysroot}; @@ -100,6 +104,7 @@ impl Tester { } fn test(&mut self, p: PathBuf) { + println!("{}", p.display()); if p.parent().unwrap().file_name().unwrap() == "auxiliary" { // These are not tests return; @@ -132,15 +137,44 @@ impl Tester { self.host.apply_change(change); let diagnostic_config = DiagnosticsConfig::test_sample(); + let res = std::thread::scope(|s| { + let worker = Builder::new() + .stack_size(40 * 1024 * 1024) + .spawn_scoped(s, { + let diagnostic_config = &diagnostic_config; + let main = std::thread::current(); + let analysis = self.host.analysis(); + let root_file = self.root_file; + move || { + let res = std::panic::catch_unwind(move || { + analysis.diagnostics( + diagnostic_config, + ide::AssistResolveStrategy::None, + root_file, + ) + }); + main.unpark(); + res + } + }) + .unwrap(); + + let timeout = Duration::from_secs(5); + let now = Instant::now(); + while now.elapsed() <= timeout && !worker.is_finished() { + std::thread::park_timeout(timeout - now.elapsed()); + } + + if !worker.is_finished() { + // attempt to cancel the worker, won't work for chalk hangs unfortunately + self.host.request_cancellation(); + } + worker.join().and_then(identity) + }); let mut actual = FxHashMap::default(); - let panicked = match std::panic::catch_unwind(|| { - self.host - .analysis() - .diagnostics(&diagnostic_config, ide::AssistResolveStrategy::None, self.root_file) - .unwrap() - }) { - Err(e) => Some(e), - Ok(diags) => { + let panicked = match res { + Err(e) => Some(Either::Left(e)), + Ok(Ok(diags)) => { for diag in diags { if !matches!(diag.code, DiagnosticCode::RustcHardError(_)) { continue; @@ -152,6 +186,7 @@ impl Tester { } None } + Ok(Err(e)) => Some(Either::Right(e)), }; // Ignore tests with diagnostics that we don't emit. ignore_test |= expected.keys().any(|k| !SUPPORTED_DIAGNOSTICS.contains(k)); @@ -159,14 +194,19 @@ impl Tester { println!("{p:?} IGNORE"); self.ignore_count += 1; } else if let Some(panic) = panicked { - if let Some(msg) = panic - .downcast_ref::() - .map(String::as_str) - .or_else(|| panic.downcast_ref::<&str>().copied()) - { - println!("{msg:?} ") + match panic { + Either::Left(panic) => { + if let Some(msg) = panic + .downcast_ref::() + .map(String::as_str) + .or_else(|| panic.downcast_ref::<&str>().copied()) + { + println!("{msg:?} ") + } + println!("{p:?} PANIC"); + } + Either::Right(_) => println!("{p:?} CANCELLED"), } - println!("PANIC"); self.fail_count += 1; } else if actual == expected { println!("{p:?} PASS"); From 07421c13d48918984bd51fad2cde529ebf23c5ae Mon Sep 17 00:00:00 2001 From: DropDemBits Date: Tue, 20 Feb 2024 14:01:50 -0500 Subject: [PATCH 178/417] fix: Don't add `\` before `{` The LSP snippet grammar only specifies that `$`, `}`, and `\` can be escaped with backslashes, but not `{`. --- crates/rust-analyzer/src/lsp/to_proto.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index 4101d476cd308..481ebfefd4eed 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -1002,10 +1002,8 @@ fn merge_text_and_snippet_edits( let mut new_text = current_indel.insert; // find which snippet bits need to be escaped - let escape_places = new_text - .rmatch_indices(['\\', '$', '{', '}']) - .map(|(insert, _)| insert) - .collect_vec(); + let escape_places = + new_text.rmatch_indices(['\\', '$', '}']).map(|(insert, _)| insert).collect_vec(); let mut escape_places = escape_places.into_iter().peekable(); let mut escape_prior_bits = |new_text: &mut String, up_to: usize| { for before in escape_places.peeking_take_while(|insert| *insert >= up_to) { @@ -2176,7 +2174,7 @@ fn bar(_: usize) {} character: 0, }, }, - new_text: "\\$${1:ab\\{\\}\\$c\\\\d}ef", + new_text: "\\$${1:ab{\\}\\$c\\\\d}ef", insert_text_format: Some( Snippet, ), @@ -2272,7 +2270,7 @@ struct ProcMacro { character: 5, }, }, - new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}", + new_text: "$0disabled = false;\n ProcMacro {\n disabled,\n \\}", insert_text_format: Some( Snippet, ), @@ -2336,7 +2334,7 @@ struct P { character: 5, }, }, - new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}", + new_text: "$0disabled = false;\n ProcMacro {\n disabled,\n \\}", insert_text_format: Some( Snippet, ), @@ -2401,7 +2399,7 @@ struct ProcMacro { character: 5, }, }, - new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}", + new_text: "${0:disabled} = false;\n ProcMacro {\n disabled,\n \\}", insert_text_format: Some( Snippet, ), @@ -2466,7 +2464,7 @@ struct P { character: 5, }, }, - new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}", + new_text: "${0:disabled} = false;\n ProcMacro {\n disabled,\n \\}", insert_text_format: Some( Snippet, ), From 344a79c17dd321279897cc287313ff38e0fe255e Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Tue, 20 Feb 2024 16:42:20 -0800 Subject: [PATCH 179/417] Drop RUSTC_BOOTSTRAP env var when building build scripts Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options it uses. This causes flapping recompiles when building outside of RA. As of Cargo 1.75 the `--keep-going` flag is stable. This change uses the flag without `RUSTC_BOOTSTRAP` if the Cargo version is >= 1.75, and drops `--keep-going` otherwise. This fixes build script recompilation. --- crates/project-model/src/build_scripts.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/project-model/src/build_scripts.rs b/crates/project-model/src/build_scripts.rs index ab72f1fba09dd..621b6ca3efa43 100644 --- a/crates/project-model/src/build_scripts.rs +++ b/crates/project-model/src/build_scripts.rs @@ -138,7 +138,7 @@ impl WorkspaceBuildScripts { toolchain: &Option, sysroot: Option<&Sysroot>, ) -> io::Result { - const RUST_1_62: Version = Version::new(1, 62, 0); + const RUST_1_75: Version = Version::new(1, 75, 0); let current_dir = match &config.invocation_location { InvocationLocation::Root(root) if config.run_build_script_command.is_some() => { @@ -162,7 +162,7 @@ impl WorkspaceBuildScripts { progress, ) { Ok(WorkspaceBuildScripts { error: Some(error), .. }) - if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_62) => + if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_75) => { // building build scripts failed, attempt to build with --keep-going so // that we potentially get more build data @@ -172,7 +172,8 @@ impl WorkspaceBuildScripts { &workspace.workspace_root().to_path_buf(), sysroot, )?; - cmd.args(["-Z", "unstable-options", "--keep-going"]).env("RUSTC_BOOTSTRAP", "1"); + + cmd.args(["--keep-going"]); let mut res = Self::run_per_ws(cmd, workspace, current_dir, progress)?; res.error = Some(error); Ok(res) From 2826eb51aa60e2e73d7f35408d2ee2727ec36334 Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Tue, 20 Feb 2024 16:49:07 -0800 Subject: [PATCH 180/417] Don't build dependencies when retrieving target data layout `cargo rustc -- ` first builds dependencies then calls `rustc ` for the current package. Here, we don't want to build dependencies, we just want to call `rustc --print`. An unstable `cargo rustc` `--print` command bypasses building dependencies first. This speeds up execution of this code path and ensures RA doesn't recompile dependencies with the `RUSTC_BOOTSRAP=1` env var flag set. Note that we must pass `-Z unstable-options` twice, first to enable the `cargo` unstable `--print` flag, then later to enable the unstable `rustc` `target-spec-json` print request. --- crates/project-model/src/target_data_layout.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/project-model/src/target_data_layout.rs b/crates/project-model/src/target_data_layout.rs index af635dda5782d..98917351c5e88 100644 --- a/crates/project-model/src/target_data_layout.rs +++ b/crates/project-model/src/target_data_layout.rs @@ -32,7 +32,16 @@ pub fn get( Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot); cmd.envs(extra_env); cmd.current_dir(cargo_toml.parent()) - .args(["rustc", "--", "-Z", "unstable-options", "--print", "target-spec-json"]) + .args([ + "rustc", + "-Z", + "unstable-options", + "--print", + "target-spec-json", + "--", + "-Z", + "unstable-options", + ]) .env("RUSTC_BOOTSTRAP", "1"); if let Some(target) = target { cmd.args(["--target", target]); From 205cfcba200b13af31c39e67127cb3c07d491702 Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 21 Feb 2024 12:18:59 +0300 Subject: [PATCH 181/417] llvm-wrapper: fix warning C4244 llvm-wrapper/RustWrapper.cpp(1234): warning C4244: '=': conversion from 'uint64_t' to 'unsigned int', possible loss of data nice consistency: uint64_t https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/include/llvm/IR/DiagnosticInfo.h#L172 but unsigned https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/include/llvm/IR/DiagnosticInfo.h#L1091 --- compiler/rustc_codegen_llvm/src/back/write.rs | 6 +++--- compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs | 4 ++-- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 2 +- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 27cb0366f17dc..08aab84986800 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -36,7 +36,7 @@ use rustc_span::InnerSpan; use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; use crate::llvm::diagnostic::OptimizationDiagnosticKind; -use libc::{c_char, c_int, c_uint, c_void, size_t}; +use libc::{c_char, c_int, c_void, size_t}; use std::ffi::CString; use std::fs; use std::io::{self, Write}; @@ -406,7 +406,7 @@ fn report_inline_asm( cgcx: &CodegenContext, msg: String, level: llvm::DiagnosticLevel, - mut cookie: c_uint, + mut cookie: u64, source: Option<(String, Vec)>, ) { // In LTO build we may get srcloc values from other crates which are invalid @@ -420,7 +420,7 @@ fn report_inline_asm( llvm::DiagnosticLevel::Warning => Level::Warning, llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note, }; - cgcx.diag_emitter.inline_asm_error(cookie as u32, msg, level, source); + cgcx.diag_emitter.inline_asm_error(cookie.try_into().unwrap(), msg, level, source); } unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) { diff --git a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs index 06e846a2b45eb..f9b28178ddb97 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs @@ -123,7 +123,7 @@ impl SrcMgrDiagnostic { #[derive(Clone)] pub struct InlineAsmDiagnostic { pub level: super::DiagnosticLevel, - pub cookie: c_uint, + pub cookie: u64, pub message: String, pub source: Option<(String, Vec)>, } @@ -149,7 +149,7 @@ impl InlineAsmDiagnostic { let smdiag = SrcMgrDiagnostic::unpack(super::LLVMRustGetSMDiagnostic(di, &mut cookie)); InlineAsmDiagnostic { level: smdiag.level, - cookie, + cookie: cookie.into(), message: smdiag.message, source: smdiag.source, } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index d0044086c616e..90116b90478a9 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2254,7 +2254,7 @@ extern "C" { pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>( DI: &'a DiagnosticInfo, level_out: &mut DiagnosticLevel, - cookie_out: &mut c_uint, + cookie_out: &mut u64, message_out: &mut Option<&'a Twine>, ); diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index b45706fd1e5b2..e645f25c8d4e2 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1225,7 +1225,7 @@ enum class LLVMRustDiagnosticLevel { extern "C" void LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI, LLVMRustDiagnosticLevel *LevelOut, - unsigned *CookieOut, + uint64_t *CookieOut, LLVMTwineRef *MessageOut) { // Undefined to call this not on an inline assembly diagnostic! llvm::DiagnosticInfoInlineAsm *IA = From 0ce966fd6415773698fd9f85a86ef49dd4225ecf Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 21 Feb 2024 13:13:50 +0300 Subject: [PATCH 182/417] llvm-wrapper: fix warning C4305 llvm-wrapper/ArchiveWrapper.cpp(70): warning C4305: 'argument': truncation from 'int' to 'bool' while in llvm 12 signature was static ErrorOr> getFile(const Twine &Filename, int64_t FileSize = -1, bool RequiresNullTerminator = true, bool IsVolatile = false); https://github.com/llvm/llvm-project/blame/fed41342a82f5a3a9201819a82bf7a48313e296b/llvm/include/llvm/Support/MemoryBuffer.h#L85-L87 in llvm 13 and later it was changed to static ErrorOr> getFile(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true, bool IsVolatile = false); https://github.com/llvm/llvm-project/blame/75e33f71c2dae584b13a7d1186ae0a038ba98838/llvm/include/llvm/Support/MemoryBuffer.h#L86-L88 so code was interpreted as MemoryBuffer::getFile(Path, /*IsText*/true, /*RequiresNullTerminator=*/false), but now will be MemoryBuffer::getFile(Path, /*IsText*/false, /*RequiresNullTerminator=*/false). How that worked before? --- compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp index 54fdc84c77d26..40723ff9f5ef2 100644 --- a/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp @@ -67,7 +67,7 @@ typedef RustArchiveIterator *LLVMRustArchiveIteratorRef; extern "C" LLVMRustArchiveRef LLVMRustOpenArchive(char *Path) { ErrorOr> BufOr = - MemoryBuffer::getFile(Path, -1, false); + MemoryBuffer::getFile(Path, /*IsText*/false, /*RequiresNullTerminator=*/false); if (!BufOr) { LLVMRustSetLastError(BufOr.getError().message().c_str()); return nullptr; From 893cb760e0cf6af0b60e628bc3adade814c59953 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 12 Feb 2024 04:27:37 +0100 Subject: [PATCH 183/417] Split off `test_candidates` into several functions and improve comments --- .../rustc_mir_build/src/build/matches/mod.rs | 369 +++++++++++------- 1 file changed, 218 insertions(+), 151 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index ccf299649cf8f..fab8f9d2254d9 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -1137,39 +1137,61 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// the value, we will set and generate a branch to the appropriate /// pre-binding block. /// - /// If we find that *NONE* of the candidates apply, we branch to the - /// `otherwise_block`, setting it to `Some` if required. In principle, this - /// means that the input list was not exhaustive, though at present we - /// sometimes are not smart enough to recognize all exhaustive inputs. + /// If we find that *NONE* of the candidates apply, we branch to `otherwise_block`. /// /// It might be surprising that the input can be non-exhaustive. /// Indeed, initially, it is not, because all matches are /// exhaustive in Rust. But during processing we sometimes divide /// up the list of candidates and recurse with a non-exhaustive - /// list. This is important to keep the size of the generated code - /// under control. See [`Builder::test_candidates`] for more details. + /// list. This is how our lowering approach (called "backtracking + /// automaton" in the literature) works. + /// See [`Builder::test_candidates`] for more details. /// /// If `fake_borrows` is `Some`, then places which need fake borrows /// will be added to it. /// - /// For an example of a case where we set `otherwise_block`, even for an - /// exhaustive match, consider: - /// + /// For an example of how we use `otherwise_block`, consider: + /// ``` + /// # fn foo((x, y): (bool, bool)) -> u32 { + /// match (x, y) { + /// (true, true) => 1, + /// (_, false) => 2, + /// (false, true) => 3, + /// } + /// # } + /// ``` + /// For this match, we generate something like: /// ``` - /// # fn foo(x: (bool, bool)) { - /// match x { - /// (true, true) => (), - /// (_, false) => (), - /// (false, true) => (), + /// # fn foo((x, y): (bool, bool)) -> u32 { + /// if x { + /// if y { + /// return 1 + /// } else { + /// // continue + /// } + /// } else { + /// // continue /// } + /// if y { + /// if x { + /// // This is actually unreachable because the `(true, true)` case was handled above. + /// // continue + /// } else { + /// return 3 + /// } + /// } else { + /// return 2 + /// } + /// // this is the final `otherwise_block`, which is unreachable because the match was exhaustive. + /// unreachable!() /// # } /// ``` /// - /// For this match, we check if `x.0` matches `true` (for the first - /// arm). If it doesn't match, we check `x.1`. If `x.1` is `true` we check - /// if `x.0` matches `false` (for the third arm). In the (impossible at - /// runtime) case when `x.0` is now `true`, we branch to - /// `otherwise_block`. + /// Every `continue` is an instance of branching to some `otherwise_block` somewhere deep within + /// the algorithm. For more details on why we lower like this, see [`Builder::test_candidates`]. + /// + /// Note how we test `x` twice. This is the tradeoff of backtracking automata: we prefer smaller + /// code size at the expense of non-optimal code paths. #[instrument(skip(self, fake_borrows), level = "debug")] fn match_candidates<'pat>( &mut self, @@ -1533,18 +1555,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - /// This is the most subtle part of the matching algorithm. At - /// this point, the input candidates have been fully simplified, - /// and so we know that all remaining match-pairs require some - /// sort of test. To decide what test to perform, we take the highest - /// priority candidate (the first one in the list, as of January 2021) - /// and extract the first match-pair from the list. From this we decide - /// what kind of test is needed using [`Builder::test`], defined in the - /// [`test` module](mod@test). + /// Pick a test to run. Which test doesn't matter as long as it is guaranteed to fully match at + /// least one match pair. We currently simply pick the test corresponding to the first match + /// pair of the first candidate in the list. /// - /// *Note:* taking the first match pair is somewhat arbitrary, and - /// we might do better here by choosing more carefully what to - /// test. + /// *Note:* taking the first match pair is somewhat arbitrary, and we might do better here by + /// choosing more carefully what to test. /// /// For example, consider the following possible match-pairs: /// @@ -1556,121 +1572,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// [`Switch`]: TestKind::Switch /// [`SwitchInt`]: TestKind::SwitchInt /// [`Range`]: TestKind::Range - /// - /// Once we know what sort of test we are going to perform, this - /// test may also help us winnow down our candidates. So we walk over - /// the candidates (from high to low priority) and check. This - /// gives us, for each outcome of the test, a transformed list of - /// candidates. For example, if we are testing `x.0`'s variant, - /// and we have a candidate `(x.0 @ Some(v), x.1 @ 22)`, - /// then we would have a resulting candidate of `((x.0 as Some).0 @ v, x.1 @ 22)`. - /// Note that the first match-pair is now simpler (and, in fact, irrefutable). - /// - /// But there may also be candidates that the test just doesn't - /// apply to. The classical example involves wildcards: - /// - /// ``` - /// # let (x, y, z) = (true, true, true); - /// match (x, y, z) { - /// (true , _ , true ) => true, // (0) - /// (_ , true , _ ) => true, // (1) - /// (false, false, _ ) => false, // (2) - /// (true , _ , false) => false, // (3) - /// } - /// # ; - /// ``` - /// - /// In that case, after we test on `x`, there are 2 overlapping candidate - /// sets: - /// - /// - If the outcome is that `x` is true, candidates 0, 1, and 3 - /// - If the outcome is that `x` is false, candidates 1 and 2 - /// - /// Here, the traditional "decision tree" method would generate 2 - /// separate code-paths for the 2 separate cases. - /// - /// In some cases, this duplication can create an exponential amount of - /// code. This is most easily seen by noticing that this method terminates - /// with precisely the reachable arms being reachable - but that problem - /// is trivially NP-complete: - /// - /// ```ignore (illustrative) - /// match (var0, var1, var2, var3, ...) { - /// (true , _ , _ , false, true, ...) => false, - /// (_ , true, true , false, _ , ...) => false, - /// (false, _ , false, false, _ , ...) => false, - /// ... - /// _ => true - /// } - /// ``` - /// - /// Here the last arm is reachable only if there is an assignment to - /// the variables that does not match any of the literals. Therefore, - /// compilation would take an exponential amount of time in some cases. - /// - /// That kind of exponential worst-case might not occur in practice, but - /// our simplistic treatment of constants and guards would make it occur - /// in very common situations - for example [#29740]: - /// - /// ```ignore (illustrative) - /// match x { - /// "foo" if foo_guard => ..., - /// "bar" if bar_guard => ..., - /// "baz" if baz_guard => ..., - /// ... - /// } - /// ``` - /// - /// [#29740]: https://github.com/rust-lang/rust/issues/29740 - /// - /// Here we first test the match-pair `x @ "foo"`, which is an [`Eq` test]. - /// - /// [`Eq` test]: TestKind::Eq - /// - /// It might seem that we would end up with 2 disjoint candidate - /// sets, consisting of the first candidate or the other two, but our - /// algorithm doesn't reason about `"foo"` being distinct from the other - /// constants; it considers the latter arms to potentially match after - /// both outcomes, which obviously leads to an exponential number - /// of tests. - /// - /// To avoid these kinds of problems, our algorithm tries to ensure - /// the amount of generated tests is linear. When we do a k-way test, - /// we return an additional "unmatched" set alongside the obvious `k` - /// sets. When we encounter a candidate that would be present in more - /// than one of the sets, we put it and all candidates below it into the - /// "unmatched" set. This ensures these `k+1` sets are disjoint. - /// - /// After we perform our test, we branch into the appropriate candidate - /// set and recurse with `match_candidates`. These sub-matches are - /// obviously non-exhaustive - as we discarded our otherwise set - so - /// we set their continuation to do `match_candidates` on the - /// "unmatched" set (which is again non-exhaustive). - /// - /// If you apply this to the above test, you basically wind up - /// with an if-else-if chain, testing each candidate in turn, - /// which is precisely what we want. - /// - /// In addition to avoiding exponential-time blowups, this algorithm - /// also has the nice property that each guard and arm is only generated - /// once. - fn test_candidates<'pat, 'b, 'c>( + fn pick_test( &mut self, - span: Span, - scrutinee_span: Span, - mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], - start_block: BasicBlock, - otherwise_block: BasicBlock, + candidates: &mut [&mut Candidate<'_, 'tcx>], fake_borrows: &mut Option>>, - ) { - // extract the match-pair from the highest priority candidate + ) -> (PlaceBuilder<'tcx>, Test<'tcx>) { + // Extract the match-pair from the highest priority candidate let match_pair = &candidates.first().unwrap().match_pairs[0]; let mut test = self.test(match_pair); let match_place = match_pair.place.clone(); - // most of the time, the test to perform is simply a function - // of the main candidate; but for a test like SwitchInt, we - // may want to add cases based on the candidates that are + debug!("test_candidates: test={:?} match_pair={:?}", test, match_pair); + // Most of the time, the test to perform is simply a function of the main candidate; but for + // a test like SwitchInt, we may want to add cases based on the candidates that are // available match test.kind { TestKind::SwitchInt { switch_ty: _, ref mut options } => { @@ -1697,20 +1611,58 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fb.insert(resolved_place); } - // perform the test, branching to one of N blocks. For each of - // those N possible outcomes, create a (initially empty) - // vector of candidates. Those are the candidates that still - // apply if the test has that particular outcome. - debug!("test_candidates: test={:?} match_pair={:?}", test, match_pair); + (match_place, test) + } + + /// Given a test, we sort the input candidates into several buckets. If a candidate only matches + /// in one of the branches of `test`, we move it there. If it could match in more than one of + /// the branches of `test`, we stop sorting candidates. + /// + /// This returns a pair of + /// - the candidates that weren't sorted; + /// - for each possible outcome of the test, the candidates that match in that outcome. + /// + /// Moreover, we transform the branched candidates to reflect the fact that we know which + /// outcome of `test` occurred. + /// + /// For example: + /// ``` + /// # let (x, y, z) = (true, true, true); + /// match (x, y, z) { + /// (true , _ , true ) => true, // (0) + /// (false, false, _ ) => false, // (1) + /// (_ , true , _ ) => true, // (2) + /// (true , _ , false) => false, // (3) + /// } + /// # ; + /// ``` + /// + /// Assume we are testing on `x`. There are 2 overlapping candidate sets: + /// - If the outcome is that `x` is true, candidates 0, 2, and 3 + /// - If the outcome is that `x` is false, candidates 1 and 2 + /// + /// Following our algorithm, candidate 0 is sorted into outcome `x == true`, candidate 1 goes + /// into outcome `x == false`, and candidate 2 and 3 remain unsorted. + /// + /// The sorted candidates are transformed: + /// - candidate 0 becomes `[z @ true]` since we know that `x` was `true`; + /// - candidate 1 becomes `[y @ false]` since we know that `x` was `false`. + fn sort_candidates<'b, 'c, 'pat>( + &mut self, + match_place: &PlaceBuilder<'tcx>, + test: &Test<'tcx>, + mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], + ) -> (&'b mut [&'c mut Candidate<'pat, 'tcx>], Vec>>) { + // For each of the N possible outcomes, create a (initially empty) vector of candidates. + // Those are the candidates that apply if the test has that particular outcome. let mut target_candidates: Vec>> = vec![]; target_candidates.resize_with(test.targets(), Default::default); let total_candidate_count = candidates.len(); - // Sort the candidates into the appropriate vector in - // `target_candidates`. Note that at some point we may - // encounter a candidate where the test is not relevant; at - // that point, we stop sorting. + // Sort the candidates into the appropriate vector in `target_candidates`. Note that at some + // point we may encounter a candidate where the test is not relevant; at that point, we stop + // sorting. while let Some(candidate) = candidates.first_mut() { let Some(idx) = self.sort_candidate(&match_place, &test, candidate) else { break; @@ -1719,7 +1671,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { target_candidates[idx].push(candidate); candidates = rest; } - // at least the first candidate ought to be tested + + // At least the first candidate ought to be tested assert!( total_candidate_count > candidates.len(), "{total_candidate_count}, {candidates:#?}" @@ -1727,16 +1680,130 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug!("tested_candidates: {}", total_candidate_count - candidates.len()); debug!("untested_candidates: {}", candidates.len()); + (candidates, target_candidates) + } + + /// This is the most subtle part of the match lowering algorithm. At this point, the input + /// candidates have been fully simplified, so all remaining match-pairs require some sort of + /// test. + /// + /// Once we pick what sort of test we are going to perform, this test will help us winnow down + /// our candidates. So we walk over the candidates (from high to low priority) and check. We + /// compute, for each outcome of the test, a transformed list of candidates. If a candidate + /// matches in a single branch of our test, we add it to the corresponding outcome. We also + /// transform it to record the fact that we know which outcome occurred. + /// + /// For example, if we are testing `x.0`'s variant, and we have a candidate `(x.0 @ Some(v), x.1 + /// @ 22)`, then we would have a resulting candidate of `((x.0 as Some).0 @ v, x.1 @ 22)` in the + /// branch corresponding to `Some`. To ensure we make progress, we always pick a test that + /// results in simplifying the first candidate. + /// + /// But there may also be candidates that the test doesn't + /// apply to. The classical example is wildcards: + /// + /// ``` + /// # let (x, y, z) = (true, true, true); + /// match (x, y, z) { + /// (true , _ , true ) => true, // (0) + /// (false, false, _ ) => false, // (1) + /// (_ , true , _ ) => true, // (2) + /// (true , _ , false) => false, // (3) + /// } + /// # ; + /// ``` + /// + /// Here, the traditional "decision tree" method would generate 2 separate code-paths for the 2 + /// possible values of `x`. This would however duplicate some candidates, which would need to be + /// lowered several times. + /// + /// In some cases, this duplication can create an exponential amount of + /// code. This is most easily seen by noticing that this method terminates + /// with precisely the reachable arms being reachable - but that problem + /// is trivially NP-complete: + /// + /// ```ignore (illustrative) + /// match (var0, var1, var2, var3, ...) { + /// (true , _ , _ , false, true, ...) => false, + /// (_ , true, true , false, _ , ...) => false, + /// (false, _ , false, false, _ , ...) => false, + /// ... + /// _ => true + /// } + /// ``` + /// + /// Here the last arm is reachable only if there is an assignment to + /// the variables that does not match any of the literals. Therefore, + /// compilation would take an exponential amount of time in some cases. + /// + /// In rustc, we opt instead for the "backtracking automaton" approach. This guarantees we never + /// duplicate a candidate (except in the presence of or-patterns). In fact this guarantee is + /// ensured by the fact that we carry around `&mut Candidate`s which can't be duplicated. + /// + /// To make this work, whenever we decide to perform a test, if we encounter a candidate that + /// could match in more than one branch of the test, we stop. We generate code for the test and + /// for the candidates in its branches; the remaining candidates will be tested if the + /// candidates in the branches fail to match. + /// + /// For example, if we test on `x` in the following: + /// ``` + /// # fn foo((x, y, z): (bool, bool, bool)) -> u32 { + /// match (x, y, z) { + /// (true , _ , true ) => 0, + /// (false, false, _ ) => 1, + /// (_ , true , _ ) => 2, + /// (true , _ , false) => 3, + /// } + /// # } + /// ``` + /// this function generates code that looks more of less like: + /// ``` + /// # fn foo((x, y, z): (bool, bool, bool)) -> u32 { + /// if x { + /// match (y, z) { + /// (_, true) => return 0, + /// _ => {} // continue matching + /// } + /// } else { + /// match (y, z) { + /// (false, _) => return 1, + /// _ => {} // continue matching + /// } + /// } + /// // the block here is `remainder_start` + /// match (x, y, z) { + /// (_ , true , _ ) => 2, + /// (true , _ , false) => 3, + /// _ => unreachable!(), + /// } + /// # } + /// ``` + fn test_candidates<'pat, 'b, 'c>( + &mut self, + span: Span, + scrutinee_span: Span, + candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], + start_block: BasicBlock, + otherwise_block: BasicBlock, + fake_borrows: &mut Option>>, + ) { + // Extract the match-pair from the highest priority candidate and build a test from it. + let (match_place, test) = self.pick_test(candidates, fake_borrows); + + // For each of the N possible test outcomes, build the vector of candidates that applies if + // the test has that particular outcome. + let (remaining_candidates, target_candidates) = + self.sort_candidates(&match_place, &test, candidates); + // The block that we should branch to if none of the // `target_candidates` match. - let remainder_start = if !candidates.is_empty() { + let remainder_start = if !remaining_candidates.is_empty() { let remainder_start = self.cfg.start_new_block(); self.match_candidates( span, scrutinee_span, remainder_start, otherwise_block, - candidates, + remaining_candidates, fake_borrows, ); remainder_start From aa99d954faae0446664f82b0c3c597664845ca90 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Wed, 21 Feb 2024 08:40:02 -0300 Subject: [PATCH 184/417] Test windows random shims --- .../miri/tests/pass/shims/windows-rand.rs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/tools/miri/tests/pass/shims/windows-rand.rs diff --git a/src/tools/miri/tests/pass/shims/windows-rand.rs b/src/tools/miri/tests/pass/shims/windows-rand.rs new file mode 100644 index 0000000000000..e2bcb7bd7cb77 --- /dev/null +++ b/src/tools/miri/tests/pass/shims/windows-rand.rs @@ -0,0 +1,41 @@ +//@only-target-windows: this directly tests windows only random functions +use core::ffi::c_void; +use core::mem::size_of_val; +use core::ptr::null_mut; + +// Windows API definitions. +type NTSTATUS = i32; +type BOOLEAN = u8; +const BCRYPT_USE_SYSTEM_PREFERRED_RNG: u32 = 0x00000002; +const BCRYPT_RNG_ALG_HANDLE: *mut c_void = 0x81 as *mut c_void; +#[link(name = "bcrypt")] +extern "system" { + fn BCryptGenRandom( + halgorithm: *mut c_void, + pbbuffer: *mut u8, + cbbuffer: u32, + dwflags: u32, + ) -> NTSTATUS; +} +#[link(name = "advapi32")] +extern "system" { + #[link_name = "SystemFunction036"] + fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: u32) -> BOOLEAN; +} + +fn main() { + let mut key = [0u8; 24]; + let len: u32 = size_of_val(&key).try_into().unwrap(); + let ret = unsafe { + BCryptGenRandom(null_mut(), key.as_mut_ptr(), len, BCRYPT_USE_SYSTEM_PREFERRED_RNG) + }; + // NTSTATUS codes use the high bit to indicate an error + assert!(ret >= 0); + + let ret = unsafe { BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, key.as_mut_ptr(), len, 0) }; + assert!(ret >= 0); + + let ret = unsafe { RtlGenRandom(key.as_mut_ptr(), len) }; + // RtlGenRandom returns a BOOLEAN where 0 indicates an error + assert_ne!(ret, 0); +} From aa8a82ec269a34d9bed7919ba8926c8551efdbeb Mon Sep 17 00:00:00 2001 From: "taiga.watanabe" Date: Tue, 20 Feb 2024 14:25:56 +0900 Subject: [PATCH 185/417] FIX: issue-12279 ---- UPDATE: add async block into test. FIX: no_effect Fixed asynchronous function parameter names with underscores so that warnings are not displayed when underscores are added to parameter names ADD: test case --- clippy_lints/src/no_effect.rs | 5 +-- tests/ui/no_effect_async_fn.rs | 50 ++++++++++++++++++++++++++++++ tests/ui/no_effect_async_fn.stderr | 29 +++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tests/ui/no_effect_async_fn.rs create mode 100644 tests/ui/no_effect_async_fn.stderr diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 580160efeb701..6adb5098ed347 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -5,8 +5,8 @@ use clippy_utils::{any_parent_is_automatically_derived, get_parent_node, is_lint use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{ - is_range_literal, BinOpKind, BlockCheckMode, Expr, ExprKind, HirId, HirIdMap, ItemKind, Node, PatKind, Stmt, - StmtKind, UnsafeSource, + is_range_literal, BinOpKind, BlockCheckMode, Expr, ExprKind, HirId, HirIdMap, ItemKind, LocalSource, Node, PatKind, + Stmt, StmtKind, UnsafeSource, }; use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -178,6 +178,7 @@ impl NoEffect { } } else if let StmtKind::Local(local) = stmt.kind { if !is_lint_allowed(cx, NO_EFFECT_UNDERSCORE_BINDING, local.hir_id) + && !matches!(local.source, LocalSource::AsyncFn) && let Some(init) = local.init && local.els.is_none() && !local.pat.span.from_expansion() diff --git a/tests/ui/no_effect_async_fn.rs b/tests/ui/no_effect_async_fn.rs new file mode 100644 index 0000000000000..ef0f3d1df1acc --- /dev/null +++ b/tests/ui/no_effect_async_fn.rs @@ -0,0 +1,50 @@ +#![warn(clippy::no_effect_underscore_binding)] +#![no_main] + +trait AsyncTrait { + async fn bar(i: u64); +} + +struct Bar; + +impl AsyncTrait for Bar { + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + async fn bar(_i: u64) { + let _a = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _b = num(); + + let _ = async { + let _c = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _d = num(); + } + .await; + } +} + +// Shouldn't lint `binding to `_` prefixed variable with no side-effect` +async fn foo(_i: u64) { + let _a = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _b = num(); + + let _ = async { + let _c = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _d = num(); + } + .await; +} + +fn num() -> usize { + 0 +} diff --git a/tests/ui/no_effect_async_fn.stderr b/tests/ui/no_effect_async_fn.stderr new file mode 100644 index 0000000000000..2325eb9aae592 --- /dev/null +++ b/tests/ui/no_effect_async_fn.stderr @@ -0,0 +1,29 @@ +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:20:17 + | +LL | let _c = 0; + | ^^ + | + = note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]` + +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:13:13 + | +LL | let _a = 0; + | ^^ + +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:39:13 + | +LL | let _c = 0; + | ^^ + +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:32:9 + | +LL | let _a = 0; + | ^^ + +error: aborting due to 4 previous errors + From 672bd5e3876290185e1e1b421ff0f0d50ea1e568 Mon Sep 17 00:00:00 2001 From: "taiga.watanabe" Date: Wed, 21 Feb 2024 10:42:45 +0900 Subject: [PATCH 186/417] DELETE: Known problems Section The `Known problems` section was removed because it is old information. --- clippy_lints/src/no_effect.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 6adb5098ed347..1b4e1ed066b47 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -43,10 +43,6 @@ declare_clippy_lint! { /// executed. However, as they have no effect and shouldn't be used further on, all they /// do is make the code less readable. /// - /// ### Known problems - /// Further usage of this variable is not checked, which can lead to false positives if it is - /// used later in the code. - /// /// ### Example /// ```rust,ignore /// let _i_serve_no_purpose = 1; From 9cde201ba1c4ca23fb3d1776969b58b2e8d8997e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Feb 2024 17:53:06 +0100 Subject: [PATCH 187/417] Extend `unnecessary_to_owned` to handle `Borrow` trait in map types --- .../src/methods/unnecessary_to_owned.rs | 98 ++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs index 64fcd9f8f459a..c234e4f9b110c 100644 --- a/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -3,7 +3,9 @@ use super::unnecessary_iter_cloned::{self, is_into_iter}; use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; -use clippy_utils::ty::{get_iterator_item_ty, implements_trait, is_copy, is_type_lang_item, peel_mid_ty_refs}; +use clippy_utils::ty::{ + get_iterator_item_ty, implements_trait, is_copy, is_type_diagnostic_item, is_type_lang_item, peel_mid_ty_refs, +}; use clippy_utils::visitors::find_all_ret_expressions; use clippy_utils::{fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, return_ty}; use rustc_errors::Applicability; @@ -16,7 +18,8 @@ use rustc_lint::LateContext; use rustc_middle::mir::Mutability; use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref}; use rustc_middle::ty::{ - self, ClauseKind, GenericArg, GenericArgKind, GenericArgsRef, ParamTy, ProjectionPredicate, TraitPredicate, Ty, + self, ClauseKind, GenericArg, GenericArgKind, GenericArgsRef, ImplPolarity, ParamTy, ProjectionPredicate, + TraitPredicate, Ty, }; use rustc_span::{sym, Symbol}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; @@ -53,6 +56,8 @@ pub fn check<'tcx>( } check_other_call_arg(cx, expr, method_name, receiver); } + } else { + check_borrow_predicate(cx, expr); } } @@ -590,3 +595,92 @@ fn is_to_string_on_string_like<'a>( false } } + +fn is_a_std_map_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { + is_type_diagnostic_item(cx, ty, sym::HashSet) + || is_type_diagnostic_item(cx, ty, sym::HashMap) + || is_type_diagnostic_item(cx, ty, sym::BTreeMap) + || is_type_diagnostic_item(cx, ty, sym::BTreeSet) +} + +fn is_str_and_string(cx: &LateContext<'_>, arg_ty: Ty<'_>, original_arg_ty: Ty<'_>) -> bool { + original_arg_ty.is_str() && is_type_lang_item(cx, arg_ty, LangItem::String) +} + +fn is_slice_and_vec(cx: &LateContext<'_>, arg_ty: Ty<'_>, original_arg_ty: Ty<'_>) -> bool { + (original_arg_ty.is_slice() || original_arg_ty.is_array() || original_arg_ty.is_array_slice()) + && is_type_diagnostic_item(cx, arg_ty, sym::Vec) +} + +// This function will check the following: +// 1. The argument is a non-mutable reference. +// 2. It calls `to_owned()`, `to_string()` or `to_vec()`. +// 3. That the method is called on `String` or on `Vec` (only types supported for the moment). +fn check_if_applicable_to_argument<'tcx>(cx: &LateContext<'tcx>, arg: &Expr<'tcx>) { + if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, expr) = arg.kind + && let ExprKind::MethodCall(method_path, caller, &[], _) = expr.kind + && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) + && let method_name = method_path.ident.name.as_str() + && match method_name { + "to_owned" => cx.tcx.is_diagnostic_item(sym::to_owned_method, method_def_id), + "to_string" => cx.tcx.is_diagnostic_item(sym::to_string_method, method_def_id), + "to_vec" => cx + .tcx + .impl_of_method(method_def_id) + .filter(|&impl_did| cx.tcx.type_of(impl_did).instantiate_identity().is_slice()) + .is_some(), + _ => false, + } + && let original_arg_ty = cx.typeck_results().node_type(caller.hir_id).peel_refs() + && let arg_ty = cx.typeck_results().expr_ty(arg) + && let ty::Ref(_, arg_ty, Mutability::Not) = arg_ty.kind() + // FIXME: try to fix `can_change_type` to make it work in this case. + // && can_change_type(cx, caller, *arg_ty) + && let arg_ty = arg_ty.peel_refs() + // For now we limit this lint to `String` and `Vec`. + && (is_str_and_string(cx, arg_ty, original_arg_ty) || is_slice_and_vec(cx, arg_ty, original_arg_ty)) + && let Some(snippet) = snippet_opt(cx, caller.span) + { + span_lint_and_sugg( + cx, + UNNECESSARY_TO_OWNED, + arg.span, + &format!("unnecessary use of `{method_name}`"), + "replace it with", + if original_arg_ty.is_array() { + format!("{snippet}.as_slice()") + } else { + snippet + }, + Applicability::MaybeIncorrect, + ); + } +} + +// In std "map types", the getters all expect a `Borrow` generic argument. So in here, we +// check that: +// 1. This is a method with only one argument that doesn't come from a trait. +// 2. That it has `Borrow` in its generic predicates. +// 3. `Self` is a std "map type" (ie `HashSet`, `HashMap`, BTreeSet`, `BTreeMap`). +fn check_borrow_predicate<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) { + if let ExprKind::MethodCall(_, caller, &[arg], _) = expr.kind + && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) + && cx.tcx.trait_of_item(method_def_id).is_none() + && let Some(borrow_id) = cx.tcx.get_diagnostic_item(sym::Borrow) + && cx.tcx.predicates_of(method_def_id).predicates.iter().any(|(pred, _)| { + if let ClauseKind::Trait(trait_pred) = pred.kind().skip_binder() + && trait_pred.polarity == ImplPolarity::Positive + && trait_pred.trait_ref.def_id == borrow_id + { + true + } else { + false + } + }) + && let caller_ty = cx.typeck_results().expr_ty(caller) + // For now we limit it to "map types". + && is_a_std_map_type(cx, caller_ty) + { + check_if_applicable_to_argument(cx, &arg); + } +} From d28146133cfc11d9dfe6a082881c7242061275dc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Feb 2024 17:53:19 +0100 Subject: [PATCH 188/417] Add more ui tests for `unnecessary_to_owned` --- tests/ui/unnecessary_to_owned.fixed | 36 ++++++++++++++++++++++++++++ tests/ui/unnecessary_to_owned.rs | 36 ++++++++++++++++++++++++++++ tests/ui/unnecessary_to_owned.stderr | 32 ++++++++++++++++++++++++- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/tests/ui/unnecessary_to_owned.fixed b/tests/ui/unnecessary_to_owned.fixed index 7f01c981a9380..1afa5ab54c461 100644 --- a/tests/ui/unnecessary_to_owned.fixed +++ b/tests/ui/unnecessary_to_owned.fixed @@ -530,3 +530,39 @@ mod issue_11952 { IntoFuture::into_future(foo([], &0)); } } + +fn borrow_checks() { + use std::borrow::Borrow; + use std::collections::HashSet; + + fn inner(a: &[&str]) { + let mut s = HashSet::from([vec!["a"]]); + s.remove(a); //~ ERROR: unnecessary use of `to_vec` + } + + let mut s = HashSet::from(["a".to_string()]); + s.remove("b"); //~ ERROR: unnecessary use of `to_owned` + s.remove("b"); //~ ERROR: unnecessary use of `to_string` + // Should not warn. + s.remove("b"); + + let mut s = HashSet::from([vec!["a"]]); + s.remove(["b"].as_slice()); //~ ERROR: unnecessary use of `to_vec` + s.remove((&["b"]).as_slice()); //~ ERROR: unnecessary use of `to_vec` + + // Should not warn. + s.remove(&["b"].to_vec().clone()); + s.remove(["a"].as_slice()); + + trait SetExt { + fn foo>(&self, _: &String); + } + + impl SetExt for HashSet { + fn foo>(&self, _: &String) {} + } + + // Should not lint! + HashSet::::new().foo::<&str>(&"".to_owned()); + HashSet::::new().get(&1.to_string()); +} diff --git a/tests/ui/unnecessary_to_owned.rs b/tests/ui/unnecessary_to_owned.rs index a270ed1e1c21e..aa88dde43bf66 100644 --- a/tests/ui/unnecessary_to_owned.rs +++ b/tests/ui/unnecessary_to_owned.rs @@ -530,3 +530,39 @@ mod issue_11952 { IntoFuture::into_future(foo([].to_vec(), &0)); } } + +fn borrow_checks() { + use std::borrow::Borrow; + use std::collections::HashSet; + + fn inner(a: &[&str]) { + let mut s = HashSet::from([vec!["a"]]); + s.remove(&a.to_vec()); //~ ERROR: unnecessary use of `to_vec` + } + + let mut s = HashSet::from(["a".to_string()]); + s.remove(&"b".to_owned()); //~ ERROR: unnecessary use of `to_owned` + s.remove(&"b".to_string()); //~ ERROR: unnecessary use of `to_string` + // Should not warn. + s.remove("b"); + + let mut s = HashSet::from([vec!["a"]]); + s.remove(&["b"].to_vec()); //~ ERROR: unnecessary use of `to_vec` + s.remove(&(&["b"]).to_vec()); //~ ERROR: unnecessary use of `to_vec` + + // Should not warn. + s.remove(&["b"].to_vec().clone()); + s.remove(["a"].as_slice()); + + trait SetExt { + fn foo>(&self, _: &String); + } + + impl SetExt for HashSet { + fn foo>(&self, _: &String) {} + } + + // Should not lint! + HashSet::::new().foo::<&str>(&"".to_owned()); + HashSet::::new().get(&1.to_string()); +} diff --git a/tests/ui/unnecessary_to_owned.stderr b/tests/ui/unnecessary_to_owned.stderr index d4199f8a30a70..5475df9c7b936 100644 --- a/tests/ui/unnecessary_to_owned.stderr +++ b/tests/ui/unnecessary_to_owned.stderr @@ -523,5 +523,35 @@ error: unnecessary use of `to_vec` LL | IntoFuture::into_future(foo([].to_vec(), &0)); | ^^^^^^^^^^^ help: use: `[]` -error: aborting due to 80 previous errors +error: unnecessary use of `to_vec` + --> tests/ui/unnecessary_to_owned.rs:540:18 + | +LL | s.remove(&a.to_vec()); + | ^^^^^^^^^^^ help: replace it with: `a` + +error: unnecessary use of `to_owned` + --> tests/ui/unnecessary_to_owned.rs:544:14 + | +LL | s.remove(&"b".to_owned()); + | ^^^^^^^^^^^^^^^ help: replace it with: `"b"` + +error: unnecessary use of `to_string` + --> tests/ui/unnecessary_to_owned.rs:545:14 + | +LL | s.remove(&"b".to_string()); + | ^^^^^^^^^^^^^^^^ help: replace it with: `"b"` + +error: unnecessary use of `to_vec` + --> tests/ui/unnecessary_to_owned.rs:550:14 + | +LL | s.remove(&["b"].to_vec()); + | ^^^^^^^^^^^^^^^ help: replace it with: `["b"].as_slice()` + +error: unnecessary use of `to_vec` + --> tests/ui/unnecessary_to_owned.rs:551:14 + | +LL | s.remove(&(&["b"]).to_vec()); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `(&["b"]).as_slice()` + +error: aborting due to 85 previous errors From 635acb6804ac5e944ca86375c05c262c582163e7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Feb 2024 17:58:23 +0100 Subject: [PATCH 189/417] Fix newly detected lint issues --- clippy_config/src/conf.rs | 2 +- clippy_lints/src/min_ident_chars.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs index 6a1d7cb852a2a..b781259ad9695 100644 --- a/clippy_config/src/conf.rs +++ b/clippy_config/src/conf.rs @@ -648,7 +648,7 @@ fn deserialize(file: &SourceFile) -> TryConf { extend_vec_if_indicator_present(&mut conf.conf.doc_valid_idents, DEFAULT_DOC_VALID_IDENTS); extend_vec_if_indicator_present(&mut conf.conf.disallowed_names, DEFAULT_DISALLOWED_NAMES); // TODO: THIS SHOULD BE TESTED, this comment will be gone soon - if conf.conf.allowed_idents_below_min_chars.contains(&"..".to_owned()) { + if conf.conf.allowed_idents_below_min_chars.contains("..") { conf.conf .allowed_idents_below_min_chars .extend(DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS.iter().map(ToString::to_string)); diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index ec07f283c468a..31bc59fe9409d 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -53,7 +53,7 @@ impl MinIdentChars { && str.len() <= self.min_ident_chars_threshold as usize && !str.starts_with('_') && !str.is_empty() - && self.allowed_idents_below_min_chars.get(&str.to_owned()).is_none() + && !self.allowed_idents_below_min_chars.contains(str) } } From 6edbc8d875987b25c7bc64c6c903611841645e5f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 21 Feb 2024 19:05:45 +0000 Subject: [PATCH 190/417] Prevent cycle in implied predicates computation --- .../src/collect/predicates_of.rs | 30 ++++++++++++++----- .../implied-bounds-cycle.rs | 10 +++++++ .../implied-bounds-cycle.stderr | 17 +++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 tests/ui/associated-type-bounds/implied-bounds-cycle.rs create mode 100644 tests/ui/associated-type-bounds/implied-bounds-cycle.stderr diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 351ac2eb7702e..f70bb8c4289f6 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -640,16 +640,30 @@ pub(super) fn implied_predicates_with_filter( // Now require that immediate supertraits are converted, which will, in // turn, reach indirect supertraits, so we detect cycles now instead of - // overflowing during elaboration. - if matches!(filter, PredicateFilter::SelfOnly) { - for &(pred, span) in implied_bounds { - debug!("superbound: {:?}", pred); - if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() - && bound.polarity == ty::ImplPolarity::Positive - { - tcx.at(span).super_predicates_of(bound.def_id()); + // overflowing during elaboration. Same for implied predicates, which + // make sure we walk into associated type bounds. + match filter { + PredicateFilter::SelfOnly => { + for &(pred, span) in implied_bounds { + debug!("superbound: {:?}", pred); + if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() + && bound.polarity == ty::ImplPolarity::Positive + { + tcx.at(span).super_predicates_of(bound.def_id()); + } + } + } + PredicateFilter::SelfAndAssociatedTypeBounds => { + for &(pred, span) in implied_bounds { + debug!("superbound: {:?}", pred); + if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() + && bound.polarity == ty::ImplPolarity::Positive + { + tcx.at(span).implied_predicates_of(bound.def_id()); + } } } + _ => {} } ty::GenericPredicates { parent: None, predicates: implied_bounds } diff --git a/tests/ui/associated-type-bounds/implied-bounds-cycle.rs b/tests/ui/associated-type-bounds/implied-bounds-cycle.rs new file mode 100644 index 0000000000000..785d47d479148 --- /dev/null +++ b/tests/ui/associated-type-bounds/implied-bounds-cycle.rs @@ -0,0 +1,10 @@ +#![feature(associated_type_bounds)] + +trait A { + type T; +} + +trait B: A {} +//~^ ERROR cycle detected when computing the implied predicates of `B` + +fn main() {} diff --git a/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr b/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr new file mode 100644 index 0000000000000..1c1c64ea5f5ec --- /dev/null +++ b/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr @@ -0,0 +1,17 @@ +error[E0391]: cycle detected when computing the implied predicates of `B` + --> $DIR/implied-bounds-cycle.rs:7:15 + | +LL | trait B: A {} + | ^ + | + = note: ...which immediately requires computing the implied predicates of `B` again +note: cycle used when computing normalized predicates of `B` + --> $DIR/implied-bounds-cycle.rs:7:1 + | +LL | trait B: A {} + | ^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. From 85bf4439e614f2971523e380b69bb3be4c995894 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 5 Jan 2024 21:22:42 +0000 Subject: [PATCH 191/417] os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`. allows for socket to process only when there is data to process, the option sets a number of seconds until the data is ready. --- library/std/src/os/net/linux_ext/tcp.rs | 55 +++++++++++++++++++++++ library/std/src/os/net/linux_ext/tests.rs | 26 +++++++++++ library/std/src/sys/pal/unix/net.rs | 12 +++++ 3 files changed, 93 insertions(+) diff --git a/library/std/src/os/net/linux_ext/tcp.rs b/library/std/src/os/net/linux_ext/tcp.rs index 5e9ee65a4152e..ff29afe7ed311 100644 --- a/library/std/src/os/net/linux_ext/tcp.rs +++ b/library/std/src/os/net/linux_ext/tcp.rs @@ -53,6 +53,51 @@ pub trait TcpStreamExt: Sealed { /// ``` #[unstable(feature = "tcp_quickack", issue = "96256")] fn quickack(&self) -> io::Result; + + /// A socket listener will be awakened solely when data arrives. + /// + /// The `accept` argument set the delay in seconds until the + /// data is available to read, reducing the number of short lived + /// connections without data to process. + /// Contrary to other platforms `SO_ACCEPTFILTER` feature equivalent, there is + /// no necessity to set it after the `listen` call. + /// + /// See [`man 7 tcp`](https://man7.org/linux/man-pages/man7/tcp.7.html) + /// + /// # Examples + /// + /// ```no run + /// #![feature(tcp_deferaccept)] + /// use std::net::TcpStream; + /// use std::os::linux::net::TcpStreamExt; + /// + /// let stream = TcpStream::connect("127.0.0.1:8080") + /// .expect("Couldn't connect to the server..."); + /// stream.set_deferaccept(1).expect("set_deferaccept call failed"); + /// ``` + #[unstable(feature = "tcp_deferaccept", issue = "119639")] + #[cfg(target_os = "linux")] + fn set_deferaccept(&self, accept: u32) -> io::Result<()>; + + /// Gets the accept delay value (in seconds) of the `TCP_DEFER_ACCEPT` option. + /// + /// For more information about this option, see [`TcpStreamExt::set_deferaccept`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(tcp_deferaccept)] + /// use std::net::TcpStream; + /// use std::os::linux::net::TcpStreamExt; + /// + /// let stream = TcpStream::connect("127.0.0.1:8080") + /// .expect("Couldn't connect to the server..."); + /// stream.set_deferaccept(1).expect("set_deferaccept call failed"); + /// assert_eq!(stream.deferaccept().unwrap_or(0), 1); + /// ``` + #[unstable(feature = "tcp_deferaccept", issue = "119639")] + #[cfg(target_os = "linux")] + fn deferaccept(&self) -> io::Result; } #[unstable(feature = "tcp_quickack", issue = "96256")] @@ -67,4 +112,14 @@ impl TcpStreamExt for net::TcpStream { fn quickack(&self) -> io::Result { self.as_inner().as_inner().quickack() } + + #[cfg(target_os = "linux")] + fn set_deferaccept(&self, accept: u32) -> io::Result<()> { + self.as_inner().as_inner().set_deferaccept(accept) + } + + #[cfg(target_os = "linux")] + fn deferaccept(&self) -> io::Result { + self.as_inner().as_inner().deferaccept() + } } diff --git a/library/std/src/os/net/linux_ext/tests.rs b/library/std/src/os/net/linux_ext/tests.rs index 2db4deed03630..f8dbbfc18e28e 100644 --- a/library/std/src/os/net/linux_ext/tests.rs +++ b/library/std/src/os/net/linux_ext/tests.rs @@ -26,3 +26,29 @@ fn quickack() { t!(stream.set_quickack(false)); assert_eq!(false, t!(stream.quickack())); } + +#[test] +#[cfg(target_os = "linux")] +fn deferaccept() { + use crate::{ + net::{test::next_test_ip4, TcpListener, TcpStream}, + os::net::linux_ext::tcp::TcpStreamExt, + }; + + macro_rules! t { + ($e:expr) => { + match $e { + Ok(t) => t, + Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), + } + }; + } + + let addr = next_test_ip4(); + let _listener = t!(TcpListener::bind(&addr)); + let stream = t!(TcpStream::connect(&("localhost", addr.port()))); + stream.set_deferaccept(1).expect("set_deferaccept failed"); + assert_eq!(stream.deferaccept().unwrap(), 1); + stream.set_deferaccept(0).expect("set_deferaccept failed"); + assert_eq!(stream.deferaccept().unwrap(), 0); +} diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs index 1b6a6bb2c5c77..54b74d3f35286 100644 --- a/library/std/src/sys/pal/unix/net.rs +++ b/library/std/src/sys/pal/unix/net.rs @@ -441,6 +441,18 @@ impl Socket { Ok(raw != 0) } + // bionic libc makes no use of this flag + #[cfg(target_os = "linux")] + pub fn set_deferaccept(&self, accept: u32) -> io::Result<()> { + setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, accept as c_int) + } + + #[cfg(target_os = "linux")] + pub fn deferaccept(&self) -> io::Result { + let raw: c_int = getsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT)?; + Ok(raw as u32) + } + #[cfg(any(target_os = "android", target_os = "linux",))] pub fn set_passcred(&self, passcred: bool) -> io::Result<()> { setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int) From b72996e3220d4a32f1d2bd40c3e0b8ae5d87d351 Mon Sep 17 00:00:00 2001 From: "Christopher B. Speir" Date: Tue, 20 Feb 2024 20:07:54 -0600 Subject: [PATCH 192/417] Add check for 'in_external_macro' and 'is_from_proc_macro' inside [infinite_loop] lint. --- clippy_lints/src/loops/infinite_loop.rs | 11 +++++--- tests/ui/infinite_loops.rs | 27 ++++++++++++++++++++ tests/ui/infinite_loops.stderr | 34 ++++++++++++------------- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/clippy_lints/src/loops/infinite_loop.rs b/clippy_lints/src/loops/infinite_loop.rs index 5e099f1e76f86..5b5bb88c17908 100644 --- a/clippy_lints/src/loops/infinite_loop.rs +++ b/clippy_lints/src/loops/infinite_loop.rs @@ -1,17 +1,18 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{fn_def_id, is_lint_allowed}; +use clippy_utils::{fn_def_id, is_from_proc_macro, is_lint_allowed}; use hir::intravisit::{walk_expr, Visitor}; use hir::{Expr, ExprKind, FnRetTy, FnSig, Node}; use rustc_ast::Label; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_lint::LateContext; +use rustc_lint::{LateContext, LintContext}; +use rustc_middle::lint::in_external_macro; use super::INFINITE_LOOP; pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, - expr: &Expr<'_>, + expr: &Expr<'tcx>, loop_block: &'tcx hir::Block<'_>, label: Option", - "../".repeat(len), + path, prim.as_sym() )?; needs_termination = true; From 30429f8ece19d701cff8f5c547c2069fbf651cfd Mon Sep 17 00:00:00 2001 From: Graeme Read Date: Sat, 24 Feb 2024 06:45:00 +0000 Subject: [PATCH 270/417] feat: Add short flag -V for consistency with other rust tooling --- crates/rust-analyzer/src/cli/flags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/cli/flags.rs b/crates/rust-analyzer/src/cli/flags.rs index 493e614dce682..3f68c5d053b7b 100644 --- a/crates/rust-analyzer/src/cli/flags.rs +++ b/crates/rust-analyzer/src/cli/flags.rs @@ -30,7 +30,7 @@ xflags::xflags! { default cmd lsp-server { /// Print version. - optional --version + optional -V, --version /// Dump a LSP config JSON schema. optional --print-config-schema From de4efa5e46d219f7622659c7a7551411520adf76 Mon Sep 17 00:00:00 2001 From: Guillaume Boisseau Date: Sat, 24 Feb 2024 09:17:26 +0100 Subject: [PATCH 271/417] Tweak debug!() call Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com> --- compiler/rustc_mir_build/src/build/matches/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index fab8f9d2254d9..60245a8c4b66c 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -1582,7 +1582,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let mut test = self.test(match_pair); let match_place = match_pair.place.clone(); - debug!("test_candidates: test={:?} match_pair={:?}", test, match_pair); + debug!(?test, ?match_pair); // Most of the time, the test to perform is simply a function of the main candidate; but for // a test like SwitchInt, we may want to add cases based on the candidates that are // available From ff930d4fed085dcff75c7b9df6af3a4e099d2f21 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 24 Feb 2024 09:46:18 +0100 Subject: [PATCH 272/417] compiler/rustc_target/src/spec/base/apple/tests.rs: Avoid unnecessary large move Fixes: $ MAGIC_EXTRA_RUSTFLAGS=-Zmove-size-limit=4096 ./x test compiler/rustc_target error: moving 6216 bytes --> compiler/rustc_target/src/spec/base/apple/tests.rs:17:19 | 17 | for target in all_sim_targets { | ^^^^^^^^^^^^^^^ value moved from here | = note: The current maximum size is 4096, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` = note: `-D large-assignments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(large_assignments)]` --- compiler/rustc_target/src/spec/base/apple/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs index f13058ebc82ad..097039d6c7382 100644 --- a/compiler/rustc_target/src/spec/base/apple/tests.rs +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -14,7 +14,7 @@ fn simulator_targets_set_abi() { aarch64_apple_watchos_sim::target(), ]; - for target in all_sim_targets { + for target in &all_sim_targets { assert_eq!(target.abi, "sim") } } From 55ee14005f7f5798c7cf4c99e2d127c389c23fa7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 24 Feb 2024 12:15:21 +0100 Subject: [PATCH 273/417] update stdarch --- library/stdarch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch b/library/stdarch index d5fab978fe1c2..56087ea170d87 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit d5fab978fe1c2f0043db0451e9f4857eeba17437 +Subproject commit 56087ea170d878a7a57b3a5725e0c00f5f5cad70 From f32095cd8d43de470c2d3daa5b3cb8f494cfa770 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 23 Feb 2024 18:00:51 +0100 Subject: [PATCH 274/417] promotion: don't promote int::MIN / -1 --- .../rustc_mir_transform/src/promote_consts.rs | 29 +- tests/ui/consts/promote-not.rs | 4 + tests/ui/consts/promote-not.stderr | 64 +++- tests/ui/consts/promotion.rs | 5 +- .../ui/lint/lint-overflowing-ops.noopt.stderr | 263 +++---------- tests/ui/lint/lint-overflowing-ops.opt.stderr | 359 +++--------------- ...lowing-ops.opt_with_overflow_checks.stderr | 263 +++---------- tests/ui/lint/lint-overflowing-ops.rs | 12 - 8 files changed, 265 insertions(+), 734 deletions(-) diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 577b8f2080fcd..2e11da4d585ef 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -482,17 +482,40 @@ impl<'tcx> Validator<'_, 'tcx> { match op { BinOp::Div | BinOp::Rem => { if lhs_ty.is_integral() { + let sz = lhs_ty.primitive_size(self.tcx); // Integer division: the RHS must be a non-zero const. - let const_val = match rhs { + let rhs_val = match rhs { Operand::Constant(c) => { - c.const_.try_eval_bits(self.tcx, self.param_env) + c.const_.try_eval_scalar_int(self.tcx, self.param_env) } _ => None, }; - match const_val { + match rhs_val.map(|x| x.try_to_uint(sz).unwrap()) { + // for the zero test, int vs uint does not matter Some(x) if x != 0 => {} // okay _ => return Err(Unpromotable), // value not known or 0 -- not okay } + // Furthermore, for signed divison, we also have to exclude `int::MIN / -1`. + if lhs_ty.is_signed() { + match rhs_val.map(|x| x.try_to_int(sz).unwrap()) { + Some(-1) | None => { + // The RHS is -1 or unknown, so we have to be careful. + // But is the LHS int::MIN? + let lhs_val = match lhs { + Operand::Constant(c) => c + .const_ + .try_eval_scalar_int(self.tcx, self.param_env), + _ => None, + }; + let lhs_min = sz.signed_int_min(); + match lhs_val.map(|x| x.try_to_int(sz).unwrap()) { + Some(x) if x != lhs_min => {} // okay + _ => return Err(Unpromotable), // value not known or int::MIN -- not okay + } + } + _ => {} + } + } } } // The remaining operations can never fail. diff --git a/tests/ui/consts/promote-not.rs b/tests/ui/consts/promote-not.rs index 907617052f119..47a06e8a72b71 100644 --- a/tests/ui/consts/promote-not.rs +++ b/tests/ui/consts/promote-not.rs @@ -49,6 +49,10 @@ fn main() { // No promotion of fallible operations. let _val: &'static _ = &(1/0); //~ ERROR temporary value dropped while borrowed let _val: &'static _ = &(1/(1-1)); //~ ERROR temporary value dropped while borrowed + let _val: &'static _ = &((1+1)/(1-1)); //~ ERROR temporary value dropped while borrowed + let _val: &'static _ = &(i32::MIN/-1); //~ ERROR temporary value dropped while borrowed + let _val: &'static _ = &(i32::MIN/(0-1)); //~ ERROR temporary value dropped while borrowed + let _val: &'static _ = &(-128i8/-1); //~ ERROR temporary value dropped while borrowed let _val: &'static _ = &(1%0); //~ ERROR temporary value dropped while borrowed let _val: &'static _ = &(1%(1-1)); //~ ERROR temporary value dropped while borrowed let _val: &'static _ = &([1,2,3][4]+1); //~ ERROR temporary value dropped while borrowed diff --git a/tests/ui/consts/promote-not.stderr b/tests/ui/consts/promote-not.stderr index 524d69817217d..67ac5922efd96 100644 --- a/tests/ui/consts/promote-not.stderr +++ b/tests/ui/consts/promote-not.stderr @@ -105,6 +105,50 @@ LL | } error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:52:29 | +LL | let _val: &'static _ = &((1+1)/(1-1)); + | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote-not.rs:53:29 + | +LL | let _val: &'static _ = &(i32::MIN/-1); + | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote-not.rs:54:29 + | +LL | let _val: &'static _ = &(i32::MIN/(0-1)); + | ---------- ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote-not.rs:55:29 + | +LL | let _val: &'static _ = &(-128i8/-1); + | ---------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote-not.rs:56:29 + | LL | let _val: &'static _ = &(1%0); | ---------- ^^^^^ creates a temporary value which is freed while still in use | | @@ -114,7 +158,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:53:29 + --> $DIR/promote-not.rs:57:29 | LL | let _val: &'static _ = &(1%(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -125,7 +169,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:54:29 + --> $DIR/promote-not.rs:58:29 | LL | let _val: &'static _ = &([1,2,3][4]+1); | ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -136,7 +180,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:57:29 + --> $DIR/promote-not.rs:61:29 | LL | let _val: &'static _ = &TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -147,7 +191,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:59:29 + --> $DIR/promote-not.rs:63:29 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -158,7 +202,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:59:30 + --> $DIR/promote-not.rs:63:30 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -169,7 +213,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:62:29 + --> $DIR/promote-not.rs:66:29 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -180,7 +224,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:62:31 + --> $DIR/promote-not.rs:66:31 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -191,7 +235,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:65:29 + --> $DIR/promote-not.rs:69:29 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -202,7 +246,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:65:31 + --> $DIR/promote-not.rs:69:31 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement @@ -210,6 +254,6 @@ LL | let _val: &'static _ = &[&TEST_DROP; 1]; | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` -error: aborting due to 20 previous errors +error: aborting due to 24 previous errors For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/consts/promotion.rs b/tests/ui/consts/promotion.rs index 211dcf8a4e8f2..b18495a4a6bf5 100644 --- a/tests/ui/consts/promotion.rs +++ b/tests/ui/consts/promotion.rs @@ -28,8 +28,11 @@ fn main() { // make sure that this does not cause trouble despite overflowing assert_static(&(0-1)); - // div-by-non-0 is okay + // div-by-non-0 (and also not MIN/-1) is okay assert_static(&(1/1)); + assert_static(&(0/1)); + assert_static(&(1/-1)); + assert_static(&(i32::MIN/1)); assert_static(&(1%1)); // in-bounds array access is okay diff --git a/tests/ui/lint/lint-overflowing-ops.noopt.stderr b/tests/ui/lint/lint-overflowing-ops.noopt.stderr index f89ee8569c66f..1b7b73cec38d5 100644 --- a/tests/ui/lint/lint-overflowing-ops.noopt.stderr +++ b/tests/ui/lint/lint-overflowing-ops.noopt.stderr @@ -876,498 +876,353 @@ error: this operation will panic at runtime LL | let _n = &(i8::MIN / -1); | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:251:15 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:251:14 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:254:14 + --> $DIR/lint-overflowing-ops.rs:253:14 | LL | let _n = 1i16 / 0; | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:255:15 + --> $DIR/lint-overflowing-ops.rs:254:15 | LL | let _n = &(1i16 / 0); | ^^^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:256:14 + --> $DIR/lint-overflowing-ops.rs:255:14 | LL | let _n = i16::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:257:15 + --> $DIR/lint-overflowing-ops.rs:256:15 | LL | let _n = &(i16::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:257:15 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:257:14 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:260:14 + --> $DIR/lint-overflowing-ops.rs:258:14 | LL | let _n = 1i32 / 0; | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:261:15 + --> $DIR/lint-overflowing-ops.rs:259:15 | LL | let _n = &(1i32 / 0); | ^^^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:262:14 + --> $DIR/lint-overflowing-ops.rs:260:14 | LL | let _n = i32::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:263:15 + --> $DIR/lint-overflowing-ops.rs:261:15 | LL | let _n = &(i32::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:263:15 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:263:14 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:266:14 + --> $DIR/lint-overflowing-ops.rs:263:14 | LL | let _n = 1i64 / 0; | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:267:15 + --> $DIR/lint-overflowing-ops.rs:264:15 | LL | let _n = &(1i64 / 0); | ^^^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:265:14 | LL | let _n = i64::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:269:15 + --> $DIR/lint-overflowing-ops.rs:266:15 | LL | let _n = &(i64::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:269:15 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:269:14 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:272:14 + --> $DIR/lint-overflowing-ops.rs:268:14 | LL | let _n = 1i128 / 0; | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:273:15 + --> $DIR/lint-overflowing-ops.rs:269:15 | LL | let _n = &(1i128 / 0); | ^^^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:274:14 + --> $DIR/lint-overflowing-ops.rs:270:14 | LL | let _n = i128::MIN / -1; | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:275:15 + --> $DIR/lint-overflowing-ops.rs:271:15 | LL | let _n = &(i128::MIN / -1); | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:275:15 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:275:14 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:278:14 + --> $DIR/lint-overflowing-ops.rs:273:14 | LL | let _n = 1isize / 0; | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:279:15 + --> $DIR/lint-overflowing-ops.rs:274:15 | LL | let _n = &(1isize / 0); | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:280:14 + --> $DIR/lint-overflowing-ops.rs:275:14 | LL | let _n = isize::MIN / -1; | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:281:15 + --> $DIR/lint-overflowing-ops.rs:276:15 | LL | let _n = &(isize::MIN / -1); | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:281:15 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:281:14 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:286:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | LL | let _n = 1u8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:287:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | LL | let _n = &(1u8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:289:14 + --> $DIR/lint-overflowing-ops.rs:283:14 | LL | let _n = 1u16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:284:15 | LL | let _n = &(1u16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 + --> $DIR/lint-overflowing-ops.rs:286:14 | LL | let _n = 1u32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 + --> $DIR/lint-overflowing-ops.rs:287:15 | LL | let _n = &(1u32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:289:14 | LL | let _n = 1u64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:296:15 + --> $DIR/lint-overflowing-ops.rs:290:15 | LL | let _n = &(1u64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:292:14 | LL | let _n = 1u128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:293:15 | LL | let _n = &(1u128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 + --> $DIR/lint-overflowing-ops.rs:295:14 | LL | let _n = 1usize % 0; | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 + --> $DIR/lint-overflowing-ops.rs:296:15 | LL | let _n = &(1usize % 0); | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:304:14 + --> $DIR/lint-overflowing-ops.rs:298:14 | LL | let _n = 1i8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:305:15 + --> $DIR/lint-overflowing-ops.rs:299:15 | LL | let _n = &(1i8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:300:14 | LL | let _n = i8::MIN % -1; | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 + --> $DIR/lint-overflowing-ops.rs:301:15 | LL | let _n = &(i8::MIN % -1); | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:307:15 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:307:14 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:310:14 + --> $DIR/lint-overflowing-ops.rs:303:14 | LL | let _n = 1i16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:15 + --> $DIR/lint-overflowing-ops.rs:304:15 | LL | let _n = &(1i16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:312:14 + --> $DIR/lint-overflowing-ops.rs:305:14 | LL | let _n = i16::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:15 + --> $DIR/lint-overflowing-ops.rs:306:15 | LL | let _n = &(i16::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:313:15 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:313:14 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:316:14 + --> $DIR/lint-overflowing-ops.rs:308:14 | LL | let _n = 1i32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:15 + --> $DIR/lint-overflowing-ops.rs:309:15 | LL | let _n = &(1i32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:318:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | LL | let _n = i32::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | LL | let _n = &(i32::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:319:15 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:319:14 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:322:14 + --> $DIR/lint-overflowing-ops.rs:313:14 | LL | let _n = 1i64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:15 + --> $DIR/lint-overflowing-ops.rs:314:15 | LL | let _n = &(1i64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:324:14 + --> $DIR/lint-overflowing-ops.rs:315:14 | LL | let _n = i64::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:15 + --> $DIR/lint-overflowing-ops.rs:316:15 | LL | let _n = &(i64::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:325:15 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:325:14 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:328:14 + --> $DIR/lint-overflowing-ops.rs:318:14 | LL | let _n = 1i128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:15 + --> $DIR/lint-overflowing-ops.rs:319:15 | LL | let _n = &(1i128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:330:14 + --> $DIR/lint-overflowing-ops.rs:320:14 | LL | let _n = i128::MIN % -1; | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:15 + --> $DIR/lint-overflowing-ops.rs:321:15 | LL | let _n = &(i128::MIN % -1); | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:331:15 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:331:14 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:334:14 + --> $DIR/lint-overflowing-ops.rs:323:14 | LL | let _n = 1isize % 0; | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:15 + --> $DIR/lint-overflowing-ops.rs:324:15 | LL | let _n = &(1isize % 0); | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:336:14 + --> $DIR/lint-overflowing-ops.rs:325:14 | LL | let _n = isize::MIN % -1; | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:15 + --> $DIR/lint-overflowing-ops.rs:326:15 | LL | let _n = &(isize::MIN % -1); | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:337:15 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:337:14 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:14 + --> $DIR/lint-overflowing-ops.rs:329:14 | LL | let _n = [1, 2, 3][4]; | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:342:15 + --> $DIR/lint-overflowing-ops.rs:330:15 | LL | let _n = &([1, 2, 3][4]); | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 215 previous errors +error: aborting due to 203 previous errors -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.opt.stderr b/tests/ui/lint/lint-overflowing-ops.opt.stderr index 7ac5c4e0d76ff..1b7b73cec38d5 100644 --- a/tests/ui/lint/lint-overflowing-ops.opt.stderr +++ b/tests/ui/lint/lint-overflowing-ops.opt.stderr @@ -876,594 +876,353 @@ error: this operation will panic at runtime LL | let _n = &(i8::MIN / -1); | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:251:15 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:251:14 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:251:14 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:254:14 + --> $DIR/lint-overflowing-ops.rs:253:14 | LL | let _n = 1i16 / 0; | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:255:15 + --> $DIR/lint-overflowing-ops.rs:254:15 | LL | let _n = &(1i16 / 0); | ^^^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:256:14 + --> $DIR/lint-overflowing-ops.rs:255:14 | LL | let _n = i16::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:257:15 + --> $DIR/lint-overflowing-ops.rs:256:15 | LL | let _n = &(i16::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:257:15 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:257:14 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:257:14 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:260:14 + --> $DIR/lint-overflowing-ops.rs:258:14 | LL | let _n = 1i32 / 0; | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:261:15 + --> $DIR/lint-overflowing-ops.rs:259:15 | LL | let _n = &(1i32 / 0); | ^^^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:262:14 + --> $DIR/lint-overflowing-ops.rs:260:14 | LL | let _n = i32::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:263:15 + --> $DIR/lint-overflowing-ops.rs:261:15 | LL | let _n = &(i32::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:263:15 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:263:14 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:263:14 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:266:14 + --> $DIR/lint-overflowing-ops.rs:263:14 | LL | let _n = 1i64 / 0; | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:267:15 + --> $DIR/lint-overflowing-ops.rs:264:15 | LL | let _n = &(1i64 / 0); | ^^^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:265:14 | LL | let _n = i64::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:269:15 + --> $DIR/lint-overflowing-ops.rs:266:15 | LL | let _n = &(i64::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:269:15 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:269:14 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:269:14 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:272:14 + --> $DIR/lint-overflowing-ops.rs:268:14 | LL | let _n = 1i128 / 0; | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:273:15 + --> $DIR/lint-overflowing-ops.rs:269:15 | LL | let _n = &(1i128 / 0); | ^^^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:274:14 + --> $DIR/lint-overflowing-ops.rs:270:14 | LL | let _n = i128::MIN / -1; | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:275:15 + --> $DIR/lint-overflowing-ops.rs:271:15 | LL | let _n = &(i128::MIN / -1); | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:275:15 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:275:14 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:275:14 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:278:14 + --> $DIR/lint-overflowing-ops.rs:273:14 | LL | let _n = 1isize / 0; | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:279:15 + --> $DIR/lint-overflowing-ops.rs:274:15 | LL | let _n = &(1isize / 0); | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:280:14 + --> $DIR/lint-overflowing-ops.rs:275:14 | LL | let _n = isize::MIN / -1; | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:281:15 + --> $DIR/lint-overflowing-ops.rs:276:15 | LL | let _n = &(isize::MIN / -1); | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:281:15 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:281:14 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:281:14 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:286:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | LL | let _n = 1u8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:287:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | LL | let _n = &(1u8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:289:14 + --> $DIR/lint-overflowing-ops.rs:283:14 | LL | let _n = 1u16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:284:15 | LL | let _n = &(1u16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 + --> $DIR/lint-overflowing-ops.rs:286:14 | LL | let _n = 1u32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 + --> $DIR/lint-overflowing-ops.rs:287:15 | LL | let _n = &(1u32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:289:14 | LL | let _n = 1u64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:296:15 + --> $DIR/lint-overflowing-ops.rs:290:15 | LL | let _n = &(1u64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:292:14 | LL | let _n = 1u128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:293:15 | LL | let _n = &(1u128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 + --> $DIR/lint-overflowing-ops.rs:295:14 | LL | let _n = 1usize % 0; | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 + --> $DIR/lint-overflowing-ops.rs:296:15 | LL | let _n = &(1usize % 0); | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:304:14 + --> $DIR/lint-overflowing-ops.rs:298:14 | LL | let _n = 1i8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:305:15 + --> $DIR/lint-overflowing-ops.rs:299:15 | LL | let _n = &(1i8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:300:14 | LL | let _n = i8::MIN % -1; | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 + --> $DIR/lint-overflowing-ops.rs:301:15 | LL | let _n = &(i8::MIN % -1); | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:307:15 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:307:14 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:307:14 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:310:14 + --> $DIR/lint-overflowing-ops.rs:303:14 | LL | let _n = 1i16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:15 + --> $DIR/lint-overflowing-ops.rs:304:15 | LL | let _n = &(1i16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:312:14 + --> $DIR/lint-overflowing-ops.rs:305:14 | LL | let _n = i16::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:15 + --> $DIR/lint-overflowing-ops.rs:306:15 | LL | let _n = &(i16::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:313:15 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:313:14 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:313:14 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:316:14 + --> $DIR/lint-overflowing-ops.rs:308:14 | LL | let _n = 1i32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:15 + --> $DIR/lint-overflowing-ops.rs:309:15 | LL | let _n = &(1i32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:318:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | LL | let _n = i32::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | LL | let _n = &(i32::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:319:15 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:319:14 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:319:14 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:322:14 + --> $DIR/lint-overflowing-ops.rs:313:14 | LL | let _n = 1i64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:15 + --> $DIR/lint-overflowing-ops.rs:314:15 | LL | let _n = &(1i64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:324:14 + --> $DIR/lint-overflowing-ops.rs:315:14 | LL | let _n = i64::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:15 + --> $DIR/lint-overflowing-ops.rs:316:15 | LL | let _n = &(i64::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:325:15 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:325:14 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:325:14 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:328:14 + --> $DIR/lint-overflowing-ops.rs:318:14 | LL | let _n = 1i128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:15 + --> $DIR/lint-overflowing-ops.rs:319:15 | LL | let _n = &(1i128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:330:14 + --> $DIR/lint-overflowing-ops.rs:320:14 | LL | let _n = i128::MIN % -1; | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:15 + --> $DIR/lint-overflowing-ops.rs:321:15 | LL | let _n = &(i128::MIN % -1); | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:331:15 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:331:14 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:331:14 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:334:14 + --> $DIR/lint-overflowing-ops.rs:323:14 | LL | let _n = 1isize % 0; | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:15 + --> $DIR/lint-overflowing-ops.rs:324:15 | LL | let _n = &(1isize % 0); | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:336:14 + --> $DIR/lint-overflowing-ops.rs:325:14 | LL | let _n = isize::MIN % -1; | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:15 + --> $DIR/lint-overflowing-ops.rs:326:15 | LL | let _n = &(isize::MIN % -1); | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:337:15 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:337:14 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:337:14 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:14 + --> $DIR/lint-overflowing-ops.rs:329:14 | LL | let _n = [1, 2, 3][4]; | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:342:15 + --> $DIR/lint-overflowing-ops.rs:330:15 | LL | let _n = &([1, 2, 3][4]); | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 215 previous errors +error: aborting due to 203 previous errors -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr index f89ee8569c66f..1b7b73cec38d5 100644 --- a/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr +++ b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr @@ -876,498 +876,353 @@ error: this operation will panic at runtime LL | let _n = &(i8::MIN / -1); | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:251:15 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:251:14 - | -LL | let _n = &(i8::MIN / -1); - | ^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:254:14 + --> $DIR/lint-overflowing-ops.rs:253:14 | LL | let _n = 1i16 / 0; | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:255:15 + --> $DIR/lint-overflowing-ops.rs:254:15 | LL | let _n = &(1i16 / 0); | ^^^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:256:14 + --> $DIR/lint-overflowing-ops.rs:255:14 | LL | let _n = i16::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:257:15 + --> $DIR/lint-overflowing-ops.rs:256:15 | LL | let _n = &(i16::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:257:15 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:257:14 - | -LL | let _n = &(i16::MIN / -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:260:14 + --> $DIR/lint-overflowing-ops.rs:258:14 | LL | let _n = 1i32 / 0; | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:261:15 + --> $DIR/lint-overflowing-ops.rs:259:15 | LL | let _n = &(1i32 / 0); | ^^^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:262:14 + --> $DIR/lint-overflowing-ops.rs:260:14 | LL | let _n = i32::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:263:15 + --> $DIR/lint-overflowing-ops.rs:261:15 | LL | let _n = &(i32::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:263:15 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:263:14 - | -LL | let _n = &(i32::MIN / -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:266:14 + --> $DIR/lint-overflowing-ops.rs:263:14 | LL | let _n = 1i64 / 0; | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:267:15 + --> $DIR/lint-overflowing-ops.rs:264:15 | LL | let _n = &(1i64 / 0); | ^^^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:265:14 | LL | let _n = i64::MIN / -1; | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:269:15 + --> $DIR/lint-overflowing-ops.rs:266:15 | LL | let _n = &(i64::MIN / -1); | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:269:15 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:269:14 - | -LL | let _n = &(i64::MIN / -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:272:14 + --> $DIR/lint-overflowing-ops.rs:268:14 | LL | let _n = 1i128 / 0; | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:273:15 + --> $DIR/lint-overflowing-ops.rs:269:15 | LL | let _n = &(1i128 / 0); | ^^^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:274:14 + --> $DIR/lint-overflowing-ops.rs:270:14 | LL | let _n = i128::MIN / -1; | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:275:15 + --> $DIR/lint-overflowing-ops.rs:271:15 | LL | let _n = &(i128::MIN / -1); | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:275:15 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:275:14 - | -LL | let _n = &(i128::MIN / -1); - | ^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:278:14 + --> $DIR/lint-overflowing-ops.rs:273:14 | LL | let _n = 1isize / 0; | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:279:15 + --> $DIR/lint-overflowing-ops.rs:274:15 | LL | let _n = &(1isize / 0); | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:280:14 + --> $DIR/lint-overflowing-ops.rs:275:14 | LL | let _n = isize::MIN / -1; | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:281:15 + --> $DIR/lint-overflowing-ops.rs:276:15 | LL | let _n = &(isize::MIN / -1); | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:281:15 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:281:14 - | -LL | let _n = &(isize::MIN / -1); - | ^^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:286:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | LL | let _n = 1u8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:287:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | LL | let _n = &(1u8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:289:14 + --> $DIR/lint-overflowing-ops.rs:283:14 | LL | let _n = 1u16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:284:15 | LL | let _n = &(1u16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 + --> $DIR/lint-overflowing-ops.rs:286:14 | LL | let _n = 1u32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 + --> $DIR/lint-overflowing-ops.rs:287:15 | LL | let _n = &(1u32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:289:14 | LL | let _n = 1u64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:296:15 + --> $DIR/lint-overflowing-ops.rs:290:15 | LL | let _n = &(1u64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:292:14 | LL | let _n = 1u128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:293:15 | LL | let _n = &(1u128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 + --> $DIR/lint-overflowing-ops.rs:295:14 | LL | let _n = 1usize % 0; | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 + --> $DIR/lint-overflowing-ops.rs:296:15 | LL | let _n = &(1usize % 0); | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:304:14 + --> $DIR/lint-overflowing-ops.rs:298:14 | LL | let _n = 1i8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:305:15 + --> $DIR/lint-overflowing-ops.rs:299:15 | LL | let _n = &(1i8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:300:14 | LL | let _n = i8::MIN % -1; | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 + --> $DIR/lint-overflowing-ops.rs:301:15 | LL | let _n = &(i8::MIN % -1); | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:307:15 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:307:14 - | -LL | let _n = &(i8::MIN % -1); - | ^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:310:14 + --> $DIR/lint-overflowing-ops.rs:303:14 | LL | let _n = 1i16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:15 + --> $DIR/lint-overflowing-ops.rs:304:15 | LL | let _n = &(1i16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:312:14 + --> $DIR/lint-overflowing-ops.rs:305:14 | LL | let _n = i16::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:15 + --> $DIR/lint-overflowing-ops.rs:306:15 | LL | let _n = &(i16::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:313:15 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:313:14 - | -LL | let _n = &(i16::MIN % -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:316:14 + --> $DIR/lint-overflowing-ops.rs:308:14 | LL | let _n = 1i32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:15 + --> $DIR/lint-overflowing-ops.rs:309:15 | LL | let _n = &(1i32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:318:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | LL | let _n = i32::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | LL | let _n = &(i32::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:319:15 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:319:14 - | -LL | let _n = &(i32::MIN % -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:322:14 + --> $DIR/lint-overflowing-ops.rs:313:14 | LL | let _n = 1i64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:15 + --> $DIR/lint-overflowing-ops.rs:314:15 | LL | let _n = &(1i64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:324:14 + --> $DIR/lint-overflowing-ops.rs:315:14 | LL | let _n = i64::MIN % -1; | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:15 + --> $DIR/lint-overflowing-ops.rs:316:15 | LL | let _n = &(i64::MIN % -1); | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:325:15 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:325:14 - | -LL | let _n = &(i64::MIN % -1); - | ^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:328:14 + --> $DIR/lint-overflowing-ops.rs:318:14 | LL | let _n = 1i128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:15 + --> $DIR/lint-overflowing-ops.rs:319:15 | LL | let _n = &(1i128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:330:14 + --> $DIR/lint-overflowing-ops.rs:320:14 | LL | let _n = i128::MIN % -1; | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:15 + --> $DIR/lint-overflowing-ops.rs:321:15 | LL | let _n = &(i128::MIN % -1); | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:331:15 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:331:14 - | -LL | let _n = &(i128::MIN % -1); - | ^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:334:14 + --> $DIR/lint-overflowing-ops.rs:323:14 | LL | let _n = 1isize % 0; | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:15 + --> $DIR/lint-overflowing-ops.rs:324:15 | LL | let _n = &(1isize % 0); | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:336:14 + --> $DIR/lint-overflowing-ops.rs:325:14 | LL | let _n = isize::MIN % -1; | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:15 + --> $DIR/lint-overflowing-ops.rs:326:15 | LL | let _n = &(isize::MIN % -1); | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error[E0080]: evaluation of constant value failed - --> $DIR/lint-overflowing-ops.rs:337:15 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) - -note: erroneous constant encountered - --> $DIR/lint-overflowing-ops.rs:337:14 - | -LL | let _n = &(isize::MIN % -1); - | ^^^^^^^^^^^^^^^^^^ - error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:14 + --> $DIR/lint-overflowing-ops.rs:329:14 | LL | let _n = [1, 2, 3][4]; | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:342:15 + --> $DIR/lint-overflowing-ops.rs:330:15 | LL | let _n = &([1, 2, 3][4]); | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 215 previous errors +error: aborting due to 203 previous errors -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.rs b/tests/ui/lint/lint-overflowing-ops.rs index 4ef99f6c5fa18..3aadf77324377 100644 --- a/tests/ui/lint/lint-overflowing-ops.rs +++ b/tests/ui/lint/lint-overflowing-ops.rs @@ -249,37 +249,31 @@ fn main() { let _n = &(1i8 / 0); //~ ERROR: this operation will panic at runtime let _n = i8::MIN / -1; //~ ERROR: this operation will panic at runtime let _n = &(i8::MIN / -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i16 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i16 / 0); //~ ERROR: this operation will panic at runtime let _n = i16::MIN / -1; //~ ERROR: this operation will panic at runtime let _n = &(i16::MIN / -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i32 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i32 / 0); //~ ERROR: this operation will panic at runtime let _n = i32::MIN / -1; //~ ERROR: this operation will panic at runtime let _n = &(i32::MIN / -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i64 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i64 / 0); //~ ERROR: this operation will panic at runtime let _n = i64::MIN / -1; //~ ERROR: this operation will panic at runtime let _n = &(i64::MIN / -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i128 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i128 / 0); //~ ERROR: this operation will panic at runtime let _n = i128::MIN / -1; //~ ERROR: this operation will panic at runtime let _n = &(i128::MIN / -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1isize / 0; //~ ERROR: this operation will panic at runtime let _n = &(1isize / 0); //~ ERROR: this operation will panic at runtime let _n = isize::MIN / -1; //~ ERROR: this operation will panic at runtime let _n = &(isize::MIN / -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed // Modulus @@ -305,37 +299,31 @@ fn main() { let _n = &(1i8 % 0); //~ ERROR: this operation will panic at runtime let _n = i8::MIN % -1; //~ ERROR: this operation will panic at runtime let _n = &(i8::MIN % -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i16 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i16 % 0); //~ ERROR: this operation will panic at runtime let _n = i16::MIN % -1; //~ ERROR: this operation will panic at runtime let _n = &(i16::MIN % -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i32 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i32 % 0); //~ ERROR: this operation will panic at runtime let _n = i32::MIN % -1; //~ ERROR: this operation will panic at runtime let _n = &(i32::MIN % -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i64 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i64 % 0); //~ ERROR: this operation will panic at runtime let _n = i64::MIN % -1; //~ ERROR: this operation will panic at runtime let _n = &(i64::MIN % -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1i128 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i128 % 0); //~ ERROR: this operation will panic at runtime let _n = i128::MIN % -1; //~ ERROR: this operation will panic at runtime let _n = &(i128::MIN % -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed let _n = 1isize % 0; //~ ERROR: this operation will panic at runtime let _n = &(1isize % 0); //~ ERROR: this operation will panic at runtime let _n = isize::MIN % -1; //~ ERROR: this operation will panic at runtime let _n = &(isize::MIN % -1); //~ ERROR: this operation will panic at runtime - //~^ERROR: evaluation of constant value failed // Out of bounds access let _n = [1, 2, 3][4]; //~ ERROR: this operation will panic at runtime From ff187a92d84f352670a9a63e8519eac114456d38 Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Sat, 24 Feb 2024 16:02:17 +0300 Subject: [PATCH 275/417] library: use `addr_of!` --- library/alloc/src/boxed/thin.rs | 2 +- library/alloc/src/rc.rs | 4 ++-- library/alloc/src/sync.rs | 4 ++-- library/core/src/ffi/c_str.rs | 3 ++- library/core/src/iter/adapters/filter_map.rs | 6 +++--- library/core/src/ptr/mod.rs | 2 +- library/std/src/os/unix/net/addr.rs | 4 ++-- library/std/src/os/unix/net/ancillary.rs | 4 ++-- library/std/src/os/unix/net/datagram.rs | 12 ++++++------ library/std/src/os/unix/net/listener.rs | 10 +++++++--- library/std/src/os/unix/net/stream.rs | 4 ++-- library/std/src/os/unix/ucred.rs | 4 ++-- library/std/src/panicking.rs | 2 +- library/std/src/sync/mpmc/zero.rs | 8 ++++++-- library/std/src/sys/pal/hermit/net.rs | 4 ++-- library/std/src/sys/pal/hermit/time.rs | 4 ++-- library/std/src/sys/pal/sgx/abi/tls/mod.rs | 2 +- library/std/src/sys/pal/unix/fs.rs | 6 +++--- library/std/src/sys/pal/unix/mod.rs | 2 +- library/std/src/sys/pal/unix/net.rs | 2 +- .../std/src/sys/pal/unix/process/process_fuchsia.rs | 4 ++-- library/std/src/sys/pal/unix/process/process_unix.rs | 12 ++++++------ library/std/src/sys/pal/unix/thread.rs | 8 ++++---- library/std/src/sys/pal/unix/thread_local_dtor.rs | 2 +- library/std/src/sys/pal/wasi/mod.rs | 2 +- library/std/src/sys/pal/windows/fs.rs | 8 ++++---- library/std/src/sys/pal/windows/io.rs | 2 +- library/std/src/sys/pal/windows/net.rs | 2 +- library/std/src/sys/pal/windows/pipe.rs | 2 +- library/std/src/sys/pal/windows/process.rs | 6 +++--- library/std/src/sys/pal/windows/rand.rs | 4 ++-- library/std/src/sys/pal/windows/thread_parking.rs | 2 +- library/std/src/sys_common/net.rs | 8 ++++---- library/std/src/sys_common/once/queue.rs | 2 +- library/unwind/src/libunwind.rs | 4 ++-- 35 files changed, 83 insertions(+), 74 deletions(-) diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 3b29c144a89f8..0421a12b3a952 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -176,7 +176,7 @@ impl ThinBox { fn with_header(&self) -> &WithHeader<::Metadata> { // SAFETY: both types are transparent to `NonNull` - unsafe { &*((&self.ptr) as *const WithOpaqueHeader as *const WithHeader<_>) } + unsafe { &*(core::ptr::addr_of!(self.ptr) as *const WithHeader<_>) } } } diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index c3d0019be3975..084157b97ab41 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1969,7 +1969,7 @@ impl Rc { // Copy value as bytes ptr::copy_nonoverlapping( - &*src as *const T as *const u8, + core::ptr::addr_of!(*src) as *const u8, ptr::addr_of_mut!((*ptr).value) as *mut u8, value_size, ); @@ -2440,7 +2440,7 @@ impl fmt::Debug for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Rc { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&(&**self as *const T), f) + fmt::Pointer::fmt(&core::ptr::addr_of!(**self), f) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 524aa35e04529..00f47f5c6e0ed 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1914,7 +1914,7 @@ impl Arc { // Copy value as bytes ptr::copy_nonoverlapping( - &*src as *const T as *const u8, + core::ptr::addr_of!(*src) as *const u8, ptr::addr_of_mut!((*ptr).data) as *mut u8, value_size, ); @@ -3265,7 +3265,7 @@ impl fmt::Debug for Arc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Arc { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&(&**self as *const T), f) + fmt::Pointer::fmt(&core::ptr::addr_of!(**self), f) } } diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 248943cf02260..20186a2de0fd8 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -4,6 +4,7 @@ use crate::ffi::c_char; use crate::fmt; use crate::intrinsics; use crate::ops; +use crate::ptr::addr_of; use crate::slice; use crate::slice::memchr; use crate::str; @@ -603,7 +604,7 @@ impl CStr { pub const fn to_bytes_with_nul(&self) -> &[u8] { // SAFETY: Transmuting a slice of `c_char`s to a slice of `u8`s // is safe on all supported targets. - unsafe { &*(&self.inner as *const [c_char] as *const [u8]) } + unsafe { &*(addr_of!(self.inner) as *const [u8]) } } /// Yields a &[str] slice if the `CStr` contains valid UTF-8. diff --git a/library/core/src/iter/adapters/filter_map.rs b/library/core/src/iter/adapters/filter_map.rs index 64bd5b3e2b668..1a5f9e6265454 100644 --- a/library/core/src/iter/adapters/filter_map.rs +++ b/library/core/src/iter/adapters/filter_map.rs @@ -2,6 +2,7 @@ use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedF use crate::mem::{ManuallyDrop, MaybeUninit}; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; +use crate::ptr::addr_of; use crate::{array, fmt}; /// An iterator that uses `f` to both filter and map elements from `iter`. @@ -98,9 +99,8 @@ where // SAFETY: Loop conditions ensure the index is in bounds. unsafe { - let opt_payload_at: *const MaybeUninit = (&val as *const Option) - .byte_add(core::mem::offset_of!(Option, Some.0)) - .cast(); + let opt_payload_at: *const MaybeUninit = + addr_of!(val).byte_add(core::mem::offset_of!(Option, Some.0)).cast(); let dst = guard.array.as_mut_ptr().add(idx); crate::ptr::copy_nonoverlapping(opt_payload_at, dst, 1); crate::mem::forget(val); diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 90b3341f0ad4d..fc5b08c9801a8 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1553,7 +1553,7 @@ pub const unsafe fn write_unaligned(dst: *mut T, src: T) { // `dst` cannot overlap `src` because the caller has mutable access // to `dst` while `src` is owned by this function. unsafe { - copy_nonoverlapping(&src as *const T as *const u8, dst as *mut u8, mem::size_of::()); + copy_nonoverlapping(addr_of!(src) as *const u8, dst as *mut u8, mem::size_of::()); // We are calling the intrinsic directly to avoid function calls in the generated code. intrinsics::forget(src); } diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index 6c99e8c36203a..9757653e02c06 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -21,7 +21,7 @@ mod libc { fn sun_path_offset(addr: &libc::sockaddr_un) -> usize { // Work with an actual instance of the type since using a null pointer is UB let base = (addr as *const libc::sockaddr_un).addr(); - let path = (&addr.sun_path as *const libc::c_char).addr(); + let path = core::ptr::addr_of!(addr.sun_path).addr(); path - base } @@ -98,7 +98,7 @@ impl SocketAddr { unsafe { let mut addr: libc::sockaddr_un = mem::zeroed(); let mut len = mem::size_of::() as libc::socklen_t; - cvt(f(&mut addr as *mut _ as *mut _, &mut len))?; + cvt(f(core::ptr::addr_of_mut!(addr) as *mut _, &mut len))?; SocketAddr::from_parts(addr, len) } } diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index 218536689fdbe..1d279d6adbc25 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -37,7 +37,7 @@ pub(super) fn recv_vectored_with_ancillary_from( unsafe { let mut msg_name: libc::sockaddr_un = zeroed(); let mut msg: libc::msghdr = zeroed(); - msg.msg_name = &mut msg_name as *mut _ as *mut _; + msg.msg_name = core::ptr::addr_of_mut!(msg_name) as *mut _; msg.msg_namelen = size_of::() as libc::socklen_t; msg.msg_iov = bufs.as_mut_ptr().cast(); msg.msg_iovlen = bufs.len() as _; @@ -70,7 +70,7 @@ pub(super) fn send_vectored_with_ancillary_to( if let Some(path) = path { sockaddr_un(path)? } else { (zeroed(), 0) }; let mut msg: libc::msghdr = zeroed(); - msg.msg_name = &mut msg_name as *mut _ as *mut _; + msg.msg_name = core::ptr::addr_of_mut!(msg_name) as *mut _; msg.msg_namelen = msg_namelen; msg.msg_iov = bufs.as_ptr() as *mut _; msg.msg_iovlen = bufs.len() as _; diff --git a/library/std/src/os/unix/net/datagram.rs b/library/std/src/os/unix/net/datagram.rs index 3b7b610fdf96c..0b4d955294ca5 100644 --- a/library/std/src/os/unix/net/datagram.rs +++ b/library/std/src/os/unix/net/datagram.rs @@ -91,7 +91,7 @@ impl UnixDatagram { let socket = UnixDatagram::unbound()?; let (addr, len) = sockaddr_un(path.as_ref())?; - cvt(libc::bind(socket.as_raw_fd(), &addr as *const _ as *const _, len as _))?; + cvt(libc::bind(socket.as_raw_fd(), core::ptr::addr_of!(addr) as *const _, len as _))?; Ok(socket) } @@ -124,7 +124,7 @@ impl UnixDatagram { let socket = UnixDatagram::unbound()?; cvt(libc::bind( socket.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len as _, ))?; Ok(socket) @@ -206,7 +206,7 @@ impl UnixDatagram { unsafe { let (addr, len) = sockaddr_un(path.as_ref())?; - cvt(libc::connect(self.as_raw_fd(), &addr as *const _ as *const _, len))?; + cvt(libc::connect(self.as_raw_fd(), core::ptr::addr_of!(addr) as *const _, len))?; } Ok(()) } @@ -238,7 +238,7 @@ impl UnixDatagram { unsafe { cvt(libc::connect( self.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len, ))?; } @@ -505,7 +505,7 @@ impl UnixDatagram { buf.as_ptr() as *const _, buf.len(), MSG_NOSIGNAL, - &addr as *const _ as *const _, + core::ptr::addr_of!(addr) as *const _, len, ))?; Ok(count as usize) @@ -540,7 +540,7 @@ impl UnixDatagram { buf.as_ptr() as *const _, buf.len(), MSG_NOSIGNAL, - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len, ))?; Ok(count as usize) diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs index d64a43bc20bab..31286a906ea99 100644 --- a/library/std/src/os/unix/net/listener.rs +++ b/library/std/src/os/unix/net/listener.rs @@ -99,7 +99,11 @@ impl UnixListener { )))] const backlog: libc::c_int = libc::SOMAXCONN; - cvt(libc::bind(inner.as_inner().as_raw_fd(), &addr as *const _ as *const _, len as _))?; + cvt(libc::bind( + inner.as_inner().as_raw_fd(), + core::ptr::addr_of!(addr) as *const _, + len as _, + ))?; cvt(libc::listen(inner.as_inner().as_raw_fd(), backlog))?; Ok(UnixListener(inner)) @@ -139,7 +143,7 @@ impl UnixListener { const backlog: libc::c_int = 128; cvt(libc::bind( inner.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len as _, ))?; cvt(libc::listen(inner.as_raw_fd(), backlog))?; @@ -174,7 +178,7 @@ impl UnixListener { pub fn accept(&self) -> io::Result<(UnixStream, SocketAddr)> { let mut storage: libc::sockaddr_un = unsafe { mem::zeroed() }; let mut len = mem::size_of_val(&storage) as libc::socklen_t; - let sock = self.0.accept(&mut storage as *mut _ as *mut _, &mut len)?; + let sock = self.0.accept(core::ptr::addr_of_mut!(storage) as *mut _, &mut len)?; let addr = SocketAddr::from_parts(storage, len)?; Ok((UnixStream(sock), addr)) } diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index e117f616cafd4..b1cd504e21939 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -96,7 +96,7 @@ impl UnixStream { let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?; let (addr, len) = sockaddr_un(path.as_ref())?; - cvt(libc::connect(inner.as_raw_fd(), &addr as *const _ as *const _, len))?; + cvt(libc::connect(inner.as_raw_fd(), core::ptr::addr_of!(addr) as *const _, len))?; Ok(UnixStream(inner)) } } @@ -130,7 +130,7 @@ impl UnixStream { let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?; cvt(libc::connect( inner.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len, ))?; Ok(UnixStream(inner)) diff --git a/library/std/src/os/unix/ucred.rs b/library/std/src/os/unix/ucred.rs index 6a0cc2d2c48ff..6efa74182cc0b 100644 --- a/library/std/src/os/unix/ucred.rs +++ b/library/std/src/os/unix/ucred.rs @@ -62,7 +62,7 @@ pub mod impl_linux { socket.as_raw_fd(), SOL_SOCKET, SO_PEERCRED, - &mut ucred as *mut ucred as *mut c_void, + core::ptr::addr_of_mut!(ucred) as *mut c_void, &mut ucred_size, ); @@ -122,7 +122,7 @@ pub mod impl_mac { socket.as_raw_fd(), SOL_LOCAL, LOCAL_PEERPID, - &mut pid as *mut pid_t as *mut c_void, + core::ptr::addr_of_mut!(pid) as *mut c_void, &mut pid_size, ); diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 66b4ec37c8ec5..ef701d3867a1b 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -502,7 +502,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // method of calling a catch panic whilst juggling ownership. let mut data = Data { f: ManuallyDrop::new(f) }; - let data_ptr = &mut data as *mut _ as *mut u8; + let data_ptr = core::ptr::addr_of_mut!(data) as *mut u8; // SAFETY: // // Access to the union's fields: this is `std` and we know that the `r#try` diff --git a/library/std/src/sync/mpmc/zero.rs b/library/std/src/sync/mpmc/zero.rs index 33f768dcbe902..1b82713edc748 100644 --- a/library/std/src/sync/mpmc/zero.rs +++ b/library/std/src/sync/mpmc/zero.rs @@ -182,7 +182,11 @@ impl Channel { // Prepare for blocking until a receiver wakes us up. let oper = Operation::hook(token); let mut packet = Packet::::message_on_stack(msg); - inner.senders.register_with_packet(oper, &mut packet as *mut Packet as *mut (), cx); + inner.senders.register_with_packet( + oper, + core::ptr::addr_of_mut!(packet) as *mut (), + cx, + ); inner.receivers.notify(); drop(inner); @@ -251,7 +255,7 @@ impl Channel { let mut packet = Packet::::empty_on_stack(); inner.receivers.register_with_packet( oper, - &mut packet as *mut Packet as *mut (), + core::ptr::addr_of_mut!(packet) as *mut (), cx, ); inner.senders.notify(); diff --git a/library/std/src/sys/pal/hermit/net.rs b/library/std/src/sys/pal/hermit/net.rs index 871a2ccdfa49c..1c53796f5d49c 100644 --- a/library/std/src/sys/pal/hermit/net.rs +++ b/library/std/src/sys/pal/hermit/net.rs @@ -207,7 +207,7 @@ impl Socket { buf.as_mut_ptr(), buf.len(), flags, - &mut storage as *mut _ as *mut _, + core::ptr::addr_of_mut!(storage) as *mut _, &mut addrlen, ) })?; @@ -323,7 +323,7 @@ impl Socket { netc::ioctl( self.as_raw_fd(), netc::FIONBIO, - &mut nonblocking as *mut _ as *mut core::ffi::c_void, + core::ptr::addr_of_mut!(nonblocking) as *mut core::ffi::c_void, ) }) .map(drop) diff --git a/library/std/src/sys/pal/hermit/time.rs b/library/std/src/sys/pal/hermit/time.rs index b0e9634d2299c..f289dafd8bc56 100644 --- a/library/std/src/sys/pal/hermit/time.rs +++ b/library/std/src/sys/pal/hermit/time.rs @@ -100,7 +100,7 @@ pub struct Instant(Timespec); impl Instant { pub fn now() -> Instant { let mut time: Timespec = Timespec::zero(); - let _ = unsafe { abi::clock_gettime(CLOCK_MONOTONIC, &mut time.t as *mut timespec) }; + let _ = unsafe { abi::clock_gettime(CLOCK_MONOTONIC, core::ptr::addr_of_mut!(time.t)) }; Instant(time) } @@ -197,7 +197,7 @@ pub const UNIX_EPOCH: SystemTime = SystemTime(Timespec::zero()); impl SystemTime { pub fn now() -> SystemTime { let mut time: Timespec = Timespec::zero(); - let _ = unsafe { abi::clock_gettime(CLOCK_REALTIME, &mut time.t as *mut timespec) }; + let _ = unsafe { abi::clock_gettime(CLOCK_REALTIME, core::ptr::addr_of_mut!(time.t)) }; SystemTime(time) } diff --git a/library/std/src/sys/pal/sgx/abi/tls/mod.rs b/library/std/src/sys/pal/sgx/abi/tls/mod.rs index 6762a43b483a4..8a9ea4ac00df0 100644 --- a/library/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/library/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -95,7 +95,7 @@ impl Tls { #[allow(unused)] pub unsafe fn activate_persistent(self: Box) { // FIXME: Needs safety information. See entry.S for `set_tls_ptr` definition. - unsafe { set_tls_ptr((&*self) as *const Tls as _) }; + unsafe { set_tls_ptr(core::ptr::addr_of!(*self) as _) }; mem::forget(self); } diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index c75323ef7757a..086cdfe6e9434 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -1344,7 +1344,7 @@ impl File { } cvt(unsafe { libc::fsetattrlist( self.as_raw_fd(), - (&attrlist as *const libc::attrlist).cast::().cast_mut(), + core::ptr::addr_of!(attrlist).cast::().cast_mut(), buf.as_ptr().cast::().cast_mut(), num_times * mem::size_of::(), 0 @@ -1744,7 +1744,7 @@ fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> #[cfg(target_os = "espidf")] fn open_to_and_set_permissions( to: &Path, - reader_metadata: crate::fs::Metadata, + _reader_metadata: crate::fs::Metadata, ) -> io::Result<(crate::fs::File, crate::fs::Metadata)> { use crate::fs::OpenOptions; let writer = OpenOptions::new().open(to)?; @@ -1918,7 +1918,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { copyfile_state_get( state.0, COPYFILE_STATE_COPIED, - &mut bytes_copied as *mut libc::off_t as *mut libc::c_void, + core::ptr::addr_of_mut!(bytes_copied) as *mut libc::c_void, ) })?; Ok(bytes_copied as u64) diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 04b8c5ca91604..23287258f2f87 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -38,7 +38,7 @@ pub mod thread_parking; pub mod time; #[cfg(target_os = "espidf")] -pub fn init(argc: isize, argv: *const *const u8, _sigpipe: u8) {} +pub fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {} #[cfg(not(target_os = "espidf"))] // SAFETY: must be called only once during runtime initialization. diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs index 1b6a6bb2c5c77..f4ae7d21781a6 100644 --- a/library/std/src/sys/pal/unix/net.rs +++ b/library/std/src/sys/pal/unix/net.rs @@ -316,7 +316,7 @@ impl Socket { buf.as_mut_ptr() as *mut c_void, buf.len(), flags, - &mut storage as *mut _ as *mut _, + core::ptr::addr_of_mut!(storage) as *mut _, &mut addrlen, ) })?; diff --git a/library/std/src/sys/pal/unix/process/process_fuchsia.rs b/library/std/src/sys/pal/unix/process/process_fuchsia.rs index b6a74fb48318c..23c2be6adf9ee 100644 --- a/library/std/src/sys/pal/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/pal/unix/process/process_fuchsia.rs @@ -182,7 +182,7 @@ impl Process { zx_cvt(zx_object_get_info( self.handle.raw(), ZX_INFO_PROCESS, - &mut proc_info as *mut _ as *mut libc::c_void, + core::ptr::addr_of_mut!(proc_info) as *mut libc::c_void, mem::size_of::(), &mut actual, &mut avail, @@ -219,7 +219,7 @@ impl Process { zx_cvt(zx_object_get_info( self.handle.raw(), ZX_INFO_PROCESS, - &mut proc_info as *mut _ as *mut libc::c_void, + core::ptr::addr_of_mut!(proc_info) as *mut libc::c_void, mem::size_of::(), &mut actual, &mut avail, diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs index d5a77085725c5..97cbd1929d329 100644 --- a/library/std/src/sys/pal/unix/process/process_unix.rs +++ b/library/std/src/sys/pal/unix/process/process_unix.rs @@ -694,15 +694,15 @@ impl Command { let mut iov = [IoSlice::new(b"")]; let mut msg: libc::msghdr = mem::zeroed(); - msg.msg_iov = &mut iov as *mut _ as *mut _; + msg.msg_iov = core::ptr::addr_of_mut!(iov) as *mut _; msg.msg_iovlen = 1; // only attach cmsg if we successfully acquired the pidfd if pidfd >= 0 { msg.msg_controllen = mem::size_of_val(&cmsg.buf) as _; - msg.msg_control = &mut cmsg.buf as *mut _ as *mut _; + msg.msg_control = core::ptr::addr_of_mut!(cmsg.buf) as *mut _; - let hdr = CMSG_FIRSTHDR(&mut msg as *mut _ as *mut _); + let hdr = CMSG_FIRSTHDR(core::ptr::addr_of_mut!(msg) as *mut _); (*hdr).cmsg_level = SOL_SOCKET; (*hdr).cmsg_type = SCM_RIGHTS; (*hdr).cmsg_len = CMSG_LEN(SCM_MSG_LEN as _) as _; @@ -744,17 +744,17 @@ impl Command { let mut msg: libc::msghdr = mem::zeroed(); - msg.msg_iov = &mut iov as *mut _ as *mut _; + msg.msg_iov = core::ptr::addr_of_mut!(iov) as *mut _; msg.msg_iovlen = 1; msg.msg_controllen = mem::size_of::() as _; - msg.msg_control = &mut cmsg as *mut _ as *mut _; + msg.msg_control = core::ptr::addr_of_mut!(cmsg) as *mut _; match cvt_r(|| libc::recvmsg(sock.as_raw(), &mut msg, libc::MSG_CMSG_CLOEXEC)) { Err(_) => return -1, Ok(_) => {} } - let hdr = CMSG_FIRSTHDR(&mut msg as *mut _ as *mut _); + let hdr = CMSG_FIRSTHDR(core::ptr::addr_of_mut!(msg) as *mut _); if hdr.is_null() || (*hdr).cmsg_level != SOL_SOCKET || (*hdr).cmsg_type != SCM_RIGHTS diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 97976407bb40f..864de31c6ebfc 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -239,7 +239,7 @@ impl Thread { tv_nsec: nsecs, }; secs -= ts.tv_sec as u64; - let ts_ptr = &mut ts as *mut _; + let ts_ptr = core::ptr::addr_of_mut!(ts); if libc::nanosleep(ts_ptr, ts_ptr) == -1 { assert_eq!(os::errno(), libc::EINTR); secs += ts.tv_sec as u64; @@ -418,8 +418,8 @@ pub fn available_parallelism() -> io::Result> { libc::sysctl( mib.as_mut_ptr(), 2, - &mut cpus as *mut _ as *mut _, - &mut cpus_size as *mut _ as *mut _, + core::ptr::addr_of_mut!(cpus) as *mut _, + core::ptr::addr_of_mut!(cpus_size) as *mut _, ptr::null_mut(), 0, ) @@ -864,7 +864,7 @@ pub mod guard { .unwrap(); match sysctlbyname.get() { Some(fcn) => { - if fcn(oid.as_ptr(), &mut guard as *mut _ as *mut _, &mut size as *mut _ as *mut _, crate::ptr::null_mut(), 0) == 0 { + if fcn(oid.as_ptr(), core::ptr::addr_of_mut!(guard) as *mut _, core::ptr::addr_of_mut!(size) as *mut _, crate::ptr::null_mut(), 0) == 0 { return guard; } return 1; diff --git a/library/std/src/sys/pal/unix/thread_local_dtor.rs b/library/std/src/sys/pal/unix/thread_local_dtor.rs index 8857f96501c19..79b152cece945 100644 --- a/library/std/src/sys/pal/unix/thread_local_dtor.rs +++ b/library/std/src/sys/pal/unix/thread_local_dtor.rs @@ -58,7 +58,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { unsafe extern "C" fn(*mut libc::c_void), >(dtor), t.cast(), - &__dso_handle as *const _ as *mut _, + core::ptr::addr_of!(__dso_handle) as *mut _, ); } return; diff --git a/library/std/src/sys/pal/wasi/mod.rs b/library/std/src/sys/pal/wasi/mod.rs index 084b8e0e21639..e6cbd51e768a7 100644 --- a/library/std/src/sys/pal/wasi/mod.rs +++ b/library/std/src/sys/pal/wasi/mod.rs @@ -166,7 +166,7 @@ pub fn abort_internal() -> ! { pub fn hashmap_random_keys() -> (u64, u64) { let mut ret = (0u64, 0u64); unsafe { - let base = &mut ret as *mut (u64, u64) as *mut u8; + let base = core::ptr::addr_of_mut!(ret) as *mut u8; let len = mem::size_of_val(&ret); wasi::random_get(base, len).expect("random_get failure"); } diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs index b82a83ae7a3e8..3a9e7b4660b36 100644 --- a/library/std/src/sys/pal/windows/fs.rs +++ b/library/std/src/sys/pal/windows/fs.rs @@ -394,7 +394,7 @@ impl File { cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileBasicInfo, - &mut info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(info) as *mut c_void, size as c::DWORD, ))?; let mut attr = FileAttr { @@ -422,7 +422,7 @@ impl File { cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileStandardInfo, - &mut info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(info) as *mut c_void, size as c::DWORD, ))?; attr.file_size = info.AllocationSize as u64; @@ -638,7 +638,7 @@ impl File { cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileBasicInfo, - &mut info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(info) as *mut c_void, size as c::DWORD, ))?; Ok(info) @@ -1438,7 +1438,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { pfrom.as_ptr(), pto.as_ptr(), Some(callback), - &mut size as *mut _ as *mut _, + core::ptr::addr_of_mut!(size) as *mut _, ptr::null_mut(), 0, ) diff --git a/library/std/src/sys/pal/windows/io.rs b/library/std/src/sys/pal/windows/io.rs index b73d9f3ff4c4a..77b8f3c410eb8 100644 --- a/library/std/src/sys/pal/windows/io.rs +++ b/library/std/src/sys/pal/windows/io.rs @@ -122,7 +122,7 @@ unsafe fn msys_tty_on(handle: c::HANDLE) -> bool { let res = c::GetFileInformationByHandleEx( handle, c::FileNameInfo, - &mut name_info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(name_info) as *mut c_void, size_of::() as u32, ); if res == 0 { diff --git a/library/std/src/sys/pal/windows/net.rs b/library/std/src/sys/pal/windows/net.rs index e37fbe9ef83e4..1e6169ea8ece0 100644 --- a/library/std/src/sys/pal/windows/net.rs +++ b/library/std/src/sys/pal/windows/net.rs @@ -310,7 +310,7 @@ impl Socket { buf.as_mut_ptr() as *mut _, length, flags, - &mut storage as *mut _ as *mut _, + core::ptr::addr_of_mut!(storage) as *mut _, &mut addrlen, ) }; diff --git a/library/std/src/sys/pal/windows/pipe.rs b/library/std/src/sys/pal/windows/pipe.rs index fd10df82d8b47..013f588676ae8 100644 --- a/library/std/src/sys/pal/windows/pipe.rs +++ b/library/std/src/sys/pal/windows/pipe.rs @@ -375,7 +375,7 @@ impl AnonPipe { let mut overlapped: c::OVERLAPPED = crate::mem::zeroed(); // `hEvent` is unused by `ReadFileEx` and `WriteFileEx`. // Therefore the documentation suggests using it to smuggle a pointer to the callback. - overlapped.hEvent = &mut async_result as *mut _ as *mut _; + overlapped.hEvent = core::ptr::addr_of_mut!(async_result) as *mut _; // Asynchronous read of the pipe. // If successful, `callback` will be called once it completes. diff --git a/library/std/src/sys/pal/windows/process.rs b/library/std/src/sys/pal/windows/process.rs index 6a94d37714038..e4ab2ca7da1ce 100644 --- a/library/std/src/sys/pal/windows/process.rs +++ b/library/std/src/sys/pal/windows/process.rs @@ -350,10 +350,10 @@ impl Command { StartupInfo: si, lpAttributeList: proc_thread_attribute_list.0.as_mut_ptr() as _, }; - si_ptr = &mut si_ex as *mut _ as _; + si_ptr = core::ptr::addr_of_mut!(si_ex) as _; } else { si.cb = mem::size_of::() as c::DWORD; - si_ptr = &mut si as *mut _ as _; + si_ptr = core::ptr::addr_of_mut!(si) as _; } unsafe { @@ -935,7 +935,7 @@ fn make_proc_thread_attribute_list( // It's theoretically possible for the attribute count to exceed a u32 value. // Therefore, we ensure that we don't add more attributes than the buffer was initialized for. for (&attribute, value) in attributes.iter().take(attribute_count as usize) { - let value_ptr = &*value.data as *const (dyn Send + Sync) as _; + let value_ptr = core::ptr::addr_of!(*value.data) as _; cvt(unsafe { c::UpdateProcThreadAttribute( proc_thread_attribute_list.0.as_mut_ptr() as _, diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs index 5d8fd13785a09..bd1ae6b06076e 100644 --- a/library/std/src/sys/pal/windows/rand.rs +++ b/library/std/src/sys/pal/windows/rand.rs @@ -7,7 +7,7 @@ pub fn hashmap_random_keys() -> (u64, u64) { let ret = unsafe { c::BCryptGenRandom( ptr::null_mut(), - &mut v as *mut _ as *mut u8, + core::ptr::addr_of_mut!(v) as *mut u8, mem::size_of_val(&v) as c::ULONG, c::BCRYPT_USE_SYSTEM_PREFERRED_RNG, ) @@ -28,7 +28,7 @@ fn fallback_rng() -> (u64, u64) { let mut v = (0, 0); let ret = unsafe { - c::RtlGenRandom(&mut v as *mut _ as *mut c_void, mem::size_of_val(&v) as c::ULONG) + c::RtlGenRandom(core::ptr::addr_of_mut!(v) as *mut c_void, mem::size_of_val(&v) as c::ULONG) }; if ret != 0 { v } else { panic!("fallback RNG broken: {}", io::Error::last_os_error()) } diff --git a/library/std/src/sys/pal/windows/thread_parking.rs b/library/std/src/sys/pal/windows/thread_parking.rs index 343b530b15ef9..ea485d71f5adc 100644 --- a/library/std/src/sys/pal/windows/thread_parking.rs +++ b/library/std/src/sys/pal/windows/thread_parking.rs @@ -215,7 +215,7 @@ impl Parker { } fn ptr(&self) -> c::LPVOID { - &self.state as *const _ as c::LPVOID + core::ptr::addr_of!(self.state) as c::LPVOID } } diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index de7d31baaaf8c..581c46af0eacf 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -70,7 +70,7 @@ pub fn setsockopt( sock.as_raw(), level, option_name, - &option_value as *const T as *const _, + core::ptr::addr_of!(option_value) as *const _, mem::size_of::() as c::socklen_t, ))?; Ok(()) @@ -85,7 +85,7 @@ pub fn getsockopt(sock: &Socket, level: c_int, option_name: c_int) -> i sock.as_raw(), level, option_name, - &mut option_value as *mut T as *mut _, + core::ptr::addr_of_mut!(option_value) as *mut _, &mut option_len, ))?; Ok(option_value) @@ -99,7 +99,7 @@ where unsafe { let mut storage: c::sockaddr_storage = mem::zeroed(); let mut len = mem::size_of_val(&storage) as c::socklen_t; - cvt(f(&mut storage as *mut _ as *mut _, &mut len))?; + cvt(f(core::ptr::addr_of_mut!(storage) as *mut _, &mut len))?; sockaddr_to_addr(&storage, len as usize) } } @@ -444,7 +444,7 @@ impl TcpListener { pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; let mut len = mem::size_of_val(&storage) as c::socklen_t; - let sock = self.inner.accept(&mut storage as *mut _ as *mut _, &mut len)?; + let sock = self.inner.accept(core::ptr::addr_of_mut!(storage) as *mut _, &mut len)?; let addr = sockaddr_to_addr(&storage, len as usize)?; Ok((TcpStream { inner: sock }, addr)) } diff --git a/library/std/src/sys_common/once/queue.rs b/library/std/src/sys_common/once/queue.rs index 3cc1df113e3f1..730cdb768bd27 100644 --- a/library/std/src/sys_common/once/queue.rs +++ b/library/std/src/sys_common/once/queue.rs @@ -212,7 +212,7 @@ fn wait(state_and_queue: &AtomicPtr, mut current_state: *mut Masked) { signaled: AtomicBool::new(false), next: current_state.with_addr(current_state.addr() & !STATE_MASK) as *const Waiter, }; - let me = &node as *const Waiter as *const Masked as *mut Masked; + let me = core::ptr::addr_of!(node) as *const Masked as *mut Masked; // Try to slide in the node at the head of the linked list, making sure // that another thread didn't just replace the head of the linked list. diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 1b5f6f9dde36c..527c408c89edd 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -219,14 +219,14 @@ if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", targe pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word { let mut val: _Unwind_Word = core::ptr::null(); _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - &mut val as *mut _ as *mut c_void); + core::ptr::addr_of_mut!(val) as *mut c_void); val } pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { let mut value = value; _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - &mut value as *mut _ as *mut c_void); + core::ptr::addr_of_mut!(value) as *mut c_void); } pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) From ad319484f1505420586a68c9d77493898579d331 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 23 Feb 2024 16:32:34 +0100 Subject: [PATCH 276/417] Add new `unnecessary_get_then_check` clippy lint --- CHANGELOG.md | 1 + clippy_lints/src/declared_lints.rs | 1 + clippy_lints/src/methods/mod.rs | 47 ++++++++-- .../src/methods/unnecessary_get_then_check.rs | 85 +++++++++++++++++++ 4 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 clippy_lints/src/methods/unnecessary_get_then_check.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 5805511c70f9f..26dce1f926572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5732,6 +5732,7 @@ Released 2018-09-13 [`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map [`unnecessary_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_find_map [`unnecessary_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fold +[`unnecessary_get_then_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check [`unnecessary_join`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_join [`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations [`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 79fd76393074a..b6a35bb3e0328 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -455,6 +455,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::methods::UNNECESSARY_FILTER_MAP_INFO, crate::methods::UNNECESSARY_FIND_MAP_INFO, crate::methods::UNNECESSARY_FOLD_INFO, + crate::methods::UNNECESSARY_GET_THEN_CHECK_INFO, crate::methods::UNNECESSARY_JOIN_INFO, crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO, crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO, diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 1452547807ba2..820f4c8589065 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -110,6 +110,7 @@ mod unit_hash; mod unnecessary_fallible_conversions; mod unnecessary_filter_map; mod unnecessary_fold; +mod unnecessary_get_then_check; mod unnecessary_iter_cloned; mod unnecessary_join; mod unnecessary_lazy_eval; @@ -4011,6 +4012,35 @@ declare_clippy_lint! { r#"creating a `CStr` through functions when `c""` literals can be used"# } +declare_clippy_lint! { + /// ### What it does + /// Checks the usage of `.get().is_some()` or `.get().is_none()` on std map types. + /// + /// ### Why is this bad? + /// It can be done in one call with `.contains()`/`.contains_keys()`. + /// + /// ### Example + /// ```no_run + /// # use std::collections::HashSet; + /// let s: HashSet = HashSet::new(); + /// if s.get("a").is_some() { + /// // code + /// } + /// ``` + /// Use instead: + /// ```no_run + /// # use std::collections::HashSet; + /// let s: HashSet = HashSet::new(); + /// if s.contains("a") { + /// // code + /// } + /// ``` + #[clippy::version = "1.78.0"] + pub UNNECESSARY_GET_THEN_CHECK, + suspicious, + "calling `.get().is_some()` or `.get().is_none()` instead of `.contains()` or `.contains_key()`" +} + pub struct Methods { avoid_breaking_exported_api: bool, msrv: Msrv, @@ -4171,6 +4201,7 @@ impl_lint_pass!(Methods => [ OPTION_AS_REF_CLONED, UNNECESSARY_RESULT_MAP_OR_ELSE, MANUAL_C_STR_LITERALS, + UNNECESSARY_GET_THEN_CHECK, ]); /// Extracts a method call name, args, and `Span` of the method name. @@ -4587,8 +4618,8 @@ impl Methods { }, ("is_file", []) => filetype_is_file::check(cx, expr, recv), ("is_digit", [radix]) => is_digit_ascii_radix::check(cx, expr, recv, radix, &self.msrv), - ("is_none", []) => check_is_some_is_none(cx, expr, recv, false), - ("is_some", []) => check_is_some_is_none(cx, expr, recv, true), + ("is_none", []) => check_is_some_is_none(cx, expr, recv, call_span, false), + ("is_some", []) => check_is_some_is_none(cx, expr, recv, call_span, true), ("iter" | "iter_mut" | "into_iter", []) => { iter_on_single_or_empty_collections::check(cx, expr, name, recv); }, @@ -4899,9 +4930,15 @@ impl Methods { } } -fn check_is_some_is_none(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, is_some: bool) { - if let Some((name @ ("find" | "position" | "rposition"), f_recv, [arg], span, _)) = method_call(recv) { - search_is_some::check(cx, expr, name, is_some, f_recv, arg, recv, span); +fn check_is_some_is_none(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, call_span: Span, is_some: bool) { + match method_call(recv) { + Some((name @ ("find" | "position" | "rposition"), f_recv, [arg], span, _)) => { + search_is_some::check(cx, expr, name, is_some, f_recv, arg, recv, span); + }, + Some(("get", f_recv, [arg], _, _)) => { + unnecessary_get_then_check::check(cx, call_span, recv, f_recv, arg, is_some); + }, + _ => {}, } } diff --git a/clippy_lints/src/methods/unnecessary_get_then_check.rs b/clippy_lints/src/methods/unnecessary_get_then_check.rs new file mode 100644 index 0000000000000..cc8053ef507a5 --- /dev/null +++ b/clippy_lints/src/methods/unnecessary_get_then_check.rs @@ -0,0 +1,85 @@ +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::source::snippet_opt; +use clippy_utils::ty::is_type_diagnostic_item; + +use rustc_errors::Applicability; +use rustc_hir::{Expr, ExprKind}; +use rustc_lint::LateContext; +use rustc_middle::ty::Ty; +use rustc_span::{sym, Span}; + +use super::UNNECESSARY_GET_THEN_CHECK; + +fn is_a_std_set_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { + is_type_diagnostic_item(cx, ty, sym::HashSet) || is_type_diagnostic_item(cx, ty, sym::BTreeSet) +} + +fn is_a_std_map_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { + is_type_diagnostic_item(cx, ty, sym::HashMap) || is_type_diagnostic_item(cx, ty, sym::BTreeMap) +} + +pub(super) fn check( + cx: &LateContext<'_>, + call_span: Span, + get_call: &Expr<'_>, + get_caller: &Expr<'_>, + arg: &Expr<'_>, + is_some: bool, +) { + let caller_ty = cx.typeck_results().expr_ty(get_caller); + + let is_set = is_a_std_set_type(cx, caller_ty); + let is_map = is_a_std_map_type(cx, caller_ty); + + if !is_set && !is_map { + return; + } + let ExprKind::MethodCall(path, _, _, get_call_span) = get_call.kind else { + return; + }; + let both_calls_span = get_call_span.with_hi(call_span.hi()); + if let Some(snippet) = snippet_opt(cx, both_calls_span) + && let Some(arg_snippet) = snippet_opt(cx, arg.span) + { + let generics_snippet = if let Some(generics) = path.args + && let Some(generics_snippet) = snippet_opt(cx, generics.span_ext) + { + format!("::{generics_snippet}") + } else { + String::new() + }; + let suggestion = if is_set { + format!("contains{generics_snippet}({arg_snippet})") + } else { + format!("contains_key{generics_snippet}({arg_snippet})") + }; + if is_some { + span_lint_and_sugg( + cx, + UNNECESSARY_GET_THEN_CHECK, + both_calls_span, + &format!("unnecessary use of `{snippet}`"), + "replace it with", + suggestion, + Applicability::MaybeIncorrect, + ); + } else if let Some(caller_snippet) = snippet_opt(cx, get_caller.span) { + let full_span = get_caller.span.with_hi(call_span.hi()); + + span_lint_and_then( + cx, + UNNECESSARY_GET_THEN_CHECK, + both_calls_span, + &format!("unnecessary use of `{snippet}`"), + |diag| { + diag.span_suggestion( + full_span, + "replace it with", + format!("{}{caller_snippet}.{suggestion}", if is_some { "" } else { "!" }), + Applicability::MaybeIncorrect, + ); + }, + ); + } + } +} From 40cff2d99f9723f4bfcf4bd9c7291bbb35fc323e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 23 Feb 2024 16:33:08 +0100 Subject: [PATCH 277/417] Add ui test for `unnecessary_get_then_check` --- tests/ui/unnecessary_get_then_check.fixed | 26 ++++++++ tests/ui/unnecessary_get_then_check.rs | 26 ++++++++ tests/ui/unnecessary_get_then_check.stderr | 75 ++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 tests/ui/unnecessary_get_then_check.fixed create mode 100644 tests/ui/unnecessary_get_then_check.rs create mode 100644 tests/ui/unnecessary_get_then_check.stderr diff --git a/tests/ui/unnecessary_get_then_check.fixed b/tests/ui/unnecessary_get_then_check.fixed new file mode 100644 index 0000000000000..178a3300c3460 --- /dev/null +++ b/tests/ui/unnecessary_get_then_check.fixed @@ -0,0 +1,26 @@ +#![warn(clippy::unnecessary_get_then_check)] + +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; + +fn main() { + let s: HashSet = HashSet::new(); + let _ = s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: HashMap = HashMap::new(); + let _ = s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeSet = BTreeSet::new(); + let _ = s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeMap = BTreeMap::new(); + let _ = s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + // Import to check that the generic annotations are kept! + let s: HashSet = HashSet::new(); + let _ = s.contains::("a"); //~ ERROR: unnecessary use of `get::("a").is_some()` + let _ = !s.contains::("a"); //~ ERROR: unnecessary use of `get::("a").is_none()` +} diff --git a/tests/ui/unnecessary_get_then_check.rs b/tests/ui/unnecessary_get_then_check.rs new file mode 100644 index 0000000000000..c197bdef47eaf --- /dev/null +++ b/tests/ui/unnecessary_get_then_check.rs @@ -0,0 +1,26 @@ +#![warn(clippy::unnecessary_get_then_check)] + +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; + +fn main() { + let s: HashSet = HashSet::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: HashMap = HashMap::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeSet = BTreeSet::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeMap = BTreeMap::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + // Import to check that the generic annotations are kept! + let s: HashSet = HashSet::new(); + let _ = s.get::("a").is_some(); //~ ERROR: unnecessary use of `get::("a").is_some()` + let _ = s.get::("a").is_none(); //~ ERROR: unnecessary use of `get::("a").is_none()` +} diff --git a/tests/ui/unnecessary_get_then_check.stderr b/tests/ui/unnecessary_get_then_check.stderr new file mode 100644 index 0000000000000..0477c03d16dd9 --- /dev/null +++ b/tests/ui/unnecessary_get_then_check.stderr @@ -0,0 +1,75 @@ +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:7:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` + | + = note: `-D clippy::unnecessary-get-then-check` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_get_then_check)]` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:8:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains("a")` + +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:11:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:12:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains_key("a")` + +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:15:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:16:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains("a")` + +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:19:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:20:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains_key("a")` + +error: unnecessary use of `get::("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:24:15 + | +LL | let _ = s.get::("a").is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains::("a")` + +error: unnecessary use of `get::("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:25:15 + | +LL | let _ = s.get::("a").is_none(); + | --^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains::("a")` + +error: aborting due to 10 previous errors + From a1971414ec707df5a4071f91c4beaf5123aa8d18 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 23 Feb 2024 16:35:37 +0100 Subject: [PATCH 278/417] Update ui tests --- tests/ui/iter_filter_is_some.fixed | 3 ++- tests/ui/iter_filter_is_some.rs | 3 ++- tests/ui/iter_filter_is_some.stderr | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/ui/iter_filter_is_some.fixed b/tests/ui/iter_filter_is_some.fixed index abc3a47fa46a7..8a818c0c6728d 100644 --- a/tests/ui/iter_filter_is_some.fixed +++ b/tests/ui/iter_filter_is_some.fixed @@ -4,7 +4,8 @@ clippy::result_filter_map, clippy::needless_borrow, clippy::option_filter_map, - clippy::redundant_closure + clippy::redundant_closure, + clippy::unnecessary_get_then_check )] use std::collections::HashMap; diff --git a/tests/ui/iter_filter_is_some.rs b/tests/ui/iter_filter_is_some.rs index c74775a82ba07..9eda93a259218 100644 --- a/tests/ui/iter_filter_is_some.rs +++ b/tests/ui/iter_filter_is_some.rs @@ -4,7 +4,8 @@ clippy::result_filter_map, clippy::needless_borrow, clippy::option_filter_map, - clippy::redundant_closure + clippy::redundant_closure, + clippy::unnecessary_get_then_check )] use std::collections::HashMap; diff --git a/tests/ui/iter_filter_is_some.stderr b/tests/ui/iter_filter_is_some.stderr index 165ccfedf14dc..54aff892b1f0f 100644 --- a/tests/ui/iter_filter_is_some.stderr +++ b/tests/ui/iter_filter_is_some.stderr @@ -1,5 +1,5 @@ error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:14:58 + --> tests/ui/iter_filter_is_some.rs:15:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,55 +8,55 @@ LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(Option::is_ = help: to override `-D warnings` add `#[allow(clippy::iter_filter_is_some)]` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:16:58 + --> tests/ui/iter_filter_is_some.rs:17:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:19:58 + --> tests/ui/iter_filter_is_some.rs:20:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:26:14 + --> tests/ui/iter_filter_is_some.rs:27:14 | LL | .filter(std::option::Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:31:14 + --> tests/ui/iter_filter_is_some.rs:32:14 | LL | .filter(|a| std::option::Option::is_some(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:34:58 + --> tests/ui/iter_filter_is_some.rs:35:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| { std::option::Option::is_some(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:39:58 + --> tests/ui/iter_filter_is_some.rs:40:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:43:58 + --> tests/ui/iter_filter_is_some.rs:44:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:48:58 + --> tests/ui/iter_filter_is_some.rs:49:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:52:58 + --> tests/ui/iter_filter_is_some.rs:53:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` From 5e2707d343587c7fa588159949a479f1f1962922 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 23 Feb 2024 17:23:47 +0100 Subject: [PATCH 279/417] Fix new lint warnings --- lintcheck/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lintcheck/src/main.rs b/lintcheck/src/main.rs index 88966b41f69ff..6644299816199 100644 --- a/lintcheck/src/main.rs +++ b/lintcheck/src/main.rs @@ -749,7 +749,7 @@ fn print_stats(old_stats: HashMap, new_stats: HashMap<&String, us // list all new counts (key is in new stats but not in old stats) new_stats_deduped .iter() - .filter(|(new_key, _)| old_stats_deduped.get::(new_key).is_none()) + .filter(|(new_key, _)| !old_stats_deduped.contains_key::(new_key)) .for_each(|(new_key, new_value)| { println!("{new_key} 0 => {new_value}"); }); @@ -757,7 +757,7 @@ fn print_stats(old_stats: HashMap, new_stats: HashMap<&String, us // list all changed counts (key is in both maps but value differs) new_stats_deduped .iter() - .filter(|(new_key, _new_val)| old_stats_deduped.get::(new_key).is_some()) + .filter(|(new_key, _new_val)| old_stats_deduped.contains_key::(new_key)) .for_each(|(new_key, new_val)| { let old_val = old_stats_deduped.get::(new_key).unwrap(); println!("{new_key} {old_val} => {new_val}"); @@ -766,7 +766,7 @@ fn print_stats(old_stats: HashMap, new_stats: HashMap<&String, us // list all gone counts (key is in old status but not in new stats) old_stats_deduped .iter() - .filter(|(old_key, _)| new_stats_deduped.get::<&String>(old_key).is_none()) + .filter(|(old_key, _)| !new_stats_deduped.contains_key::<&String>(old_key)) .filter(|(old_key, _)| lint_filter.is_empty() || lint_filter.contains(old_key)) .for_each(|(old_key, old_value)| { println!("{old_key} {old_value} => 0"); From f08e2d4137bdf0e443f4061c8b1289f0a92513be Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sat, 16 Dec 2023 01:49:01 +0000 Subject: [PATCH 280/417] Forbid use of `extern "C-unwind"` inside standard library Those libraries are build with `-C panic=unwind` and is expected to be linkable to `-C panic=abort` library. To ensure unsoundness compiler needs to prevent a `C-unwind` call to exist, as doing so may leak foreign exceptions into `-C panic=abort`. --- library/alloc/src/lib.rs | 1 + library/core/src/lib.rs | 1 + library/proc_macro/src/lib.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index b84273848ee95..45e93feb6c5b3 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -92,6 +92,7 @@ #![warn(multiple_supertrait_upcastable)] #![allow(internal_features)] #![allow(rustdoc::redundant_explicit_links)] +#![deny(ffi_unwind_calls)] // // Library features: // tidy-alphabetical-start diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 456d88122af64..49cead680e33b 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -106,6 +106,7 @@ #![allow(incomplete_features)] #![warn(multiple_supertrait_upcastable)] #![allow(internal_features)] +#![deny(ffi_unwind_calls)] // Do not check link redundancy on bootstraping phase #![allow(rustdoc::redundant_explicit_links)] // diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index d05458a6944ac..610966625b535 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -36,6 +36,7 @@ #![feature(strict_provenance)] #![recursion_limit = "256"] #![allow(internal_features)] +#![deny(ffi_unwind_calls)] #[unstable(feature = "proc_macro_internals", issue = "27812")] #[doc(hidden)] From f5b9eaf18f3486feaf6bf765409449e37b38f9d2 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 24 Feb 2024 11:19:14 +0100 Subject: [PATCH 281/417] Don't unnecessarily change `SIGPIPE` disposition in unix_sigpipe tests In `auxiliary/sigpipe-utils.rs`, all we want to know is the current `SIGPIPE` disposition. We should not change it. So use `libc::sigaction` instead of `libc::signal`. That way we can also remove the code that restores it. --- .../unix_sigpipe/auxiliary/sigpipe-utils.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs b/tests/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs index 74fbae0350e48..3d93d50ca3fbb 100644 --- a/tests/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs +++ b/tests/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs @@ -17,17 +17,17 @@ pub fn assert_sigpipe_handler(expected_handler: SignalHandler) { target_os = "android", )))] { - let prev = unsafe { libc::signal(libc::SIGPIPE, libc::SIG_IGN) }; + let actual = unsafe { + let mut actual: libc::sigaction = std::mem::zeroed(); + libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual); + actual.sa_sigaction + }; let expected = match expected_handler { SignalHandler::Ignore => libc::SIG_IGN, SignalHandler::Default => libc::SIG_DFL, }; - assert_eq!(prev, expected, "expected sigpipe value matches actual value"); - // Unlikely to matter, but restore the old value anyway - unsafe { - libc::signal(libc::SIGPIPE, prev); - }; + assert_eq!(actual, expected, "actual and expected SIGPIPE disposition differs"); } } From 613cb3262dfca935cac5a198f835f2aaa73faf18 Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Sat, 24 Feb 2024 16:47:34 +0300 Subject: [PATCH 282/417] compiler: use `addr_of!` --- compiler/rustc_codegen_llvm/src/back/archive.rs | 2 +- compiler/rustc_codegen_llvm/src/lib.rs | 4 ++-- compiler/rustc_codegen_llvm/src/llvm_util.rs | 2 +- compiler/rustc_data_structures/src/sync.rs | 2 +- compiler/rustc_middle/src/query/on_disk_cache.rs | 4 ++-- compiler/rustc_middle/src/ty/list.rs | 2 +- compiler/stable_mir/src/compiler_interface.rs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 67bc86e4c9026..b6bbc81732ee2 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -313,7 +313,7 @@ fn get_llvm_object_symbols( llvm::LLVMRustGetSymbols( buf.as_ptr(), buf.len(), - &mut *state as *mut &mut _ as *mut c_void, + std::ptr::addr_of_mut!(*state) as *mut c_void, callback, error_callback, ) diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 35210b0b2e86d..c84461e53eb1b 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -169,7 +169,7 @@ impl WriteBackendMethods for LlvmCodegenBackend { fn print_pass_timings(&self) { unsafe { let mut size = 0; - let cstr = llvm::LLVMRustPrintPassTimings(&mut size as *mut usize); + let cstr = llvm::LLVMRustPrintPassTimings(std::ptr::addr_of_mut!(size)); if cstr.is_null() { println!("failed to get pass timings"); } else { @@ -182,7 +182,7 @@ impl WriteBackendMethods for LlvmCodegenBackend { fn print_statistics(&self) { unsafe { let mut size = 0; - let cstr = llvm::LLVMRustPrintStatistics(&mut size as *mut usize); + let cstr = llvm::LLVMRustPrintStatistics(std::ptr::addr_of_mut!(size)); if cstr.is_null() { println!("failed to get pass stats"); } else { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 54e8ed85e3250..1b2beac56a20b 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -435,7 +435,7 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut dyn PrintBackendInfo, sess &tm, cpu_cstring.as_ptr(), callback, - &mut out as *mut &mut dyn PrintBackendInfo as *mut c_void, + std::ptr::addr_of_mut!(out) as *mut c_void, ); } } diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index adcb6ceaebf89..32202ac3eded1 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -429,7 +429,7 @@ impl RwLock { #[inline(always)] pub fn leak(&self) -> &T { let guard = self.read(); - let ret = unsafe { &*(&*guard as *const T) }; + let ret = unsafe { &*std::ptr::addr_of!(*guard) }; std::mem::forget(guard); ret } diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index f4dfbe059ebcd..9c7c46f2ad24b 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -233,7 +233,7 @@ impl<'sess> OnDiskCache<'sess> { for (index, file) in files.iter().enumerate() { let index = SourceFileIndex(index as u32); - let file_ptr: *const SourceFile = &**file as *const _; + let file_ptr: *const SourceFile = std::ptr::addr_of!(**file); file_to_file_index.insert(file_ptr, index); let source_file_id = EncodedSourceFileId::new(tcx, file); file_index_to_stable_id.insert(index, source_file_id); @@ -835,7 +835,7 @@ pub struct CacheEncoder<'a, 'tcx> { impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { #[inline] fn source_file_index(&mut self, source_file: Lrc) -> SourceFileIndex { - self.file_to_file_index[&(&*source_file as *const SourceFile)] + self.file_to_file_index[&std::ptr::addr_of!(*source_file)] } /// Encode something with additional information that allows to do some diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 4f9c9d85763a2..336c2dce1141c 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -61,7 +61,7 @@ impl List { // length) that is 64-byte aligned, thus featuring the necessary // trailing padding for elements with up to 64-byte alignment. static EMPTY_SLICE: InOrder = InOrder(0, MaxAlign); - unsafe { &*(&EMPTY_SLICE as *const _ as *const List) } + unsafe { &*(std::ptr::addr_of!(EMPTY_SLICE) as *const List) } } pub fn len(&self) -> usize { diff --git a/compiler/stable_mir/src/compiler_interface.rs b/compiler/stable_mir/src/compiler_interface.rs index 6272f793f40cc..0f7d8d7e083bf 100644 --- a/compiler/stable_mir/src/compiler_interface.rs +++ b/compiler/stable_mir/src/compiler_interface.rs @@ -208,7 +208,7 @@ where if TLV.is_set() { Err(Error::from("StableMIR already running")) } else { - let ptr: *const () = &context as *const &_ as _; + let ptr: *const () = std::ptr::addr_of!(context) as _; TLV.set(&Cell::new(ptr), || Ok(f())) } } From c7be4439ade7cd4b1e506bd87f2c9b131c6d594e Mon Sep 17 00:00:00 2001 From: Ross Smyth Date: Fri, 23 Feb 2024 19:09:46 -0500 Subject: [PATCH 283/417] Windows miri-script execution egronomics This allows for Windows users to use miri-script without pain --- src/tools/miri/miri.bat | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/tools/miri/miri.bat diff --git a/src/tools/miri/miri.bat b/src/tools/miri/miri.bat new file mode 100644 index 0000000000000..91e8a6e8f3b25 --- /dev/null +++ b/src/tools/miri/miri.bat @@ -0,0 +1,10 @@ +:: This makes execution of ./miri on Linux and Windows the same. +:: Windows will not execute the bash script, and select this. +@echo off +set MIRI_SCRIPT_TARGET_DIR=%0\..\miri-script\target +cargo build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml + +:: Forwards all arguments to this file to the executable. +:: We invoke the binary directly to avoid going through rustup, which would set some extra +:: env vars that we do not want. +%MIRI_SCRIPT_TARGET_DIR%\debug\miri-script %* From 3e7c2e1f6dcfb2d1b1c81885c274a4d73f91b0f3 Mon Sep 17 00:00:00 2001 From: Ross Smyth Date: Fri, 23 Feb 2024 12:03:01 -0500 Subject: [PATCH 284/417] Add "cargo miri clean" command --- src/tools/miri/README.md | 4 +- src/tools/miri/cargo-miri/src/phases.rs | 23 ++++++--- src/tools/miri/cargo-miri/src/setup.rs | 9 +--- src/tools/miri/cargo-miri/src/util.rs | 64 +++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 16 deletions(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 60bf07b1736e4..944d2bbe87941 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -279,7 +279,7 @@ Miri builds and vice-versa. You may be running `cargo miri` with a different compiler version than the one used to build the custom libstd that Miri uses, and Miri failed to detect that. -Try deleting `~/.cache/miri`. +Try running `cargo miri clean`. #### "no mir for `std::rt::lang_start_internal`" @@ -465,7 +465,7 @@ Moreover, Miri recognizes some environment variables: must point to the `library` subdirectory of a `rust-lang/rust` repository checkout. Note that changing files in that directory does not automatically trigger a re-build of the standard library; you have to clear the Miri build - cache manually (on Linux, `rm -rf ~/.cache/miri`; + cache with `cargo miri clean` or deleting it manually (on Linux, `rm -rf ~/.cache/miri`; on Windows, `rmdir /S "%LOCALAPPDATA%\rust-lang\miri\cache"`; and on macOS, `rm -rf ~/Library/Caches/org.rust-lang.miri`). * `MIRI_SYSROOT` (recognized by `cargo miri` and the Miri driver) indicates the sysroot to use. When diff --git a/src/tools/miri/cargo-miri/src/phases.rs b/src/tools/miri/cargo-miri/src/phases.rs index 79ce1f4ca3226..315f7a23a912a 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -20,6 +20,7 @@ Subcommands: test, t Run tests nextest Run tests with nextest (requires cargo-nextest installed) setup Only perform automatic setup, but without asking questions (for getting a proper libstd) + clean Clean the Miri cache & target directory The cargo options are exactly the same as for `cargo run` and `cargo test`, respectively. @@ -74,14 +75,15 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { // We cannot know which of those flags take arguments and which do not, // so we cannot detect subcommands later. let Some(subcommand) = args.next() else { - show_error!("`cargo miri` needs to be called with a subcommand (`run`, `test`)"); + show_error!("`cargo miri` needs to be called with a subcommand (`run`, `test`, `clean`)"); }; let subcommand = match &*subcommand { "setup" => MiriCommand::Setup, "test" | "t" | "run" | "r" | "nextest" => MiriCommand::Forward(subcommand), + "clean" => MiriCommand::Clean, _ => show_error!( - "`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, and `setup`." + "`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, `clean`, and `setup`." ), }; let verbose = num_arg_flag("-v"); @@ -93,6 +95,16 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { let target = get_arg_flag_value("--target"); let target = target.as_ref().unwrap_or(host); + // If cleaning the the target directory & sysroot cache, + // delete them then exit. There is no reason to setup a new + // sysroot in this execution. + if let MiriCommand::Clean = subcommand { + let metadata = get_cargo_metadata(); + clean_target_dir(&metadata); + clean_sysroot(); + return; + } + // We always setup. let miri_sysroot = setup(&subcommand, target, &rustc_version, verbose); @@ -110,6 +122,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { let cargo_cmd = match subcommand { MiriCommand::Forward(s) => s, MiriCommand::Setup => return, // `cargo miri setup` stops here. + MiriCommand::Clean => unreachable!(), }; let metadata = get_cargo_metadata(); let mut cmd = cargo(); @@ -142,11 +155,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { .arg(format!("target.'cfg(all())'.runner=[{cargo_miri_path_for_toml}, 'runner']")); // Set `--target-dir` to `miri` inside the original target directory. - let mut target_dir = match get_arg_flag_value("--target-dir") { - Some(dir) => PathBuf::from(dir), - None => metadata.target_directory.clone().into_std_path_buf(), - }; - target_dir.push("miri"); + let target_dir = get_target_dir(&metadata); cmd.arg("--target-dir").arg(target_dir); // *After* we set all the flags that need setting, forward everything else. Make sure to skip diff --git a/src/tools/miri/cargo-miri/src/setup.rs b/src/tools/miri/cargo-miri/src/setup.rs index 8ae5b8c3e82cc..a98e1fcd485ea 100644 --- a/src/tools/miri/cargo-miri/src/setup.rs +++ b/src/tools/miri/cargo-miri/src/setup.rs @@ -67,13 +67,8 @@ pub fn setup( } // Determine where to put the sysroot. - let sysroot_dir = match std::env::var_os("MIRI_SYSROOT") { - Some(dir) => PathBuf::from(dir), - None => { - let user_dirs = directories::ProjectDirs::from("org", "rust-lang", "miri").unwrap(); - user_dirs.cache_dir().to_owned() - } - }; + let sysroot_dir = get_sysroot_dir(); + // Sysroot configuration and build details. let no_std = match std::env::var_os("MIRI_NO_STD") { None => diff --git a/src/tools/miri/cargo-miri/src/util.rs b/src/tools/miri/cargo-miri/src/util.rs index 3c5912684556c..6c1a074cd8c6e 100644 --- a/src/tools/miri/cargo-miri/src/util.rs +++ b/src/tools/miri/cargo-miri/src/util.rs @@ -74,6 +74,8 @@ pub enum MiriCommand { Setup, /// A command to be forwarded to cargo. Forward(String), + /// Clean the miri cache + Clean, } /// Escapes `s` in a way that is suitable for using it as a string literal in TOML syntax. @@ -249,3 +251,65 @@ pub fn debug_cmd(prefix: &str, verbose: usize, cmd: &Command) { } eprintln!("{prefix} running command: {cmd:?}"); } + +/// Get the target directory for miri output. +/// +/// Either in an argument passed-in, or from cargo metadata. +pub fn get_target_dir(meta: &Metadata) -> PathBuf { + let mut output = match get_arg_flag_value("--target-dir") { + Some(dir) => PathBuf::from(dir), + None => meta.target_directory.clone().into_std_path_buf(), + }; + output.push("miri"); + output +} + +/// Determines where the sysroot of this exeuction is +/// +/// Either in a user-specified spot by an envar, or in a default cache location. +pub fn get_sysroot_dir() -> PathBuf { + match std::env::var_os("MIRI_SYSROOT") { + Some(dir) => PathBuf::from(dir), + None => { + let user_dirs = directories::ProjectDirs::from("org", "rust-lang", "miri").unwrap(); + user_dirs.cache_dir().to_owned() + } + } +} + +/// An idempotent version of the stdlib's remove_dir_all +/// it is considered a success if the directory was not there. +fn remove_dir_all_idem(dir: &Path) -> std::io::Result<()> { + match std::fs::remove_dir_all(dir) { + Ok(_) => Ok(()), + // If the directory doesn't exist, it is still a success. + Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(()), + Err(err) => Err(err), + } +} + +/// Deletes the Miri sysroot cache +/// Returns an error if the MIRI_SYSROOT env var is set. +pub fn clean_sysroot() { + if std::env::var_os("MIRI_SYSROOT").is_some() { + show_error!( + "MIRI_SYSROOT is set. Please clean your custom sysroot cache directory manually." + ) + } + + let sysroot_dir = get_sysroot_dir(); + + eprintln!("Cleaning sysroot cache at {}", sysroot_dir.display()); + + // Keep it simple, just remove the directory. + remove_dir_all_idem(&sysroot_dir).unwrap_or_else(|err| show_error!("{}", err)); +} + +/// Deletes the Miri target directory +pub fn clean_target_dir(meta: &Metadata) { + let target_dir = get_target_dir(meta); + + eprintln!("Cleaning target directory at {}", target_dir.display()); + + remove_dir_all_idem(&target_dir).unwrap_or_else(|err| show_error!("{}", err)) +} From cd36cda60c99cc17183a206c93713c375838af81 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 24 Feb 2024 18:26:07 +0100 Subject: [PATCH 285/417] compiletest: call cargo-miri directly rather than via 'cargo run' --- src/tools/miri/tests/compiletest.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 8bed321e6551c..d8f7cafe3b2ed 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -99,18 +99,15 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> }; if with_dependencies { + // Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary. + // (It's a separate crate, so we don't get an env var from cargo.) + let mut prog = miri_path(); + prog.set_file_name("cargo-miri"); + config.dependency_builder.program = prog; + let builder_args = ["miri", "run"]; // There is no `cargo miri build` so we just use `cargo miri run`. + config.dependency_builder.args = builder_args.into_iter().map(Into::into).collect(); config.dependencies_crate_manifest_path = Some(Path::new("test_dependencies").join("Cargo.toml")); - let mut builder_args = vec!["run".into()]; - builder_args.extend(flagsplit(&env::var("CARGO_EXTRA_FLAGS").unwrap_or_default())); - builder_args.extend([ - "--manifest-path".into(), - "cargo-miri/Cargo.toml".into(), - "--".into(), - "miri".into(), - "run".into(), // There is no `cargo miri build` so we just use `cargo miri run`. - ]); - config.dependency_builder.args = builder_args.into_iter().map(Into::into).collect(); // Reset `RUSTFLAGS` to work around . config.dependency_builder.envs.push(("RUSTFLAGS".into(), None)); } From 81d7069e342fe506baa2a8431a975ec63e9b9713 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:08:03 +0100 Subject: [PATCH 286/417] Add `#[rustc_no_mir_inline]` for standard library UB checks Co-authored-by: Ben Kimock --- compiler/rustc_feature/src/builtin_attrs.rs | 4 ++++ compiler/rustc_mir_transform/src/inline.rs | 4 ++++ compiler/rustc_span/src/symbol.rs | 1 + library/core/src/intrinsics.rs | 18 +++++++++++++++--- ..._mir_inline.caller.Inline.panic-abort.diff | 19 +++++++++++++++++++ ...mir_inline.caller.Inline.panic-unwind.diff | 19 +++++++++++++++++++ ...ne.caller.PreCodegen.after.panic-abort.mir | 14 ++++++++++++++ ...e.caller.PreCodegen.after.panic-unwind.mir | 14 ++++++++++++++ tests/mir-opt/inline/rustc_no_mir_inline.rs | 17 +++++++++++++++++ 9 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-abort.diff create mode 100644 tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-unwind.diff create mode 100644 tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-abort.mir create mode 100644 tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-unwind.mir create mode 100644 tests/mir-opt/inline/rustc_no_mir_inline.rs diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 99875ec540545..003baf071b8c8 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -792,6 +792,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_intrinsic, Normal, template!(Word), ErrorFollowing, "the `#[rustc_intrinsic]` attribute is used to declare intrinsics with function bodies", ), + rustc_attr!( + rustc_no_mir_inline, Normal, template!(Word), WarnFollowing, + "#[rustc_no_mir_inline] prevents the MIR inliner from inlining a function while not affecting codegen" + ), // ========================================================================== // Internal attributes, Testing: diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 2009539d4d084..36546a03cdfc5 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -421,6 +421,10 @@ impl<'tcx> Inliner<'tcx> { callee_attrs: &CodegenFnAttrs, cross_crate_inlinable: bool, ) -> Result<(), &'static str> { + if self.tcx.has_attr(callsite.callee.def_id(), sym::rustc_no_mir_inline) { + return Err("#[rustc_no_mir_inline]"); + } + if let InlineAttr::Never = callee_attrs.inline { return Err("never inline hint"); } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 46472a131ff4b..609ab054da21e 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1441,6 +1441,7 @@ symbols! { rustc_mir, rustc_must_implement_one_of, rustc_never_returns_null_ptr, + rustc_no_mir_inline, rustc_nonnull_optimization_guaranteed, rustc_nounwind, rustc_object_lifetime_default, diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index e42b2315ea5d7..f9d89795a9988 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2706,13 +2706,25 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) macro_rules! assert_unsafe_precondition { ($message:expr, ($($name:ident:$ty:ty = $arg:expr),*$(,)?) => $e:expr $(,)?) => { { + // #[cfg(bootstrap)] (this comment) // When the standard library is compiled with debug assertions, we want the check to inline for better performance. // This is important when working on the compiler, which is compiled with debug assertions locally. // When not compiled with debug assertions (so the precompiled std) we outline the check to minimize the compile // time impact when debug assertions are disabled. - // It is not clear whether that is the best solution, see #120848. - #[cfg_attr(debug_assertions, inline(always))] - #[cfg_attr(not(debug_assertions), inline(never))] + // The proper solution to this is the `#[rustc_no_mir_inline]` below, but we still want decent performance for cfg(bootstrap). + #[cfg_attr(all(debug_assertions, bootstrap), inline(always))] + #[cfg_attr(all(not(debug_assertions), bootstrap), inline(never))] + + // This check is inlineable, but not by the MIR inliner. + // The reason for this is that the MIR inliner is in an exceptionally bad position + // to think about whether or not to inline this. In MIR, this call is gated behind `debug_assertions`, + // which will codegen to `false` in release builds. Inlining the check would be wasted work in that case and + // would be bad for compile times. + // + // LLVM on the other hand sees the constant branch, so if it's `false`, it can immediately delete it without + // inlining the check. If it's `true`, it can inline it and get significantly better performance. + #[cfg_attr(not(bootstrap), rustc_no_mir_inline)] + #[cfg_attr(not(bootstrap), inline)] #[rustc_nounwind] fn precondition_check($($name:$ty),*) { if !$e { diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-abort.diff b/tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-abort.diff new file mode 100644 index 0000000000000..dd79cff1dcf80 --- /dev/null +++ b/tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-abort.diff @@ -0,0 +1,19 @@ +- // MIR for `caller` before Inline ++ // MIR for `caller` after Inline + + fn caller() -> () { + let mut _0: (); + let _1: (); + + bb0: { + StorageLive(_1); + _1 = callee() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-unwind.diff b/tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-unwind.diff new file mode 100644 index 0000000000000..4506a338edd7a --- /dev/null +++ b/tests/mir-opt/inline/rustc_no_mir_inline.caller.Inline.panic-unwind.diff @@ -0,0 +1,19 @@ +- // MIR for `caller` before Inline ++ // MIR for `caller` after Inline + + fn caller() -> () { + let mut _0: (); + let _1: (); + + bb0: { + StorageLive(_1); + _1 = callee() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-abort.mir new file mode 100644 index 0000000000000..d0772e51a07fe --- /dev/null +++ b/tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-abort.mir @@ -0,0 +1,14 @@ +// MIR for `caller` after PreCodegen + +fn caller() -> () { + let mut _0: (); + let _1: (); + + bb0: { + _1 = callee() -> [return: bb1, unwind unreachable]; + } + + bb1: { + return; + } +} diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-unwind.mir new file mode 100644 index 0000000000000..39ad4f1010b79 --- /dev/null +++ b/tests/mir-opt/inline/rustc_no_mir_inline.caller.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,14 @@ +// MIR for `caller` after PreCodegen + +fn caller() -> () { + let mut _0: (); + let _1: (); + + bb0: { + _1 = callee() -> [return: bb1, unwind continue]; + } + + bb1: { + return; + } +} diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.rs b/tests/mir-opt/inline/rustc_no_mir_inline.rs new file mode 100644 index 0000000000000..b008df32726b5 --- /dev/null +++ b/tests/mir-opt/inline/rustc_no_mir_inline.rs @@ -0,0 +1,17 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +#![crate_type = "lib"] +#![feature(rustc_attrs)] + +//@ compile-flags: -Zmir-opt-level=2 -Zinline-mir + +#[inline] +#[rustc_no_mir_inline] +pub fn callee() {} + +// EMIT_MIR rustc_no_mir_inline.caller.Inline.diff +// EMIT_MIR rustc_no_mir_inline.caller.PreCodegen.after.mir +pub fn caller() { + // CHECK-LABEL: fn caller( + // CHECK: callee() + callee(); +} From 93ec0e6299e31e6857e8ad741750034f35762b11 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 4 Jan 2024 19:06:37 +0000 Subject: [PATCH 287/417] Stabilize `cfg_target_abi` --- compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/builtin_attrs.rs | 1 - compiler/rustc_feature/src/unstable.rs | 2 - .../src/spec/targets/armv6_unknown_freebsd.rs | 3 +- .../targets/armv6_unknown_netbsd_eabihf.rs | 2 - .../src/spec/targets/armv7_unknown_freebsd.rs | 3 +- .../targets/armv7_unknown_netbsd_eabihf.rs | 2 - library/unwind/src/lib.rs | 2 +- tests/ui/cfg/cfg-target-abi.rs | 1 - tests/ui/check-cfg/well-known-values.rs | 1 - tests/ui/check-cfg/well-known-values.stderr | 56 +++++++++---------- .../feature-gate-cfg-target-abi.rs | 13 ----- .../feature-gate-cfg-target-abi.stderr | 43 -------------- 13 files changed, 33 insertions(+), 98 deletions(-) delete mode 100644 tests/ui/feature-gates/feature-gate-cfg-target-abi.rs delete mode 100644 tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 18f6ae35054b4..1b2993dabdb83 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -84,6 +84,8 @@ declare_features! ( (accepted, cfg_doctest, "1.40.0", Some(62210)), /// Enables `#[cfg(panic = "...")]` config key. (accepted, cfg_panic, "1.60.0", Some(77443)), + /// Allows `cfg(target_abi = "...")`. + (accepted, cfg_target_abi, "CURRENT_RUSTC_VERSION", Some(80970)), /// Allows `cfg(target_feature = "...")`. (accepted, cfg_target_feature, "1.27.0", Some(29717)), /// Allows `cfg(target_vendor = "...")`. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 99875ec540545..5b4221a9f400d 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -25,7 +25,6 @@ pub type GatedCfg = (Symbol, Symbol, GateFn); const GATED_CFGS: &[GatedCfg] = &[ // (name in cfg, feature, function to check if the feature is enabled) (sym::overflow_checks, sym::cfg_overflow_checks, cfg_fn!(cfg_overflow_checks)), - (sym::target_abi, sym::cfg_target_abi, cfg_fn!(cfg_target_abi)), (sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)), ( sym::target_has_atomic_equal_alignment, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 93c183a65ef3e..8eea4b7d8a8d3 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -373,8 +373,6 @@ declare_features! ( (unstable, cfg_sanitize, "1.41.0", Some(39699)), /// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`. (unstable, cfg_sanitizer_cfi, "1.77.0", Some(89653)), - /// Allows `cfg(target_abi = "...")`. - (unstable, cfg_target_abi, "1.55.0", Some(80970)), /// Allows `cfg(target(abi = "..."))`. (unstable, cfg_target_compact, "1.63.0", Some(96901)), /// Allows `cfg(target_has_atomic_load_store = "...")`. diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs index 22f6ee8105576..70e40f60f22a0 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs @@ -8,8 +8,7 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".into(), + env: "gnu".into(), features: "+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs index 84d9ceac04d46..ca0db5e564001 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs @@ -8,8 +8,6 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".into(), features: "+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), mcount: "__mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs index 9f4a432c6fa5f..61b6d7a63e358 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs @@ -8,8 +8,7 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".into(), + env: "gnu".into(), features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs index e5518c6daecf0..7afdb87b62eee 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs @@ -8,8 +8,6 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".into(), features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "__mcount".into(), diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index f5988a4df1364..a64f290463374 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -3,7 +3,7 @@ #![feature(link_cfg)] #![feature(staged_api)] #![feature(c_unwind)] -#![feature(cfg_target_abi)] +#![cfg_attr(bootstrap, feature(cfg_target_abi))] #![feature(strict_provenance)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] #![allow(internal_features)] diff --git a/tests/ui/cfg/cfg-target-abi.rs b/tests/ui/cfg/cfg-target-abi.rs index 5d13337c1c303..306ae077325b4 100644 --- a/tests/ui/cfg/cfg-target-abi.rs +++ b/tests/ui/cfg/cfg-target-abi.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(cfg_target_abi)] #[cfg(target_abi = "eabihf")] pub fn main() { diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index 0c55e35a993fb..859a36c604c6f 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -10,7 +10,6 @@ #![feature(cfg_overflow_checks)] #![feature(cfg_relocation_model)] #![feature(cfg_sanitize)] -#![feature(cfg_target_abi)] #![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic_equal_alignment)] #![feature(cfg_target_thread_local)] diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 6535cd9a1a1f0..5f52421fef5b2 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:26:5 + --> $DIR/well-known-values.rs:25:5 | LL | clippy = "_UNEXPECTED_VALUE", | ^^^^^^---------------------- @@ -11,7 +11,7 @@ LL | clippy = "_UNEXPECTED_VALUE", = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:28:5 + --> $DIR/well-known-values.rs:27:5 | LL | debug_assertions = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^---------------------- @@ -22,7 +22,7 @@ LL | debug_assertions = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:30:5 + --> $DIR/well-known-values.rs:29:5 | LL | doc = "_UNEXPECTED_VALUE", | ^^^---------------------- @@ -33,7 +33,7 @@ LL | doc = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:32:5 + --> $DIR/well-known-values.rs:31:5 | LL | doctest = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -44,7 +44,7 @@ LL | doctest = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:34:5 + --> $DIR/well-known-values.rs:33:5 | LL | miri = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -55,7 +55,7 @@ LL | miri = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:36:5 + --> $DIR/well-known-values.rs:35:5 | LL | overflow_checks = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^---------------------- @@ -66,7 +66,7 @@ LL | overflow_checks = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:38:5 + --> $DIR/well-known-values.rs:37:5 | LL | panic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL | panic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:40:5 + --> $DIR/well-known-values.rs:39:5 | LL | proc_macro = "_UNEXPECTED_VALUE", | ^^^^^^^^^^---------------------- @@ -86,7 +86,7 @@ LL | proc_macro = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:42:5 + --> $DIR/well-known-values.rs:41:5 | LL | relocation_model = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | relocation_model = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:44:5 + --> $DIR/well-known-values.rs:43:5 | LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | sanitize = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:46:5 + --> $DIR/well-known-values.rs:45:5 | LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | target_abi = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:48:5 + --> $DIR/well-known-values.rs:47:5 | LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | target_arch = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:50:5 + --> $DIR/well-known-values.rs:49:5 | LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -131,16 +131,16 @@ LL | target_endian = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:52:5 + --> $DIR/well-known-values.rs:51:5 | LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_env` are: ``, `eabihf`, `gnu`, `gnueabihf`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `psx`, `relibc`, `sgx`, `uclibc` + = note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `psx`, `relibc`, `sgx`, `uclibc` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:54:5 + --> $DIR/well-known-values.rs:53:5 | LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | target_family = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:56:5 + --> $DIR/well-known-values.rs:55:5 | LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | target_feature = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:58:5 + --> $DIR/well-known-values.rs:57:5 | LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:60:5 + --> $DIR/well-known-values.rs:59:5 | LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -176,7 +176,7 @@ LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:62:5 + --> $DIR/well-known-values.rs:61:5 | LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -185,7 +185,7 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:64:5 + --> $DIR/well-known-values.rs:63:5 | LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ LL | target_os = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:66:5 + --> $DIR/well-known-values.rs:65:5 | LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:68:5 + --> $DIR/well-known-values.rs:67:5 | LL | target_thread_local = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^---------------------- @@ -214,7 +214,7 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:70:5 + --> $DIR/well-known-values.rs:69:5 | LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -223,7 +223,7 @@ LL | target_vendor = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:72:5 + --> $DIR/well-known-values.rs:71:5 | LL | test = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -234,7 +234,7 @@ LL | test = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:74:5 + --> $DIR/well-known-values.rs:73:5 | LL | unix = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -245,7 +245,7 @@ LL | unix = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:76:5 + --> $DIR/well-known-values.rs:75:5 | LL | windows = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -256,7 +256,7 @@ LL | windows = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` - --> $DIR/well-known-values.rs:82:7 + --> $DIR/well-known-values.rs:81:7 | LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | ^^^^^^^^^^^^------- diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-abi.rs b/tests/ui/feature-gates/feature-gate-cfg-target-abi.rs deleted file mode 100644 index d005dc3ad456d..0000000000000 --- a/tests/ui/feature-gates/feature-gate-cfg-target-abi.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[cfg(target_abi = "x")] //~ ERROR `cfg(target_abi)` is experimental -struct Foo(u64, u64); - -#[cfg_attr(target_abi = "x", x)] //~ ERROR `cfg(target_abi)` is experimental -struct Bar(u64, u64); - -#[cfg(not(any(all(target_abi = "x"))))] //~ ERROR `cfg(target_abi)` is experimental -fn foo() {} - -fn main() { - cfg!(target_abi = "x"); - //~^ ERROR `cfg(target_abi)` is experimental and subject to change -} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr deleted file mode 100644 index 4829f8572cc5f..0000000000000 --- a/tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0658]: `cfg(target_abi)` is experimental and subject to change - --> $DIR/feature-gate-cfg-target-abi.rs:1:7 - | -LL | #[cfg(target_abi = "x")] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #80970 for more information - = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `cfg(target_abi)` is experimental and subject to change - --> $DIR/feature-gate-cfg-target-abi.rs:4:12 - | -LL | #[cfg_attr(target_abi = "x", x)] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #80970 for more information - = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `cfg(target_abi)` is experimental and subject to change - --> $DIR/feature-gate-cfg-target-abi.rs:7:19 - | -LL | #[cfg(not(any(all(target_abi = "x"))))] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #80970 for more information - = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `cfg(target_abi)` is experimental and subject to change - --> $DIR/feature-gate-cfg-target-abi.rs:11:10 - | -LL | cfg!(target_abi = "x"); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #80970 for more information - = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. From 2401ae1896bf47d0c393dd21596817cf83153320 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:44:21 +0100 Subject: [PATCH 288/417] Make most bootstrap step types !Copy This makes all bootstrap types except for `Compiler` and `TargetSelection` `!Copy`. This makes it easier to modify them by adding !Copy types in the future and comes at no cost of code clarity, the impls were completely unused. --- src/bootstrap/src/core/build_steps/check.rs | 4 +- src/bootstrap/src/core/build_steps/clean.rs | 2 +- src/bootstrap/src/core/build_steps/compile.rs | 6 +- src/bootstrap/src/core/build_steps/dist.rs | 38 +++++------ src/bootstrap/src/core/build_steps/doc.rs | 20 +++--- src/bootstrap/src/core/build_steps/install.rs | 4 +- src/bootstrap/src/core/build_steps/llvm.rs | 10 +-- src/bootstrap/src/core/build_steps/run.rs | 18 ++--- src/bootstrap/src/core/build_steps/setup.rs | 6 +- .../src/core/build_steps/synthetic_targets.rs | 2 +- src/bootstrap/src/core/build_steps/test.rs | 66 +++++++++---------- src/bootstrap/src/core/build_steps/tool.rs | 20 +++--- src/bootstrap/src/core/builder.rs | 2 +- 13 files changed, 99 insertions(+), 99 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 3ac60f15ef67e..f6f4253a36435 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -367,7 +367,7 @@ impl Step for CodegenBackend { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustAnalyzer { pub target: TargetSelection, } @@ -441,7 +441,7 @@ impl Step for RustAnalyzer { macro_rules! tool_check_step { ($name:ident, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )?) => { - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index 4b993945f19fc..17ca92f25a928 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -14,7 +14,7 @@ use crate::utils::cache::Interned; use crate::utils::helpers::t; use crate::{Build, Compiler, Mode, Subcommand}; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CleanAll {} impl Step for CleanAll { diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d349cd67fed2c..938813044217b 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -727,7 +727,7 @@ fn apple_darwin_sign_file(file_path: &Path) { assert!(status.success()); } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StartupObjects { pub compiler: Compiler, pub target: TargetSelection, @@ -1491,7 +1491,7 @@ pub fn compiler_file( PathBuf::from(out.trim()) } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Sysroot { pub compiler: Compiler, /// See [`Std::force_recompile`]. @@ -1653,7 +1653,7 @@ impl Step for Sysroot { } } -#[derive(Debug, Copy, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] pub struct Assemble { /// The compiler which we will produce in this step. Assemble itself will /// take care of ensuring that the necessary prerequisites to do so exist, diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index d9ab18e7250b0..fe50a787f9f05 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -50,7 +50,7 @@ fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool { builder.config.tools.as_ref().map_or(true, |tools| tools.contains(tool)) } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Docs { pub host: TargetSelection, } @@ -83,7 +83,7 @@ impl Step for Docs { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct JsonDocs { pub host: TargetSelection, } @@ -121,7 +121,7 @@ impl Step for JsonDocs { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustcDocs { pub host: TargetSelection, } @@ -308,7 +308,7 @@ fn make_win_dist( } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Mingw { pub host: TargetSelection, } @@ -348,7 +348,7 @@ impl Step for Mingw { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Rustc { pub compiler: Compiler, } @@ -476,7 +476,7 @@ impl Step for Rustc { let man_src = builder.src.join("src/doc/man"); let man_dst = image.join("share/man/man1"); - // don't use our `bootstrap::{copy, cp_r}`, because those try + // don't use our `bootstrap::{copy_internal, cp_r}`, because those try // to hardlink, and we don't want to edit the source templates for file_entry in builder.read_dir(&man_src) { let page_src = file_entry.path(); @@ -617,7 +617,7 @@ fn copy_target_libs(builder: &Builder<'_>, target: TargetSelection, image: &Path } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Std { pub compiler: Compiler, pub target: TargetSelection, @@ -664,7 +664,7 @@ impl Step for Std { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct RustcDev { pub compiler: Compiler, pub target: TargetSelection, @@ -723,7 +723,7 @@ impl Step for RustcDev { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Analysis { pub compiler: Compiler, pub target: TargetSelection, @@ -870,7 +870,7 @@ fn copy_src_dirs( } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Src; impl Step for Src { @@ -931,7 +931,7 @@ impl Step for Src { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct PlainSourceTarball; impl Step for PlainSourceTarball { @@ -1031,7 +1031,7 @@ impl Step for PlainSourceTarball { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, pub target: TargetSelection, @@ -1080,7 +1080,7 @@ impl Step for Cargo { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Rls { pub compiler: Compiler, pub target: TargetSelection, @@ -1122,7 +1122,7 @@ impl Step for Rls { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzer { pub compiler: Compiler, pub target: TargetSelection, @@ -1164,7 +1164,7 @@ impl Step for RustAnalyzer { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Clippy { pub compiler: Compiler, pub target: TargetSelection, @@ -1212,7 +1212,7 @@ impl Step for Clippy { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Miri { pub compiler: Compiler, pub target: TargetSelection, @@ -1359,7 +1359,7 @@ impl Step for CodegenBackend { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Rustfmt { pub compiler: Compiler, pub target: TargetSelection, @@ -1404,7 +1404,7 @@ impl Step for Rustfmt { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct RustDemangler { pub compiler: Compiler, pub target: TargetSelection, @@ -1460,7 +1460,7 @@ impl Step for RustDemangler { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Extended { stage: u32, host: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 7a122a8676ba7..a4903ce235365 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -32,7 +32,7 @@ macro_rules! submodule_helper { macro_rules! book { ($($name:ident, $path:expr, $book_name:expr $(, submodule $(= $submodule:literal)? )? ;)+) => { $( - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { target: TargetSelection, } @@ -86,7 +86,7 @@ book!( StyleGuide, "src/doc/style-guide", "style-guide"; ); -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct UnstableBook { target: TargetSelection, } @@ -160,7 +160,7 @@ impl Step for RustbookSrc

{ } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct TheBook { compiler: Compiler, target: TargetSelection, @@ -286,7 +286,7 @@ fn invoke_rustdoc( builder.run(&mut cmd); } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Standalone { compiler: Compiler, target: TargetSelection, @@ -389,7 +389,7 @@ impl Step for Standalone { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Releases { compiler: Compiler, target: TargetSelection, @@ -492,7 +492,7 @@ pub struct SharedAssetsPaths { pub version_info: PathBuf, } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct SharedAssets { target: TargetSelection, } @@ -872,7 +872,7 @@ macro_rules! tool_doc { $(is_library = $is_library:expr,)? $(crates = $crates:expr)? ) => { - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $tool { target: TargetSelection, } @@ -1021,7 +1021,7 @@ tool_doc!( crates = ["bootstrap"] ); -#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { pub target: TargetSelection, } @@ -1056,7 +1056,7 @@ impl Step for ErrorIndex { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct UnstableBookGen { target: TargetSelection, } @@ -1112,7 +1112,7 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) { ); } -#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)] pub struct RustcBook { pub compiler: Compiler, pub target: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 29238b90225af..6726671ddd9b3 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -159,7 +159,7 @@ macro_rules! install { only_hosts: $only_hosts:expr, $run_item:block $(, $c:ident)*;)+) => { $( - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -303,7 +303,7 @@ install!((self, builder, _config), }; ); -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Src { pub stage: u32, } diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 9622321a74e7c..4a92acfa3d90d 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -242,7 +242,7 @@ pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Llvm { pub target: TargetSelection, } @@ -815,7 +815,7 @@ fn get_var(var_base: &str, host: &str, target: &str) -> Option { .or_else(|| env::var_os(var_base)) } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Lld { pub target: TargetSelection, } @@ -937,7 +937,7 @@ impl Step for Lld { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Sanitizers { pub target: TargetSelection, } @@ -1147,7 +1147,7 @@ impl HashStamp { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrtBeginEnd { pub target: TargetSelection, } @@ -1215,7 +1215,7 @@ impl Step for CrtBeginEnd { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Libunwind { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 27b0c7760f078..61ee2fc1f6f3d 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -10,7 +10,7 @@ use crate::core::config::TargetSelection; use crate::utils::helpers::output; use crate::Mode; -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExpandYamlAnchors; impl Step for ExpandYamlAnchors { @@ -36,7 +36,7 @@ impl Step for ExpandYamlAnchors { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct BuildManifest; impl Step for BuildManifest { @@ -75,7 +75,7 @@ impl Step for BuildManifest { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct BumpStage0; impl Step for BumpStage0 { @@ -97,7 +97,7 @@ impl Step for BumpStage0 { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct ReplaceVersionPlaceholder; impl Step for ReplaceVersionPlaceholder { @@ -119,7 +119,7 @@ impl Step for ReplaceVersionPlaceholder { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Miri { stage: u32, host: TargetSelection, @@ -178,7 +178,7 @@ impl Step for Miri { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct CollectLicenseMetadata; impl Step for CollectLicenseMetadata { @@ -210,7 +210,7 @@ impl Step for CollectLicenseMetadata { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct GenerateCopyright; impl Step for GenerateCopyright { @@ -240,7 +240,7 @@ impl Step for GenerateCopyright { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct GenerateWindowsSys; impl Step for GenerateWindowsSys { @@ -262,7 +262,7 @@ impl Step for GenerateWindowsSys { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct GenerateCompletions; macro_rules! generate_completions { diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 74a5578b43ec1..7bc68b5aec11f 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -233,7 +233,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) { } /// Creates a toolchain link for stage1 using `rustup` -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Link; impl Step for Link { type Output = (); @@ -444,7 +444,7 @@ fn prompt_user(prompt: &str) -> io::Result> { } /// Installs `src/etc/pre-push.sh` as a Git hook -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Hook; impl Step for Hook { @@ -516,7 +516,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." } /// Sets up or displays `src/etc/rust_analyzer_settings.json` -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Vscode; impl Step for Vscode { diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index a00835402ec8b..89d50b5ffffa4 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -12,7 +12,7 @@ use crate::core::config::TargetSelection; use crate::Compiler; use std::process::{Command, Stdio}; -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) struct MirOptPanicAbortSyntheticTarget { pub(crate) compiler: Compiler, pub(crate) base: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 791f847a8661a..a2c6e79d5e25c 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -86,7 +86,7 @@ impl Step for CrateBootstrap { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Linkcheck { host: TargetSelection, } @@ -179,7 +179,7 @@ fn check_if_tidy_is_installed() -> bool { .map_or(false, |status| status.success()) } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct HtmlCheck { target: TargetSelection, } @@ -220,7 +220,7 @@ impl Step for HtmlCheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Cargotest { stage: u32, host: TargetSelection, @@ -266,7 +266,7 @@ impl Step for Cargotest { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Cargo { stage: u32, host: TargetSelection, @@ -327,7 +327,7 @@ impl Step for Cargo { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustAnalyzer { stage: u32, host: TargetSelection, @@ -386,7 +386,7 @@ impl Step for RustAnalyzer { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Rustfmt { stage: u32, host: TargetSelection, @@ -433,7 +433,7 @@ impl Step for Rustfmt { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustDemangler { stage: u32, host: TargetSelection, @@ -492,7 +492,7 @@ impl Step for RustDemangler { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Miri { stage: u32, host: TargetSelection, @@ -699,7 +699,7 @@ impl Step for Miri { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CompiletestTest { host: TargetSelection, } @@ -747,7 +747,7 @@ impl Step for CompiletestTest { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Clippy { stage: u32, host: TargetSelection, @@ -815,7 +815,7 @@ fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString { env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocTheme { pub compiler: Compiler, } @@ -852,7 +852,7 @@ impl Step for RustdocTheme { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocJSStd { pub target: TargetSelection, } @@ -912,7 +912,7 @@ impl Step for RustdocJSStd { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocJSNotStd { pub target: TargetSelection, pub compiler: Compiler, @@ -966,7 +966,7 @@ fn get_browser_ui_test_version(npm: &Path) -> Option { .or_else(|| get_browser_ui_test_version_inner(npm, true)) } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocGUI { pub target: TargetSelection, pub compiler: Compiler, @@ -1060,7 +1060,7 @@ impl Step for RustdocGUI { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Tidy; impl Step for Tidy { @@ -1151,7 +1151,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExpandYamlAnchors; impl Step for ExpandYamlAnchors { @@ -1251,7 +1251,7 @@ macro_rules! test_definitions { host: $host:expr, compare_mode: $compare_mode:expr }) => { - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -1294,7 +1294,7 @@ macro_rules! coverage_test_alias { default: $default:expr, only_hosts: $only_hosts:expr $(,)? }) => { - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -1376,7 +1376,7 @@ default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assem /// /// Each individual mode also has its own alias that will run the tests in /// just that mode. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Coverage { pub compiler: Compiler, pub target: TargetSelection, @@ -1438,7 +1438,7 @@ host_test!(CoverageRunRustdoc { }); // For the mir-opt suite we do not use macros, as we need custom behavior when blessing. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct MirOpt { pub compiler: Compiler, pub target: TargetSelection, @@ -1494,7 +1494,7 @@ impl Step for MirOpt { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] struct Compiletest { compiler: Compiler, target: TargetSelection, @@ -2142,7 +2142,7 @@ impl BookTest { macro_rules! test_book { ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => { $( - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { compiler: Compiler, } @@ -2187,7 +2187,7 @@ test_book!( EditionGuide, "src/doc/edition-guide", "edition-guide", default=false; ); -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ErrorIndex { compiler: Compiler, } @@ -2264,7 +2264,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustcGuide; impl Step for RustcGuide { @@ -2537,7 +2537,7 @@ impl Step for Crate { } /// Rustdoc is special in various ways, which is why this step is different from `Crate`. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdoc { host: TargetSelection, } @@ -2638,7 +2638,7 @@ impl Step for CrateRustdoc { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdocJsonTypes { host: TargetSelection, } @@ -2708,7 +2708,7 @@ impl Step for CrateRustdocJsonTypes { /// QEMU we have to build our own tools so we've got conditional dependencies /// on those programs as well. Note that the remote test client is built for /// the build target (us) and the server is built for the target. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RemoteCopyLibs { compiler: Compiler, target: TargetSelection, @@ -2754,7 +2754,7 @@ impl Step for RemoteCopyLibs { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Distcheck; impl Step for Distcheck { @@ -2824,7 +2824,7 @@ impl Step for Distcheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Bootstrap; impl Step for Bootstrap { @@ -2876,7 +2876,7 @@ impl Step for Bootstrap { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TierCheck { pub compiler: Compiler, } @@ -2926,7 +2926,7 @@ impl Step for TierCheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct LintDocs { pub compiler: Compiler, pub target: TargetSelection, @@ -2959,7 +2959,7 @@ impl Step for LintDocs { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustInstaller; impl Step for RustInstaller { @@ -3020,7 +3020,7 @@ impl Step for RustInstaller { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TestHelpers { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index ba867a04ec55f..889876f461df2 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -15,7 +15,7 @@ use crate::Compiler; use crate::Mode; use crate::{gha, Kind}; -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum SourceType { InTree, Submodule, @@ -220,7 +220,7 @@ macro_rules! bootstrap_tool { $(,allow_features = $allow_features:expr)? ; )+) => { - #[derive(Copy, PartialEq, Eq, Clone)] + #[derive(PartialEq, Eq, Clone)] pub enum Tool { $( $name, @@ -241,7 +241,7 @@ macro_rules! bootstrap_tool { } $( - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -315,7 +315,7 @@ bootstrap_tool!( CoverageDump, "src/tools/coverage-dump", "coverage-dump"; ); -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] pub struct ErrorIndex { pub compiler: Compiler, } @@ -369,7 +369,7 @@ impl Step for ErrorIndex { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RemoteTestServer { pub compiler: Compiler, pub target: TargetSelection, @@ -403,7 +403,7 @@ impl Step for RemoteTestServer { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] pub struct Rustdoc { /// This should only ever be 0 or 2. /// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here. @@ -515,7 +515,7 @@ impl Step for Rustdoc { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, pub target: TargetSelection, @@ -560,7 +560,7 @@ impl Step for Cargo { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct LldWrapper { pub compiler: Compiler, pub target: TargetSelection, @@ -589,7 +589,7 @@ impl Step for LldWrapper { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzer { pub compiler: Compiler, pub target: TargetSelection, @@ -637,7 +637,7 @@ impl Step for RustAnalyzer { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzerProcMacroSrv { pub compiler: Compiler, pub target: TargetSelection, diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 0ec5e16de1da5..e169cba3c13ae 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1069,7 +1069,7 @@ impl<'a> Builder<'a> { /// Returns the libdir where the standard library and other artifacts are /// found for a compiler's sysroot. pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> Interned { - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct Libdir { compiler: Compiler, target: TargetSelection, From 24aa34858645e96316bb61f4a095d13486a56892 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 24 Feb 2024 15:38:55 -0700 Subject: [PATCH 289/417] Add test cases for inlining compiler-private items Closes #106421 This was already fixed by f5d43a052b9eb464e54af819143467954d814a24, but now the test cases are added. --- tests/rustdoc/auxiliary/issue-106421-force-unstable.rs | 9 +++++++++ tests/rustdoc/issue-106421-not-internal.rs | 8 ++++++++ tests/rustdoc/issue-106421.rs | 8 ++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/rustdoc/auxiliary/issue-106421-force-unstable.rs create mode 100644 tests/rustdoc/issue-106421-not-internal.rs create mode 100644 tests/rustdoc/issue-106421.rs diff --git a/tests/rustdoc/auxiliary/issue-106421-force-unstable.rs b/tests/rustdoc/auxiliary/issue-106421-force-unstable.rs new file mode 100644 index 0000000000000..589d44c1f774d --- /dev/null +++ b/tests/rustdoc/auxiliary/issue-106421-force-unstable.rs @@ -0,0 +1,9 @@ +//@ compile-flags: -Zforce-unstable-if-unmarked +#![crate_name="foo"] +pub struct FatalError; + +impl FatalError { + pub fn raise(self) -> ! { + loop {} + } +} diff --git a/tests/rustdoc/issue-106421-not-internal.rs b/tests/rustdoc/issue-106421-not-internal.rs new file mode 100644 index 0000000000000..1d744fba53f8a --- /dev/null +++ b/tests/rustdoc/issue-106421-not-internal.rs @@ -0,0 +1,8 @@ +//@ aux-build:issue-106421-force-unstable.rs +//@ ignore-cross-compile +// This is the version where a non-compiler-internal crate inlines a compiler-internal one. +// In this case, the item shouldn't be documented, because regular users can't get at it. +extern crate foo; + +// @!has issue_106421_not_internal/struct.FatalError.html '//*[@id="method.raise"]' 'fn raise' +pub use foo::FatalError; diff --git a/tests/rustdoc/issue-106421.rs b/tests/rustdoc/issue-106421.rs new file mode 100644 index 0000000000000..d4141a4ab0c70 --- /dev/null +++ b/tests/rustdoc/issue-106421.rs @@ -0,0 +1,8 @@ +//@ aux-build:issue-106421-force-unstable.rs +//@ ignore-cross-compile +//@ compile-flags: -Zforce-unstable-if-unmarked + +extern crate foo; + +// @has issue_106421/struct.FatalError.html '//*[@id="method.raise"]' 'fn raise' +pub use foo::FatalError; From 0da1b71053e03ed0c49e9c589045bbb39b70d45d Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 24 Feb 2024 16:47:29 -0700 Subject: [PATCH 290/417] Add test case for primitive links in alias js --- .../type-alias/primitive-local-link-121106.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/rustdoc/type-alias/primitive-local-link-121106.rs diff --git a/tests/rustdoc/type-alias/primitive-local-link-121106.rs b/tests/rustdoc/type-alias/primitive-local-link-121106.rs new file mode 100644 index 0000000000000..c11d35d86464d --- /dev/null +++ b/tests/rustdoc/type-alias/primitive-local-link-121106.rs @@ -0,0 +1,19 @@ +#![crate_name = "foo"] + +#![feature(rustc_attrs)] + +// @has foo/primitive.i32.html '//h1' 'Primitive Type i32' +// @has foo/index.html '//a/@href' '../foo/index.html' +#[rustc_doc_primitive = "i32"] +mod i32 {} + +// @has foo/struct.Node.html '//a/@href' 'primitive.i32.html' +pub struct Node; + +impl Node { + pub fn edge(&self) -> i32 { 0 } +} + +// @!has foo/type.Alias.html '//a/@href' 'primitive.i32.html' +// @hasraw 'type.impl/foo/struct.Node.js' 'href=\"foo/primitive.i32.html\"' +pub type Alias = Node; From 3bcef2dc1b145ebe32d317e331579fd4c20e0bd8 Mon Sep 17 00:00:00 2001 From: yukang Date: Sat, 17 Feb 2024 17:54:06 +0800 Subject: [PATCH 291/417] Fix issues in suggesting importing extern crate paths --- compiler/rustc_resolve/src/diagnostics.rs | 12 +++++++++++- .../import-alias-issue-121168-extern.rs | 1 + .../import-alias-issue-121168.edition2015.stderr | 14 ++++++++++++++ .../import-alias-issue-121168.edition2018.stderr | 16 ++++++++++++++++ .../import-alias-issue-121168.edition2021.stderr | 16 ++++++++++++++++ tests/ui/imports/import-alias-issue-121168.rs | 14 ++++++++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/ui/imports/auxiliary/import-alias-issue-121168-extern.rs create mode 100644 tests/ui/imports/import-alias-issue-121168.edition2015.stderr create mode 100644 tests/ui/imports/import-alias-issue-121168.edition2018.stderr create mode 100644 tests/ui/imports/import-alias-issue-121168.edition2021.stderr create mode 100644 tests/ui/imports/import-alias-issue-121168.rs diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index d64a3b43aad31..0b545ce6a893f 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1290,10 +1290,20 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut path_segments = path_segments.clone(); path_segments.push(ast::PathSegment::from_ident(ident)); + let alias_import = if let NameBindingKind::Import { import, .. } = + name_binding.kind + && let ImportKind::ExternCrate { source: Some(_), .. } = import.kind + && import.parent_scope.expansion == parent_scope.expansion + { + true + } else { + false + }; + let is_extern_crate_that_also_appears_in_prelude = name_binding.is_extern_crate() && lookup_ident.span.at_least_rust_2018(); - if !is_extern_crate_that_also_appears_in_prelude { + if !is_extern_crate_that_also_appears_in_prelude || alias_import { // add the module to the lookup if seen_modules.insert(module.def_id()) { if via_import { &mut worklist_via_import } else { &mut worklist } diff --git a/tests/ui/imports/auxiliary/import-alias-issue-121168-extern.rs b/tests/ui/imports/auxiliary/import-alias-issue-121168-extern.rs new file mode 100644 index 0000000000000..a665eb8eb96aa --- /dev/null +++ b/tests/ui/imports/auxiliary/import-alias-issue-121168-extern.rs @@ -0,0 +1 @@ +pub struct Foo(pub core::ptr::NonNull); diff --git a/tests/ui/imports/import-alias-issue-121168.edition2015.stderr b/tests/ui/imports/import-alias-issue-121168.edition2015.stderr new file mode 100644 index 0000000000000..47001fc1a5291 --- /dev/null +++ b/tests/ui/imports/import-alias-issue-121168.edition2015.stderr @@ -0,0 +1,14 @@ +error[E0412]: cannot find type `Foo` in this scope + --> $DIR/import-alias-issue-121168.rs:11:12 + | +LL | let _: Foo = todo!(); + | ^^^ not found in this scope + | +help: consider importing this struct + | +LL + use nice_crate_name::Foo; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/imports/import-alias-issue-121168.edition2018.stderr b/tests/ui/imports/import-alias-issue-121168.edition2018.stderr new file mode 100644 index 0000000000000..b61a0e3edd524 --- /dev/null +++ b/tests/ui/imports/import-alias-issue-121168.edition2018.stderr @@ -0,0 +1,16 @@ +error[E0412]: cannot find type `Foo` in this scope + --> $DIR/import-alias-issue-121168.rs:11:12 + | +LL | let _: Foo = todo!(); + | ^^^ not found in this scope + | +help: consider importing one of these items + | +LL + use crate::nice_crate_name::Foo; + | +LL + use import_alias_issue_121168_extern::Foo; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/imports/import-alias-issue-121168.edition2021.stderr b/tests/ui/imports/import-alias-issue-121168.edition2021.stderr new file mode 100644 index 0000000000000..b61a0e3edd524 --- /dev/null +++ b/tests/ui/imports/import-alias-issue-121168.edition2021.stderr @@ -0,0 +1,16 @@ +error[E0412]: cannot find type `Foo` in this scope + --> $DIR/import-alias-issue-121168.rs:11:12 + | +LL | let _: Foo = todo!(); + | ^^^ not found in this scope + | +help: consider importing one of these items + | +LL + use crate::nice_crate_name::Foo; + | +LL + use import_alias_issue_121168_extern::Foo; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/imports/import-alias-issue-121168.rs b/tests/ui/imports/import-alias-issue-121168.rs new file mode 100644 index 0000000000000..826a6765b0399 --- /dev/null +++ b/tests/ui/imports/import-alias-issue-121168.rs @@ -0,0 +1,14 @@ +//@ revisions: edition2015 edition2018 edition2021 +//@ [edition2015] edition:2015 +//@ [edition2018] edition:2018 +//@ [edition2021] edition:2021 +//@ compile-flags: --extern import_alias_issue_121168_extern +//@ aux-build: import-alias-issue-121168-extern.rs + +extern crate import_alias_issue_121168_extern as nice_crate_name; + +fn use_foo_from_another_crate_without_importing_it_first() { + let _: Foo = todo!(); //~ ERROR cannot find type `Foo` in this scope +} + +fn main() {} From 3093b291f6ba37dd51d45d002e6863b44ee3af7d Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 09:55:58 +0400 Subject: [PATCH 292/417] WIP: empty doc span is still broken --- CHANGELOG.md | 1 + clippy_lints/src/declared_lints.rs | 1 + clippy_lints/src/doc/mod.rs | 65 ++++++++++++++++++++++++++++-- tests/ui/empty_docs.rs | 43 ++++++++++++++++++++ tests/ui/empty_docs.stderr | 35 ++++++++++++++++ 5 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 tests/ui/empty_docs.rs create mode 100644 tests/ui/empty_docs.stderr diff --git a/CHANGELOG.md b/CHANGELOG.md index 5805511c70f9f..eef43ed888221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5158,6 +5158,7 @@ Released 2018-09-13 [`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec [`eager_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#eager_transmute [`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else +[`empty_docs`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_docs [`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop [`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum [`empty_enum_variants_with_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum_variants_with_brackets diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 79fd76393074a..eef66c4a51b78 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -139,6 +139,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::disallowed_types::DISALLOWED_TYPES_INFO, crate::doc::DOC_LINK_WITH_QUOTES_INFO, crate::doc::DOC_MARKDOWN_INFO, + crate::doc::EMPTY_DOCS_INFO, crate::doc::MISSING_ERRORS_DOC_INFO, crate::doc::MISSING_PANICS_DOC_INFO, crate::doc::MISSING_SAFETY_DOC_INFO, diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 2b4ce6ddfaaa3..26bfdf4a072cf 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -23,7 +23,7 @@ use rustc_resolve::rustdoc::{ }; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; -use rustc_span::{sym, Span}; +use rustc_span::{sym, Span, DUMMY_SP}; use std::ops::Range; use url::Url; @@ -338,6 +338,29 @@ declare_clippy_lint! { "suspicious usage of (outer) doc comments" } +declare_clippy_lint! { + /// ### What it does + /// Detects documentation that is empty. + /// ### Why is this bad? + /// It is unlikely that there is any reason to have empty documentation for an item + /// ### Example + /// ```rust + /// /// + /// fn returns_true() -> bool { + /// true + /// } + /// Use instead: + /// ```rust + /// fn returns_true() -> bool { + /// true + /// } + /// ``` + #[clippy::version = "1.78.0"] + pub EMPTY_DOCS, + suspicious, + "docstrings exist but documentation is empty" +} + #[derive(Clone)] pub struct Documentation { valid_idents: FxHashSet, @@ -364,7 +387,8 @@ impl_lint_pass!(Documentation => [ NEEDLESS_DOCTEST_MAIN, TEST_ATTR_IN_DOCTEST, UNNECESSARY_SAFETY_DOC, - SUSPICIOUS_DOC_COMMENTS + SUSPICIOUS_DOC_COMMENTS, + EMPTY_DOCS, ]); impl<'tcx> LateLintPass<'tcx> for Documentation { @@ -378,6 +402,20 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return; }; + + if let Some(span) = get_empty_doc_combined_span(attrs, item.span) + && headers.empty + { + span_lint_and_help( + cx, + EMPTY_DOCS, + span, + "empty doc comment", + None, + "consider removing or filling it", + ); + } + match item.kind { hir::ItemKind::Fn(ref sig, _, body_id) => { if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) { @@ -477,6 +515,7 @@ struct DocHeaders { safety: bool, errors: bool, panics: bool, + empty: bool, } /// Does some pre-processing on raw, desugared `#[doc]` attributes such as parsing them and @@ -509,7 +548,10 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ doc.pop(); if doc.is_empty() { - return Some(DocHeaders::default()); + return Some(DocHeaders { + empty: true, + ..DocHeaders::default() + }); } let mut cb = fake_broken_link_callback; @@ -717,3 +759,20 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { self.cx.tcx.hir() } } + +fn get_empty_doc_combined_span(attrs: &[Attribute], item_span: Span) -> Option { + let mut attrs_span = DUMMY_SP; + if attrs.len() > 0 { + attrs_span = attrs + .iter() + .map(|attr| attr.span) + .fold(attrs[0].span, |acc, next| acc.to(next)); + } + + match (!item_span.is_dummy(), !attrs_span.is_dummy()) { + (true, true) => Some(item_span.shrink_to_lo().to(attrs_span)), + (true, false) => Some(item_span), + (false, true) => Some(attrs_span), + (false, false) => None, + } +} diff --git a/tests/ui/empty_docs.rs b/tests/ui/empty_docs.rs new file mode 100644 index 0000000000000..394e62ab2a61c --- /dev/null +++ b/tests/ui/empty_docs.rs @@ -0,0 +1,43 @@ +#![allow(unused)] +#![warn(clippy::empty_docs)] + +/// this is a struct +struct Bananas { + /// count + count: usize, +} + +/// +enum Warn { + /// + A, + /// + B, +} + +enum WarnForB { + /// it's ok + A, + /// + B, +} + +#[doc = ""] +#[doc = ""] +fn warn_about_this() {} + +#[doc = "a fine function"] +fn this_is_fine() {} + +fn warn_about_this_as_well() { + //! +} + +fn this_is_ok() { + //! + //! inside the function +} + +fn warn() { + /*! inside the function */ +} diff --git a/tests/ui/empty_docs.stderr b/tests/ui/empty_docs.stderr new file mode 100644 index 0000000000000..27d49b4ff3b60 --- /dev/null +++ b/tests/ui/empty_docs.stderr @@ -0,0 +1,35 @@ +error: empty doc comment + --> tests/ui/empty_docs.rs:10:1 + | +LL | / /// +LL | | enum Warn { + | |_ + | + = help: consider removing or filling it + = note: `-D clippy::empty-docs` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_docs)]` + +error: empty doc comment + --> tests/ui/empty_docs.rs:18:1 + | +LL | / enum WarnForB { +LL | | /// it's ok +LL | | A, +LL | | /// +LL | | B, +LL | | } + | |_^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:32:1 + | +LL | / fn warn_about_this_as_well() { +LL | | //! + | |_______^ + | + = help: consider removing or filling it + +error: aborting due to 3 previous errors + From 5a63cd82cb1e94736fa6217d3004b77212c8132a Mon Sep 17 00:00:00 2001 From: not-elm Date: Fri, 23 Feb 2024 17:53:22 +0900 Subject: [PATCH 293/417] FIX(12243): redundant_guard A warning is now suppressed when " if .is_empty" is used in a constant function. FIX: instead of clippy_util::in_const FIX: Merged `redundant_guards_const_fn.rs` into `redundant_guards.rs`. --- clippy_lints/src/matches/redundant_guards.rs | 4 +- tests/ui/redundant_guards.fixed | 49 +++++++++++- tests/ui/redundant_guards.rs | 49 +++++++++++- tests/ui/redundant_guards.stderr | 78 +++++++++++++------- 4 files changed, 149 insertions(+), 31 deletions(-) diff --git a/clippy_lints/src/matches/redundant_guards.rs b/clippy_lints/src/matches/redundant_guards.rs index d3986cc7c2210..6bae51b45b8fa 100644 --- a/clippy_lints/src/matches/redundant_guards.rs +++ b/clippy_lints/src/matches/redundant_guards.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::path_to_local; use clippy_utils::source::snippet; use clippy_utils::visitors::{for_each_expr, is_local_used}; +use clippy_utils::{in_constant, path_to_local}; use rustc_ast::{BorrowKind, LitKind}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; @@ -123,7 +123,7 @@ fn check_method_calls<'tcx>( // `s if s.is_empty()` becomes "" // `arr if arr.is_empty()` becomes [] - if ty.is_str() { + if ty.is_str() && !in_constant(cx, if_expr.hir_id) { r#""""#.into() } else if slice_like { "[]".into() diff --git a/tests/ui/redundant_guards.fixed b/tests/ui/redundant_guards.fixed index 0a2ae911ad43d..ded91e0837699 100644 --- a/tests/ui/redundant_guards.fixed +++ b/tests/ui/redundant_guards.fixed @@ -1,6 +1,6 @@ //@aux-build:proc_macros.rs #![feature(if_let_guard)] -#![allow(clippy::no_effect, unused)] +#![allow(clippy::no_effect, unused, clippy::single_match)] #![warn(clippy::redundant_guards)] #[macro_use] @@ -16,6 +16,7 @@ struct C(u32, u32); #[derive(PartialEq)] struct FloatWrapper(f32); + fn issue11304() { match 0.1 { x if x == 0.0 => todo!(), @@ -258,3 +259,49 @@ fn issue11807() { _ => {}, } } + +mod issue12243 { + pub const fn const_fn(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_fn(x: &str) { + match x { + "" => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + + struct Bar; + + impl Bar { + pub const fn const_bar(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_bar(x: &str) { + match x { + "" => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + } + + static FOO: () = { + match "" { + // Shouldn't lint. + x if x.is_empty() => {}, + _ => {}, + } + }; +} diff --git a/tests/ui/redundant_guards.rs b/tests/ui/redundant_guards.rs index c8656f26ef339..2aaa2ace3982e 100644 --- a/tests/ui/redundant_guards.rs +++ b/tests/ui/redundant_guards.rs @@ -1,6 +1,6 @@ //@aux-build:proc_macros.rs #![feature(if_let_guard)] -#![allow(clippy::no_effect, unused)] +#![allow(clippy::no_effect, unused, clippy::single_match)] #![warn(clippy::redundant_guards)] #[macro_use] @@ -16,6 +16,7 @@ struct C(u32, u32); #[derive(PartialEq)] struct FloatWrapper(f32); + fn issue11304() { match 0.1 { x if x == 0.0 => todo!(), @@ -258,3 +259,49 @@ fn issue11807() { _ => {}, } } + +mod issue12243 { + pub const fn const_fn(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_fn(x: &str) { + match x { + y if y.is_empty() => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + + struct Bar; + + impl Bar { + pub const fn const_bar(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_bar(x: &str) { + match x { + y if y.is_empty() => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + } + + static FOO: () = { + match "" { + // Shouldn't lint. + x if x.is_empty() => {}, + _ => {}, + } + }; +} diff --git a/tests/ui/redundant_guards.stderr b/tests/ui/redundant_guards.stderr index 93b24a713dcfa..01ca91fcd09e8 100644 --- a/tests/ui/redundant_guards.stderr +++ b/tests/ui/redundant_guards.stderr @@ -1,5 +1,5 @@ error: redundant guard - --> tests/ui/redundant_guards.rs:33:20 + --> tests/ui/redundant_guards.rs:34:20 | LL | C(x, y) if let 1 = y => .., | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + C(x, 1) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:39:20 + --> tests/ui/redundant_guards.rs:40:20 | LL | Some(x) if matches!(x, Some(1) if true) => .., | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | Some(Some(1)) if true => .., | ~~~~~~~ ~~~~~~~ error: redundant guard - --> tests/ui/redundant_guards.rs:40:20 + --> tests/ui/redundant_guards.rs:41:20 | LL | Some(x) if matches!(x, Some(1)) => { | ^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL + Some(Some(1)) => { | error: redundant guard - --> tests/ui/redundant_guards.rs:44:20 + --> tests/ui/redundant_guards.rs:45:20 | LL | Some(x) if let Some(1) = x => .., | ^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL + Some(Some(1)) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:45:20 + --> tests/ui/redundant_guards.rs:46:20 | LL | Some(x) if x == Some(2) => .., | ^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:46:20 + --> tests/ui/redundant_guards.rs:47:20 | LL | Some(x) if Some(2) == x => .., | ^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:71:20 + --> tests/ui/redundant_guards.rs:72:20 | LL | B { e } if matches!(e, Some(A(2))) => .., | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL + B { e: Some(A(2)) } => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:108:20 + --> tests/ui/redundant_guards.rs:109:20 | LL | E::A(y) if y == "not from an or pattern" => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + E::A("not from an or pattern") => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:115:14 + --> tests/ui/redundant_guards.rs:116:14 | LL | x if matches!(x, Some(0)) => .., | ^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + Some(0) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:122:14 + --> tests/ui/redundant_guards.rs:123:14 | LL | i if i == -1 => {}, | ^^^^^^^ @@ -120,7 +120,7 @@ LL + -1 => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:123:14 + --> tests/ui/redundant_guards.rs:124:14 | LL | i if i == 1 => {}, | ^^^^^^ @@ -132,7 +132,7 @@ LL + 1 => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:173:28 + --> tests/ui/redundant_guards.rs:174:28 | LL | Some(ref x) if x == &1 => {}, | ^^^^^^^ @@ -144,7 +144,7 @@ LL + Some(1) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:174:28 + --> tests/ui/redundant_guards.rs:175:28 | LL | Some(ref x) if &1 == x => {}, | ^^^^^^^ @@ -156,7 +156,7 @@ LL + Some(1) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:175:28 + --> tests/ui/redundant_guards.rs:176:28 | LL | Some(ref x) if let &2 = x => {}, | ^^^^^^^^^^ @@ -168,7 +168,7 @@ LL + Some(2) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:176:28 + --> tests/ui/redundant_guards.rs:177:28 | LL | Some(ref x) if matches!(x, &3) => {}, | ^^^^^^^^^^^^^^^ @@ -180,7 +180,7 @@ LL + Some(3) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:196:32 + --> tests/ui/redundant_guards.rs:197:32 | LL | B { ref c, .. } if c == &1 => {}, | ^^^^^^^ @@ -192,7 +192,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:197:32 + --> tests/ui/redundant_guards.rs:198:32 | LL | B { ref c, .. } if &1 == c => {}, | ^^^^^^^ @@ -204,7 +204,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:198:32 + --> tests/ui/redundant_guards.rs:199:32 | LL | B { ref c, .. } if let &1 = c => {}, | ^^^^^^^^^^ @@ -216,7 +216,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:199:32 + --> tests/ui/redundant_guards.rs:200:32 | LL | B { ref c, .. } if matches!(c, &1) => {}, | ^^^^^^^^^^^^^^^ @@ -228,7 +228,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:209:26 + --> tests/ui/redundant_guards.rs:210:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -240,7 +240,7 @@ LL + Some(Some("")) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:220:26 + --> tests/ui/redundant_guards.rs:221:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -252,7 +252,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:225:26 + --> tests/ui/redundant_guards.rs:226:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -264,7 +264,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:236:26 + --> tests/ui/redundant_guards.rs:237:26 | LL | Some(Some(x)) if x.starts_with(&[]) => {}, | ^^^^^^^^^^^^^^^^^^ @@ -276,7 +276,7 @@ LL + Some(Some([..])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:241:26 + --> tests/ui/redundant_guards.rs:242:26 | LL | Some(Some(x)) if x.starts_with(&[1]) => {}, | ^^^^^^^^^^^^^^^^^^^ @@ -288,7 +288,7 @@ LL + Some(Some([1, ..])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:246:26 + --> tests/ui/redundant_guards.rs:247:26 | LL | Some(Some(x)) if x.starts_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^^^ @@ -300,7 +300,7 @@ LL + Some(Some([1, 2, ..])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:251:26 + --> tests/ui/redundant_guards.rs:252:26 | LL | Some(Some(x)) if x.ends_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^ @@ -311,5 +311,29 @@ LL - Some(Some(x)) if x.ends_with(&[1, 2]) => {}, LL + Some(Some([.., 1, 2])) => {}, | -error: aborting due to 26 previous errors +error: redundant guard + --> tests/ui/redundant_guards.rs:274:18 + | +LL | y if y.is_empty() => {}, + | ^^^^^^^^^^^^ + | +help: try + | +LL - y if y.is_empty() => {}, +LL + "" => {}, + | + +error: redundant guard + --> tests/ui/redundant_guards.rs:293:22 + | +LL | y if y.is_empty() => {}, + | ^^^^^^^^^^^^ + | +help: try + | +LL - y if y.is_empty() => {}, +LL + "" => {}, + | + +error: aborting due to 28 previous errors From cc3df0af7ba25a9a7bc82dac52e4b0fbb9d9713a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 23 Feb 2024 18:26:39 +0100 Subject: [PATCH 294/417] remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics --- .../example/float-minmax-pass.rs | 4 +- .../src/error_codes/E0511.md | 8 +- compiler/rustc_feature/src/removed.rs | 3 + compiler/rustc_feature/src/unstable.rs | 2 - .../rustc_hir_analysis/src/check/check.rs | 11 -- .../rustc_hir_analysis/src/check/intrinsic.rs | 170 ++++++++---------- compiler/rustc_hir_analysis/src/check/mod.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 5 +- compiler/rustc_hir_typeck/src/coercion.rs | 6 +- compiler/rustc_lint/src/types.rs | 5 +- compiler/rustc_metadata/src/native_libs.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 1 - compiler/rustc_middle/src/ty/util.rs | 2 +- .../src/ffi_unwind_calls.rs | 1 - compiler/rustc_passes/src/check_attr.rs | 4 +- compiler/rustc_passes/src/stability.rs | 5 +- .../rustc_smir/src/rustc_internal/internal.rs | 1 - .../rustc_smir/src/rustc_smir/convert/ty.rs | 1 - compiler/rustc_target/src/spec/abi/mod.rs | 15 +- compiler/rustc_target/src/spec/mod.rs | 1 - compiler/rustc_ty_utils/src/abi.rs | 15 +- compiler/stable_mir/src/ty.rs | 1 - library/core/src/intrinsics/simd.rs | 80 ++++++++- library/core/src/lib.rs | 2 +- library/std/src/lib.rs | 2 +- 25 files changed, 179 insertions(+), 170 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs b/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs index 80a2776ca1e2f..eebd77083ec64 100644 --- a/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs +++ b/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs @@ -4,14 +4,14 @@ // Test that the simd_f{min,max} intrinsics produce the correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "intrinsic" { fn simd_fmin(x: T, y: T) -> T; fn simd_fmax(x: T, y: T) -> T; } diff --git a/compiler/rustc_error_codes/src/error_codes/E0511.md b/compiler/rustc_error_codes/src/error_codes/E0511.md index 5351a685eb512..681f4e611c32d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0511.md +++ b/compiler/rustc_error_codes/src/error_codes/E0511.md @@ -3,9 +3,9 @@ Invalid monomorphization of an intrinsic function was used. Erroneous code example: ```compile_fail,E0511 -#![feature(platform_intrinsics)] +#![feature(intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(a: T, b: T) -> T; } @@ -19,13 +19,13 @@ The generic type has to be a SIMD type. Example: ``` #![feature(repr_simd)] -#![feature(platform_intrinsics)] +#![feature(intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] struct i32x2(i32, i32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(a: T, b: T) -> T; } diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 008c59e1be3db..05bb74807326f 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -156,6 +156,9 @@ declare_features! ( Some("removed in favor of `#![feature(marker_trait_attr)]`")), (removed, panic_implementation, "1.28.0", Some(44489), Some("subsumed by `#[panic_handler]`")), + /// Allows `extern "platform-intrinsic" { ... }`. + (removed, platform_intrinsics, "1.4.0", Some(27731), + Some("SIMD intrinsics use the regular intrinsics ABI now")), /// Allows using `#![plugin(myplugin)]`. (removed, plugin, "1.75.0", Some(29597), Some("plugins are no longer supported")), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 93c183a65ef3e..eb107e6ef3fa5 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -259,8 +259,6 @@ declare_features! ( (internal, needs_panic_runtime, "1.10.0", Some(32837)), /// Allows using the `#![panic_runtime]` attribute. (internal, panic_runtime, "1.10.0", Some(32837)), - /// Allows `extern "platform-intrinsic" { ... }`. - (internal, platform_intrinsics, "1.4.0", Some(27731)), /// Allows using `#[rustc_allow_const_fn_unstable]`. /// This is an attribute on `const fn` for the same /// purpose as `#[allow_internal_unstable]`. diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index deabb9c373857..3d9aa428c743c 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -612,17 +612,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) { } } - Abi::PlatformIntrinsic => { - for item in items { - intrinsic::check_platform_intrinsic_type( - tcx, - item.id.owner_id.def_id, - item.span, - item.ident.name, - ); - } - } - _ => { for item in items { let def_id = item.id.owner_id.def_id; diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index d7277b22c8410..f4b601f58b959 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -510,6 +510,77 @@ pub fn check_intrinsic_type( sym::debug_assertions => (0, 1, Vec::new(), tcx.types.bool), + sym::simd_eq + | sym::simd_ne + | sym::simd_lt + | sym::simd_le + | sym::simd_gt + | sym::simd_ge => (2, 0, vec![param(0), param(0)], param(1)), + sym::simd_add + | sym::simd_sub + | sym::simd_mul + | sym::simd_rem + | sym::simd_div + | sym::simd_shl + | sym::simd_shr + | sym::simd_and + | sym::simd_or + | sym::simd_xor + | sym::simd_fmin + | sym::simd_fmax + | sym::simd_fpow + | sym::simd_saturating_add + | sym::simd_saturating_sub => (1, 0, vec![param(0), param(0)], param(0)), + sym::simd_arith_offset => (2, 0, vec![param(0), param(1)], param(0)), + sym::simd_neg + | sym::simd_bswap + | sym::simd_bitreverse + | sym::simd_ctlz + | sym::simd_cttz + | sym::simd_fsqrt + | sym::simd_fsin + | sym::simd_fcos + | sym::simd_fexp + | sym::simd_fexp2 + | sym::simd_flog2 + | sym::simd_flog10 + | sym::simd_flog + | sym::simd_fabs + | sym::simd_ceil + | sym::simd_floor + | sym::simd_round + | sym::simd_trunc => (1, 0, vec![param(0)], param(0)), + sym::simd_fpowi => (1, 0, vec![param(0), tcx.types.i32], param(0)), + sym::simd_fma => (1, 0, vec![param(0), param(0), param(0)], param(0)), + sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)), + sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)), + sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), + sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), + sym::simd_insert => (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0)), + sym::simd_extract => (2, 0, vec![param(0), tcx.types.u32], param(1)), + sym::simd_cast + | sym::simd_as + | sym::simd_cast_ptr + | sym::simd_expose_addr + | sym::simd_from_exposed_addr => (2, 0, vec![param(0)], param(1)), + sym::simd_bitmask => (2, 0, vec![param(0)], param(1)), + sym::simd_select | sym::simd_select_bitmask => { + (2, 0, vec![param(0), param(1), param(1)], param(1)) + } + sym::simd_reduce_all | sym::simd_reduce_any => (1, 0, vec![param(0)], tcx.types.bool), + sym::simd_reduce_add_ordered | sym::simd_reduce_mul_ordered => { + (2, 0, vec![param(0), param(1)], param(1)) + } + sym::simd_reduce_add_unordered + | sym::simd_reduce_mul_unordered + | sym::simd_reduce_and + | sym::simd_reduce_or + | sym::simd_reduce_xor + | sym::simd_reduce_min + | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)), + sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)), + sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)), + other => { tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other }); return; @@ -521,102 +592,3 @@ pub fn check_intrinsic_type( let sig = ty::Binder::bind_with_vars(sig, bound_vars); equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig) } - -/// Type-check `extern "platform-intrinsic" { ... }` functions. -pub fn check_platform_intrinsic_type( - tcx: TyCtxt<'_>, - intrinsic_id: LocalDefId, - span: Span, - name: Symbol, -) { - let generics = tcx.generics_of(intrinsic_id); - let param = |n| { - if let Some(&ty::GenericParamDef { - name, kind: ty::GenericParamDefKind::Type { .. }, .. - }) = generics.opt_param_at(n as usize, tcx) - { - Ty::new_param(tcx, n, name) - } else { - Ty::new_error_with_message(tcx, span, "expected param") - } - }; - - let (n_tps, n_cts, inputs, output) = match name { - sym::simd_eq | sym::simd_ne | sym::simd_lt | sym::simd_le | sym::simd_gt | sym::simd_ge => { - (2, 0, vec![param(0), param(0)], param(1)) - } - sym::simd_add - | sym::simd_sub - | sym::simd_mul - | sym::simd_rem - | sym::simd_div - | sym::simd_shl - | sym::simd_shr - | sym::simd_and - | sym::simd_or - | sym::simd_xor - | sym::simd_fmin - | sym::simd_fmax - | sym::simd_fpow - | sym::simd_saturating_add - | sym::simd_saturating_sub => (1, 0, vec![param(0), param(0)], param(0)), - sym::simd_arith_offset => (2, 0, vec![param(0), param(1)], param(0)), - sym::simd_neg - | sym::simd_bswap - | sym::simd_bitreverse - | sym::simd_ctlz - | sym::simd_cttz - | sym::simd_fsqrt - | sym::simd_fsin - | sym::simd_fcos - | sym::simd_fexp - | sym::simd_fexp2 - | sym::simd_flog2 - | sym::simd_flog10 - | sym::simd_flog - | sym::simd_fabs - | sym::simd_ceil - | sym::simd_floor - | sym::simd_round - | sym::simd_trunc => (1, 0, vec![param(0)], param(0)), - sym::simd_fpowi => (1, 0, vec![param(0), tcx.types.i32], param(0)), - sym::simd_fma => (1, 0, vec![param(0), param(0), param(0)], param(0)), - sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)), - sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)), - sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), - sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), - sym::simd_insert => (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0)), - sym::simd_extract => (2, 0, vec![param(0), tcx.types.u32], param(1)), - sym::simd_cast - | sym::simd_as - | sym::simd_cast_ptr - | sym::simd_expose_addr - | sym::simd_from_exposed_addr => (2, 0, vec![param(0)], param(1)), - sym::simd_bitmask => (2, 0, vec![param(0)], param(1)), - sym::simd_select | sym::simd_select_bitmask => { - (2, 0, vec![param(0), param(1), param(1)], param(1)) - } - sym::simd_reduce_all | sym::simd_reduce_any => (1, 0, vec![param(0)], tcx.types.bool), - sym::simd_reduce_add_ordered | sym::simd_reduce_mul_ordered => { - (2, 0, vec![param(0), param(1)], param(1)) - } - sym::simd_reduce_add_unordered - | sym::simd_reduce_mul_unordered - | sym::simd_reduce_and - | sym::simd_reduce_or - | sym::simd_reduce_xor - | sym::simd_reduce_min - | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)), - sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)), - sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)), - _ => { - let msg = format!("unrecognized platform-specific intrinsic function: `{name}`"); - tcx.dcx().span_err(span, msg); - return; - } - }; - - let sig = tcx.mk_fn_sig(inputs, output, false, hir::Unsafety::Unsafe, Abi::PlatformIntrinsic); - let sig = ty::Binder::dummy(sig); - equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, 0, n_cts, sig) -} diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 36a92a4cf7cc0..24280dbf0b3c9 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -142,7 +142,7 @@ fn get_owner_return_paths( /// as they must always be defined by the compiler. // FIXME: Move this to a more appropriate place. pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: Abi) { - if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi { + if let Abi::RustIntrinsic = abi { tcx.dcx().span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block"); } } diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index e9c9ec6ba53f8..126766ce278be 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1677,10 +1677,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( // Feature gate SIMD types in FFI, since I am not sure that the // ABIs are handled at all correctly. -huonw - if abi != abi::Abi::RustIntrinsic - && abi != abi::Abi::PlatformIntrinsic - && !tcx.features().simd_ffi - { + if abi != abi::Abi::RustIntrinsic && !tcx.features().simd_ffi { let check = |ast_ty: &hir::Ty<'_>, ty: Ty<'_>| { if ty.is_simd() { let snip = tcx diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 9f6175eac1350..1d1f58c6332f0 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1173,11 +1173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if let (Some(a_sig), Some(b_sig)) = (a_sig, b_sig) { // Intrinsics are not coercible to function pointers. - if a_sig.abi() == Abi::RustIntrinsic - || a_sig.abi() == Abi::PlatformIntrinsic - || b_sig.abi() == Abi::RustIntrinsic - || b_sig.abi() == Abi::PlatformIntrinsic - { + if a_sig.abi() == Abi::RustIntrinsic || b_sig.abi() == Abi::RustIntrinsic { return Err(TypeError::IntrinsicCast); } // The signature must match. diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index e4ebae2a97320..2ea891ce04d01 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1587,10 +1587,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } fn is_internal_abi(&self, abi: SpecAbi) -> bool { - matches!( - abi, - SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic | SpecAbi::PlatformIntrinsic - ) + matches!(abi, SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic) } /// Find any fn-ptr types with external ABIs in `ty`. diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 5e20a03bbc0cd..cdcc586b09e70 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -99,7 +99,7 @@ impl<'tcx> Collector<'tcx> { let sess = self.tcx.sess; - if matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic) { + if matches!(abi, Abi::Rust | Abi::RustIntrinsic) { return; } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index c1e33fe114fb5..38aca3326d3b8 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1244,7 +1244,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: SpecAbi) -> | RiscvInterruptS | CCmseNonSecureCall | Wasm - | PlatformIntrinsic | Unadjusted => false, Rust | RustCall | RustCold | RustIntrinsic => { tcx.sess.panic_strategy() == PanicStrategy::Unwind diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 72a1905c147ae..5ead620927cd9 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1643,7 +1643,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool { /// Determines whether an item is an intrinsic by Abi. or by whether it has a `rustc_intrinsic` attribute pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { - if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic) + if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic) || tcx.has_attr(def_id, sym::rustc_intrinsic) { Some(tcx.item_name(def_id.into())) diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 663abbece851d..0dc06524c7944 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -34,7 +34,6 @@ fn abi_can_unwind(abi: Abi) -> bool { | CCmseNonSecureCall | Wasm | RustIntrinsic - | PlatformIntrinsic | Unadjusted => false, Rust | RustCall | RustCold => true, } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d8ae82d11bcf4..194533047d4a5 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1389,7 +1389,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { if target == Target::ForeignMod && let hir::Node::Item(item) = self.tcx.hir_node(hir_id) && let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item - && !matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic) + && !matches!(abi, Abi::Rust | Abi::RustIntrinsic) { return; } @@ -2071,7 +2071,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { ) -> bool { if let Target::ForeignFn = target && let hir::Node::Item(Item { - kind: ItemKind::ForeignMod { abi: Abi::RustIntrinsic | Abi::PlatformIntrinsic, .. }, + kind: ItemKind::ForeignMod { abi: Abi::RustIntrinsic, .. }, .. }) = self.tcx.parent_hir_node(hir_id) { diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 19272b52b32e6..05c833cdfb657 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -173,10 +173,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { // If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI, // check if the function/method is const or the parent impl block is const if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig) { - if fn_sig.header.abi != Abi::RustIntrinsic - && fn_sig.header.abi != Abi::PlatformIntrinsic - && !fn_sig.header.is_const() - { + if fn_sig.header.abi != Abi::RustIntrinsic && !fn_sig.header.is_const() { if !self.in_trait_impl || (self.in_trait_impl && !self.tcx.is_const_fn_raw(def_id.to_def_id())) { diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index 6bbfcff5e87cc..2cc9bc31873a4 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -457,7 +457,6 @@ impl RustcInternal for Abi { Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind }, Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic, Abi::RustCall => rustc_target::spec::abi::Abi::RustCall, - Abi::PlatformIntrinsic => rustc_target::spec::abi::Abi::PlatformIntrinsic, Abi::Unadjusted => rustc_target::spec::abi::Abi::Unadjusted, Abi::RustCold => rustc_target::spec::abi::Abi::RustCold, Abi::RiscvInterruptM => rustc_target::spec::abi::Abi::RiscvInterruptM, diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index 29081418200e7..a066b9ed3aa2d 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -833,7 +833,6 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi { abi::Abi::System { unwind } => Abi::System { unwind }, abi::Abi::RustIntrinsic => Abi::RustIntrinsic, abi::Abi::RustCall => Abi::RustCall, - abi::Abi::PlatformIntrinsic => Abi::PlatformIntrinsic, abi::Abi::Unadjusted => Abi::Unadjusted, abi::Abi::RustCold => Abi::RustCold, abi::Abi::RiscvInterruptM => Abi::RiscvInterruptM, diff --git a/compiler/rustc_target/src/spec/abi/mod.rs b/compiler/rustc_target/src/spec/abi/mod.rs index 6231787bb9fdb..388e76d83e243 100644 --- a/compiler/rustc_target/src/spec/abi/mod.rs +++ b/compiler/rustc_target/src/spec/abi/mod.rs @@ -54,7 +54,6 @@ pub enum Abi { }, RustIntrinsic, RustCall, - PlatformIntrinsic, Unadjusted, /// For things unlikely to be called, where reducing register pressure in /// `extern "Rust"` callers is worth paying extra cost in the callee. @@ -129,7 +128,6 @@ const AbiDatas: &[AbiData] = &[ AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" }, AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" }, AbiData { abi: Abi::RustCall, name: "rust-call" }, - AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" }, AbiData { abi: Abi::Unadjusted, name: "unadjusted" }, AbiData { abi: Abi::RustCold, name: "rust-cold" }, AbiData { abi: Abi::RiscvInterruptM, name: "riscv-interrupt-m" }, @@ -199,10 +197,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { feature: sym::intrinsics, explain: "intrinsics are subject to change", }), - "platform-intrinsic" => Err(AbiDisabled::Unstable { - feature: sym::platform_intrinsics, - explain: "platform intrinsics are experimental and possibly buggy", - }), "vectorcall" => Err(AbiDisabled::Unstable { feature: sym::abi_vectorcall, explain: "vectorcall is experimental and subject to change", @@ -299,11 +293,10 @@ impl Abi { System { unwind: true } => 28, RustIntrinsic => 29, RustCall => 30, - PlatformIntrinsic => 31, - Unadjusted => 32, - RustCold => 33, - RiscvInterruptM => 34, - RiscvInterruptS => 35, + Unadjusted => 31, + RustCold => 32, + RiscvInterruptM => 33, + RiscvInterruptS => 34, }; debug_assert!( AbiDatas diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d04bcb2d78aac..084a8b9db81e3 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2448,7 +2448,6 @@ impl Target { | System { .. } | RustIntrinsic | RustCall - | PlatformIntrinsic | Unadjusted | Cdecl { .. } | RustCold => true, diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 638c9a53d22ab..43042dbd36641 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -312,7 +312,7 @@ fn fn_sig_for_fn_abi<'tcx>( fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv { use rustc_target::spec::abi::Abi::*; match tcx.sess.target.adjust_abi(abi, c_variadic) { - RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::Rust, + RustIntrinsic | Rust | RustCall => Conv::Rust, // This is intentionally not using `Conv::Cold`, as that has to preserve // even SIMD registers, which is generally not a good trade-off. @@ -605,7 +605,7 @@ fn fn_abi_new_uncached<'tcx>( let linux_powerpc_gnu_like = target.os == "linux" && target.arch == "powerpc" && target_env_gnu_like; use SpecAbi::*; - let rust_abi = matches!(sig.abi, RustIntrinsic | PlatformIntrinsic | Rust | RustCall); + let rust_abi = matches!(sig.abi, RustIntrinsic | Rust | RustCall); let is_drop_in_place = fn_def_id.is_some() && fn_def_id == cx.tcx.lang_items().drop_in_place_fn(); @@ -713,11 +713,7 @@ fn fn_abi_adjust_for_abi<'tcx>( return Ok(()); } - if abi == SpecAbi::Rust - || abi == SpecAbi::RustCall - || abi == SpecAbi::RustIntrinsic - || abi == SpecAbi::PlatformIntrinsic - { + if abi == SpecAbi::Rust || abi == SpecAbi::RustCall || abi == SpecAbi::RustIntrinsic { // Look up the deduced parameter attributes for this function, if we have its def ID and // we're optimizing in non-incremental mode. We'll tag its parameters with those attributes // as appropriate. @@ -753,12 +749,11 @@ fn fn_abi_adjust_for_abi<'tcx>( // target feature sets. Some more information about this // issue can be found in #44367. // - // Note that the platform intrinsic ABI is exempt here as + // Note that the intrinsic ABI is exempt here as // that's how we connect up to LLVM and it's unstable // anyway, we control all calls to it in libstd. Abi::Vector { .. } - if abi != SpecAbi::PlatformIntrinsic - && cx.tcx.sess.target.simd_types_indirect => + if abi != SpecAbi::RustIntrinsic && cx.tcx.sess.target.simd_types_indirect => { arg.make_indirect(); return; diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 658e8aa28b544..ed4a4290246b0 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -906,7 +906,6 @@ pub enum Abi { System { unwind: bool }, RustIntrinsic, RustCall, - PlatformIntrinsic, Unadjusted, RustCold, RiscvInterruptM, diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index d8a1ad778d752..2eaca3b6fe4d5 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -2,7 +2,11 @@ //! //! In this module, a "vector" is any `repr(simd)` type. -extern "platform-intrinsic" { +// Temporary macro while we switch the ABI from "platform-intrinsics" to "intrinsics". +#[rustfmt::skip] +macro_rules! declare_intrinsics { +($abi:tt) => { +extern $abi { /// Insert an element into a vector, returning the updated vector. /// /// `T` must be a vector with element type `U`. @@ -10,6 +14,7 @@ extern "platform-intrinsic" { /// # Safety /// /// `idx` must be in-bounds of the vector. + #[rustc_nounwind] pub fn simd_insert(x: T, idx: u32, val: U) -> T; /// Extract an element from a vector. @@ -19,21 +24,25 @@ extern "platform-intrinsic" { /// # Safety /// /// `idx` must be in-bounds of the vector. + #[rustc_nounwind] pub fn simd_extract(x: T, idx: u32) -> U; /// Add two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. + #[rustc_nounwind] pub fn simd_add(x: T, y: T) -> T; /// Subtract `rhs` from `lhs` elementwise. /// /// `T` must be a vector of integer or floating point primitive types. + #[rustc_nounwind] pub fn simd_sub(lhs: T, rhs: T) -> T; /// Multiply two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. + #[rustc_nounwind] pub fn simd_mul(x: T, y: T) -> T; /// Divide `lhs` by `rhs` elementwise. @@ -43,6 +52,7 @@ extern "platform-intrinsic" { /// # Safety /// For integers, `rhs` must not contain any zero elements. /// Additionally for signed integers, `::MIN / -1` is undefined behavior. + #[rustc_nounwind] pub fn simd_div(lhs: T, rhs: T) -> T; /// Remainder of two vectors elementwise @@ -52,6 +62,7 @@ extern "platform-intrinsic" { /// # Safety /// For integers, `rhs` must not contain any zero elements. /// Additionally for signed integers, `::MIN / -1` is undefined behavior. + #[rustc_nounwind] pub fn simd_rem(lhs: T, rhs: T) -> T; /// Elementwise vector left shift, with UB on overflow. @@ -63,6 +74,7 @@ extern "platform-intrinsic" { /// # Safety /// /// Each element of `rhs` must be less than `::BITS`. + #[rustc_nounwind] pub fn simd_shl(lhs: T, rhs: T) -> T; /// Elementwise vector right shift, with UB on overflow. @@ -74,21 +86,25 @@ extern "platform-intrinsic" { /// # Safety /// /// Each element of `rhs` must be less than `::BITS`. + #[rustc_nounwind] pub fn simd_shr(lhs: T, rhs: T) -> T; /// Elementwise vector "and". /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_and(x: T, y: T) -> T; /// Elementwise vector "or". /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_or(x: T, y: T) -> T; /// Elementwise vector "exclusive or". /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_xor(x: T, y: T) -> T; /// Numerically cast a vector, elementwise. @@ -109,6 +125,7 @@ extern "platform-intrinsic" { /// * Not be `NaN` /// * Not be infinite /// * Be representable in the return type, after truncating off its fractional part + #[rustc_nounwind] pub fn simd_cast(x: T) -> U; /// Numerically cast a vector, elementwise. @@ -122,6 +139,7 @@ extern "platform-intrinsic" { /// When casting floats to integers, the result is truncated. /// When casting integers to floats, the result is rounded. /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. + #[rustc_nounwind] pub fn simd_as(x: T) -> U; /// Elementwise negation of a vector. @@ -129,11 +147,13 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. + #[rustc_nounwind] pub fn simd_neg(x: T) -> T; /// Elementwise absolute value of a vector. /// /// `T` must be a vector of floating-point primitive types. + #[rustc_nounwind] pub fn simd_fabs(x: T) -> T; /// Elementwise minimum of a vector. @@ -141,6 +161,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of floating-point primitive types. /// /// Follows IEEE-754 `minNum` semantics. + #[rustc_nounwind] pub fn simd_fmin(x: T, y: T) -> T; /// Elementwise maximum of a vector. @@ -148,6 +169,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of floating-point primitive types. /// /// Follows IEEE-754 `maxNum` semantics. + #[rustc_nounwind] pub fn simd_fmax(x: T, y: T) -> T; /// Tests elementwise equality of two vectors. @@ -157,6 +179,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_eq(x: T, y: T) -> U; /// Tests elementwise inequality equality of two vectors. @@ -166,6 +189,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_ne(x: T, y: T) -> U; /// Tests if `x` is less than `y`, elementwise. @@ -175,6 +199,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_lt(x: T, y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. @@ -184,6 +209,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_le(x: T, y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. @@ -193,6 +219,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_gt(x: T, y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. @@ -202,6 +229,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_ge(x: T, y: T) -> U; /// Shuffle two vectors by const indices. @@ -216,6 +244,7 @@ extern "platform-intrinsic" { /// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy` /// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds /// of `xy`. + #[rustc_nounwind] pub fn simd_shuffle(x: T, y: T, idx: U) -> V; /// Shuffle two vectors by const indices. @@ -227,6 +256,7 @@ extern "platform-intrinsic" { /// Returns a new vector such that element `i` is selected from `xy[IDX[i]]`, where `xy` /// is the concatenation of `x` and `y`. It is a compile-time error if `IDX[i]` is out-of-bounds /// of `xy`. + #[rustc_nounwind] pub fn simd_shuffle_generic(x: T, y: T) -> U; /// Read a vector of pointers. @@ -249,6 +279,7 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_gather(val: T, ptr: U, mask: V) -> T; /// Write to a vector of pointers. @@ -271,6 +302,7 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_scatter(val: T, ptr: U, mask: V); /// Read a vector of pointers. @@ -292,6 +324,7 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_masked_load(mask: V, ptr: U, val: T) -> T; /// Write to a vector of pointers. @@ -312,11 +345,13 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_masked_store(mask: V, ptr: U, val: T); /// Add two simd vectors elementwise, with saturation. /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_saturating_add(x: T, y: T) -> T; /// Subtract two simd vectors elementwise, with saturation. @@ -324,6 +359,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer primitive types. /// /// Subtract `rhs` from `lhs`. + #[rustc_nounwind] pub fn simd_saturating_sub(lhs: T, rhs: T) -> T; /// Add elements within a vector from left to right. @@ -333,6 +369,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// Starting with the value `y`, add the elements of `x` and accumulate. + #[rustc_nounwind] pub fn simd_reduce_add_ordered(x: T, y: U) -> U; /// Add elements within a vector in arbitrary order. May also be re-associated with @@ -341,6 +378,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_add_unordered(x: T) -> U; /// Multiply elements within a vector from left to right. @@ -350,6 +388,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// Starting with the value `y`, multiply the elements of `x` and accumulate. + #[rustc_nounwind] pub fn simd_reduce_mul_ordered(x: T, y: U) -> U; /// Add elements within a vector in arbitrary order. May also be re-associated with @@ -358,6 +397,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_mul_unordered(x: T) -> U; /// Check if all mask values are true. @@ -366,6 +406,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `x` must contain only `0` or `!0`. + #[rustc_nounwind] pub fn simd_reduce_all(x: T) -> bool; /// Check if all mask values are true. @@ -374,6 +415,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `x` must contain only `0` or `!0`. + #[rustc_nounwind] pub fn simd_reduce_any(x: T) -> bool; /// Return the maximum element of a vector. @@ -383,6 +425,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// For floating-point values, uses IEEE-754 `maxNum`. + #[rustc_nounwind] pub fn simd_reduce_max(x: T) -> U; /// Return the minimum element of a vector. @@ -392,6 +435,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// For floating-point values, uses IEEE-754 `minNum`. + #[rustc_nounwind] pub fn simd_reduce_min(x: T) -> U; /// Logical "and" all elements together. @@ -399,6 +443,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_and(x: T) -> U; /// Logical "or" all elements together. @@ -406,6 +451,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_or(x: T) -> U; /// Logical "exclusive or" all elements together. @@ -413,6 +459,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_xor(x: T) -> U; /// Truncate an integer vector to a bitmask. @@ -441,6 +488,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `x` must contain only `0` and `!0`. + #[rustc_nounwind] pub fn simd_bitmask(x: T) -> U; /// Select elements from a mask. @@ -455,6 +503,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `mask` must only contain `0` and `!0`. + #[rustc_nounwind] pub fn simd_select(mask: M, if_true: T, if_false: T) -> T; /// Select elements from a bitmask. @@ -471,6 +520,7 @@ extern "platform-intrinsic" { /// /// # Safety /// Padding bits must be all zero. + #[rustc_nounwind] pub fn simd_select_bitmask(m: M, yes: T, no: T) -> T; /// Elementwise calculates the offset from a pointer vector, potentially wrapping. @@ -480,11 +530,13 @@ extern "platform-intrinsic" { /// `U` must be a vector of `isize` or `usize` with the same number of elements as `T`. /// /// Operates as if by `::wrapping_offset`. + #[rustc_nounwind] pub fn simd_arith_offset(ptr: T, offset: U) -> T; /// Cast a vector of pointers. /// /// `T` and `U` must be vectors of pointers with the same number of elements. + #[rustc_nounwind] pub fn simd_cast_ptr(ptr: T) -> U; /// Expose a vector of pointers as a vector of addresses. @@ -492,6 +544,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of pointers. /// /// `U` must be a vector of `usize` with the same length as `T`. + #[rustc_nounwind] pub fn simd_expose_addr(ptr: T) -> U; /// Create a vector of pointers from a vector of addresses. @@ -499,92 +552,117 @@ extern "platform-intrinsic" { /// `T` must be a vector of `usize`. /// /// `U` must be a vector of pointers, with the same length as `T`. + #[rustc_nounwind] pub fn simd_from_exposed_addr(addr: T) -> U; /// Swap bytes of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_bswap(x: T) -> T; /// Reverse bits of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_bitreverse(x: T) -> T; /// Count the leading zeros of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_ctlz(x: T) -> T; /// Count the trailing zeros of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_cttz(x: T) -> T; /// Round up each element to the next highest integer-valued float. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_ceil(x: T) -> T; /// Round down each element to the next lowest integer-valued float. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_floor(x: T) -> T; /// Round each element to the closest integer-valued float. /// Ties are resolved by rounding away from 0. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_round(x: T) -> T; /// Return the integer part of each element as an integer-valued float. /// In other words, non-integer values are truncated towards zero. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_trunc(x: T) -> T; /// Takes the square root of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fsqrt(x: T) -> T; /// Computes `(x*y) + z` for each element, but without any intermediate rounding. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fma(x: T, y: T, z: T) -> T; // Computes the sine of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fsin(a: T) -> T; // Computes the cosine of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fcos(a: T) -> T; // Computes the exponential function of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fexp(a: T) -> T; // Computes 2 raised to the power of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fexp2(a: T) -> T; // Computes the base 10 logarithm of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_flog10(a: T) -> T; // Computes the base 2 logarithm of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_flog2(a: T) -> T; // Computes the natural logarithm of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_flog(a: T) -> T; } +} +} + +#[cfg(bootstrap)] +declare_intrinsics!("platform-intrinsic"); +#[cfg(not(bootstrap))] +declare_intrinsics!("rust-intrinsic"); diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 49cead680e33b..7b735d48bdfce 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -202,6 +202,7 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(platform_intrinsics))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] #![feature(allow_internal_unsafe)] @@ -246,7 +247,6 @@ #![feature(never_type)] #![feature(no_core)] #![feature(no_sanitize)] -#![feature(platform_intrinsics)] #![feature(prelude_import)] #![feature(repr_simd)] #![feature(rustc_allow_const_fn_unstable)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c6cd2c6786ad6..288cce3aa085e 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -270,6 +270,7 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(platform_intrinsics))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] @@ -301,7 +302,6 @@ #![feature(negative_impls)] #![feature(never_type)] #![feature(no_sanitize)] -#![feature(platform_intrinsics)] #![feature(prelude_import)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] From c1d0e489e564049eae866d6beb5b192c36b3b835 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 23 Feb 2024 18:36:24 +0100 Subject: [PATCH 295/417] fix use of platform_intrinsics in tests --- .../example/float-minmax-pass.rs | 7 +- .../tests/fail/intrinsics/simd-div-by-zero.rs | 6 +- .../fail/intrinsics/simd-div-overflow.rs | 6 +- .../intrinsics/simd-reduce-invalid-bool.rs | 6 +- .../tests/fail/intrinsics/simd-rem-by-zero.rs | 6 +- .../intrinsics/simd-select-bitmask-invalid.rs | 6 +- .../intrinsics/simd-select-invalid-bool.rs | 6 +- .../tests/fail/intrinsics/simd-shl-too-far.rs | 6 +- .../tests/fail/intrinsics/simd-shr-too-far.rs | 6 +- src/tools/miri/tests/pass/float_nan.rs | 8 +- .../miri/tests/pass/portable-simd-ptrs.rs | 2 +- src/tools/miri/tests/pass/portable-simd.rs | 10 +- .../pass/simd-intrinsic-generic-elements.rs | 2 +- tests/codegen/issues/issue-84268.rs | 4 +- .../simd-intrinsic-float-abs.rs | 4 +- .../simd-intrinsic-float-ceil.rs | 4 +- .../simd-intrinsic-float-cos.rs | 4 +- .../simd-intrinsic-float-exp.rs | 4 +- .../simd-intrinsic-float-exp2.rs | 4 +- .../simd-intrinsic-float-floor.rs | 4 +- .../simd-intrinsic-float-fma.rs | 4 +- .../simd-intrinsic-float-fsqrt.rs | 4 +- .../simd-intrinsic-float-log.rs | 4 +- .../simd-intrinsic-float-log10.rs | 4 +- .../simd-intrinsic-float-log2.rs | 4 +- .../simd-intrinsic-float-minmax.rs | 4 +- .../simd-intrinsic-float-pow.rs | 4 +- .../simd-intrinsic-float-powi.rs | 4 +- .../simd-intrinsic-float-sin.rs | 4 +- ...intrinsic-generic-arithmetic-saturating.rs | 4 +- .../simd-intrinsic-generic-bitmask.rs | 4 +- .../simd-intrinsic-generic-gather.rs | 4 +- .../simd-intrinsic-generic-masked-load.rs | 4 +- .../simd-intrinsic-generic-masked-store.rs | 4 +- .../simd-intrinsic-generic-scatter.rs | 4 +- .../simd-intrinsic-generic-select.rs | 4 +- .../simd-intrinsic-transmute-array.rs | 2 +- tests/codegen/simd/simd_arith_offset.rs | 4 +- tests/incremental/issue-61530.rs | 4 +- .../consts/const-eval/simd/insert_extract.rs | 4 +- tests/ui/error-codes/E0511.rs | 4 +- tests/ui/feature-gates/feature-gate-abi.rs | 13 +- .../ui/feature-gates/feature-gate-abi.stderr | 132 +++++++++--------- .../instance-doesnt-depend-on-type.rs | 2 +- .../bad-intrinsic-monomorphization.rs | 4 +- tests/ui/simd/array-trait.rs | 4 +- tests/ui/simd/array-type.rs | 4 +- tests/ui/simd/generics.rs | 4 +- tests/ui/simd/intrinsic/float-math-pass.rs | 4 +- tests/ui/simd/intrinsic/float-minmax-pass.rs | 7 +- .../ui/simd/intrinsic/generic-arithmetic-2.rs | 4 +- .../simd/intrinsic/generic-arithmetic-pass.rs | 4 +- .../generic-arithmetic-saturating-2.rs | 4 +- .../generic-arithmetic-saturating-pass.rs | 4 +- tests/ui/simd/intrinsic/generic-as.rs | 4 +- .../ui/simd/intrinsic/generic-bitmask-pass.rs | 4 +- tests/ui/simd/intrinsic/generic-bitmask.rs | 4 +- tests/ui/simd/intrinsic/generic-bswap-byte.rs | 4 +- tests/ui/simd/intrinsic/generic-cast-pass.rs | 4 +- .../intrinsic/generic-cast-pointer-width.rs | 4 +- tests/ui/simd/intrinsic/generic-cast.rs | 4 +- .../simd/intrinsic/generic-comparison-pass.rs | 4 +- tests/ui/simd/intrinsic/generic-comparison.rs | 4 +- .../simd/intrinsic/generic-elements-pass.rs | 4 +- tests/ui/simd/intrinsic/generic-elements.rs | 4 +- .../ui/simd/intrinsic/generic-gather-pass.rs | 4 +- .../simd/intrinsic/generic-reduction-pass.rs | 4 +- tests/ui/simd/intrinsic/generic-reduction.rs | 4 +- .../ui/simd/intrinsic/generic-select-pass.rs | 4 +- tests/ui/simd/intrinsic/generic-select.rs | 4 +- tests/ui/simd/intrinsic/generic-shuffle.rs | 4 +- .../simd/intrinsic/inlining-issue67557-ice.rs | 4 +- .../ui/simd/intrinsic/inlining-issue67557.rs | 4 +- tests/ui/simd/intrinsic/issue-85855.rs | 4 +- tests/ui/simd/intrinsic/ptr-cast.rs | 4 +- tests/ui/simd/issue-105439.rs | 4 +- tests/ui/simd/issue-39720.rs | 4 +- tests/ui/simd/issue-85915-simd-ptrs.rs | 4 +- tests/ui/simd/issue-89193.rs | 4 +- tests/ui/simd/masked-load-store-build-fail.rs | 4 +- tests/ui/simd/masked-load-store-check-fail.rs | 4 +- tests/ui/simd/masked-load-store.rs | 4 +- tests/ui/simd/monomorphize-shuffle-index.rs | 4 +- tests/ui/simd/repr_packed.rs | 4 +- tests/ui/simd/shuffle.rs | 4 +- tests/ui/simd/simd-bitmask.rs | 4 +- .../type-generic-monomorphisation-empty.rs | 2 +- ...type-generic-monomorphisation-oversized.rs | 2 +- ...e-generic-monomorphisation-power-of-two.rs | 2 +- .../ui/simd/type-generic-monomorphisation.rs | 2 +- 90 files changed, 236 insertions(+), 277 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs b/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs index eebd77083ec64..a71217a554b57 100644 --- a/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs +++ b/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs @@ -4,17 +4,14 @@ // Test that the simd_f{min,max} intrinsics produce the correct results. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "intrinsic" { - fn simd_fmin(x: T, y: T) -> T; - fn simd_fmax(x: T, y: T) -> T; -} +use std::intrinsics::simd::*; fn main() { let x = f32x4(1.0, 2.0, 3.0, 4.0); diff --git a/src/tools/miri/tests/fail/intrinsics/simd-div-by-zero.rs b/src/tools/miri/tests/fail/intrinsics/simd-div-by-zero.rs index 5fa6f69d00593..ba474332b811c 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-div-by-zero.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-div-by-zero.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - pub(crate) fn simd_div(x: T, y: T) -> T; -} +use std::intrinsics::simd::simd_div; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-div-overflow.rs b/src/tools/miri/tests/fail/intrinsics/simd-div-overflow.rs index 57712b1b836b5..d01e41de0e4be 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-div-overflow.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-div-overflow.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - pub(crate) fn simd_div(x: T, y: T) -> T; -} +use std::intrinsics::simd::simd_div; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-reduce-invalid-bool.rs b/src/tools/miri/tests/fail/intrinsics/simd-reduce-invalid-bool.rs index 354f8213120a2..a194f0dd18aa8 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-reduce-invalid-bool.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-reduce-invalid-bool.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - pub(crate) fn simd_reduce_any(x: T) -> bool; -} +use std::intrinsics::simd::simd_reduce_any; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-rem-by-zero.rs b/src/tools/miri/tests/fail/intrinsics/simd-rem-by-zero.rs index 625889bb67b57..cd1e4b8162b36 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-rem-by-zero.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-rem-by-zero.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - pub(crate) fn simd_rem(x: T, y: T) -> T; -} +use std::intrinsics::simd::simd_rem; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-select-bitmask-invalid.rs b/src/tools/miri/tests/fail/intrinsics/simd-select-bitmask-invalid.rs index 8a3895ac14cf8..96802fae49c23 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-select-bitmask-invalid.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-select-bitmask-invalid.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - fn simd_select_bitmask(m: M, yes: T, no: T) -> T; -} +use std::intrinsics::simd::simd_select_bitmask; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-select-invalid-bool.rs b/src/tools/miri/tests/fail/intrinsics/simd-select-invalid-bool.rs index 7f7ee3af49516..388fb2e2a84ae 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-select-invalid-bool.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-select-invalid-bool.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - fn simd_select(m: M, yes: T, no: T) -> T; -} +use std::intrinsics::simd::simd_select; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-shl-too-far.rs b/src/tools/miri/tests/fail/intrinsics/simd-shl-too-far.rs index 5c517c17b3a4b..8a49c8403ae37 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-shl-too-far.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-shl-too-far.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - pub(crate) fn simd_shl(x: T, y: T) -> T; -} +use std::intrinsics::simd::simd_shl; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/fail/intrinsics/simd-shr-too-far.rs b/src/tools/miri/tests/fail/intrinsics/simd-shr-too-far.rs index 5f1475a677813..433998cbde665 100644 --- a/src/tools/miri/tests/fail/intrinsics/simd-shr-too-far.rs +++ b/src/tools/miri/tests/fail/intrinsics/simd-shr-too-far.rs @@ -1,8 +1,6 @@ -#![feature(platform_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "platform-intrinsic" { - pub(crate) fn simd_shr(x: T, y: T) -> T; -} +use std::intrinsics::simd::simd_shr; #[repr(simd)] #[allow(non_camel_case_types)] diff --git a/src/tools/miri/tests/pass/float_nan.rs b/src/tools/miri/tests/pass/float_nan.rs index 4bfd12245ef1c..cadbbd58af591 100644 --- a/src/tools/miri/tests/pass/float_nan.rs +++ b/src/tools/miri/tests/pass/float_nan.rs @@ -1,4 +1,4 @@ -#![feature(float_gamma, portable_simd, core_intrinsics, platform_intrinsics)] +#![feature(float_gamma, portable_simd, core_intrinsics)] use std::collections::HashSet; use std::fmt; use std::hash::Hash; @@ -525,12 +525,6 @@ fn test_simd() { use std::intrinsics::simd::*; use std::simd::*; - extern "platform-intrinsic" { - fn simd_fsqrt(x: T) -> T; - fn simd_ceil(x: T) -> T; - fn simd_fma(x: T, y: T, z: T) -> T; - } - let nan = F32::nan(Neg, Quiet, 0).as_f32(); check_all_outcomes( HashSet::from_iter([F32::nan(Pos, Quiet, 0), F32::nan(Neg, Quiet, 0)]), diff --git a/src/tools/miri/tests/pass/portable-simd-ptrs.rs b/src/tools/miri/tests/pass/portable-simd-ptrs.rs index a73b1d03cfa5f..70ba5636c600e 100644 --- a/src/tools/miri/tests/pass/portable-simd-ptrs.rs +++ b/src/tools/miri/tests/pass/portable-simd-ptrs.rs @@ -1,6 +1,6 @@ // Separate test without strict provenance //@compile-flags: -Zmiri-permissive-provenance -#![feature(portable_simd, platform_intrinsics)] +#![feature(portable_simd)] use std::ptr; use std::simd::prelude::*; diff --git a/src/tools/miri/tests/pass/portable-simd.rs b/src/tools/miri/tests/pass/portable-simd.rs index 57d0b6a87b22a..193b778008375 100644 --- a/src/tools/miri/tests/pass/portable-simd.rs +++ b/src/tools/miri/tests/pass/portable-simd.rs @@ -1,5 +1,5 @@ //@compile-flags: -Zmiri-strict-provenance -#![feature(portable_simd, platform_intrinsics, adt_const_params, inline_const, core_intrinsics)] +#![feature(portable_simd, adt_const_params, inline_const, core_intrinsics)] #![allow(incomplete_features, internal_features)] use std::intrinsics::simd as intrinsics; use std::ptr; @@ -216,10 +216,7 @@ fn simd_ops_i32() { } fn simd_mask() { - extern "platform-intrinsic" { - pub(crate) fn simd_bitmask(x: T) -> U; - pub(crate) fn simd_select_bitmask(m: M, yes: T, no: T) -> T; - } + use std::intrinsics::simd::*; let intmask = Mask::from_int(i32x4::from_array([0, -1, 0, 0])); assert_eq!(intmask, Mask::from_array([false, true, false, false])); @@ -497,9 +494,6 @@ fn simd_round() { fn simd_intrinsics() { use intrinsics::*; - extern "platform-intrinsic" { - fn simd_shuffle_generic(x: T, y: T) -> U; - } unsafe { // Make sure simd_eq returns all-1 for `true` diff --git a/src/tools/miri/tests/pass/simd-intrinsic-generic-elements.rs b/src/tools/miri/tests/pass/simd-intrinsic-generic-elements.rs index 5958357c8b7b1..4a87f8c3ca720 100644 --- a/src/tools/miri/tests/pass/simd-intrinsic-generic-elements.rs +++ b/src/tools/miri/tests/pass/simd-intrinsic-generic-elements.rs @@ -1,4 +1,4 @@ -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd)] #[repr(simd)] #[derive(Copy, Clone, Debug, PartialEq)] diff --git a/tests/codegen/issues/issue-84268.rs b/tests/codegen/issues/issue-84268.rs index 379ee4f13f642..1e3950609b33a 100644 --- a/tests/codegen/issues/issue-84268.rs +++ b/tests/codegen/issues/issue-84268.rs @@ -1,7 +1,7 @@ //@ compile-flags: -O --crate-type=rlib -#![feature(platform_intrinsics, repr_simd)] +#![feature(intrinsics, repr_simd)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fabs(x: T) -> T; fn simd_eq(x: T, y: T) -> U; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs index 3eb1c9d405151..f8efb678f76ef 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fabs(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs index 05c2c0f6d0448..a3ebec174b679 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_ceil(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs index 8b51e76a515cd..00f97eef6f0cb 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fcos(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs index 370bacdaee985..48c1a8ec489db 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fexp(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs index 888ec6ec42cf2..23c38d8162157 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fexp2(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs index b15d89a15b279..978f263031ac3 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_floor(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs index 16017526c34a9..200d67180265a 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fma(x: T, b: T, c: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs index 9e0f7edd62b7f..f70de3e27536e 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fsqrt(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs index 0324411c91bd8..c0edd3ea48fc9 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_flog(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs index e7e2b0838cc28..766307f47ed35 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_flog10(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs index 912e15c6a1d81..90c5918c33ea3 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_flog2(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs index ad297952916cc..d949112bae762 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs @@ -2,14 +2,14 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fmin(x: T, y: T) -> T; fn simd_fmax(x: T, y: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-pow.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-pow.rs index 1ae983ca20b87..21641c80d313c 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-pow.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-pow.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fpow(x: T, b: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-powi.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-powi.rs index 638b78b2d72ac..3985bdd50df70 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-powi.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-powi.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fpowi(x: T, b: i32) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs index c0caedb749879..f6978e32df724 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -25,7 +25,7 @@ pub struct f32x16(pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fsin(x: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs index 1426b439c4435..809f9a32226f4 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #![deny(unused)] @@ -111,7 +111,7 @@ #[repr(simd)] #[derive(Copy, Clone)] pub struct u128x2(u128, u128); #[repr(simd)] #[derive(Copy, Clone)] pub struct u128x4(u128, u128, u128, u128); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_saturating_add(x: T, y: T) -> T; fn simd_saturating_sub(x: T, y: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs index 43012dece622e..44a4c52d64a87 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -22,7 +22,7 @@ pub struct i8x16( ); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_bitmask(x: T) -> U; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs index 29d9e4018e0d2..863a9606c7e99 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs @@ -4,7 +4,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -15,7 +15,7 @@ pub struct Vec2(pub T, pub T); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_gather(value: T, pointers: P, mask: M) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs index 7c48f7d5120ef..b41c42810aafd 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -13,7 +13,7 @@ pub struct Vec2(pub T, pub T); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_masked_load(mask: M, pointer: P, values: T) -> T; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs index 366592ba3f1e9..066392bcde682 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -13,7 +13,7 @@ pub struct Vec2(pub T, pub T); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_masked_store(mask: M, pointer: P, values: T) -> (); } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs index ccfedb31dc572..e85bd61c7f83b 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs @@ -4,7 +4,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -15,7 +15,7 @@ pub struct Vec2(pub T, pub T); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_scatter(value: T, pointers: P, mask: M); } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs index 903bd3f4dc606..05d2bf627ef12 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[allow(non_camel_case_types)] #[repr(simd)] @@ -17,7 +17,7 @@ pub struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); #[derive(Copy, Clone, PartialEq, Debug)] pub struct b8x4(pub i8, pub i8, pub i8, pub i8); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_select(x: T, a: U, b: U) -> U; fn simd_select_bitmask(x: T, a: U, b: U) -> U; } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index c92ae4163ae57..488be2a8629dd 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] #![allow(non_camel_case_types)] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![feature(inline_const)] #[repr(simd)] diff --git a/tests/codegen/simd/simd_arith_offset.rs b/tests/codegen/simd/simd_arith_offset.rs index 9f1ef27053e6e..e14fce1d41870 100644 --- a/tests/codegen/simd/simd_arith_offset.rs +++ b/tests/codegen/simd/simd_arith_offset.rs @@ -3,9 +3,9 @@ // #![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { pub(crate) fn simd_arith_offset(ptrs: T, offsets: U) -> T; } diff --git a/tests/incremental/issue-61530.rs b/tests/incremental/issue-61530.rs index 0197beb48d8c2..e4ee8ccbc4bd2 100644 --- a/tests/incremental/issue-61530.rs +++ b/tests/incremental/issue-61530.rs @@ -1,11 +1,11 @@ -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] //@ revisions:rpass1 rpass2 #[repr(simd)] struct I32x2(i32, i32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_shuffle(x: T, y: T, idx: I) -> U; } diff --git a/tests/ui/consts/const-eval/simd/insert_extract.rs b/tests/ui/consts/const-eval/simd/insert_extract.rs index c0113904edf0c..fc7dbd5a41c34 100644 --- a/tests/ui/consts/const-eval/simd/insert_extract.rs +++ b/tests/ui/consts/const-eval/simd/insert_extract.rs @@ -1,6 +1,6 @@ //@ run-pass #![feature(repr_simd)] -#![feature(platform_intrinsics)] +#![feature(intrinsics)] #![feature(staged_api)] #![stable(feature = "foo", since = "1.3.37")] #![allow(non_camel_case_types)] @@ -11,7 +11,7 @@ #[repr(simd)] struct i8x1_arr([i8; 1]); #[repr(simd)] struct f32x4([f32; 4]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { #[rustc_const_stable(feature = "foo", since = "1.3.37")] fn simd_insert(x: T, idx: u32, val: U) -> T; #[rustc_const_stable(feature = "foo", since = "1.3.37")] diff --git a/tests/ui/error-codes/E0511.rs b/tests/ui/error-codes/E0511.rs index 8c79bcf5a6720..81656c710882d 100644 --- a/tests/ui/error-codes/E0511.rs +++ b/tests/ui/error-codes/E0511.rs @@ -1,8 +1,8 @@ //@ build-fail -#![feature(platform_intrinsics)] +#![feature(intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(a: T, b: T) -> T; } diff --git a/tests/ui/feature-gates/feature-gate-abi.rs b/tests/ui/feature-gates/feature-gate-abi.rs index 02568b4778b9c..1c3a732a497fa 100644 --- a/tests/ui/feature-gates/feature-gate-abi.rs +++ b/tests/ui/feature-gates/feature-gate-abi.rs @@ -1,5 +1,4 @@ // gate-test-intrinsics -// gate-test-platform_intrinsics //@ compile-flags: --crate-type=rlib #![feature(no_core, lang_items)] @@ -15,7 +14,7 @@ trait Tuple { } extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in //~| ERROR unrecognized intrinsic function: `f1` -extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental +extern "rust-intrinsic" fn f2() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in //~| ERROR unrecognized intrinsic function: `f2` extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change @@ -24,7 +23,7 @@ extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change trait Tr { extern "rust-intrinsic" fn m1(); //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in - extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental + extern "rust-intrinsic" fn m2(); //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change @@ -37,7 +36,7 @@ struct S; impl Tr for S { extern "rust-intrinsic" fn m1() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in - extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental + extern "rust-intrinsic" fn m2() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change } @@ -46,17 +45,17 @@ impl Tr for S { impl S { extern "rust-intrinsic" fn im1() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in - extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental + extern "rust-intrinsic" fn im2() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change } // Function pointer types type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change -type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental +type A2 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change // Foreign modules extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change -extern "platform-intrinsic" {} //~ ERROR platform intrinsics are experimental +extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change extern "rust-call" {} //~ ERROR rust-call ABI is subject to change diff --git a/tests/ui/feature-gates/feature-gate-abi.stderr b/tests/ui/feature-gates/feature-gate-abi.stderr index 3fd1e1189abc7..c28cd05a96ad6 100644 --- a/tests/ui/feature-gates/feature-gate-abi.stderr +++ b/tests/ui/feature-gates/feature-gate-abi.stderr @@ -1,5 +1,5 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:15:8 + --> $DIR/feature-gate-abi.rs:14:8 | LL | extern "rust-intrinsic" fn f1() {} | ^^^^^^^^^^^^^^^^ @@ -7,18 +7,17 @@ LL | extern "rust-intrinsic" fn f1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:18:8 +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:17:8 | -LL | extern "platform-intrinsic" fn f2() {} - | ^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-intrinsic" fn f2() {} + | ^^^^^^^^^^^^^^^^ | - = note: see issue #27731 for more information - = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:21:8 + --> $DIR/feature-gate-abi.rs:20:8 | LL | extern "rust-call" fn f4(_: ()) {} | ^^^^^^^^^^^ @@ -28,7 +27,7 @@ LL | extern "rust-call" fn f4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:25:12 + --> $DIR/feature-gate-abi.rs:24:12 | LL | extern "rust-intrinsic" fn m1(); | ^^^^^^^^^^^^^^^^ @@ -36,18 +35,17 @@ LL | extern "rust-intrinsic" fn m1(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:27:12 +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:26:12 | -LL | extern "platform-intrinsic" fn m2(); - | ^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-intrinsic" fn m2(); + | ^^^^^^^^^^^^^^^^ | - = note: see issue #27731 for more information - = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:29:12 + --> $DIR/feature-gate-abi.rs:28:12 | LL | extern "rust-call" fn m4(_: ()); | ^^^^^^^^^^^ @@ -57,7 +55,7 @@ LL | extern "rust-call" fn m4(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:31:12 + --> $DIR/feature-gate-abi.rs:30:12 | LL | extern "rust-call" fn dm4(_: ()) {} | ^^^^^^^^^^^ @@ -67,7 +65,7 @@ LL | extern "rust-call" fn dm4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:38:12 + --> $DIR/feature-gate-abi.rs:37:12 | LL | extern "rust-intrinsic" fn m1() {} | ^^^^^^^^^^^^^^^^ @@ -75,18 +73,17 @@ LL | extern "rust-intrinsic" fn m1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:40:12 +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:39:12 | -LL | extern "platform-intrinsic" fn m2() {} - | ^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-intrinsic" fn m2() {} + | ^^^^^^^^^^^^^^^^ | - = note: see issue #27731 for more information - = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:42:12 + --> $DIR/feature-gate-abi.rs:41:12 | LL | extern "rust-call" fn m4(_: ()) {} | ^^^^^^^^^^^ @@ -96,7 +93,7 @@ LL | extern "rust-call" fn m4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:47:12 + --> $DIR/feature-gate-abi.rs:46:12 | LL | extern "rust-intrinsic" fn im1() {} | ^^^^^^^^^^^^^^^^ @@ -104,18 +101,17 @@ LL | extern "rust-intrinsic" fn im1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:49:12 +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:48:12 | -LL | extern "platform-intrinsic" fn im2() {} - | ^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-intrinsic" fn im2() {} + | ^^^^^^^^^^^^^^^^ | - = note: see issue #27731 for more information - = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:51:12 + --> $DIR/feature-gate-abi.rs:50:12 | LL | extern "rust-call" fn im4(_: ()) {} | ^^^^^^^^^^^ @@ -125,7 +121,7 @@ LL | extern "rust-call" fn im4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:55:18 + --> $DIR/feature-gate-abi.rs:54:18 | LL | type A1 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^ @@ -133,18 +129,17 @@ LL | type A1 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:56:18 +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:55:18 | -LL | type A2 = extern "platform-intrinsic" fn(); - | ^^^^^^^^^^^^^^^^^^^^ +LL | type A2 = extern "rust-intrinsic" fn(); + | ^^^^^^^^^^^^^^^^ | - = note: see issue #27731 for more information - = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:57:18 + --> $DIR/feature-gate-abi.rs:56:18 | LL | type A4 = extern "rust-call" fn(_: ()); | ^^^^^^^^^^^ @@ -154,7 +149,7 @@ LL | type A4 = extern "rust-call" fn(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:60:8 + --> $DIR/feature-gate-abi.rs:59:8 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^ @@ -162,18 +157,17 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:61:8 +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:60:8 | -LL | extern "platform-intrinsic" {} - | ^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-intrinsic" {} + | ^^^^^^^^^^^^^^^^ | - = note: see issue #27731 for more information - = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:62:8 + --> $DIR/feature-gate-abi.rs:61:8 | LL | extern "rust-call" {} | ^^^^^^^^^^^ @@ -183,7 +177,7 @@ LL | extern "rust-call" {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0093]: unrecognized intrinsic function: `f1` - --> $DIR/feature-gate-abi.rs:15:28 + --> $DIR/feature-gate-abi.rs:14:28 | LL | extern "rust-intrinsic" fn f1() {} | ^^ unrecognized intrinsic @@ -191,60 +185,60 @@ LL | extern "rust-intrinsic" fn f1() {} = help: if you're adding an intrinsic, be sure to update `check_intrinsic_type` error[E0093]: unrecognized intrinsic function: `f2` - --> $DIR/feature-gate-abi.rs:18:32 + --> $DIR/feature-gate-abi.rs:17:28 | -LL | extern "platform-intrinsic" fn f2() {} - | ^^ unrecognized intrinsic +LL | extern "rust-intrinsic" fn f2() {} + | ^^ unrecognized intrinsic | = help: if you're adding an intrinsic, be sure to update `check_intrinsic_type` error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:25:32 + --> $DIR/feature-gate-abi.rs:24:32 | LL | extern "rust-intrinsic" fn m1(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:27:36 + --> $DIR/feature-gate-abi.rs:26:32 | -LL | extern "platform-intrinsic" fn m2(); - | ^^ +LL | extern "rust-intrinsic" fn m2(); + | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:15:33 + --> $DIR/feature-gate-abi.rs:14:33 | LL | extern "rust-intrinsic" fn f1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:18:37 + --> $DIR/feature-gate-abi.rs:17:33 | -LL | extern "platform-intrinsic" fn f2() {} - | ^^ +LL | extern "rust-intrinsic" fn f2() {} + | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:38:37 + --> $DIR/feature-gate-abi.rs:37:37 | LL | extern "rust-intrinsic" fn m1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:40:41 + --> $DIR/feature-gate-abi.rs:39:37 | -LL | extern "platform-intrinsic" fn m2() {} - | ^^ +LL | extern "rust-intrinsic" fn m2() {} + | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:47:38 + --> $DIR/feature-gate-abi.rs:46:38 | LL | extern "rust-intrinsic" fn im1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:49:42 + --> $DIR/feature-gate-abi.rs:48:38 | -LL | extern "platform-intrinsic" fn im2() {} - | ^^ +LL | extern "rust-intrinsic" fn im2() {} + | ^^ error: aborting due to 29 previous errors diff --git a/tests/ui/inline-const/instance-doesnt-depend-on-type.rs b/tests/ui/inline-const/instance-doesnt-depend-on-type.rs index 17208a230883f..e69106a43af49 100644 --- a/tests/ui/inline-const/instance-doesnt-depend-on-type.rs +++ b/tests/ui/inline-const/instance-doesnt-depend-on-type.rs @@ -6,5 +6,5 @@ fn main() { const { core::mem::transmute:: }; // Don't resolve the instance of this inline constant to be an intrinsic, - // even if the type of the constant is `extern "intrinsic" fn(u8) -> u8`. + // even if the type of the constant is `extern "rust-intrinsic" fn(u8) -> u8`. } diff --git a/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs b/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs index a9c92f23cdd09..fa9cbe4400cef 100644 --- a/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs +++ b/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs @@ -1,13 +1,13 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics, core_intrinsics)] +#![feature(repr_simd, intrinsics, core_intrinsics)] #![allow(warnings)] #![crate_type = "rlib"] // Bad monomorphizations could previously cause LLVM asserts even though the // error was caught in the compiler. -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(x: T, y: T) -> T; } diff --git a/tests/ui/simd/array-trait.rs b/tests/ui/simd/array-trait.rs index 55fec7a3948bf..d2f246a2146ca 100644 --- a/tests/ui/simd/array-trait.rs +++ b/tests/ui/simd/array-trait.rs @@ -4,7 +4,7 @@ //@ pretty-expanded FIXME #23616 -#![feature(repr_simd, platform_intrinsics, generic_const_exprs)] +#![feature(repr_simd, intrinsics, generic_const_exprs)] #![allow(non_camel_case_types, incomplete_features)] pub trait Simd { @@ -25,7 +25,7 @@ pub struct T([S::Lane; S::SIZE]); //~| ERROR SIMD vector element type should be a primitive scalar //~| ERROR unconstrained generic constant -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; fn simd_extract(x: T, idx: u32) -> E; } diff --git a/tests/ui/simd/array-type.rs b/tests/ui/simd/array-type.rs index 0864c3e7418d0..4063dcd703cd7 100644 --- a/tests/ui/simd/array-type.rs +++ b/tests/ui/simd/array-type.rs @@ -3,7 +3,7 @@ //@ pretty-expanded FIXME #23616 -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] @@ -13,7 +13,7 @@ struct S([i32; 4]); #[derive(Copy, Clone)] struct T([i32; N]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; fn simd_extract(x: T, idx: u32) -> E; } diff --git a/tests/ui/simd/generics.rs b/tests/ui/simd/generics.rs index 9b54de809ed1a..bd048b19ca886 100644 --- a/tests/ui/simd/generics.rs +++ b/tests/ui/simd/generics.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(non_camel_case_types)] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] use std::ops; @@ -21,7 +21,7 @@ struct B([T; 4]); struct C([T; N]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(x: T, y: T) -> T; } diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index c1ba50a910b17..ea31e2a7c570e 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -8,14 +8,14 @@ // Test that the simd floating-point math intrinsics produce correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_fsqrt(x: T) -> T; fn simd_fabs(x: T) -> T; fn simd_fsin(x: T) -> T; diff --git a/tests/ui/simd/intrinsic/float-minmax-pass.rs b/tests/ui/simd/intrinsic/float-minmax-pass.rs index a773c79dbe9d4..d6cbcd4e05a63 100644 --- a/tests/ui/simd/intrinsic/float-minmax-pass.rs +++ b/tests/ui/simd/intrinsic/float-minmax-pass.rs @@ -3,17 +3,14 @@ // Test that the simd_f{min,max} intrinsics produce the correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { - fn simd_fmin(x: T, y: T) -> T; - fn simd_fmax(x: T, y: T) -> T; -} +use std::intrinsics::simd::*; fn main() { let x = f32x4(1.0, 2.0, 3.0, 4.0); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index b337a77c24c31..4ad98d5671135 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone)] @@ -14,7 +14,7 @@ pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[derive(Copy, Clone)] pub struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(x: T, y: T) -> T; fn simd_sub(x: T, y: T) -> T; fn simd_mul(x: T, y: T) -> T; diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index fa54228bbcfbd..33143b1f7b53b 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -1,7 +1,7 @@ //@ run-pass #![allow(non_camel_case_types)] //@ ignore-emscripten FIXME(#45351) hits an LLVM assert -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] @@ -31,7 +31,7 @@ macro_rules! all_eq_ { }}; } -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(x: T, y: T) -> T; fn simd_sub(x: T, y: T) -> T; fn simd_mul(x: T, y: T) -> T; diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs index b31a604cb14c5..36be8cc62a8c8 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs @@ -1,6 +1,6 @@ //@ build-fail //@ ignore-emscripten -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone)] @@ -14,7 +14,7 @@ pub struct x4(pub T, pub T, pub T, pub T); #[derive(Copy, Clone)] pub struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_saturating_add(x: T, y: T) -> T; fn simd_saturating_sub(x: T, y: T) -> T; } diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs index 1a4ba3659c1d5..deee9c2ac41e6 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs @@ -2,7 +2,7 @@ //@ ignore-emscripten #![allow(non_camel_case_types)] -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] @@ -12,7 +12,7 @@ struct u32x4(pub u32, pub u32, pub u32, pub u32); #[derive(Copy, Clone)] struct I32([i32; N]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_saturating_add(x: T, y: T) -> T; fn simd_saturating_sub(x: T, y: T) -> T; } diff --git a/tests/ui/simd/intrinsic/generic-as.rs b/tests/ui/simd/intrinsic/generic-as.rs index 807cd927734d5..e97bf12c14473 100644 --- a/tests/ui/simd/intrinsic/generic-as.rs +++ b/tests/ui/simd/intrinsic/generic-as.rs @@ -1,8 +1,8 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_as(x: T) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs index 3063a0a4a3afd..5c6a07876e35e 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs @@ -6,7 +6,7 @@ // Test that the simd_bitmask intrinsic produces correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[allow(non_camel_case_types)] #[repr(simd)] @@ -21,7 +21,7 @@ struct u8x4(pub u8, pub u8, pub u8, pub u8); #[derive(Copy, Clone, PartialEq, Debug)] struct Tx4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_bitmask(x: T) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-bitmask.rs b/tests/ui/simd/intrinsic/generic-bitmask.rs index f1bda34a85ed8..29b9279c370f5 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask.rs @@ -3,7 +3,7 @@ // Test that the simd_bitmask intrinsic produces ok-ish error // messages when misused. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -30,7 +30,7 @@ struct u8x32([u8; 32]); #[derive(Copy, Clone)] struct u8x64([u8; 64]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_bitmask(x: T) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-bswap-byte.rs b/tests/ui/simd/intrinsic/generic-bswap-byte.rs index d86db6601b239..f1702538165d3 100644 --- a/tests/ui/simd/intrinsic/generic-bswap-byte.rs +++ b/tests/ui/simd/intrinsic/generic-bswap-byte.rs @@ -1,5 +1,5 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -10,7 +10,7 @@ struct i8x4([i8; 4]); #[derive(Copy, Clone)] struct u8x4([u8; 4]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_bswap(x: T) -> T; } diff --git a/tests/ui/simd/intrinsic/generic-cast-pass.rs b/tests/ui/simd/intrinsic/generic-cast-pass.rs index 24ec910f53439..e0319a6461ad2 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pass.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pass.rs @@ -1,9 +1,9 @@ //@ run-pass //@ ignore-emscripten FIXME(#45351) hits an LLVM assert -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_cast(x: T) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs index ade52086bc42f..1c09a9fbf3bfd 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs @@ -1,7 +1,7 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_cast(x: T) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-cast.rs b/tests/ui/simd/intrinsic/generic-cast.rs index 9488d9a42ab74..f3fdbe3403f79 100644 --- a/tests/ui/simd/intrinsic/generic-cast.rs +++ b/tests/ui/simd/intrinsic/generic-cast.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] @@ -23,7 +23,7 @@ struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_cast(x: T) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-comparison-pass.rs b/tests/ui/simd/intrinsic/generic-comparison-pass.rs index 083236387e477..a4df836b6f82a 100644 --- a/tests/ui/simd/intrinsic/generic-comparison-pass.rs +++ b/tests/ui/simd/intrinsic/generic-comparison-pass.rs @@ -1,7 +1,7 @@ //@ run-pass //@ ignore-emscripten FIXME(#45351) hits an LLVM assert -#![feature(repr_simd, platform_intrinsics, concat_idents)] +#![feature(repr_simd, intrinsics, concat_idents)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -14,7 +14,7 @@ struct u32x4(pub u32, pub u32, pub u32, pub u32); #[derive(Copy, Clone)] struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_eq(x: T, y: T) -> U; fn simd_ne(x: T, y: T) -> U; fn simd_lt(x: T, y: T) -> U; diff --git a/tests/ui/simd/intrinsic/generic-comparison.rs b/tests/ui/simd/intrinsic/generic-comparison.rs index 710e660d9cbbc..bb2720f615fef 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.rs +++ b/tests/ui/simd/intrinsic/generic-comparison.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] @@ -12,7 +12,7 @@ struct i32x4(i32, i32, i32, i32); struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_eq(x: T, y: T) -> U; fn simd_ne(x: T, y: T) -> U; fn simd_lt(x: T, y: T) -> U; diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index e3b527fa4fe45..7300308781932 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -1,7 +1,7 @@ //@ run-pass //@ ignore-emscripten FIXME(#45351) hits an LLVM assert -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![feature(inline_const)] #[repr(simd)] @@ -18,7 +18,7 @@ struct i32x4(i32, i32, i32, i32); struct i32x8(i32, i32, i32, i32, i32, i32, i32, i32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; fn simd_extract(x: T, idx: u32) -> E; diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index a8ee4cf396577..abceb08ecc5a6 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics, rustc_attrs, adt_const_params)] +#![feature(repr_simd, intrinsics, rustc_attrs, adt_const_params)] #![allow(incomplete_features)] #[repr(simd)] @@ -31,7 +31,7 @@ struct f32x4(f32, f32, f32, f32); struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; fn simd_extract(x: T, idx: u32) -> E; diff --git a/tests/ui/simd/intrinsic/generic-gather-pass.rs b/tests/ui/simd/intrinsic/generic-gather-pass.rs index ca9e9de2afa18..a00bc67e73bd4 100644 --- a/tests/ui/simd/intrinsic/generic-gather-pass.rs +++ b/tests/ui/simd/intrinsic/generic-gather-pass.rs @@ -3,14 +3,14 @@ // Test that the simd_{gather,scatter} intrinsics produce the correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct x4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_gather(x: T, y: U, z: V) -> T; fn simd_scatter(x: T, y: U, z: V) -> (); } diff --git a/tests/ui/simd/intrinsic/generic-reduction-pass.rs b/tests/ui/simd/intrinsic/generic-reduction-pass.rs index cf4669cd61f5c..64902788709eb 100644 --- a/tests/ui/simd/intrinsic/generic-reduction-pass.rs +++ b/tests/ui/simd/intrinsic/generic-reduction-pass.rs @@ -5,7 +5,7 @@ // Test that the simd_reduce_{op} intrinsics produce the correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[allow(non_camel_case_types)] #[repr(simd)] @@ -24,7 +24,7 @@ struct f32x4(pub f32, pub f32, pub f32, pub f32); #[derive(Copy, Clone)] struct b8x4(pub i8, pub i8, pub i8, pub i8); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_reduce_add_unordered(x: T) -> U; fn simd_reduce_mul_unordered(x: T) -> U; fn simd_reduce_add_ordered(x: T, acc: U) -> U; diff --git a/tests/ui/simd/intrinsic/generic-reduction.rs b/tests/ui/simd/intrinsic/generic-reduction.rs index 5e3debb411e44..96df73591693f 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.rs +++ b/tests/ui/simd/intrinsic/generic-reduction.rs @@ -4,7 +4,7 @@ // Test that the simd_reduce_{op} intrinsics produce ok-ish error // messages when misused. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -16,7 +16,7 @@ pub struct f32x4(pub f32, pub f32, pub f32, pub f32); pub struct u32x4(pub u32, pub u32, pub u32, pub u32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_reduce_add_ordered(x: T, y: U) -> U; fn simd_reduce_mul_ordered(x: T, y: U) -> U; fn simd_reduce_and(x: T) -> U; diff --git a/tests/ui/simd/intrinsic/generic-select-pass.rs b/tests/ui/simd/intrinsic/generic-select-pass.rs index df8a89e26c9f3..98e1534e6e622 100644 --- a/tests/ui/simd/intrinsic/generic-select-pass.rs +++ b/tests/ui/simd/intrinsic/generic-select-pass.rs @@ -6,7 +6,7 @@ // Test that the simd_select intrinsics produces correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[allow(non_camel_case_types)] #[repr(simd)] @@ -29,7 +29,7 @@ struct f32x4(pub f32, pub f32, pub f32, pub f32); #[derive(Copy, Clone, PartialEq, Debug)] struct b8x4(pub i8, pub i8, pub i8, pub i8); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_select(x: T, a: U, b: U) -> U; fn simd_select_bitmask(x: T, a: U, b: U) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-select.rs b/tests/ui/simd/intrinsic/generic-select.rs index ab963ed942f74..215ae405c37e2 100644 --- a/tests/ui/simd/intrinsic/generic-select.rs +++ b/tests/ui/simd/intrinsic/generic-select.rs @@ -3,7 +3,7 @@ // Test that the simd_select intrinsic produces ok-ish error // messages when misused. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -22,7 +22,7 @@ struct b8x4(pub i8, pub i8, pub i8, pub i8); #[derive(Copy, Clone, PartialEq)] struct b8x8(pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_select(x: T, a: U, b: U) -> U; fn simd_select_bitmask(x: T, a: U, b: U) -> U; } diff --git a/tests/ui/simd/intrinsic/generic-shuffle.rs b/tests/ui/simd/intrinsic/generic-shuffle.rs index db814f02c8b34..c0888f6778414 100644 --- a/tests/ui/simd/intrinsic/generic-shuffle.rs +++ b/tests/ui/simd/intrinsic/generic-shuffle.rs @@ -3,13 +3,13 @@ // Test that the simd_shuffle intrinsic produces ok-ish error // messages when misused. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] pub struct Simd([T; N]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_shuffle(a: T, b: T, i: I) -> U; } diff --git a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs index 5b49f4f7203c5..928d3824703e7 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs @@ -3,9 +3,9 @@ // //@ run-pass //@ compile-flags: -Zmir-opt-level=4 -#![feature(platform_intrinsics, repr_simd)] +#![feature(intrinsics, repr_simd)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_shuffle(x: T, y: T, idx: I) -> U; } diff --git a/tests/ui/simd/intrinsic/inlining-issue67557.rs b/tests/ui/simd/intrinsic/inlining-issue67557.rs index 3d6284ef1c6be..b8b8dbba547d1 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557.rs @@ -3,9 +3,9 @@ // //@ run-pass //@ compile-flags: -Zmir-opt-level=4 -#![feature(platform_intrinsics, repr_simd)] +#![feature(intrinsics, repr_simd)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_shuffle(x: T, y: T, idx: I) -> U; } diff --git a/tests/ui/simd/intrinsic/issue-85855.rs b/tests/ui/simd/intrinsic/issue-85855.rs index f276fbd669470..dc04699f7f89d 100644 --- a/tests/ui/simd/intrinsic/issue-85855.rs +++ b/tests/ui/simd/intrinsic/issue-85855.rs @@ -2,10 +2,10 @@ // with the wrong number of generic lifetime/type/const parameters, and // that no ICE occurs in these cases. -#![feature(platform_intrinsics)] +#![feature(intrinsics)] #![crate_type="lib"] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_saturating_add<'a, T: 'a>(x: T, y: T); //~^ ERROR: intrinsic has wrong number of lifetime parameters diff --git a/tests/ui/simd/intrinsic/ptr-cast.rs b/tests/ui/simd/intrinsic/ptr-cast.rs index 109e1d0039a65..83d86baf334a7 100644 --- a/tests/ui/simd/intrinsic/ptr-cast.rs +++ b/tests/ui/simd/intrinsic/ptr-cast.rs @@ -1,8 +1,8 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_cast_ptr(x: T) -> U; fn simd_expose_addr(x: T) -> U; fn simd_from_exposed_addr(x: T) -> U; diff --git a/tests/ui/simd/issue-105439.rs b/tests/ui/simd/issue-105439.rs index 3eb137e4ee7d1..3cb43fc8b1af9 100644 --- a/tests/ui/simd/issue-105439.rs +++ b/tests/ui/simd/issue-105439.rs @@ -2,14 +2,14 @@ //@ compile-flags: -O -Zverify-llvm-ir #![feature(repr_simd)] -#![feature(platform_intrinsics)] +#![feature(intrinsics)] #[allow(non_camel_case_types)] #[derive(Clone, Copy)] #[repr(simd)] struct i32x4([i32; 4]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { pub(crate) fn simd_add(x: T, y: T) -> T; } diff --git a/tests/ui/simd/issue-39720.rs b/tests/ui/simd/issue-39720.rs index ea6e893b79d9c..4610b1d50044b 100644 --- a/tests/ui/simd/issue-39720.rs +++ b/tests/ui/simd/issue-39720.rs @@ -1,7 +1,7 @@ //@ run-pass //@ ignore-emscripten FIXME(#45351) -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] #[derive(Copy, Clone, Debug)] @@ -11,7 +11,7 @@ pub struct Char3(pub i8, pub i8, pub i8); #[derive(Copy, Clone, Debug)] pub struct Short3(pub i16, pub i16, pub i16); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_cast(x: T) -> U; } diff --git a/tests/ui/simd/issue-85915-simd-ptrs.rs b/tests/ui/simd/issue-85915-simd-ptrs.rs index 96ac76f0590e9..edf60e0205c29 100644 --- a/tests/ui/simd/issue-85915-simd-ptrs.rs +++ b/tests/ui/simd/issue-85915-simd-ptrs.rs @@ -3,7 +3,7 @@ // Short form of the generic gather/scatter tests, // verifying simd([*const T; N]) and simd([*mut T; N]) pass typeck and work. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] @@ -22,7 +22,7 @@ struct f32x4([f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct i32x4([i32; 4]); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_gather(x: T, y: U, z: V) -> T; fn simd_scatter(x: T, y: U, z: V) -> (); } diff --git a/tests/ui/simd/issue-89193.rs b/tests/ui/simd/issue-89193.rs index f34242e7bf894..a4ed9be9962fb 100644 --- a/tests/ui/simd/issue-89193.rs +++ b/tests/ui/simd/issue-89193.rs @@ -3,14 +3,14 @@ // Test that simd gather instructions on slice of usize don't cause crash // See issue #89183 - https://github.com/rust-lang/rust/issues/89193 -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct x4(pub T, pub T, pub T, pub T); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_gather(x: T, y: U, z: V) -> T; } diff --git a/tests/ui/simd/masked-load-store-build-fail.rs b/tests/ui/simd/masked-load-store-build-fail.rs index 7b414dfcc9324..fbd657763c984 100644 --- a/tests/ui/simd/masked-load-store-build-fail.rs +++ b/tests/ui/simd/masked-load-store-build-fail.rs @@ -1,7 +1,7 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_masked_load(mask: M, pointer: P, values: T) -> T; fn simd_masked_store(mask: M, pointer: P, values: T) -> (); } diff --git a/tests/ui/simd/masked-load-store-check-fail.rs b/tests/ui/simd/masked-load-store-check-fail.rs index a86979d8faf60..39c82c41385ce 100644 --- a/tests/ui/simd/masked-load-store-check-fail.rs +++ b/tests/ui/simd/masked-load-store-check-fail.rs @@ -1,7 +1,7 @@ //@ check-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_masked_load(mask: M, pointer: P, values: T) -> T; fn simd_masked_store(mask: M, pointer: P, values: T) -> (); } diff --git a/tests/ui/simd/masked-load-store.rs b/tests/ui/simd/masked-load-store.rs index b2f5490727fda..902143f92615e 100644 --- a/tests/ui/simd/masked-load-store.rs +++ b/tests/ui/simd/masked-load-store.rs @@ -1,7 +1,7 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_masked_load(mask: M, pointer: P, values: T) -> T; fn simd_masked_store(mask: M, pointer: P, values: T) -> (); } diff --git a/tests/ui/simd/monomorphize-shuffle-index.rs b/tests/ui/simd/monomorphize-shuffle-index.rs index 052f0eec472d3..379616884a1b5 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.rs +++ b/tests/ui/simd/monomorphize-shuffle-index.rs @@ -1,10 +1,10 @@ //@[old]run-pass //@[generic_with_fn]run-pass //@ revisions: old generic generic_with_fn -#![feature(repr_simd, platform_intrinsics, adt_const_params, generic_const_exprs)] +#![feature(repr_simd, intrinsics, adt_const_params, generic_const_exprs)] #![allow(incomplete_features)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { #[cfg(old)] fn simd_shuffle(a: T, b: T, i: I) -> U; #[cfg(any(generic, generic_with_fn))] diff --git a/tests/ui/simd/repr_packed.rs b/tests/ui/simd/repr_packed.rs index 395751e86f110..411bba3454ebe 100644 --- a/tests/ui/simd/repr_packed.rs +++ b/tests/ui/simd/repr_packed.rs @@ -1,6 +1,6 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(non_camel_case_types)] #[repr(simd, packed)] @@ -25,7 +25,7 @@ fn check_ty() { check_size_align::(); } -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(a: T, b: T) -> T; } diff --git a/tests/ui/simd/shuffle.rs b/tests/ui/simd/shuffle.rs index 5022afc5b4963..09926d95557cd 100644 --- a/tests/ui/simd/shuffle.rs +++ b/tests/ui/simd/shuffle.rs @@ -2,11 +2,11 @@ //@ revisions: opt noopt //@[noopt] compile-flags: -Copt-level=0 //@[opt] compile-flags: -O -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #![allow(incomplete_features)] #![feature(adt_const_params)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_shuffle(a: T, b: T, i: I) -> U; } diff --git a/tests/ui/simd/simd-bitmask.rs b/tests/ui/simd/simd-bitmask.rs index a3717c9e21ae5..4a7c3bc77507c 100644 --- a/tests/ui/simd/simd-bitmask.rs +++ b/tests/ui/simd/simd-bitmask.rs @@ -1,8 +1,8 @@ //@run-pass //@ignore-endian-big behavior of simd_select_bitmask is endian-specific -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_bitmask(v: T) -> U; fn simd_select_bitmask(m: T, a: U, b: U) -> U; } diff --git a/tests/ui/simd/type-generic-monomorphisation-empty.rs b/tests/ui/simd/type-generic-monomorphisation-empty.rs index 38c5581105d05..4700f642065be 100644 --- a/tests/ui/simd/type-generic-monomorphisation-empty.rs +++ b/tests/ui/simd/type-generic-monomorphisation-empty.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] //@ error-pattern:monomorphising SIMD type `Simd<0>` of zero length diff --git a/tests/ui/simd/type-generic-monomorphisation-oversized.rs b/tests/ui/simd/type-generic-monomorphisation-oversized.rs index 53f66f1d596f1..9949f913c4459 100644 --- a/tests/ui/simd/type-generic-monomorphisation-oversized.rs +++ b/tests/ui/simd/type-generic-monomorphisation-oversized.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] //@ error-pattern:monomorphising SIMD type `Simd<65536>` of length greater than 32768 diff --git a/tests/ui/simd/type-generic-monomorphisation-power-of-two.rs b/tests/ui/simd/type-generic-monomorphisation-power-of-two.rs index 26269335bc47c..b3e228970d009 100644 --- a/tests/ui/simd/type-generic-monomorphisation-power-of-two.rs +++ b/tests/ui/simd/type-generic-monomorphisation-power-of-two.rs @@ -1,6 +1,6 @@ //@ run-pass -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] #[repr(simd)] struct Simd([f32; N]); diff --git a/tests/ui/simd/type-generic-monomorphisation.rs b/tests/ui/simd/type-generic-monomorphisation.rs index 90ddd1dde0fd0..2eeba55ef913a 100644 --- a/tests/ui/simd/type-generic-monomorphisation.rs +++ b/tests/ui/simd/type-generic-monomorphisation.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, intrinsics)] //@ error-pattern:monomorphising SIMD type `Simd2` with a non-primitive-scalar (integer/float/pointer) element type `X` From 9577051174b9c77ffc4c5b427d90ba49608d5697 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 25 Feb 2024 08:17:20 +0100 Subject: [PATCH 296/417] bump rustc-build-sysroot --- Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc2c7dd7e16be..a6e016afd82d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3332,13 +3332,14 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39dcf8d82b1f79a179bdb284dc44db440a9666eefa5a6df5ef282d6db930d544" +checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea" dependencies = [ "anyhow", "rustc_version", "tempfile", + "walkdir", ] [[package]] From 9caeabe2e2e9dab5356b06d2b1a46ae11cc59ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sun, 25 Feb 2024 09:56:19 +0200 Subject: [PATCH 297/417] Add missing imports --- .../crates/hir-ty/src/mir/lower/pattern_matching.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs index a6d5ce723e31d..85c8d1685b874 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs @@ -1,6 +1,6 @@ //! MIR lowering for patterns -use hir_def::AssocItemId; +use hir_def::{hir::LiteralOrConst, resolver::HasResolver, AssocItemId}; use crate::{ mir::lower::{ From 5ee6a5d704fe9259e9719dd5a31fa3f69b68489c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sun, 25 Feb 2024 09:58:11 +0200 Subject: [PATCH 298/417] Avoid using cfg(FALSE) --- src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs b/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs index 40a195f7d95a7..e678a2fee1321 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs @@ -742,9 +742,8 @@ pub(crate) fn adt_datum_query( phantom_data, }; - #[cfg(FALSE)] // this slows down rust-analyzer by quite a bit unfortunately, so enabling this is currently not worth it - let variant_id_to_fields = |id: VariantId| { + let _variant_id_to_fields = |id: VariantId| { let variant_data = &id.variant_data(db.upcast()); let fields = if variant_data.fields().is_empty() { vec![] From 6b7700ef49b4aef5b54b40f12eff2cfe19ec3976 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Sun, 25 Feb 2024 10:08:38 +0100 Subject: [PATCH 299/417] Pause PR assignments for xFrednet :) --- triagebot.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 303a4ca900ca6..1a81394af10d5 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -6,7 +6,7 @@ allow-unauthenticated = [ # Allows shortcuts like `@rustbot ready` # -# See https://github.com/rust-lang/triagebot/wiki/Shortcuts +# See https://forge.rust-lang.org/triagebot/shortcuts.html [shortcut] # Have rustbot inform users about the *No Merge Policy* @@ -19,6 +19,7 @@ new_pr = true [assign] contributing_url = "https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md" +users_on_vacation = ["xFrednet"] [assign.owners] "/.github" = ["@flip1995"] From cdaccd7fce7ac3bba597d8a4385150ee306dc05d Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 25 Feb 2024 13:14:07 +0300 Subject: [PATCH 300/417] bump itertools to 0.12 --- Cargo.toml | 2 +- clippy_dev/Cargo.toml | 2 +- clippy_lints/Cargo.toml | 2 +- clippy_utils/Cargo.toml | 2 +- declare_clippy_lint/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c83a2e349e46e..633932a5a3b9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ toml = "0.7.3" walkdir = "2.3" # This is used by the `collect-metadata` alias. filetime = "0.2" -itertools = "0.11" +itertools = "0.12" # UI test dependencies clippy_utils = { path = "clippy_utils" } diff --git a/clippy_dev/Cargo.toml b/clippy_dev/Cargo.toml index 5ec67554e7d89..42a953039b1c0 100644 --- a/clippy_dev/Cargo.toml +++ b/clippy_dev/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" aho-corasick = "1.0" clap = "4.1.4" indoc = "1.0" -itertools = "0.11" +itertools = "0.12" opener = "0.6" shell-escape = "0.1" walkdir = "2.3" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 6e6e315bb6561..6ae089b3e0321 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -14,7 +14,7 @@ cargo_metadata = "0.18" clippy_config = { path = "../clippy_config" } clippy_utils = { path = "../clippy_utils" } declare_clippy_lint = { path = "../declare_clippy_lint" } -itertools = "0.11" +itertools = "0.12" quine-mc_cluskey = "0.2" regex-syntax = "0.8" serde = { version = "1.0", features = ["derive"] } diff --git a/clippy_utils/Cargo.toml b/clippy_utils/Cargo.toml index c7454fa3328b8..bf55040ddbc11 100644 --- a/clippy_utils/Cargo.toml +++ b/clippy_utils/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] clippy_config = { path = "../clippy_config" } arrayvec = { version = "0.7", default-features = false } -itertools = "0.11" +itertools = "0.12" rustc-semver = "1.1" [features] diff --git a/declare_clippy_lint/Cargo.toml b/declare_clippy_lint/Cargo.toml index 0f90cef5cdd2b..296eb8dd34008 100644 --- a/declare_clippy_lint/Cargo.toml +++ b/declare_clippy_lint/Cargo.toml @@ -8,7 +8,7 @@ publish = false proc-macro = true [dependencies] -itertools = "0.11" +itertools = "0.12" quote = "1.0.21" syn = "2.0" From 5b7786cd1d246fd0bbe748c8690fb99b1134d2be Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 8 Feb 2024 20:08:19 +0100 Subject: [PATCH 301/417] make non-PartialEq-typed consts as patterns a hard error --- compiler/rustc_lint/src/lib.rs | 5 ++ compiler/rustc_lint_defs/src/builtin.rs | 52 ------------------- compiler/rustc_mir_build/src/errors.rs | 14 ++--- .../src/thir/pattern/const_to_pat.rs | 15 +++--- .../ui/consts/const_in_pattern/issue-65466.rs | 7 +-- .../const_in_pattern/issue-65466.stderr | 21 ++------ .../match/issue-72896-non-partial-eq-const.rs | 4 +- .../issue-72896-non-partial-eq-const.stderr | 21 ++------ 8 files changed, 27 insertions(+), 112 deletions(-) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index d8e12c04f7536..844f87c3f5055 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -527,6 +527,11 @@ fn register_builtins(store: &mut LintStore) { "no longer needed, see #93367 \ for more information", ); + store.register_removed( + "const_patterns_without_partial_eq", + "converted into hard error, see RFC #3535 \ + for more information", + ); } fn register_internals(store: &mut LintStore) { diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 84a050a242a69..1cddb45428c8b 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -32,7 +32,6 @@ declare_lint_pass! { CONFLICTING_REPR_HINTS, CONST_EVALUATABLE_UNCHECKED, CONST_ITEM_MUTATION, - CONST_PATTERNS_WITHOUT_PARTIAL_EQ, DEAD_CODE, DEPRECATED, DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, @@ -2342,57 +2341,6 @@ declare_lint! { }; } -declare_lint! { - /// The `const_patterns_without_partial_eq` lint detects constants that are used in patterns, - /// whose type does not implement `PartialEq`. - /// - /// ### Example - /// - /// ```rust,compile_fail - /// #![deny(const_patterns_without_partial_eq)] - /// - /// trait EnumSetType { - /// type Repr; - /// } - /// - /// enum Enum8 { } - /// impl EnumSetType for Enum8 { - /// type Repr = u8; - /// } - /// - /// #[derive(PartialEq, Eq)] - /// struct EnumSet { - /// __enumset_underlying: T::Repr, - /// } - /// - /// const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; - /// - /// fn main() { - /// match CONST_SET { - /// CONST_SET => { /* ok */ } - /// _ => panic!("match fell through?"), - /// } - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Previous versions of Rust accepted constants in patterns, even if those constants' types - /// did not have `PartialEq` implemented. The compiler falls back to comparing the value - /// field-by-field. In the future we'd like to ensure that pattern matching always - /// follows `PartialEq` semantics, so that trait bound will become a requirement for - /// matching on constants. - pub CONST_PATTERNS_WITHOUT_PARTIAL_EQ, - Warn, - "constant in pattern does not implement `PartialEq`", - @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, - reference: "issue #116122 ", - }; -} - declare_lint! { /// The `ambiguous_associated_items` lint detects ambiguity between /// [associated items] and [enum variants]. diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 48b93ce0ac5cb..101f1cb9f2f5f 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -767,6 +767,14 @@ pub struct TypeNotStructural<'tcx> { pub non_sm_ty: Ty<'tcx>, } +#[derive(Diagnostic)] +#[diag(mir_build_non_partial_eq_match)] +pub struct TypeNotPartialEq<'tcx> { + #[primary_span] + pub span: Span, + pub non_peq_ty: Ty<'tcx>, +} + #[derive(Diagnostic)] #[diag(mir_build_invalid_pattern)] pub struct InvalidPattern<'tcx> { @@ -822,12 +830,6 @@ pub struct NontrivialStructuralMatch<'tcx> { pub non_sm_ty: Ty<'tcx>, } -#[derive(LintDiagnostic)] -#[diag(mir_build_non_partial_eq_match)] -pub struct NonPartialEqMatch<'tcx> { - pub non_peq_ty: Ty<'tcx>, -} - #[derive(Diagnostic)] #[diag(mir_build_pattern_not_covered, code = E0005)] pub(crate) struct PatternNotCovered<'s, 'tcx> { diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index c77c80d9f4b29..09727f9b71bef 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -16,7 +16,7 @@ use std::cell::Cell; use super::PatCtxt; use crate::errors::{ - IndirectStructuralMatch, InvalidPattern, NaNPattern, NonPartialEqMatch, PointerPattern, + IndirectStructuralMatch, InvalidPattern, NaNPattern, PointerPattern, TypeNotPartialEq, TypeNotStructural, UnionPattern, UnsizedPattern, }; @@ -208,15 +208,12 @@ impl<'tcx> ConstToPat<'tcx> { ); } - // Always check for `PartialEq`, even if we emitted other lints. (But not if there were - // any errors.) This ensures it shows up in cargo's future-compat reports as well. + // Always check for `PartialEq` if we had no other errors yet. if !self.type_has_partial_eq_impl(cv.ty()) { - self.tcx().emit_node_span_lint( - lint::builtin::CONST_PATTERNS_WITHOUT_PARTIAL_EQ, - self.id, - self.span, - NonPartialEqMatch { non_peq_ty: cv.ty() }, - ); + let err = TypeNotPartialEq { span: self.span, non_peq_ty: cv.ty() }; + let e = self.tcx().dcx().emit_err(err); + let kind = PatKind::Error(e); + return Box::new(Pat { span: self.span, ty: cv.ty(), kind }); } } diff --git a/tests/ui/consts/const_in_pattern/issue-65466.rs b/tests/ui/consts/const_in_pattern/issue-65466.rs index 048fca762d5a1..62efce648761a 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.rs +++ b/tests/ui/consts/const_in_pattern/issue-65466.rs @@ -1,7 +1,3 @@ -#![deny(indirect_structural_match)] - -//@ check-pass - #[derive(PartialEq, Eq)] enum O { Some(*const T), // Can also use PhantomData @@ -15,8 +11,7 @@ const C: &[O] = &[O::None]; fn main() { let x = O::None; match &[x][..] { - C => (), //~WARN: the type must implement `PartialEq` - //~| previously accepted + C => (), //~ERROR: the type must implement `PartialEq` _ => (), } } diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr index 9c80cb3a849c0..7d5e5b5b0c64a 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.stderr +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -1,23 +1,8 @@ -warning: to use a constant of type `&[O]` in a pattern, the type must implement `PartialEq` - --> $DIR/issue-65466.rs:18:9 +error: to use a constant of type `&[O]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:14:9 | LL | C => (), | ^ - | - = 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 #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default - -warning: 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -warning: to use a constant of type `&[O]` in a pattern, the type must implement `PartialEq` - --> $DIR/issue-65466.rs:18:9 - | -LL | C => (), - | ^ - | - = 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 #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default +error: aborting due to 1 previous error diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.rs b/tests/ui/match/issue-72896-non-partial-eq-const.rs index d497271460849..f15eae83896d1 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.rs +++ b/tests/ui/match/issue-72896-non-partial-eq-const.rs @@ -1,4 +1,3 @@ -//@ run-pass trait EnumSetType { type Repr; } @@ -17,8 +16,7 @@ const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; fn main() { match CONST_SET { - CONST_SET => { /* ok */ } //~WARN: must implement `PartialEq` - //~| previously accepted + CONST_SET => { /* ok */ } //~ERROR: must implement `PartialEq` _ => panic!("match fell through?"), } } diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr index a7fc0cfc05457..4155586c16060 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -1,23 +1,8 @@ -warning: to use a constant of type `EnumSet` in a pattern, the type must implement `PartialEq` - --> $DIR/issue-72896-non-partial-eq-const.rs:20:9 +error: to use a constant of type `EnumSet` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-72896-non-partial-eq-const.rs:19:9 | LL | CONST_SET => { /* ok */ } | ^^^^^^^^^ - | - = 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 #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default - -warning: 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -warning: to use a constant of type `EnumSet` in a pattern, the type must implement `PartialEq` - --> $DIR/issue-72896-non-partial-eq-const.rs:20:9 - | -LL | CONST_SET => { /* ok */ } - | ^^^^^^^^^ - | - = 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 #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default +error: aborting due to 1 previous error From b2fbb8a05392be976c67e3b0063203d5b049da5c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 22 Feb 2024 14:59:52 +0100 Subject: [PATCH 302/417] Use generic `NonZero` in tests. --- tests/codegen/array-equality.rs | 4 +- tests/codegen/enum/enum-debug-niche-2.rs | 17 +- tests/codegen/function-arguments.rs | 8 +- tests/codegen/intrinsics/transmute-niched.rs | 6 +- tests/codegen/issues/issue-119422.rs | 22 +-- tests/codegen/loads.rs | 8 +- tests/codegen/option-as-slice.rs | 9 +- tests/codegen/option-nonzero-eq.rs | 8 +- tests/codegen/slice-ref-equality.rs | 8 +- tests/codegen/transmute-optimized.rs | 6 +- tests/debuginfo/msvc-pretty-enums.rs | 80 ++++---- tests/debuginfo/numeric-types.rs | 28 +-- .../instsimplify/combine_transmutes.rs | 4 +- tests/rustdoc/type-layout.rs | 2 +- tests/ui/abi/compatibility.rs | 9 +- .../consts/const-eval/raw-bytes.32bit.stderr | 114 +++++------ .../consts/const-eval/raw-bytes.64bit.stderr | 114 +++++------ tests/ui/consts/const-eval/raw-bytes.rs | 9 +- tests/ui/consts/const-eval/ub-nonnull.rs | 10 +- tests/ui/consts/const-eval/ub-nonnull.stderr | 14 +- tests/ui/consts/const-eval/valid-const.rs | 9 +- tests/ui/consts/ice-48279.rs | 2 +- tests/ui/consts/tuple-struct-constructors.rs | 7 +- .../intrinsics/panic-uninitialized-zeroed.rs | 12 +- tests/ui/issues/issue-64593.rs | 3 +- tests/ui/layout/unsafe-cell-hides-niche.rs | 28 +-- .../ui/layout/zero-sized-array-enum-niche.rs | 5 +- .../layout/zero-sized-array-enum-niche.stderr | 10 +- tests/ui/lint/clashing-extern-fn.rs | 33 ++-- tests/ui/lint/clashing-extern-fn.stderr | 50 ++--- tests/ui/lint/invalid_value.rs | 13 +- tests/ui/lint/invalid_value.stderr | 186 +++++++++--------- tests/ui/lint/lint-ctypes-enum.rs | 41 ++-- tests/ui/lint/lint-ctypes-enum.stderr | 44 ++--- .../overflowing-neg-nonzero.rs | 6 +- tests/ui/print_type_sizes/niche-filling.rs | 44 ++--- .../ui/structs-enums/enum-null-pointer-opt.rs | 5 +- .../enum-null-pointer-opt.stderr | 2 +- tests/ui/structs-enums/type-sizes.rs | 25 +-- .../core-std-import-order-issue-83564.rs | 7 +- .../core-std-import-order-issue-83564.stderr | 12 +- .../next-solver/specialization-transmute.rs | 7 +- .../specialization-transmute.stderr | 6 +- 43 files changed, 520 insertions(+), 517 deletions(-) diff --git a/tests/codegen/array-equality.rs b/tests/codegen/array-equality.rs index 9435422888634..5b85da1d4a0c5 100644 --- a/tests/codegen/array-equality.rs +++ b/tests/codegen/array-equality.rs @@ -1,7 +1,7 @@ //@ compile-flags: -O -Z merge-functions=disabled //@ only-x86_64 - #![crate_type = "lib"] +#![feature(generic_nonzero)] // CHECK-LABEL: @array_eq_value #[no_mangle] @@ -63,7 +63,7 @@ pub fn array_eq_zero_short(x: [u16; 3]) -> bool { // CHECK-LABEL: @array_eq_none_short(i40 #[no_mangle] -pub fn array_eq_none_short(x: [Option; 5]) -> bool { +pub fn array_eq_none_short(x: [Option>; 5]) -> bool { // CHECK-NEXT: start: // CHECK-NEXT: %[[EQ:.+]] = icmp eq i40 %0, 0 // CHECK-NEXT: ret i1 %[[EQ]] diff --git a/tests/codegen/enum/enum-debug-niche-2.rs b/tests/codegen/enum/enum-debug-niche-2.rs index 4315741e0bdd9..25871885e7ea9 100644 --- a/tests/codegen/enum/enum-debug-niche-2.rs +++ b/tests/codegen/enum/enum-debug-niche-2.rs @@ -1,20 +1,17 @@ -// This tests that optimized enum debug info accurately reflects the enum layout. -// This is ignored for the fallback mode on MSVC due to problems with PDB. - -// -//@ ignore-msvc - +//! This tests that optimized enum debug info accurately reflects the enum layout. +//! This is ignored for the fallback mode on MSVC due to problems with PDB. +//! //@ compile-flags: -g -C no-prepopulate-passes - +//@ ignore-msvc +// // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}} // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}} - -#![feature(never_type)] +#![feature(generic_nonzero, never_type)] #[derive(Copy, Clone)] pub struct Entity { - private: std::num::NonZeroU32, + private: std::num::NonZero, } #[derive(Copy, Clone, PartialEq, Eq)] diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 88cedcf46b696..b75c188f51a9b 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,10 +1,10 @@ //@ compile-flags: -O -C no-prepopulate-passes - #![crate_type = "lib"] #![feature(dyn_star)] +#![feature(generic_nonzero)] use std::mem::MaybeUninit; -use std::num::NonZeroU64; +use std::num::NonZero; use std::marker::PhantomPinned; use std::ptr::NonNull; @@ -70,13 +70,13 @@ pub fn int(x: u64) -> u64 { // CHECK: noundef i64 @nonzero_int(i64 noundef %x) #[no_mangle] -pub fn nonzero_int(x: NonZeroU64) -> NonZeroU64 { +pub fn nonzero_int(x: NonZero) -> NonZero { x } // CHECK: noundef i64 @option_nonzero_int(i64 noundef %x) #[no_mangle] -pub fn option_nonzero_int(x: Option) -> Option { +pub fn option_nonzero_int(x: Option>) -> Option> { x } diff --git a/tests/codegen/intrinsics/transmute-niched.rs b/tests/codegen/intrinsics/transmute-niched.rs index 7c448c82e4b24..b5e0da1b2f5f6 100644 --- a/tests/codegen/intrinsics/transmute-niched.rs +++ b/tests/codegen/intrinsics/transmute-niched.rs @@ -2,11 +2,11 @@ //@ [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes //@ [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes //@ only-64bit (so I don't need to worry about usize) - #![crate_type = "lib"] +#![feature(generic_nonzero)] use std::mem::transmute; -use std::num::NonZeroU32; +use std::num::NonZero; #[repr(u8)] pub enum SmallEnum { @@ -130,7 +130,7 @@ pub unsafe fn check_enum_to_char(x: Minus100ToPlus100) -> char { // CHECK-LABEL: @check_swap_pair( #[no_mangle] -pub unsafe fn check_swap_pair(x: (char, NonZeroU32)) -> (NonZeroU32, char) { +pub unsafe fn check_swap_pair(x: (char, NonZero)) -> (NonZero, char) { // OPT: %0 = icmp ule i32 %x.0, 1114111 // OPT: call void @llvm.assume(i1 %0) // OPT: %1 = icmp uge i32 %x.0, 1 diff --git a/tests/codegen/issues/issue-119422.rs b/tests/codegen/issues/issue-119422.rs index 937fdcf28f5d6..19480b4dc9e11 100644 --- a/tests/codegen/issues/issue-119422.rs +++ b/tests/codegen/issues/issue-119422.rs @@ -1,13 +1,13 @@ //! This test checks that compiler don't generate useless compares to zeros -//! for NonZero integer types. - +//! for `NonZero` integer types. +//! //@ compile-flags: -O --edition=2021 -Zmerge-functions=disabled //@ only-64bit (because the LLVM type of i64 for usize shows up) - #![crate_type = "lib"] +#![feature(generic_nonzero)] -use core::num::*; use core::ptr::NonNull; +use core::num::NonZero; // CHECK-LABEL: @check_non_null #[no_mangle] @@ -18,7 +18,7 @@ pub fn check_non_null(x: NonNull) -> bool { // CHECK-LABEL: @equals_zero_is_false_u8 #[no_mangle] -pub fn equals_zero_is_false_u8(x: NonZeroU8) -> bool { +pub fn equals_zero_is_false_u8(x: NonZero) -> bool { // CHECK-NOT: br // CHECK: ret i1 false // CHECK-NOT: br @@ -27,7 +27,7 @@ pub fn equals_zero_is_false_u8(x: NonZeroU8) -> bool { // CHECK-LABEL: @not_equals_zero_is_true_u8 #[no_mangle] -pub fn not_equals_zero_is_true_u8(x: NonZeroU8) -> bool { +pub fn not_equals_zero_is_true_u8(x: NonZero) -> bool { // CHECK-NOT: br // CHECK: ret i1 true // CHECK-NOT: br @@ -36,7 +36,7 @@ pub fn not_equals_zero_is_true_u8(x: NonZeroU8) -> bool { // CHECK-LABEL: @equals_zero_is_false_i8 #[no_mangle] -pub fn equals_zero_is_false_i8(x: NonZeroI8) -> bool { +pub fn equals_zero_is_false_i8(x: NonZero) -> bool { // CHECK-NOT: br // CHECK: ret i1 false // CHECK-NOT: br @@ -45,7 +45,7 @@ pub fn equals_zero_is_false_i8(x: NonZeroI8) -> bool { // CHECK-LABEL: @not_equals_zero_is_true_i8 #[no_mangle] -pub fn not_equals_zero_is_true_i8(x: NonZeroI8) -> bool { +pub fn not_equals_zero_is_true_i8(x: NonZero) -> bool { // CHECK-NOT: br // CHECK: ret i1 true // CHECK-NOT: br @@ -54,7 +54,7 @@ pub fn not_equals_zero_is_true_i8(x: NonZeroI8) -> bool { // CHECK-LABEL: @usize_try_from_u32 #[no_mangle] -pub fn usize_try_from_u32(x: NonZeroU32) -> NonZeroUsize { +pub fn usize_try_from_u32(x: NonZero) -> NonZero { // CHECK-NOT: br // CHECK: zext i32 %{{.*}} to i64 // CHECK-NOT: br @@ -64,7 +64,7 @@ pub fn usize_try_from_u32(x: NonZeroU32) -> NonZeroUsize { // CHECK-LABEL: @isize_try_from_i32 #[no_mangle] -pub fn isize_try_from_i32(x: NonZeroI32) -> NonZeroIsize { +pub fn isize_try_from_i32(x: NonZero) -> NonZero { // CHECK-NOT: br // CHECK: sext i32 %{{.*}} to i64 // CHECK-NOT: br @@ -74,7 +74,7 @@ pub fn isize_try_from_i32(x: NonZeroI32) -> NonZeroIsize { // CHECK-LABEL: @u64_from_nonzero_is_not_zero #[no_mangle] -pub fn u64_from_nonzero_is_not_zero(x: NonZeroU64)->bool { +pub fn u64_from_nonzero_is_not_zero(x: NonZero)->bool { // CHECK-NOT: br // CHECK: ret i1 false // CHECK-NOT: br diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index 0471d83c25a38..b86b3dd3a1967 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -1,9 +1,9 @@ //@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 - #![crate_type = "lib"] +#![feature(generic_nonzero)] use std::mem::MaybeUninit; -use std::num::NonZeroU16; +use std::num::NonZero; pub struct Bytes { a: u8, @@ -99,14 +99,14 @@ pub fn load_int(x: &u16) -> u16 { // CHECK-LABEL: @load_nonzero_int #[no_mangle] -pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 { +pub fn load_nonzero_int(x: &NonZero) -> NonZero { // CHECK: load i16, ptr %x, align 2, !range ![[NONZEROU16_RANGE:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_option_nonzero_int #[no_mangle] -pub fn load_option_nonzero_int(x: &Option) -> Option { +pub fn load_option_nonzero_int(x: &Option>) -> Option> { // CHECK: load i16, ptr %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } diff --git a/tests/codegen/option-as-slice.rs b/tests/codegen/option-as-slice.rs index 990ec1d1f66be..14a3924360786 100644 --- a/tests/codegen/option-as-slice.rs +++ b/tests/codegen/option-as-slice.rs @@ -1,14 +1,13 @@ //@ compile-flags: -O -Z randomize-layout=no //@ only-x86_64 //@ ignore-llvm-version: 16.0.0 -// ^ needs https://reviews.llvm.org/D146149 in 16.0.1 - +// ^-- needs https://reviews.llvm.org/D146149 in 16.0.1 #![crate_type = "lib"] -#![feature(option_as_slice)] +#![feature(generic_nonzero)] extern crate core; -use core::num::NonZeroU64; +use core::num::NonZero; use core::option::Option; // CHECK-LABEL: @u64_opt_as_slice @@ -23,7 +22,7 @@ pub fn u64_opt_as_slice(o: &Option) -> &[u64] { // CHECK-LABEL: @nonzero_u64_opt_as_slice #[no_mangle] -pub fn nonzero_u64_opt_as_slice(o: &Option) -> &[NonZeroU64] { +pub fn nonzero_u64_opt_as_slice(o: &Option>) -> &[NonZero] { // CHECK-NOT: select // CHECK-NOT: br // CHECK-NOT: switch diff --git a/tests/codegen/option-nonzero-eq.rs b/tests/codegen/option-nonzero-eq.rs index f6be90a5ddeb5..f637b1aef9757 100644 --- a/tests/codegen/option-nonzero-eq.rs +++ b/tests/codegen/option-nonzero-eq.rs @@ -1,18 +1,18 @@ //@ compile-flags: -O -Zmerge-functions=disabled - #![crate_type = "lib"] +#![feature(generic_nonzero)] extern crate core; use core::cmp::Ordering; -use core::num::{NonZeroU32, NonZeroI64}; use core::ptr::NonNull; +use core::num::NonZero; // See also tests/assembly/option-nonzero-eq.rs, for cases with `assume`s in the // LLVM and thus don't optimize down clearly here, but do in assembly. // CHECK-lABEL: @non_zero_eq #[no_mangle] -pub fn non_zero_eq(l: Option, r: Option) -> bool { +pub fn non_zero_eq(l: Option>, r: Option>) -> bool { // CHECK: start: // CHECK-NEXT: icmp eq i32 // CHECK-NEXT: ret i1 @@ -21,7 +21,7 @@ pub fn non_zero_eq(l: Option, r: Option) -> bool { // CHECK-lABEL: @non_zero_signed_eq #[no_mangle] -pub fn non_zero_signed_eq(l: Option, r: Option) -> bool { +pub fn non_zero_signed_eq(l: Option>, r: Option>) -> bool { // CHECK: start: // CHECK-NEXT: icmp eq i64 // CHECK-NEXT: ret i1 diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 371e685ec6c92..85d9c34a30b5a 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -1,8 +1,8 @@ //@ compile-flags: -O -Zmerge-functions=disabled - #![crate_type = "lib"] +#![feature(generic_nonzero)] -use std::num::{NonZeroI16, NonZeroU32}; +use std::num::NonZero; // #71602 reported a simple array comparison just generating a loop. // This was originally fixed by ensuring it generates a single bcmp, @@ -70,7 +70,7 @@ fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { // CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 // CHECK-SAME: [[USIZE]] noundef %3 #[no_mangle] -fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { +fn eq_slice_of_nonzero(x: &[NonZero], y: &[NonZero]) -> bool { // CHECK: icmp eq [[USIZE]] %1, %3 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr @@ -82,7 +82,7 @@ fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { // CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 // CHECK-SAME: [[USIZE]] noundef %3 #[no_mangle] -fn eq_slice_of_option_of_nonzero(x: &[Option], y: &[Option]) -> bool { +fn eq_slice_of_option_of_nonzero(x: &[Option>], y: &[Option>]) -> bool { // CHECK: icmp eq [[USIZE]] %1, %3 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs index 9217def76b519..1a5f53e625ae5 100644 --- a/tests/codegen/transmute-optimized.rs +++ b/tests/codegen/transmute-optimized.rs @@ -1,6 +1,6 @@ //@ compile-flags: -O -Z merge-functions=disabled - #![crate_type = "lib"] +#![feature(generic_nonzero)] // This tests that LLVM can optimize based on the niches in the source or // destination types for transmutes. @@ -33,7 +33,7 @@ pub fn non_null_is_null(x: std::ptr::NonNull) -> bool { // CHECK-LABEL: i1 @non_zero_is_null( #[no_mangle] -pub fn non_zero_is_null(x: std::num::NonZeroUsize) -> bool { +pub fn non_zero_is_null(x: std::num::NonZero) -> bool { // CHECK: ret i1 false let p: *const i32 = unsafe { std::mem::transmute(x) }; p.is_null() @@ -72,7 +72,7 @@ pub fn normal_div(a: u32, b: u32) -> u32 { // CHECK-LABEL: i32 @div_transmute_nonzero(i32 #[no_mangle] -pub fn div_transmute_nonzero(a: u32, b: std::num::NonZeroI32) -> u32 { +pub fn div_transmute_nonzero(a: u32, b: std::num::NonZero) -> u32 { // CHECK-NOT: call core::panicking::panic // CHECK: %[[R:.+]] = udiv i32 %a, %b // CHECK-NEXT: ret i32 %[[R]] diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs index c6dd9f7939df4..cfac14a22c418 100644 --- a/tests/debuginfo/msvc-pretty-enums.rs +++ b/tests/debuginfo/msvc-pretty-enums.rs @@ -1,143 +1,143 @@ //@ only-cdb //@ compile-flags:-g - +// // cdb-command: g - +// // cdb-command: dx a // cdb-check:a : Some [Type: enum2$ >] // cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum] - +// // cdb-command: dx b // cdb-check:b : None [Type: enum2$ >] - +// // cdb-command: dx c // cdb-check:c : Tag1 [Type: enum2$] - +// // cdb-command: dx d // cdb-check:d : Data [Type: enum2$] // cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] - +// // cdb-command: dx e // cdb-check:e : Tag2 [Type: enum2$] - +// // cdb-command: dx f // cdb-check:f : Some [Type: enum2$ > >] // cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *] - +// // cdb-command: dx g // cdb-check:g : None [Type: enum2$ > >] - +// // cdb-command: dx h // cdb-check:h : Some [Type: enum2$ >] // cdb-check: [+0x004] __0 : 0xc [Type: unsigned int] - +// // cdb-command: dx i // cdb-check:i : None [Type: enum2$ >] - +// // cdb-command: dx j // cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] - +// // cdb-command: dx k // cdb-check:k : Some [Type: enum2$ >] // cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String] - +// // cdb-command: dx l // cdb-check:l : Ok [Type: enum2$ > >] // cdb-check: [+0x000] __0 : 0x2a [Type: unsigned int] - +// // cdb-command: dx niche128_some // cdb-check: niche128_some : Some [Type: enum2$ > >] // Note: we can't actually read the value of the field because CDB cannot handle 128 bit integers. // cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZero] - +// // cdb-command: dx niche128_none // cdb-check: niche128_none : None [Type: enum2$ > >] - +// // cdb-command: dx wrapping_niche128_untagged // cdb-check: wrapping_niche128_untagged : X [Type: enum2$] // cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] - +// // cdb-command: dx wrapping_niche128_none1 // cdb-check: wrapping_niche128_none1 : Y [Type: enum2$] // cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] - +// // cdb-command: dx wrapping_niche128_none2 // cdb-check: wrapping_niche128_none2 : Z [Type: enum2$] // cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] - +// // cdb-command: dx direct_tag_128_a,d // cdb-check: direct_tag_128_a,d : A [Type: enum2$] // cdb-check: [+0x[...]] __0 : 42 [Type: unsigned int] - +// // cdb-command: dx direct_tag_128_b,d // cdb-check: direct_tag_128_b,d : B [Type: enum2$] // cdb-check: [+0x[...]] __0 : 137 [Type: unsigned int] - +// // cdb-command: dx niche_w_fields_1_some,d // cdb-check: niche_w_fields_1_some,d : A [Type: enum2$] // cdb-check: [+0x[...]] __0 : 0x[...] : 77 [Type: unsigned char *] // cdb-check: [+0x[...]] __1 : 7 [Type: unsigned int] - +// // cdb-command: dx niche_w_fields_1_none,d // cdb-check: niche_w_fields_1_none,d : B [Type: enum2$] // cdb-check: [+0x[...]] __0 : 99 [Type: unsigned int] - +// // cdb-command: dx niche_w_fields_2_some,d // cdb-check: niche_w_fields_2_some,d : A [Type: enum2$] // cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZero] // cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64] - +// // cdb-command: dx niche_w_fields_2_none,d // cdb-check: niche_w_fields_2_none,d : B [Type: enum2$] // cdb-check: [+0x[...]] __0 : 1000 [Type: unsigned __int64] - +// // cdb-command: dx niche_w_fields_3_some,d // cdb-check: niche_w_fields_3_some,d : A [Type: enum2$] // cdb-check: [+0x[...]] __0 : 137 [Type: unsigned char] // cdb-check: [+0x[...]] __1 : true [Type: bool] - +// // cdb-command: dx niche_w_fields_3_niche1,d // cdb-check: niche_w_fields_3_niche1,d : B [Type: enum2$] // cdb-check: [+0x[...]] __0 : 12 [Type: unsigned char] - +// // cdb-command: dx niche_w_fields_3_niche2,d // cdb-check: niche_w_fields_3_niche2,d : C [Type: enum2$] // cdb-check: [+0x[...]] __0 : false [Type: bool] - +// // cdb-command: dx niche_w_fields_3_niche3,d // cdb-check: niche_w_fields_3_niche3,d : D [Type: enum2$] // cdb-check: [+0x[...]] __0 : 34 [Type: unsigned char] - +// // cdb-command: dx niche_w_fields_3_niche4,d // cdb-check: niche_w_fields_3_niche4,d : E [Type: enum2$] // cdb-check: [+0x[...]] __0 : 56 [Type: unsigned char] - +// // cdb-command: dx niche_w_fields_3_niche5,d // cdb-check: niche_w_fields_3_niche5,d : F [Type: enum2$] - +// // cdb-command: dx -r3 niche_w_fields_std_result_ok,d // cdb-check: niche_w_fields_std_result_ok,d : Ok [Type: enum2$,alloc::alloc::Global>,u64> >] // cdb-check: [+0x[...]] __0 [Type: alloc::boxed::Box,alloc::alloc::Global>] // cdb-check: [+0x[...]] data_ptr : [...] // cdb-check: [+0x[...]] length : 3 [...] - +// // cdb-command: dx -r3 niche_w_fields_std_result_err,d // cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$,alloc::alloc::Global>,u64> >] // cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64] - +// // cdb-command: dx -r2 arbitrary_discr1,d // cdb-check: arbitrary_discr1,d : Abc [Type: enum2$] // cdb-check: [+0x[...]] __0 : 1234 [Type: unsigned int] - +// // cdb-command: dx -r2 arbitrary_discr2,d // cdb-check: arbitrary_discr2,d : Def [Type: enum2$] // cdb-check: [+0x[...]] __0 : 5678 [Type: unsigned int] - +#![feature(generic_nonzero)] #![feature(rustc_attrs)] #![feature(repr128)] #![feature(arbitrary_enum_discriminant)] -use std::num::{NonZeroI128, NonZeroU32}; +use std::num::NonZero; pub enum CStyleEnum { Low = 2, @@ -160,7 +160,7 @@ enum NicheLayoutWithFields1<'a> { } enum NicheLayoutWithFields2 { - A(NonZeroU32, u64), + A(NonZero, u64), B(u64), } @@ -210,8 +210,8 @@ fn main() { let j = CStyleEnum::High; let k = Some("IAMA optional string!".to_string()); let l = Result::::Ok(42); - let niche128_some = Some(NonZeroI128::new(123456).unwrap()); - let niche128_none: Option = None; + let niche128_some = NonZero::new(123456i128); + let niche128_none: Option> = None; let wrapping_niche128_untagged = unsafe { Wrapping128Niche::X(Wrapping128(340282366920938463463374607431768211454)) }; @@ -224,7 +224,7 @@ fn main() { let niche_w_fields_1_some = NicheLayoutWithFields1::A(&77, 7); let niche_w_fields_1_none = NicheLayoutWithFields1::B(99); - let niche_w_fields_2_some = NicheLayoutWithFields2::A(NonZeroU32::new(800).unwrap(), 900); + let niche_w_fields_2_some = NicheLayoutWithFields2::A(NonZero::new(800).unwrap(), 900); let niche_w_fields_2_none = NicheLayoutWithFields2::B(1000); let niche_w_fields_3_some = NicheLayoutWithFields3::A(137, true); diff --git a/tests/debuginfo/numeric-types.rs b/tests/debuginfo/numeric-types.rs index e3df1fbc52014..74c9e5e1dc3f3 100644 --- a/tests/debuginfo/numeric-types.rs +++ b/tests/debuginfo/numeric-types.rs @@ -237,25 +237,25 @@ // lldb-command:print nz_usize // lldb-check:[...]$11 = 122 { __0 = 122 } - +#![feature(generic_nonzero)] use std::num::*; use std::sync::atomic::*; fn main() { - let nz_i8 = NonZeroI8::new(11).unwrap(); - let nz_i16 = NonZeroI16::new(22).unwrap(); - let nz_i32 = NonZeroI32::new(33).unwrap(); - let nz_i64 = NonZeroI64::new(44).unwrap(); - let nz_i128 = NonZeroI128::new(55).unwrap(); - let nz_isize = NonZeroIsize::new(66).unwrap(); - - let nz_u8 = NonZeroU8::new(77).unwrap(); - let nz_u16 = NonZeroU16::new(88).unwrap(); - let nz_u32 = NonZeroU32::new(99).unwrap(); - let nz_u64 = NonZeroU64::new(100).unwrap(); - let nz_u128 = NonZeroU128::new(111).unwrap(); - let nz_usize = NonZeroUsize::new(122).unwrap(); + let nz_i8 = NonZero::new(11i8).unwrap(); + let nz_i16 = NonZero::new(22i16).unwrap(); + let nz_i32 = NonZero::new(33i32).unwrap(); + let nz_i64 = NonZero::new(44i64).unwrap(); + let nz_i128 = NonZero::new(55i128).unwrap(); + let nz_isize = NonZero::new(66isize).unwrap(); + + let nz_u8 = NonZero::new(77u8).unwrap(); + let nz_u16 = NonZero::new(88u16).unwrap(); + let nz_u32 = NonZero::new(99u32).unwrap(); + let nz_u64 = NonZero::new(100u64).unwrap(); + let nz_u128 = NonZero::new(111u128).unwrap(); + let nz_usize = NonZero::new(122usize).unwrap(); let w_i8 = Wrapping(10i8); let w_i16 = Wrapping(20i16); diff --git a/tests/mir-opt/instsimplify/combine_transmutes.rs b/tests/mir-opt/instsimplify/combine_transmutes.rs index 7f45ebf2c863c..3707ee17690da 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.rs +++ b/tests/mir-opt/instsimplify/combine_transmutes.rs @@ -1,9 +1,9 @@ //@ unit-test: InstSimplify //@ compile-flags: -C panic=abort - #![crate_type = "lib"] #![feature(core_intrinsics)] #![feature(custom_mir)] +#![feature(generic_nonzero)] use std::intrinsics::mir::*; use std::mem::{MaybeUninit, ManuallyDrop, transmute}; @@ -54,7 +54,7 @@ pub unsafe fn adt_transmutes() { // CHECK: as i32 (Transmute); // CHECK: ({{_.*}}.1: std::mem::ManuallyDrop); - let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX)); + let _a: u8 = transmute(Some(std::num::NonZero::::MAX)); let _a: i16 = transmute(std::num::Wrapping(0_i16)); let _a: u16 = transmute(std::num::Wrapping(0_i16)); let _a: u32 = transmute(Union32 { i32: 0 }); diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs index 05f8e4dc9e9e5..b2ff4add63e2b 100644 --- a/tests/rustdoc/type-layout.rs +++ b/tests/rustdoc/type-layout.rs @@ -81,7 +81,7 @@ pub enum Variants { // @hasraw - 'Some: 4 bytes' pub enum WithNiche { None, - Some(std::num::NonZeroU32), + Some(std::num::NonZero), } // @hasraw type_layout/enum.Uninhabited.html 'Size: ' diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 911438e0d5406..fcf31aa970cd0 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -64,6 +64,7 @@ [csky] needs-llvm-components: csky */ #![feature(rustc_attrs, unsized_fn_params, transparent_unions)] +#![cfg_attr(host, feature(generic_nonzero))] #![cfg_attr(not(host), feature(no_core, lang_items), no_std, no_core)] #![allow(unused, improper_ctypes_definitions, internal_features)] @@ -74,7 +75,7 @@ #[cfg(host)] use std::{ - any::Any, marker::PhantomData, mem::ManuallyDrop, num::NonZeroI32, ptr::NonNull, rc::Rc, + any::Any, marker::PhantomData, mem::ManuallyDrop, num::NonZero, ptr::NonNull, rc::Rc, sync::Arc, }; @@ -145,7 +146,7 @@ mod prelude { #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] - pub struct NonZeroI32(i32); + pub struct NonZero(T); // This just stands in for a non-trivial type. pub struct Vec { @@ -274,7 +275,7 @@ test_abi_compatible!(isize_int, isize, i64); test_abi_compatible!(zst_unit, Zst, ()); #[cfg(not(any(target_arch = "sparc64")))] test_abi_compatible!(zst_array, Zst, [u8; 0]); -test_abi_compatible!(nonzero_int, NonZeroI32, i32); +test_abi_compatible!(nonzero_int, NonZero, i32); // `DispatchFromDyn` relies on ABI compatibility. // This is interesting since these types are not `repr(transparent)`. So this is not part of our @@ -381,6 +382,6 @@ test_nonnull!(mut_unsized, &mut [i32]); test_nonnull!(fn_, fn()); test_nonnull!(nonnull, NonNull); test_nonnull!(nonnull_unsized, NonNull); -test_nonnull!(non_zero, NonZeroI32); +test_nonnull!(non_zero, NonZero); fn main() {} diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 57815e6af65c9..c06c30741164a 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:22:1 + --> $DIR/raw-bytes.rs:21:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x00000001, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:30:1 + --> $DIR/raw-bytes.rs:29:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x00000000, but expected a valid enum tag @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:44:1 + --> $DIR/raw-bytes.rs:43:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:46:1 + --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:52:1 + --> $DIR/raw-bytes.rs:51:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:57:1 + --> $DIR/raw-bytes.rs:56:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -65,10 +65,10 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:60:1 + --> $DIR/raw-bytes.rs:59:1 | -LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 +LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater 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 rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -76,10 +76,10 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:62:1 + --> $DIR/raw-bytes.rs:61:1 | -LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 +LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater 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 rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:68:1 + --> $DIR/raw-bytes.rs:67:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:74:1 + --> $DIR/raw-bytes.rs:73:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 @@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:77:1 + --> $DIR/raw-bytes.rs:76:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:85:1 + --> $DIR/raw-bytes.rs:84:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:89:1 + --> $DIR/raw-bytes.rs:88:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) @@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:93:1 + --> $DIR/raw-bytes.rs:92:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:96:1 + --> $DIR/raw-bytes.rs:95:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:99:1 + --> $DIR/raw-bytes.rs:98:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:102:1 + --> $DIR/raw-bytes.rs:101:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:105:1 + --> $DIR/raw-bytes.rs:104:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:107:1 + --> $DIR/raw-bytes.rs:106:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:109:1 + --> $DIR/raw-bytes.rs:108:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer @@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:115:1 + --> $DIR/raw-bytes.rs:114:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:140:1 + --> $DIR/raw-bytes.rs:139:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:142:1 + --> $DIR/raw-bytes.rs:141:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object @@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:144:1 + --> $DIR/raw-bytes.rs:143:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:147:1 + --> $DIR/raw-bytes.rs:146:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string @@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:149:1 + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string @@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:151:1 + --> $DIR/raw-bytes.rs:150:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a pointer, but expected a string @@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:155:1 + --> $DIR/raw-bytes.rs:154:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:157:1 + --> $DIR/raw-bytes.rs:156:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:160:1 + --> $DIR/raw-bytes.rs:159:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) @@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:163:1 + --> $DIR/raw-bytes.rs:162:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean @@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:163:40 + --> $DIR/raw-bytes.rs:162:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:169:1 + --> $DIR/raw-bytes.rs:168:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean @@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:169:42 + --> $DIR/raw-bytes.rs:168:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:173:1 + --> $DIR/raw-bytes.rs:172:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean @@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:173:42 + --> $DIR/raw-bytes.rs:172:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:178:1 + --> $DIR/raw-bytes.rs:177:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer @@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:182:1 + --> $DIR/raw-bytes.rs:181:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer @@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:186:1 + --> $DIR/raw-bytes.rs:185:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer @@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:189:1 + --> $DIR/raw-bytes.rs:188:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer @@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:193:1 + --> $DIR/raw-bytes.rs:192:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean @@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:197:1 + --> $DIR/raw-bytes.rs:196:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer @@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:199:1 + --> $DIR/raw-bytes.rs:198:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer @@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:203:1 + --> $DIR/raw-bytes.rs:202:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:204:1 + --> $DIR/raw-bytes.rs:203:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:205:1 + --> $DIR/raw-bytes.rs:204:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` @@ -492,7 +492,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:209:1 + --> $DIR/raw-bytes.rs:208:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer @@ -503,7 +503,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) } } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 + --> $DIR/raw-bytes.rs:211:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer @@ -516,7 +516,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 + --> $DIR/raw-bytes.rs:214:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean @@ -527,7 +527,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:219:1 + --> $DIR/raw-bytes.rs:218:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer @@ -538,7 +538,7 @@ LL | pub static S7: &[u16] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:226:1 + --> $DIR/raw-bytes.rs:225:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer @@ -549,7 +549,7 @@ LL | pub static R4: &[u8] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:231:1 + --> $DIR/raw-bytes.rs:230:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer @@ -562,7 +562,7 @@ LL | pub static R5: &[u8] = unsafe { = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:236:1 + --> $DIR/raw-bytes.rs:235:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index c875d91ccb87a..0589280524cab 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:22:1 + --> $DIR/raw-bytes.rs:21:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0000000000000001, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:30:1 + --> $DIR/raw-bytes.rs:29:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0000000000000000, but expected a valid enum tag @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:44:1 + --> $DIR/raw-bytes.rs:43:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:46:1 + --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:52:1 + --> $DIR/raw-bytes.rs:51:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:57:1 + --> $DIR/raw-bytes.rs:56:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -65,10 +65,10 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:60:1 + --> $DIR/raw-bytes.rs:59:1 | -LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 +LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater 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 rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -76,10 +76,10 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:62:1 + --> $DIR/raw-bytes.rs:61:1 | -LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 +LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater 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 rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:68:1 + --> $DIR/raw-bytes.rs:67:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:74:1 + --> $DIR/raw-bytes.rs:73:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 @@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:77:1 + --> $DIR/raw-bytes.rs:76:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:85:1 + --> $DIR/raw-bytes.rs:84:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:89:1 + --> $DIR/raw-bytes.rs:88:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) @@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:93:1 + --> $DIR/raw-bytes.rs:92:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:96:1 + --> $DIR/raw-bytes.rs:95:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:99:1 + --> $DIR/raw-bytes.rs:98:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:102:1 + --> $DIR/raw-bytes.rs:101:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:105:1 + --> $DIR/raw-bytes.rs:104:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:107:1 + --> $DIR/raw-bytes.rs:106:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:109:1 + --> $DIR/raw-bytes.rs:108:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer @@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:115:1 + --> $DIR/raw-bytes.rs:114:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:140:1 + --> $DIR/raw-bytes.rs:139:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:142:1 + --> $DIR/raw-bytes.rs:141:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object @@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:144:1 + --> $DIR/raw-bytes.rs:143:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:147:1 + --> $DIR/raw-bytes.rs:146:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string @@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:149:1 + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string @@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:151:1 + --> $DIR/raw-bytes.rs:150:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a pointer, but expected a string @@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:155:1 + --> $DIR/raw-bytes.rs:154:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:157:1 + --> $DIR/raw-bytes.rs:156:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:160:1 + --> $DIR/raw-bytes.rs:159:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) @@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:163:1 + --> $DIR/raw-bytes.rs:162:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean @@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:163:40 + --> $DIR/raw-bytes.rs:162:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:169:1 + --> $DIR/raw-bytes.rs:168:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean @@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:169:42 + --> $DIR/raw-bytes.rs:168:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:173:1 + --> $DIR/raw-bytes.rs:172:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean @@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:173:42 + --> $DIR/raw-bytes.rs:172:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:178:1 + --> $DIR/raw-bytes.rs:177:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer @@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:182:1 + --> $DIR/raw-bytes.rs:181:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer @@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:186:1 + --> $DIR/raw-bytes.rs:185:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer @@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:189:1 + --> $DIR/raw-bytes.rs:188:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer @@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:193:1 + --> $DIR/raw-bytes.rs:192:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean @@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:197:1 + --> $DIR/raw-bytes.rs:196:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer @@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:199:1 + --> $DIR/raw-bytes.rs:198:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer @@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:203:1 + --> $DIR/raw-bytes.rs:202:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:204:1 + --> $DIR/raw-bytes.rs:203:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:205:1 + --> $DIR/raw-bytes.rs:204:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` @@ -492,7 +492,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:209:1 + --> $DIR/raw-bytes.rs:208:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer @@ -503,7 +503,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) } } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 + --> $DIR/raw-bytes.rs:211:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer @@ -516,7 +516,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 + --> $DIR/raw-bytes.rs:214:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean @@ -527,7 +527,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:219:1 + --> $DIR/raw-bytes.rs:218:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer @@ -538,7 +538,7 @@ LL | pub static S7: &[u16] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:226:1 + --> $DIR/raw-bytes.rs:225:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer @@ -549,7 +549,7 @@ LL | pub static R4: &[u8] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:231:1 + --> $DIR/raw-bytes.rs:230:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer @@ -562,7 +562,7 @@ LL | pub static R5: &[u8] = unsafe { = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:236:1 + --> $DIR/raw-bytes.rs:235:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 96903b322e45b..e5dfd5ca29397 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -2,14 +2,13 @@ //@ ignore-endian-big // ignore-tidy-linelength //@ normalize-stderr-test "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼" -> "╾ALLOC_ID$1╼" - -#![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] #![allow(invalid_value)] +#![feature(generic_nonzero, never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] use std::mem; use std::alloc::Layout; use std::ptr::NonNull; -use std::num::{NonZeroU8, NonZeroUsize}; +use std::num::NonZero; use std::slice::{from_ptr_range, from_raw_parts}; // # Bad enums and chars @@ -57,9 +56,9 @@ const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value -const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; +const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; //~^ ERROR it is undefined behavior to use this value -const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; +const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value #[rustc_layout_scalar_valid_range_start(10)] diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index 229ce9a7df382..76bd5248ffd89 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -1,12 +1,12 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" -#![feature(rustc_attrs, ptr_metadata)] #![allow(invalid_value)] // make sure we cannot allow away the errors tested here +#![feature(generic_nonzero, rustc_attrs, ptr_metadata)] use std::mem; use std::ptr::NonNull; -use std::num::{NonZeroU8, NonZeroUsize}; +use std::num::NonZero; const NON_NULL: NonNull = unsafe { mem::transmute(1usize) }; const NON_NULL_PTR: NonNull = unsafe { mem::transmute(&1) }; @@ -21,9 +21,9 @@ const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { mem::transmute(out_of_bounds_ptr) } }; -const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; +const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; //~^ ERROR it is undefined behavior to use this value -const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; +const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value #[repr(C)] @@ -31,7 +31,7 @@ union MaybeUninit { uninit: (), init: T, } -const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; +const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed //~| uninitialized diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 7822306b654ca..70b961fe1cd4f 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -18,8 +18,8 @@ LL | let out_of_bounds_ptr = &ptr[255]; error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:24:1 | -LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 +LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater 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 rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -29,8 +29,8 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:26:1 | -LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 +LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater 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 rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -38,10 +38,10 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:34:36 + --> $DIR/ub-nonnull.rs:34:38 | -LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:43:1 diff --git a/tests/ui/consts/const-eval/valid-const.rs b/tests/ui/consts/const-eval/valid-const.rs index 1c8c048ae28cb..15d3e88345658 100644 --- a/tests/ui/consts/const-eval/valid-const.rs +++ b/tests/ui/consts/const-eval/valid-const.rs @@ -1,16 +1,17 @@ //@ check-pass - +// // Some constants that *are* valid +#![feature(generic_nonzero)] use std::mem; use std::ptr::NonNull; -use std::num::{NonZeroU8, NonZeroUsize}; +use std::num::NonZero; const NON_NULL_PTR1: NonNull = unsafe { mem::transmute(1usize) }; const NON_NULL_PTR2: NonNull = unsafe { mem::transmute(&0) }; -const NON_NULL_U8: NonZeroU8 = unsafe { mem::transmute(1u8) }; -const NON_NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(1usize) }; +const NON_NULL_U8: NonZero = unsafe { mem::transmute(1u8) }; +const NON_NULL_USIZE: NonZero = unsafe { mem::transmute(1usize) }; const UNIT: () = (); diff --git a/tests/ui/consts/ice-48279.rs b/tests/ui/consts/ice-48279.rs index 5316974b80ad3..a4f687a3e9ce1 100644 --- a/tests/ui/consts/ice-48279.rs +++ b/tests/ui/consts/ice-48279.rs @@ -15,7 +15,7 @@ impl NonZeroU32 { } } -//pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) }; +// pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) }; pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32 { value: 7 } }; fn main() { diff --git a/tests/ui/consts/tuple-struct-constructors.rs b/tests/ui/consts/tuple-struct-constructors.rs index 8472a09844bb9..d2f25aeec9b17 100644 --- a/tests/ui/consts/tuple-struct-constructors.rs +++ b/tests/ui/consts/tuple-struct-constructors.rs @@ -1,10 +1,11 @@ //@ run-pass - +// // https://github.com/rust-lang/rust/issues/41898 +#![feature(generic_nonzero)] -use std::num::NonZeroU64; +use std::num::NonZero; fn main() { - const FOO: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(2) }; + const FOO: NonZero = unsafe { NonZero::new_unchecked(2) }; if let FOO = FOO {} } diff --git a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs index 2420aec505889..fb3b0652ddbf7 100644 --- a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -4,11 +4,11 @@ // ignore-tidy-linelength //@ ignore-emscripten spawning processes is not supported //@ ignore-sgx no processes - +// // This test checks panic emitted from `mem::{uninitialized,zeroed}`. - -#![feature(never_type)] #![allow(deprecated, invalid_value)] +#![feature(generic_nonzero)] +#![feature(never_type)] use std::{ mem::{self, MaybeUninit, ManuallyDrop}, @@ -29,7 +29,7 @@ enum OneVariant { Variant(i32) } #[allow(dead_code, non_camel_case_types)] enum OneVariant_NonZero { - Variant(i32, i32, num::NonZeroI32), + Variant(i32, i32, num::NonZero), DeadVariant(Bar), } @@ -55,8 +55,8 @@ enum LR { } #[allow(dead_code, non_camel_case_types)] enum LR_NonZero { - Left(num::NonZeroI64), - Right(num::NonZeroI64), + Left(num::NonZero), + Right(num::NonZero), } struct ZeroSized; diff --git a/tests/ui/issues/issue-64593.rs b/tests/ui/issues/issue-64593.rs index e553538100676..091c3a2f316dd 100644 --- a/tests/ui/issues/issue-64593.rs +++ b/tests/ui/issues/issue-64593.rs @@ -1,7 +1,8 @@ //@ check-pass #![deny(improper_ctypes)] +#![feature(generic_nonzero)] -pub struct Error(std::num::NonZeroU32); +pub struct Error(std::num::NonZero); extern "Rust" { fn foo(dest: &mut [u8]) -> Result<(), Error>; diff --git a/tests/ui/layout/unsafe-cell-hides-niche.rs b/tests/ui/layout/unsafe-cell-hides-niche.rs index b3158839de0d6..568eb819be2e6 100644 --- a/tests/ui/layout/unsafe-cell-hides-niche.rs +++ b/tests/ui/layout/unsafe-cell-hides-niche.rs @@ -1,17 +1,17 @@ // For rust-lang/rust#68303: the contents of `UnsafeCell` cannot // participate in the niche-optimization for enum discriminants. This -// test checks that an `Option>` has the same +// test checks that an `Option>>` has the same // size in memory as an `Option>` (namely, 8 bytes). - +// //@ check-pass //@ compile-flags: --crate-type=lib //@ only-x86 - +#![feature(generic_nonzero)] #![feature(repr_simd)] use std::cell::{UnsafeCell, RefCell, Cell}; use std::mem::size_of; -use std::num::NonZeroU32 as N32; +use std::num::NonZero; use std::sync::{Mutex, RwLock}; struct Wrapper(#[allow(dead_code)] T); @@ -54,15 +54,17 @@ macro_rules! check_sizes { const PTR_SIZE: usize = std::mem::size_of::<*const ()>(); -check_sizes!(Wrapper: 4 => 8); -check_sizes!(Wrapper: 4 => 4); // (✓ niche opt) -check_sizes!(Transparent: 4 => 8); -check_sizes!(Transparent: 4 => 4); // (✓ niche opt) -check_sizes!(NoNiche: 4 => 8); -check_sizes!(NoNiche: 4 => 8); +check_sizes!(Wrapper: 4 => 8); +check_sizes!(Wrapper>: 4 => 4); // (✓ niche opt) + +check_sizes!(Transparent: 4 => 8); +check_sizes!(Transparent>: 4 => 4); // (✓ niche opt) + +check_sizes!(NoNiche: 4 => 8); +check_sizes!(NoNiche>: 4 => 8); -check_sizes!(UnsafeCell: 4 => 8); -check_sizes!(UnsafeCell: 4 => 8); +check_sizes!(UnsafeCell: 4 => 8); +check_sizes!(UnsafeCell>: 4 => 8); check_sizes!(UnsafeCell<&()>: PTR_SIZE => PTR_SIZE * 2); check_sizes!( RefCell<&()>: PTR_SIZE * 2 => PTR_SIZE * 3); @@ -79,4 +81,4 @@ check_sizes!(UnsafeCell<&dyn Trait>: PTR_SIZE * 2 => PTR_SIZE * 3); #[repr(simd)] pub struct Vec4([T; 4]); -check_sizes!(UnsafeCell>: 16 => 32); +check_sizes!(UnsafeCell>>: 16 => 32); diff --git a/tests/ui/layout/zero-sized-array-enum-niche.rs b/tests/ui/layout/zero-sized-array-enum-niche.rs index 095afc4337a55..058f59234878f 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.rs +++ b/tests/ui/layout/zero-sized-array-enum-niche.rs @@ -1,6 +1,7 @@ //@ normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN" -#![feature(rustc_attrs)] #![crate_type = "lib"] +#![feature(generic_nonzero)] +#![feature(rustc_attrs)] // Various tests around the behavior of zero-sized arrays and // enum niches, especially that they have coherent size and alignment. @@ -34,7 +35,7 @@ enum MultipleAlignments { //~ ERROR: layout_of struct Packed(T); #[rustc_layout(debug)] -type NicheLosesToTagged = Result<[u32; 0], Packed>; //~ ERROR: layout_of +type NicheLosesToTagged = Result<[u32; 0], Packed>>; //~ ERROR: layout_of // Should get tag_encoding: Direct, size == align == 4. #[repr(u16)] diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index 0ed743818c573..af049125de467 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -98,7 +98,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/zero-sized-array-enum-niche.rs:13:1 + --> $DIR/zero-sized-array-enum-niche.rs:14:1 | LL | type AlignedResult = Result<[u32; 0], bool>; | ^^^^^^^^^^^^^^^^^^ @@ -227,7 +227,7 @@ error: layout_of(MultipleAlignments) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/zero-sized-array-enum-niche.rs:21:1 + --> $DIR/zero-sized-array-enum-niche.rs:22:1 | LL | enum MultipleAlignments { | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -332,9 +332,9 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/zero-sized-array-enum-niche.rs:37:1 + --> $DIR/zero-sized-array-enum-niche.rs:38:1 | -LL | type NicheLosesToTagged = Result<[u32; 0], Packed>; +LL | type NicheLosesToTagged = Result<[u32; 0], Packed>>; | ^^^^^^^^^^^^^^^^^^^^^^^ error: layout_of(Result<[u32; 0], Packed>) = Layout { @@ -441,7 +441,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/zero-sized-array-enum-niche.rs:44:1 + --> $DIR/zero-sized-array-enum-niche.rs:45:1 | LL | type NicheWinsOverTagged = Result<[u32; 0], Packed>; | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/clashing-extern-fn.rs b/tests/ui/lint/clashing-extern-fn.rs index ce027c8255459..cb63af0ea4228 100644 --- a/tests/ui/lint/clashing-extern-fn.rs +++ b/tests/ui/lint/clashing-extern-fn.rs @@ -2,6 +2,7 @@ //@ aux-build:external_extern_fn.rs #![crate_type = "lib"] #![warn(clashing_extern_declarations)] +#![feature(generic_nonzero)] mod redeclared_different_signature { mod a { @@ -265,7 +266,7 @@ mod missing_return_type { mod non_zero_and_non_null { mod a { extern "C" { - fn non_zero_usize() -> core::num::NonZeroUsize; + fn non_zero_usize() -> core::num::NonZero; fn non_null_ptr() -> core::ptr::NonNull; } } @@ -285,36 +286,33 @@ mod non_zero_and_non_null { // See #75739 mod non_zero_transparent { mod a1 { - use std::num::NonZeroUsize; extern "C" { - fn f1() -> NonZeroUsize; + fn f1() -> std::num::NonZero; } } mod b1 { #[repr(transparent)] - struct X(NonZeroUsize); - use std::num::NonZeroUsize; + struct X(std::num::NonZero); + extern "C" { fn f1() -> X; } } mod a2 { - use std::num::NonZeroUsize; extern "C" { - fn f2() -> NonZeroUsize; + fn f2() -> std::num::NonZero; } } mod b2 { #[repr(transparent)] - struct X1(NonZeroUsize); + struct X1(std::num::NonZero); #[repr(transparent)] struct X(X1); - use std::num::NonZeroUsize; extern "C" { // Same case as above, but with two layers of newtyping. fn f2() -> X; @@ -325,7 +323,6 @@ mod non_zero_transparent { #[repr(transparent)] struct X(core::ptr::NonNull); - use std::num::NonZeroUsize; extern "C" { fn f3() -> X; } @@ -340,7 +337,7 @@ mod non_zero_transparent { mod a4 { #[repr(transparent)] enum E { - X(std::num::NonZeroUsize), + X(std::num::NonZero), } extern "C" { fn f4() -> E; @@ -349,7 +346,7 @@ mod non_zero_transparent { mod b4 { extern "C" { - fn f4() -> std::num::NonZeroUsize; + fn f4() -> std::num::NonZero; } } } @@ -369,8 +366,8 @@ mod null_optimised_enums { extern "C" { // This should be allowed, because these conversions are guaranteed to be FFI-safe (see // #60300) - fn option_non_zero_usize() -> Option; - fn option_non_zero_isize() -> Option; + fn option_non_zero_usize() -> Option>; + fn option_non_zero_isize() -> Option>; fn option_non_null_ptr() -> Option>; // However, these should be incorrect (note isize instead of usize) @@ -415,16 +412,16 @@ mod hidden_niche { } mod b { use std::cell::UnsafeCell; - use std::num::NonZeroUsize; + use std::num::NonZero; #[repr(transparent)] struct Transparent { - x: NonZeroUsize, + x: NonZero, } #[repr(transparent)] struct TransparentNoNiche { - y: UnsafeCell, + y: UnsafeCell>, } extern "C" { @@ -434,7 +431,7 @@ mod hidden_niche { //~^ WARN redeclared with a different signature //~| WARN block uses type `Option`, which is not FFI-safe - fn hidden_niche_unsafe_cell() -> Option>; + fn hidden_niche_unsafe_cell() -> Option>>; //~^ WARN redeclared with a different signature //~| WARN block uses type `Option>>`, which is not FFI-safe } diff --git a/tests/ui/lint/clashing-extern-fn.stderr b/tests/ui/lint/clashing-extern-fn.stderr index 5b9244b699311..86ee789aeb22d 100644 --- a/tests/ui/lint/clashing-extern-fn.stderr +++ b/tests/ui/lint/clashing-extern-fn.stderr @@ -1,5 +1,5 @@ warning: `extern` block uses type `Option`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:433:55 + --> $DIR/clashing-extern-fn.rs:430:55 | LL | fn hidden_niche_transparent_no_niche() -> Option; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -9,16 +9,16 @@ LL | fn hidden_niche_transparent_no_niche() -> Option>>`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:437:46 + --> $DIR/clashing-extern-fn.rs:434:46 | -LL | fn hidden_niche_unsafe_cell() -> Option>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn hidden_niche_unsafe_cell() -> Option>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint warning: `clash` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:14:13 + --> $DIR/clashing-extern-fn.rs:15:13 | LL | fn clash(x: u8); | --------------- `clash` previously declared here @@ -35,7 +35,7 @@ LL | #![warn(clashing_extern_declarations)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: `extern_link_name` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:52:9 + --> $DIR/clashing-extern-fn.rs:53:9 | LL | #[link_name = "extern_link_name"] | --------------------------------- `extern_link_name` previously declared here @@ -47,7 +47,7 @@ LL | fn extern_link_name(x: u32); found `unsafe extern "C" fn(u32)` warning: `some_other_extern_link_name` redeclares `some_other_new_name` with a different signature - --> $DIR/clashing-extern-fn.rs:55:9 + --> $DIR/clashing-extern-fn.rs:56:9 | LL | fn some_other_new_name(x: i16); | ------------------------------ `some_other_new_name` previously declared here @@ -59,7 +59,7 @@ LL | #[link_name = "some_other_new_name"] found `unsafe extern "C" fn(u32)` warning: `other_both_names_different` redeclares `link_name_same` with a different signature - --> $DIR/clashing-extern-fn.rs:59:9 + --> $DIR/clashing-extern-fn.rs:60:9 | LL | #[link_name = "link_name_same"] | ------------------------------- `link_name_same` previously declared here @@ -71,7 +71,7 @@ LL | #[link_name = "link_name_same"] found `unsafe extern "C" fn(u32)` warning: `different_mod` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:72:9 + --> $DIR/clashing-extern-fn.rs:73:9 | LL | fn different_mod(x: u8); | ----------------------- `different_mod` previously declared here @@ -83,7 +83,7 @@ LL | fn different_mod(x: u64); found `unsafe extern "C" fn(u64)` warning: `variadic_decl` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:82:9 + --> $DIR/clashing-extern-fn.rs:83:9 | LL | fn variadic_decl(x: u8, ...); | ---------------------------- `variadic_decl` previously declared here @@ -95,7 +95,7 @@ LL | fn variadic_decl(x: u8); found `unsafe extern "C" fn(u8)` warning: `weigh_banana` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:142:13 + --> $DIR/clashing-extern-fn.rs:143:13 | LL | fn weigh_banana(count: *const Banana) -> u64; | -------------------------------------------- `weigh_banana` previously declared here @@ -107,7 +107,7 @@ LL | fn weigh_banana(count: *const Banana) -> u64; found `unsafe extern "C" fn(*const three::Banana) -> u64` warning: `draw_point` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:171:13 + --> $DIR/clashing-extern-fn.rs:172:13 | LL | fn draw_point(p: Point); | ----------------------- `draw_point` previously declared here @@ -119,7 +119,7 @@ LL | fn draw_point(p: Point); found `unsafe extern "C" fn(sameish_members::b::Point)` warning: `origin` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:197:13 + --> $DIR/clashing-extern-fn.rs:198:13 | LL | fn origin() -> Point3; | --------------------- `origin` previously declared here @@ -131,7 +131,7 @@ LL | fn origin() -> Point3; found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3` warning: `transparent_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:220:13 + --> $DIR/clashing-extern-fn.rs:221:13 | LL | fn transparent_incorrect() -> T; | ------------------------------- `transparent_incorrect` previously declared here @@ -143,7 +143,7 @@ LL | fn transparent_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `missing_return_type` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:259:13 + --> $DIR/clashing-extern-fn.rs:260:13 | LL | fn missing_return_type() -> usize; | --------------------------------- `missing_return_type` previously declared here @@ -155,10 +155,10 @@ LL | fn missing_return_type(); found `unsafe extern "C" fn()` warning: `non_zero_usize` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:277:13 + --> $DIR/clashing-extern-fn.rs:278:13 | -LL | fn non_zero_usize() -> core::num::NonZeroUsize; - | ---------------------------------------------- `non_zero_usize` previously declared here +LL | fn non_zero_usize() -> core::num::NonZero; + | ------------------------------------------------ `non_zero_usize` previously declared here ... LL | fn non_zero_usize() -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration @@ -167,7 +167,7 @@ LL | fn non_zero_usize() -> usize; found `unsafe extern "C" fn() -> usize` warning: `non_null_ptr` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:279:13 + --> $DIR/clashing-extern-fn.rs:280:13 | LL | fn non_null_ptr() -> core::ptr::NonNull; | ---------------------------------------------- `non_null_ptr` previously declared here @@ -179,7 +179,7 @@ LL | fn non_null_ptr() -> *const usize; found `unsafe extern "C" fn() -> *const usize` warning: `option_non_zero_usize_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:377:13 + --> $DIR/clashing-extern-fn.rs:374:13 | LL | fn option_non_zero_usize_incorrect() -> usize; | --------------------------------------------- `option_non_zero_usize_incorrect` previously declared here @@ -191,7 +191,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `option_non_null_ptr_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:379:13 + --> $DIR/clashing-extern-fn.rs:376:13 | LL | fn option_non_null_ptr_incorrect() -> *const usize; | -------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here @@ -203,7 +203,7 @@ LL | fn option_non_null_ptr_incorrect() -> *const isize; found `unsafe extern "C" fn() -> *const isize` warning: `hidden_niche_transparent_no_niche` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:433:13 + --> $DIR/clashing-extern-fn.rs:430:13 | LL | fn hidden_niche_transparent_no_niche() -> usize; | ----------------------------------------------- `hidden_niche_transparent_no_niche` previously declared here @@ -215,13 +215,13 @@ LL | fn hidden_niche_transparent_no_niche() -> Option Option` warning: `hidden_niche_unsafe_cell` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:437:13 + --> $DIR/clashing-extern-fn.rs:434:13 | LL | fn hidden_niche_unsafe_cell() -> usize; | -------------------------------------- `hidden_niche_unsafe_cell` previously declared here ... -LL | fn hidden_niche_unsafe_cell() -> Option>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration +LL | fn hidden_niche_unsafe_cell() -> Option>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn() -> Option>>` diff --git a/tests/ui/lint/invalid_value.rs b/tests/ui/lint/invalid_value.rs index 57d8cbe7c9341..1d2f23aaaf6f5 100644 --- a/tests/ui/lint/invalid_value.rs +++ b/tests/ui/lint/invalid_value.rs @@ -1,13 +1,12 @@ // This test checks that calling `mem::{uninitialized,zeroed}` with certain types results // in a lint. - -#![feature(never_type, rustc_attrs)] #![allow(deprecated)] #![deny(invalid_value)] +#![feature(generic_nonzero, never_type, rustc_attrs)] use std::mem::{self, MaybeUninit}; use std::ptr::NonNull; -use std::num::NonZeroU32; +use std::num::NonZero; enum Void {} @@ -36,7 +35,7 @@ enum OneFruit { enum OneFruitNonZero { Apple(!), - Banana(NonZeroU32), + Banana(NonZero), } enum TwoUninhabited { @@ -92,8 +91,8 @@ fn main() { let _val: NonNull = mem::zeroed(); //~ ERROR: does not permit zero-initialization let _val: NonNull = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized - let _val: (NonZeroU32, i32) = mem::zeroed(); //~ ERROR: does not permit zero-initialization - let _val: (NonZeroU32, i32) = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized + let _val: (NonZero, i32) = mem::zeroed(); //~ ERROR: does not permit zero-initialization + let _val: (NonZero, i32) = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized let _val: *const dyn Send = mem::zeroed(); //~ ERROR: does not permit zero-initialization let _val: *const dyn Send = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized @@ -151,7 +150,7 @@ fn main() { // Transmute-from-0 let _val: &'static i32 = mem::transmute(0usize); //~ ERROR: does not permit zero-initialization let _val: &'static [i32] = mem::transmute((0usize, 0usize)); //~ ERROR: does not permit zero-initialization - let _val: NonZeroU32 = mem::transmute(0); //~ ERROR: does not permit zero-initialization + let _val: NonZero = mem::transmute(0); //~ ERROR: does not permit zero-initialization // `MaybeUninit` cases let _val: NonNull = MaybeUninit::zeroed().assume_init(); //~ ERROR: does not permit zero-initialization diff --git a/tests/ui/lint/invalid_value.stderr b/tests/ui/lint/invalid_value.stderr index bdf47343114c6..955d01bd5d904 100644 --- a/tests/ui/lint/invalid_value.stderr +++ b/tests/ui/lint/invalid_value.stderr @@ -1,5 +1,5 @@ error: the type `&T` does not permit zero-initialization - --> $DIR/invalid_value.rs:54:32 + --> $DIR/invalid_value.rs:53:32 | LL | let _val: &'static T = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | let _val: &'static T = mem::zeroed(); | = note: references must be non-null note: the lint level is defined here - --> $DIR/invalid_value.rs:6:9 + --> $DIR/invalid_value.rs:4:9 | LL | #![deny(invalid_value)] | ^^^^^^^^^^^^^ error: the type `&T` does not permit being left uninitialized - --> $DIR/invalid_value.rs:55:32 + --> $DIR/invalid_value.rs:54:32 | LL | let _val: &'static T = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _val: &'static T = mem::uninitialized(); = note: references must be non-null error: the type `Wrap<&T>` does not permit zero-initialization - --> $DIR/invalid_value.rs:57:38 + --> $DIR/invalid_value.rs:56:38 | LL | let _val: Wrap<&'static T> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -36,13 +36,13 @@ LL | let _val: Wrap<&'static T> = mem::zeroed(); | = note: `Wrap<&T>` must be non-null note: because references must be non-null (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ error: the type `Wrap<&T>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:58:38 + --> $DIR/invalid_value.rs:57:38 | LL | let _val: Wrap<&'static T> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -52,13 +52,13 @@ LL | let _val: Wrap<&'static T> = mem::uninitialized(); | = note: `Wrap<&T>` must be non-null note: because references must be non-null (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ error: the type `!` does not permit zero-initialization - --> $DIR/invalid_value.rs:65:23 + --> $DIR/invalid_value.rs:64:23 | LL | let _val: ! = mem::zeroed(); | ^^^^^^^^^^^^^ this code causes undefined behavior when executed @@ -66,7 +66,7 @@ LL | let _val: ! = mem::zeroed(); = note: the `!` type has no valid value error: the type `!` does not permit being left uninitialized - --> $DIR/invalid_value.rs:66:23 + --> $DIR/invalid_value.rs:65:23 | LL | let _val: ! = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed @@ -74,7 +74,7 @@ LL | let _val: ! = mem::uninitialized(); = note: the `!` type has no valid value error: the type `(i32, !)` does not permit zero-initialization - --> $DIR/invalid_value.rs:68:30 + --> $DIR/invalid_value.rs:67:30 | LL | let _val: (i32, !) = mem::zeroed(); | ^^^^^^^^^^^^^ this code causes undefined behavior when executed @@ -82,7 +82,7 @@ LL | let _val: (i32, !) = mem::zeroed(); = note: the `!` type has no valid value error: the type `(i32, !)` does not permit being left uninitialized - --> $DIR/invalid_value.rs:69:30 + --> $DIR/invalid_value.rs:68:30 | LL | let _val: (i32, !) = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed @@ -90,31 +90,31 @@ LL | let _val: (i32, !) = mem::uninitialized(); = note: integers must be initialized error: the type `Void` does not permit zero-initialization - --> $DIR/invalid_value.rs:71:26 + --> $DIR/invalid_value.rs:70:26 | LL | let _val: Void = mem::zeroed(); | ^^^^^^^^^^^^^ this code causes undefined behavior when executed | note: enums with no inhabited variants have no valid value - --> $DIR/invalid_value.rs:12:1 + --> $DIR/invalid_value.rs:11:1 | LL | enum Void {} | ^^^^^^^^^ error: the type `Void` does not permit being left uninitialized - --> $DIR/invalid_value.rs:72:26 + --> $DIR/invalid_value.rs:71:26 | LL | let _val: Void = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed | note: enums with no inhabited variants have no valid value - --> $DIR/invalid_value.rs:12:1 + --> $DIR/invalid_value.rs:11:1 | LL | enum Void {} | ^^^^^^^^^ error: the type `&i32` does not permit zero-initialization - --> $DIR/invalid_value.rs:74:34 + --> $DIR/invalid_value.rs:73:34 | LL | let _val: &'static i32 = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -125,7 +125,7 @@ LL | let _val: &'static i32 = mem::zeroed(); = note: references must be non-null error: the type `&i32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:75:34 + --> $DIR/invalid_value.rs:74:34 | LL | let _val: &'static i32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | let _val: &'static i32 = mem::uninitialized(); = note: references must be non-null error: the type `Ref` does not permit zero-initialization - --> $DIR/invalid_value.rs:77:25 + --> $DIR/invalid_value.rs:76:25 | LL | let _val: Ref = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -146,13 +146,13 @@ LL | let _val: Ref = mem::zeroed(); | = note: `Ref` must be non-null note: because references must be non-null (in this struct field) - --> $DIR/invalid_value.rs:14:12 + --> $DIR/invalid_value.rs:13:12 | LL | struct Ref(&'static i32); | ^^^^^^^^^^^^ error: the type `Ref` does not permit being left uninitialized - --> $DIR/invalid_value.rs:78:25 + --> $DIR/invalid_value.rs:77:25 | LL | let _val: Ref = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -162,13 +162,13 @@ LL | let _val: Ref = mem::uninitialized(); | = note: `Ref` must be non-null note: because references must be non-null (in this struct field) - --> $DIR/invalid_value.rs:14:12 + --> $DIR/invalid_value.rs:13:12 | LL | struct Ref(&'static i32); | ^^^^^^^^^^^^ error: the type `fn()` does not permit zero-initialization - --> $DIR/invalid_value.rs:80:26 + --> $DIR/invalid_value.rs:79:26 | LL | let _val: fn() = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL | let _val: fn() = mem::zeroed(); = note: function pointers must be non-null error: the type `fn()` does not permit being left uninitialized - --> $DIR/invalid_value.rs:81:26 + --> $DIR/invalid_value.rs:80:26 | LL | let _val: fn() = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +190,7 @@ LL | let _val: fn() = mem::uninitialized(); = note: function pointers must be non-null error: the type `Wrap` does not permit zero-initialization - --> $DIR/invalid_value.rs:83:32 + --> $DIR/invalid_value.rs:82:32 | LL | let _val: Wrap = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -200,13 +200,13 @@ LL | let _val: Wrap = mem::zeroed(); | = note: `Wrap` must be non-null note: because function pointers must be non-null (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ error: the type `Wrap` does not permit being left uninitialized - --> $DIR/invalid_value.rs:84:32 + --> $DIR/invalid_value.rs:83:32 | LL | let _val: Wrap = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -216,13 +216,13 @@ LL | let _val: Wrap = mem::uninitialized(); | = note: `Wrap` must be non-null note: because function pointers must be non-null (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ error: the type `WrapEnum` does not permit zero-initialization - --> $DIR/invalid_value.rs:86:36 + --> $DIR/invalid_value.rs:85:36 | LL | let _val: WrapEnum = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -232,13 +232,13 @@ LL | let _val: WrapEnum = mem::zeroed(); | = note: `WrapEnum` must be non-null note: because function pointers must be non-null (in this field of the only potentially inhabited enum variant) - --> $DIR/invalid_value.rs:18:28 + --> $DIR/invalid_value.rs:17:28 | LL | enum WrapEnum { Wrapped(T) } | ^ error: the type `WrapEnum` does not permit being left uninitialized - --> $DIR/invalid_value.rs:87:36 + --> $DIR/invalid_value.rs:86:36 | LL | let _val: WrapEnum = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -248,13 +248,13 @@ LL | let _val: WrapEnum = mem::uninitialized(); | = note: `WrapEnum` must be non-null note: because function pointers must be non-null (in this field of the only potentially inhabited enum variant) - --> $DIR/invalid_value.rs:18:28 + --> $DIR/invalid_value.rs:17:28 | LL | enum WrapEnum { Wrapped(T) } | ^ error: the type `Wrap<(RefPair, i32)>` does not permit zero-initialization - --> $DIR/invalid_value.rs:89:42 + --> $DIR/invalid_value.rs:88:42 | LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -263,18 +263,18 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed(); | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | note: `RefPair` must be non-null (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ note: because references must be non-null (in this struct field) - --> $DIR/invalid_value.rs:15:16 + --> $DIR/invalid_value.rs:14:16 | LL | struct RefPair((&'static i32, i32)); | ^^^^^^^^^^^^^^^^^^^ error: the type `Wrap<(RefPair, i32)>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:90:42 + --> $DIR/invalid_value.rs:89:42 | LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -283,18 +283,18 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized(); | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | note: `RefPair` must be non-null (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ note: because references must be non-null (in this struct field) - --> $DIR/invalid_value.rs:15:16 + --> $DIR/invalid_value.rs:14:16 | LL | struct RefPair((&'static i32, i32)); | ^^^^^^^^^^^^^^^^^^^ error: the type `NonNull` does not permit zero-initialization - --> $DIR/invalid_value.rs:92:34 + --> $DIR/invalid_value.rs:91:34 | LL | let _val: NonNull = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -305,7 +305,7 @@ LL | let _val: NonNull = mem::zeroed(); = note: `std::ptr::NonNull` must be non-null error: the type `NonNull` does not permit being left uninitialized - --> $DIR/invalid_value.rs:93:34 + --> $DIR/invalid_value.rs:92:34 | LL | let _val: NonNull = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -317,30 +317,30 @@ LL | let _val: NonNull = mem::uninitialized(); = note: raw pointers must be initialized error: the type `(NonZero, i32)` does not permit zero-initialization - --> $DIR/invalid_value.rs:95:39 + --> $DIR/invalid_value.rs:94:41 | -LL | let _val: (NonZeroU32, i32) = mem::zeroed(); - | ^^^^^^^^^^^^^ - | | - | this code causes undefined behavior when executed - | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done +LL | let _val: (NonZero, i32) = mem::zeroed(); + | ^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | = note: `std::num::NonZero` must be non-null error: the type `(NonZero, i32)` does not permit being left uninitialized - --> $DIR/invalid_value.rs:96:39 + --> $DIR/invalid_value.rs:95:41 | -LL | let _val: (NonZeroU32, i32) = mem::uninitialized(); - | ^^^^^^^^^^^^^^^^^^^^ - | | - | this code causes undefined behavior when executed - | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done +LL | let _val: (NonZero, i32) = mem::uninitialized(); + | ^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | = note: `std::num::NonZero` must be non-null = note: integers must be initialized error: the type `*const dyn Send` does not permit zero-initialization - --> $DIR/invalid_value.rs:98:37 + --> $DIR/invalid_value.rs:97:37 | LL | let _val: *const dyn Send = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -351,7 +351,7 @@ LL | let _val: *const dyn Send = mem::zeroed(); = note: the vtable of a wide raw pointer must be non-null error: the type `*const dyn Send` does not permit being left uninitialized - --> $DIR/invalid_value.rs:99:37 + --> $DIR/invalid_value.rs:98:37 | LL | let _val: *const dyn Send = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -362,7 +362,7 @@ LL | let _val: *const dyn Send = mem::uninitialized(); = note: the vtable of a wide raw pointer must be non-null error: the type `[fn(); 2]` does not permit zero-initialization - --> $DIR/invalid_value.rs:101:31 + --> $DIR/invalid_value.rs:100:31 | LL | let _val: [fn(); 2] = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -373,7 +373,7 @@ LL | let _val: [fn(); 2] = mem::zeroed(); = note: function pointers must be non-null error: the type `[fn(); 2]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:102:31 + --> $DIR/invalid_value.rs:101:31 | LL | let _val: [fn(); 2] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -384,31 +384,31 @@ LL | let _val: [fn(); 2] = mem::uninitialized(); = note: function pointers must be non-null error: the type `TwoUninhabited` does not permit zero-initialization - --> $DIR/invalid_value.rs:104:36 + --> $DIR/invalid_value.rs:103:36 | LL | let _val: TwoUninhabited = mem::zeroed(); | ^^^^^^^^^^^^^ this code causes undefined behavior when executed | note: enums with no inhabited variants have no valid value - --> $DIR/invalid_value.rs:42:1 + --> $DIR/invalid_value.rs:41:1 | LL | enum TwoUninhabited { | ^^^^^^^^^^^^^^^^^^^ error: the type `TwoUninhabited` does not permit being left uninitialized - --> $DIR/invalid_value.rs:105:36 + --> $DIR/invalid_value.rs:104:36 | LL | let _val: TwoUninhabited = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed | note: enums with no inhabited variants have no valid value - --> $DIR/invalid_value.rs:42:1 + --> $DIR/invalid_value.rs:41:1 | LL | enum TwoUninhabited { | ^^^^^^^^^^^^^^^^^^^ error: the type `OneFruitNonZero` does not permit zero-initialization - --> $DIR/invalid_value.rs:107:37 + --> $DIR/invalid_value.rs:106:37 | LL | let _val: OneFruitNonZero = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -418,13 +418,13 @@ LL | let _val: OneFruitNonZero = mem::zeroed(); | = note: `OneFruitNonZero` must be non-null note: because `std::num::NonZero` must be non-null (in this field of the only potentially inhabited enum variant) - --> $DIR/invalid_value.rs:39:12 + --> $DIR/invalid_value.rs:38:12 | -LL | Banana(NonZeroU32), - | ^^^^^^^^^^ +LL | Banana(NonZero), + | ^^^^^^^^^^^^ error: the type `OneFruitNonZero` does not permit being left uninitialized - --> $DIR/invalid_value.rs:108:37 + --> $DIR/invalid_value.rs:107:37 | LL | let _val: OneFruitNonZero = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -434,14 +434,14 @@ LL | let _val: OneFruitNonZero = mem::uninitialized(); | = note: `OneFruitNonZero` must be non-null note: because `std::num::NonZero` must be non-null (in this field of the only potentially inhabited enum variant) - --> $DIR/invalid_value.rs:39:12 + --> $DIR/invalid_value.rs:38:12 | -LL | Banana(NonZeroU32), - | ^^^^^^^^^^ +LL | Banana(NonZero), + | ^^^^^^^^^^^^ = note: integers must be initialized error: the type `bool` does not permit being left uninitialized - --> $DIR/invalid_value.rs:112:26 + --> $DIR/invalid_value.rs:111:26 | LL | let _val: bool = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -452,7 +452,7 @@ LL | let _val: bool = mem::uninitialized(); = note: booleans must be either `true` or `false` error: the type `Wrap` does not permit being left uninitialized - --> $DIR/invalid_value.rs:115:32 + --> $DIR/invalid_value.rs:114:32 | LL | let _val: Wrap = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -462,13 +462,13 @@ LL | let _val: Wrap = mem::uninitialized(); | = note: `Wrap` must be initialized inside its custom valid range note: characters must be a valid Unicode codepoint (in this struct field) - --> $DIR/invalid_value.rs:17:18 + --> $DIR/invalid_value.rs:16:18 | LL | struct Wrap { wrapped: T } | ^^^^^^^^^^ error: the type `NonBig` does not permit being left uninitialized - --> $DIR/invalid_value.rs:118:28 + --> $DIR/invalid_value.rs:117:28 | LL | let _val: NonBig = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -478,13 +478,13 @@ LL | let _val: NonBig = mem::uninitialized(); | = note: `NonBig` must be initialized inside its custom valid range note: integers must be initialized (in this struct field) - --> $DIR/invalid_value.rs:23:26 + --> $DIR/invalid_value.rs:22:26 | LL | pub(crate) struct NonBig(u64); | ^^^ error: the type `Fruit` does not permit being left uninitialized - --> $DIR/invalid_value.rs:121:27 + --> $DIR/invalid_value.rs:120:27 | LL | let _val: Fruit = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -493,13 +493,13 @@ LL | let _val: Fruit = mem::uninitialized(); | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | note: enums with multiple inhabited variants have to be initialized to a variant - --> $DIR/invalid_value.rs:26:1 + --> $DIR/invalid_value.rs:25:1 | LL | enum Fruit { | ^^^^^^^^^^ error: the type `[bool; 2]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:124:31 + --> $DIR/invalid_value.rs:123:31 | LL | let _val: [bool; 2] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -510,7 +510,7 @@ LL | let _val: [bool; 2] = mem::uninitialized(); = note: booleans must be either `true` or `false` error: the type `i32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:127:25 + --> $DIR/invalid_value.rs:126:25 | LL | let _val: i32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -521,7 +521,7 @@ LL | let _val: i32 = mem::uninitialized(); = note: integers must be initialized error: the type `f32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:130:25 + --> $DIR/invalid_value.rs:129:25 | LL | let _val: f32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -532,7 +532,7 @@ LL | let _val: f32 = mem::uninitialized(); = note: floats must be initialized error: the type `*const ()` does not permit being left uninitialized - --> $DIR/invalid_value.rs:133:31 + --> $DIR/invalid_value.rs:132:31 | LL | let _val: *const () = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ LL | let _val: *const () = mem::uninitialized(); = note: raw pointers must be initialized error: the type `*const [()]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:136:33 + --> $DIR/invalid_value.rs:135:33 | LL | let _val: *const [()] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -554,7 +554,7 @@ LL | let _val: *const [()] = mem::uninitialized(); = note: raw pointers must be initialized error: the type `WrapAroundRange` does not permit being left uninitialized - --> $DIR/invalid_value.rs:139:37 + --> $DIR/invalid_value.rs:138:37 | LL | let _val: WrapAroundRange = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -564,13 +564,13 @@ LL | let _val: WrapAroundRange = mem::uninitialized(); | = note: `WrapAroundRange` must be initialized inside its custom valid range note: integers must be initialized (in this struct field) - --> $DIR/invalid_value.rs:49:35 + --> $DIR/invalid_value.rs:48:35 | LL | pub(crate) struct WrapAroundRange(u8); | ^^ error: the type `Result` does not permit being left uninitialized - --> $DIR/invalid_value.rs:144:38 + --> $DIR/invalid_value.rs:143:38 | LL | let _val: Result = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -582,7 +582,7 @@ note: enums with multiple inhabited variants have to be initialized to a variant --> $SRC_DIR/core/src/result.rs:LL:COL error: the type `&i32` does not permit zero-initialization - --> $DIR/invalid_value.rs:152:34 + --> $DIR/invalid_value.rs:151:34 | LL | let _val: &'static i32 = mem::transmute(0usize); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -593,7 +593,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize); = note: references must be non-null error: the type `&[i32]` does not permit zero-initialization - --> $DIR/invalid_value.rs:153:36 + --> $DIR/invalid_value.rs:152:36 | LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -604,18 +604,18 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); = note: references must be non-null error: the type `NonZero` does not permit zero-initialization - --> $DIR/invalid_value.rs:154:32 + --> $DIR/invalid_value.rs:153:34 | -LL | let _val: NonZeroU32 = mem::transmute(0); - | ^^^^^^^^^^^^^^^^^ - | | - | this code causes undefined behavior when executed - | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done +LL | let _val: NonZero = mem::transmute(0); + | ^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | = note: `std::num::NonZero` must be non-null error: the type `NonNull` does not permit zero-initialization - --> $DIR/invalid_value.rs:157:34 + --> $DIR/invalid_value.rs:156:34 | LL | let _val: NonNull = MaybeUninit::zeroed().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -626,7 +626,7 @@ LL | let _val: NonNull = MaybeUninit::zeroed().assume_init(); = note: `std::ptr::NonNull` must be non-null error: the type `NonNull` does not permit being left uninitialized - --> $DIR/invalid_value.rs:158:34 + --> $DIR/invalid_value.rs:157:34 | LL | let _val: NonNull = MaybeUninit::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -638,7 +638,7 @@ LL | let _val: NonNull = MaybeUninit::uninit().assume_init(); = note: raw pointers must be initialized error: the type `bool` does not permit being left uninitialized - --> $DIR/invalid_value.rs:159:26 + --> $DIR/invalid_value.rs:158:26 | LL | let _val: bool = MaybeUninit::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-enum.rs b/tests/ui/lint/lint-ctypes-enum.rs index 7c20608059398..3157b6e240aec 100644 --- a/tests/ui/lint/lint-ctypes-enum.rs +++ b/tests/ui/lint/lint-ctypes-enum.rs @@ -1,7 +1,8 @@ -#![feature(transparent_unions)] -#![feature(ptr_internals)] -#![deny(improper_ctypes)] #![allow(dead_code)] +#![deny(improper_ctypes)] +#![feature(generic_nonzero)] +#![feature(ptr_internals)] +#![feature(transparent_unions)] use std::num; @@ -67,26 +68,26 @@ extern "C" { fn option_fn(x: Option); fn nonnull(x: Option>); fn unique(x: Option>); - fn nonzero_u8(x: Option); - fn nonzero_u16(x: Option); - fn nonzero_u32(x: Option); - fn nonzero_u64(x: Option); - fn nonzero_u128(x: Option); + fn nonzero_u8(x: Option>); + fn nonzero_u16(x: Option>); + fn nonzero_u32(x: Option>); + fn nonzero_u64(x: Option>); + fn nonzero_u128(x: Option>); //~^ ERROR `extern` block uses type `u128` - fn nonzero_usize(x: Option); - fn nonzero_i8(x: Option); - fn nonzero_i16(x: Option); - fn nonzero_i32(x: Option); - fn nonzero_i64(x: Option); - fn nonzero_i128(x: Option); + fn nonzero_usize(x: Option>); + fn nonzero_i8(x: Option>); + fn nonzero_i16(x: Option>); + fn nonzero_i32(x: Option>); + fn nonzero_i64(x: Option>); + fn nonzero_i128(x: Option>); //~^ ERROR `extern` block uses type `i128` - fn nonzero_isize(x: Option); - fn transparent_struct(x: Option>); - fn transparent_enum(x: Option>); - fn transparent_union(x: Option>); + fn nonzero_isize(x: Option>); + fn transparent_struct(x: Option>>); + fn transparent_enum(x: Option>>); + fn transparent_union(x: Option>>); //~^ ERROR `extern` block uses type - fn repr_rust(x: Option>); //~ ERROR `extern` block uses type - fn no_result(x: Result<(), num::NonZeroI32>); //~ ERROR `extern` block uses type + fn repr_rust(x: Option>>); //~ ERROR `extern` block uses type + fn no_result(x: Result<(), num::NonZero>); //~ ERROR `extern` block uses type } pub fn main() {} diff --git a/tests/ui/lint/lint-ctypes-enum.stderr b/tests/ui/lint/lint-ctypes-enum.stderr index 64beefbb7579f..48be3eb5a5630 100644 --- a/tests/ui/lint/lint-ctypes-enum.stderr +++ b/tests/ui/lint/lint-ctypes-enum.stderr @@ -1,5 +1,5 @@ error: `extern` block uses type `U`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:60:13 + --> $DIR/lint-ctypes-enum.rs:61:13 | LL | fn uf(x: U); | ^ not FFI-safe @@ -7,18 +7,18 @@ LL | fn uf(x: U); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:9:1 + --> $DIR/lint-ctypes-enum.rs:10:1 | LL | enum U { | ^^^^^^ note: the lint level is defined here - --> $DIR/lint-ctypes-enum.rs:3:9 + --> $DIR/lint-ctypes-enum.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ error: `extern` block uses type `B`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:61:13 + --> $DIR/lint-ctypes-enum.rs:62:13 | LL | fn bf(x: B); | ^ not FFI-safe @@ -26,13 +26,13 @@ LL | fn bf(x: B); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:12:1 + --> $DIR/lint-ctypes-enum.rs:13:1 | LL | enum B { | ^^^^^^ error: `extern` block uses type `T`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:62:13 + --> $DIR/lint-ctypes-enum.rs:63:13 | LL | fn tf(x: T); | ^ not FFI-safe @@ -40,50 +40,50 @@ LL | fn tf(x: T); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:16:1 + --> $DIR/lint-ctypes-enum.rs:17:1 | LL | enum T { | ^^^^^^ error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:74:23 + --> $DIR/lint-ctypes-enum.rs:75:23 | -LL | fn nonzero_u128(x: Option); - | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn nonzero_u128(x: Option>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:81:23 + --> $DIR/lint-ctypes-enum.rs:82:23 | -LL | fn nonzero_i128(x: Option); - | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn nonzero_i128(x: Option>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `Option>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:86:28 + --> $DIR/lint-ctypes-enum.rs:87:28 | -LL | fn transparent_union(x: Option>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn transparent_union(x: Option>>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint error: `extern` block uses type `Option>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:88:20 + --> $DIR/lint-ctypes-enum.rs:89:20 | -LL | fn repr_rust(x: Option>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn repr_rust(x: Option>>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint error: `extern` block uses type `Result<(), NonZero>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:89:20 + --> $DIR/lint-ctypes-enum.rs:90:20 | -LL | fn no_result(x: Result<(), num::NonZeroI32>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn no_result(x: Result<(), num::NonZero>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint diff --git a/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs index dc3b6c280f340..bda5cef979ec2 100644 --- a/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs +++ b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs @@ -2,11 +2,11 @@ //@ error-pattern:attempt to negate with overflow //@ ignore-emscripten no processes //@ compile-flags: -C debug-assertions - #![allow(arithmetic_overflow)] +#![feature(generic_nonzero)] -use std::num::NonZeroI8; +use std::num::NonZero; fn main() { - let _x = -NonZeroI8::new(i8::MIN).unwrap(); + let _x = -NonZero::new(i8::MIN).unwrap(); } diff --git a/tests/ui/print_type_sizes/niche-filling.rs b/tests/ui/print_type_sizes/niche-filling.rs index da11f0c012170..07da1cff27a74 100644 --- a/tests/ui/print_type_sizes/niche-filling.rs +++ b/tests/ui/print_type_sizes/niche-filling.rs @@ -1,24 +1,24 @@ +//! This file illustrates how niche-filling enums are handled, +//! modelled after cases like `Option<&u32>`, `Option` and such. +//! +//! It uses `NonZero` rather than `&_` or `Unique<_>`, because +//! the test is not set up to deal with target-dependent pointer width. +//! +//! It avoids using `u64`/`i64` because on some targets that is only 4-byte +//! aligned (while on most it is 8-byte aligned) and so the resulting +//! padding and overall computed sizes can be quite different. +//! //@ compile-flags: -Z print-type-sizes --crate-type lib //@ ignore-debug: debug assertions will print more types //@ build-pass //@ ignore-pass -// ^-- needed because `--pass check` does not emit the output needed. -// FIXME: consider using an attribute instead of side-effects. - -// This file illustrates how niche-filling enums are handled, -// modelled after cases like `Option<&u32>`, `Option` and such. -// -// It uses NonZeroU32 rather than `&_` or `Unique<_>`, because -// the test is not set up to deal with target-dependent pointer width. -// -// It avoids using u64/i64 because on some targets that is only 4-byte -// aligned (while on most it is 8-byte aligned) and so the resulting -// padding and overall computed sizes can be quite different. - -#![feature(rustc_attrs)] +// ^-- needed because `--pass check` does not emit the output needed. +// FIXME: consider using an attribute instead of side-effects. #![allow(dead_code)] +#![feature(generic_nonzero)] +#![feature(rustc_attrs)] -use std::num::NonZeroU32; +use std::num::NonZero; pub enum MyOption { None, Some(T) } @@ -34,7 +34,7 @@ impl Default for MyOption { pub enum EmbeddedDiscr { None, - Record { pre: u8, val: NonZeroU32, post: u16 }, + Record { pre: u8, val: NonZero, post: u16 }, } impl Default for EmbeddedDiscr { @@ -50,13 +50,13 @@ pub struct IndirectNonZero { pub struct NestedNonZero { pre: u8, - val: NonZeroU32, + val: NonZero, post: u16, } impl Default for NestedNonZero { fn default() -> Self { - NestedNonZero { pre: 0, val: unsafe { NonZeroU32::new_unchecked(1) }, post: 0 } + NestedNonZero { pre: 0, val: unsafe { NonZero::new_unchecked(1) }, post: 0 } } } @@ -77,7 +77,7 @@ pub union Union2 { } pub fn test() { - let _x: MyOption = Default::default(); + let _x: MyOption> = Default::default(); let _y: EmbeddedDiscr = Default::default(); let _z: MyOption = Default::default(); let _a: MyOption = Default::default(); @@ -90,9 +90,9 @@ pub fn test() { let _h: MyOption = Default::default(); // Unions do not currently participate in niche filling. - let _i: MyOption> = Default::default(); + let _i: MyOption, u32>> = Default::default(); // ...even when theoretically possible. - let _j: MyOption> = Default::default(); - let _k: MyOption> = Default::default(); + let _j: MyOption>> = Default::default(); + let _k: MyOption, NonZero>> = Default::default(); } diff --git a/tests/ui/structs-enums/enum-null-pointer-opt.rs b/tests/ui/structs-enums/enum-null-pointer-opt.rs index 6f8c81689682b..a8418943ba4f3 100644 --- a/tests/ui/structs-enums/enum-null-pointer-opt.rs +++ b/tests/ui/structs-enums/enum-null-pointer-opt.rs @@ -1,8 +1,9 @@ //@ run-pass +#![feature(generic_nonzero)] #![feature(transparent_unions)] use std::mem::size_of; -use std::num::NonZeroUsize; +use std::num::NonZero; use std::ptr::NonNull; use std::rc::Rc; use std::sync::Arc; @@ -57,7 +58,7 @@ fn main() { assert_eq!(size_of::<[Box; 1]>(), size_of::; 1]>>()); // Should apply to NonZero - assert_eq!(size_of::(), size_of::>()); + assert_eq!(size_of::>(), size_of::>>()); assert_eq!(size_of::>(), size_of::>>()); // Should apply to types that use NonZero internally diff --git a/tests/ui/structs-enums/enum-null-pointer-opt.stderr b/tests/ui/structs-enums/enum-null-pointer-opt.stderr index 64e93ffaffd60..fca62bd1c801b 100644 --- a/tests/ui/structs-enums/enum-null-pointer-opt.stderr +++ b/tests/ui/structs-enums/enum-null-pointer-opt.stderr @@ -1,5 +1,5 @@ warning: method `dummy` is never used - --> $DIR/enum-null-pointer-opt.rs:10:18 + --> $DIR/enum-null-pointer-opt.rs:11:18 | LL | trait Trait { fn dummy(&self) { } } | ----- ^^^^^ diff --git a/tests/ui/structs-enums/type-sizes.rs b/tests/ui/structs-enums/type-sizes.rs index 92060e3cade3c..66f663ce0776c 100644 --- a/tests/ui/structs-enums/type-sizes.rs +++ b/tests/ui/structs-enums/type-sizes.rs @@ -2,12 +2,13 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] +#![feature(generic_nonzero)] #![feature(never_type)] #![feature(pointer_is_aligned)] #![feature(strict_provenance)] use std::mem::size_of; -use std::num::{NonZeroU8, NonZeroU16}; +use std::num::NonZero; use std::ptr; use std::ptr::NonNull; use std::borrow::Cow; @@ -110,14 +111,14 @@ enum Option2 { // Two layouts are considered for `CanBeNicheFilledButShouldnt`: // Niche-filling: -// { u32 (4 bytes), NonZeroU8 + tag in niche (1 byte), padding (3 bytes) } +// { u32 (4 bytes), NonZero + tag in niche (1 byte), padding (3 bytes) } // Tagged: -// { tag (1 byte), NonZeroU8 (1 byte), padding (2 bytes), u32 (4 bytes) } +// { tag (1 byte), NonZero (1 byte), padding (2 bytes), u32 (4 bytes) } // Both are the same size (due to padding), // but the tagged layout is better as the tag creates a niche with 254 invalid values, // allowing types like `Option>` to fit into 8 bytes. pub enum CanBeNicheFilledButShouldnt { - A(NonZeroU8, u32), + A(NonZero, u32), B } pub enum AlwaysTaggedBecauseItHasNoNiche { @@ -135,7 +136,7 @@ pub enum NicheFilledMultipleFields { G, } -struct BoolInTheMiddle(std::num::NonZeroU16, bool, u8); +struct BoolInTheMiddle(NonZero, bool, u8); enum NicheWithData { A, @@ -275,7 +276,7 @@ pub fn main() { assert_eq!(size_of::>(), 2); assert_eq!(size_of::>>(), 2); - struct S1{ a: u16, b: std::num::NonZeroU16, c: u16, d: u8, e: u32, f: u64, g:[u8;2] } + struct S1{ a: u16, b: NonZero, c: u16, d: u8, e: u32, f: u64, g:[u8;2] } assert_eq!(size_of::(), 24); assert_eq!(size_of::>(), 24); @@ -287,14 +288,14 @@ pub fn main() { size_of::<(&(), NicheWithData)>() ); - pub enum FillPadding { A(std::num::NonZeroU8, u32), B } + pub enum FillPadding { A(NonZero, u32), B } assert_eq!(size_of::(), 8); assert_eq!(size_of::>(), 8); assert_eq!(size_of::>>(), 8); - assert_eq!(size_of::>(), 4); - assert_eq!(size_of::>>(), 4); - assert_eq!(size_of::>(), 4); + assert_eq!(size_of::, u8, u8), u16>>(), 4); + assert_eq!(size_of::, u8, u8), u16>>>(), 4); + assert_eq!(size_of::, u8, u8, u8), u16>>(), 4); assert_eq!(size_of::>(), 6); assert_eq!(size_of::>(), 4); @@ -314,10 +315,10 @@ pub fn main() { assert_eq!(ptr::from_ref(&v), ptr::from_ref(&v.r.ptr).cast(), "sort niches to the front where possible"); - // Ideal layouts: (bool, u8, NonZeroU16) or (NonZeroU16, u8, bool) + // Ideal layouts: (bool, u8, NonZero) or (NonZero, u8, bool) // Currently the layout algorithm will choose the latter because it doesn't attempt // to aggregate multiple smaller fields to move a niche before a higher-alignment one. - let b = BoolInTheMiddle( NonZeroU16::new(1).unwrap(), true, 0); + let b = BoolInTheMiddle(NonZero::new(1).unwrap(), true, 0); assert!(ptr::from_ref(&b.1).addr() > ptr::from_ref(&b.2).addr()); assert_eq!(size_of::>(), size_of::()); diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.rs b/tests/ui/suggestions/core-std-import-order-issue-83564.rs index 2cf1983858a65..62b9b246cc81b 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.rs +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.rs @@ -1,10 +1,11 @@ //@ edition:2018 - +// // This is a regression test for #83564. // For some reason, Rust 2018 or higher is required to reproduce the bug. +#![feature(generic_nonzero)] fn main() { //~^ HELP consider importing one of these items - let _x = NonZeroU32::new(5).unwrap(); - //~^ ERROR failed to resolve: use of undeclared type `NonZeroU32` + let _x = NonZero::new(5u32).unwrap(); + //~^ ERROR failed to resolve: use of undeclared type `NonZero` } diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.stderr b/tests/ui/suggestions/core-std-import-order-issue-83564.stderr index c2634e3070ea9..56e10b9340c0b 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.stderr +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.stderr @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve: use of undeclared type `NonZeroU32` - --> $DIR/core-std-import-order-issue-83564.rs:8:14 +error[E0433]: failed to resolve: use of undeclared type `NonZero` + --> $DIR/core-std-import-order-issue-83564.rs:9:14 | -LL | let _x = NonZeroU32::new(5).unwrap(); - | ^^^^^^^^^^ use of undeclared type `NonZeroU32` +LL | let _x = NonZero::new(5u32).unwrap(); + | ^^^^^^^ use of undeclared type `NonZero` | help: consider importing one of these items | -LL + use core::num::NonZeroU32; +LL + use core::num::NonZero; | -LL + use std::num::NonZeroU32; +LL + use std::num::NonZero; | error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/specialization-transmute.rs b/tests/ui/traits/next-solver/specialization-transmute.rs index 41c9032201138..17c55fb4d49df 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.rs +++ b/tests/ui/traits/next-solver/specialization-transmute.rs @@ -1,6 +1,6 @@ //@ compile-flags: -Znext-solver //~^ ERROR cannot normalize `::Id: '_` - +#![feature(generic_nonzero)] #![feature(specialization)] //~^ WARN the feature `specialization` is incomplete @@ -23,8 +23,9 @@ fn transmute, U: Copy>(t: T) -> U { *t.intu() } -use std::num::NonZeroU8; +use std::num::NonZero; + fn main() { - let s = transmute::>(0); //~ ERROR cannot satisfy + let s = transmute::>>(0); //~ ERROR cannot satisfy assert_eq!(s, None); } diff --git a/tests/ui/traits/next-solver/specialization-transmute.stderr b/tests/ui/traits/next-solver/specialization-transmute.stderr index c87612d6a26ec..65e3370032522 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.stderr +++ b/tests/ui/traits/next-solver/specialization-transmute.stderr @@ -23,10 +23,10 @@ LL | self | ^^^^ cannot satisfy `T <: ::Id` error[E0284]: type annotations needed: cannot satisfy `::Id == Option>` - --> $DIR/specialization-transmute.rs:28:13 + --> $DIR/specialization-transmute.rs:29:13 | -LL | let s = transmute::>(0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `::Id == Option>` +LL | let s = transmute::>>(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `::Id == Option>` | note: required by a bound in `transmute` --> $DIR/specialization-transmute.rs:22:25 From 84219f45a3fd2a5bb86dd5ba6c56408193f16af3 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 16:11:14 +0400 Subject: [PATCH 303/417] working naive with outside check_attrs --- clippy_lints/src/doc/empty_docs.rs | 25 ++++++++++++++++++++++ clippy_lints/src/doc/mod.rs | 33 ++++-------------------------- tests/ui/empty_docs.rs | 24 +++++++++++++++++++--- tests/ui/empty_docs.stderr | 23 ++++++++------------- 4 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 clippy_lints/src/doc/empty_docs.rs diff --git a/clippy_lints/src/doc/empty_docs.rs b/clippy_lints/src/doc/empty_docs.rs new file mode 100644 index 0000000000000..bd5aeba922b59 --- /dev/null +++ b/clippy_lints/src/doc/empty_docs.rs @@ -0,0 +1,25 @@ +use clippy_utils::diagnostics::span_lint_and_help; +use rustc_ast::Attribute; +use rustc_lint::LateContext; + +use super::EMPTY_DOCS; + +// TODO: Adjust the parameters as necessary +pub(super) fn check(cx: &LateContext<'_>, attrs: &[Attribute]) { + let doc_attrs: Vec<_> = attrs.iter().filter(|attr| attr.doc_str().is_some()).collect(); + + let span; + if let Some(first) = doc_attrs.first() + && let Some(last) = doc_attrs.last() + { + span = first.span.with_hi(last.span.hi()); + span_lint_and_help( + cx, + EMPTY_DOCS, + span, + "empty doc comment", + None, + "consider removing or filling it", + ); + } +} diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 26bfdf4a072cf..a0e23983d1da5 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -23,10 +23,11 @@ use rustc_resolve::rustdoc::{ }; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; -use rustc_span::{sym, Span, DUMMY_SP}; +use rustc_span::{sym, Span}; use std::ops::Range; use url::Url; +mod empty_docs; mod link_with_quotes; mod markdown; mod missing_headers; @@ -403,17 +404,8 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { return; }; - if let Some(span) = get_empty_doc_combined_span(attrs, item.span) - && headers.empty - { - span_lint_and_help( - cx, - EMPTY_DOCS, - span, - "empty doc comment", - None, - "consider removing or filling it", - ); + if headers.empty && !item.span.is_dummy() { + empty_docs::check(cx, attrs); } match item.kind { @@ -759,20 +751,3 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { self.cx.tcx.hir() } } - -fn get_empty_doc_combined_span(attrs: &[Attribute], item_span: Span) -> Option { - let mut attrs_span = DUMMY_SP; - if attrs.len() > 0 { - attrs_span = attrs - .iter() - .map(|attr| attr.span) - .fold(attrs[0].span, |acc, next| acc.to(next)); - } - - match (!item_span.is_dummy(), !attrs_span.is_dummy()) { - (true, true) => Some(item_span.shrink_to_lo().to(attrs_span)), - (true, false) => Some(item_span), - (false, true) => Some(attrs_span), - (false, false) => None, - } -} diff --git a/tests/ui/empty_docs.rs b/tests/ui/empty_docs.rs index 394e62ab2a61c..30b1f0ed2e2ce 100644 --- a/tests/ui/empty_docs.rs +++ b/tests/ui/empty_docs.rs @@ -15,17 +15,26 @@ enum Warn { B, } -enum WarnForB { +enum WarnA { + /// + A, + B, +} + +enum DontWarn { /// it's ok A, /// B, } -#[doc = ""] #[doc = ""] fn warn_about_this() {} +#[doc = ""] +#[doc = ""] +fn this_doesn_warn() {} + #[doc = "a fine function"] fn this_is_fine() {} @@ -33,11 +42,20 @@ fn warn_about_this_as_well() { //! } +/// +fn warn_inner_outer() { + //! what +} + fn this_is_ok() { //! //! inside the function } fn warn() { - /*! inside the function */ + /*! */ +} + +fn dont_warn() { + /*! dont warn me */ } diff --git a/tests/ui/empty_docs.stderr b/tests/ui/empty_docs.stderr index 27d49b4ff3b60..0c2f175577630 100644 --- a/tests/ui/empty_docs.stderr +++ b/tests/ui/empty_docs.stderr @@ -1,33 +1,26 @@ error: empty doc comment --> tests/ui/empty_docs.rs:10:1 | -LL | / /// -LL | | enum Warn { - | |_ +LL | /// + | ^^^ | = help: consider removing or filling it = note: `-D clippy::empty-docs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::empty_docs)]` error: empty doc comment - --> tests/ui/empty_docs.rs:18:1 + --> tests/ui/empty_docs.rs:31:1 | -LL | / enum WarnForB { -LL | | /// it's ok -LL | | A, -LL | | /// -LL | | B, -LL | | } - | |_^ +LL | #[doc = ""] + | ^^^^^^^^^^^ | = help: consider removing or filling it error: empty doc comment - --> tests/ui/empty_docs.rs:32:1 + --> tests/ui/empty_docs.rs:42:5 | -LL | / fn warn_about_this_as_well() { -LL | | //! - | |_______^ +LL | //! + | ^^^ | = help: consider removing or filling it From fa7557181f371d88fb67f17b85827954f79cdf94 Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Sun, 25 Feb 2024 17:51:56 +0530 Subject: [PATCH 304/417] Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails --- compiler/rustc_lint/src/array_into_iter.rs | 14 +++++++++----- .../lint/ice-array-into-iter-lint-issue-121532.rs | 11 +++++++++++ .../ice-array-into-iter-lint-issue-121532.stderr | 9 +++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs create mode 100644 tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 3a5c585366a31..993b1d739a13d 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -70,11 +70,15 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { // Check if the method call actually calls the libcore // `IntoIterator::into_iter`. - let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap(); - match cx.tcx.trait_of_item(def_id) { - Some(trait_id) if cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id) => {} - _ => return, - }; + let trait_id = cx + .typeck_results() + .type_dependent_def_id(expr.hir_id) + .and_then(|did| cx.tcx.trait_of_item(did)); + if trait_id.is_none() + || !cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id.unwrap()) + { + return; + } // As this is a method call expression, we have at least one argument. let receiver_ty = cx.typeck_results().expr_ty(receiver_arg); diff --git a/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs new file mode 100644 index 0000000000000..92cab01fe48c8 --- /dev/null +++ b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs @@ -0,0 +1,11 @@ +// Regression test for #121532 +// Checks the we don't ICE in ArrayIntoIter +// lint when typeck has failed + + // Typeck fails for the arg type as + // `Self` makes no sense here +fn func(a: Self::ItemsIterator) { //~ ERROR failed to resolve: `Self` is only available in impls, traits, and type definitions + a.into_iter(); +} + +fn main() {} diff --git a/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr new file mode 100644 index 0000000000000..73ceddae940b2 --- /dev/null +++ b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions + --> $DIR/ice-array-into-iter-lint-issue-121532.rs:7:12 + | +LL | fn func(a: Self::ItemsIterator) { + | ^^^^ `Self` is only available in impls, traits, and type definitions + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0433`. From 09c7c5d2c9f23c16b39d2fade5567010fe33471d Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 16:52:58 +0400 Subject: [PATCH 305/417] fix bug in check_exprs --- clippy_lints/src/doc/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index a0e23983d1da5..be6748bdb7d35 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -533,10 +533,14 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ suspicious_doc_comments::check(cx, attrs); let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true); - let mut doc = String::new(); - for fragment in &fragments { - add_doc_fragment(&mut doc, fragment); - } + let mut doc = fragments + .iter() + .fold(String::new(), |mut acc, fragment| { + add_doc_fragment(&mut acc, fragment); + acc + }) + .trim() + .to_string(); doc.pop(); if doc.is_empty() { From a3fea80a6826154a23eafe8e62f6b18cfae1dfbc Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 17:04:58 +0400 Subject: [PATCH 306/417] bless tests --- tests/ui/empty_docs.stderr | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/ui/empty_docs.stderr b/tests/ui/empty_docs.stderr index 0c2f175577630..a2d8b986bf06d 100644 --- a/tests/ui/empty_docs.stderr +++ b/tests/ui/empty_docs.stderr @@ -16,6 +16,15 @@ LL | #[doc = ""] | = help: consider removing or filling it +error: empty doc comment + --> tests/ui/empty_docs.rs:34:1 + | +LL | / #[doc = ""] +LL | | #[doc = ""] + | |___________^ + | + = help: consider removing or filling it + error: empty doc comment --> tests/ui/empty_docs.rs:42:5 | @@ -24,5 +33,13 @@ LL | //! | = help: consider removing or filling it -error: aborting due to 3 previous errors +error: empty doc comment + --> tests/ui/empty_docs.rs:56:5 + | +LL | /*! */ + | ^^^^^^ + | + = help: consider removing or filling it + +error: aborting due to 5 previous errors From 08caefbb103d1809113172d16eaf8f66c2edc2f1 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Wed, 20 Dec 2023 11:57:19 +0000 Subject: [PATCH 307/417] Windows: Use ProcessPrng for random keys --- library/std/src/sys/pal/windows/c.rs | 15 +++++++ .../std/src/sys/pal/windows/c/bindings.txt | 4 -- .../std/src/sys/pal/windows/c/windows_sys.rs | 12 ------ library/std/src/sys/pal/windows/rand.rs | 41 ++++++------------- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 6b12d7db8b03a..ad8e01bfa9b03 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -321,6 +321,21 @@ pub unsafe fn NtWriteFile( } } +// Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. +cfg_if::cfg_if! { +if #[cfg(not(target_vendor = "win7"))] { + #[cfg(target_arch = "x86")] + #[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] + extern "system" { + pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; + } + #[cfg(not(target_arch = "x86"))] + #[link(name = "bcryptprimitives", kind = "raw-dylib")] + extern "system" { + pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; + } +}} + // Functions that aren't available on every version of Windows that we support, // but we still use them and just provide some form of a fallback implementation. compat_fn_with_fallback! { diff --git a/library/std/src/sys/pal/windows/c/bindings.txt b/library/std/src/sys/pal/windows/c/bindings.txt index 726f1c3df8294..ab2a8caf5dfd9 100644 --- a/library/std/src/sys/pal/windows/c/bindings.txt +++ b/library/std/src/sys/pal/windows/c/bindings.txt @@ -2180,10 +2180,6 @@ Windows.Win32.Networking.WinSock.WSATRY_AGAIN Windows.Win32.Networking.WinSock.WSATYPE_NOT_FOUND Windows.Win32.Networking.WinSock.WSAVERNOTSUPPORTED Windows.Win32.Security.Authentication.Identity.RtlGenRandom -Windows.Win32.Security.Cryptography.BCRYPT_ALG_HANDLE -Windows.Win32.Security.Cryptography.BCRYPT_USE_SYSTEM_PREFERRED_RNG -Windows.Win32.Security.Cryptography.BCryptGenRandom -Windows.Win32.Security.Cryptography.BCRYPTGENRANDOM_FLAGS Windows.Win32.Security.SECURITY_ATTRIBUTES Windows.Win32.Security.TOKEN_ACCESS_MASK Windows.Win32.Security.TOKEN_ACCESS_PSEUDO_HANDLE diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs index c386b66a722df..8eb779373f7e4 100644 --- a/library/std/src/sys/pal/windows/c/windows_sys.rs +++ b/library/std/src/sys/pal/windows/c/windows_sys.rs @@ -15,15 +15,6 @@ extern "system" { pub fn RtlGenRandom(randombuffer: *mut ::core::ffi::c_void, randombufferlength: u32) -> BOOLEAN; } -#[link(name = "bcrypt")] -extern "system" { - pub fn BCryptGenRandom( - halgorithm: BCRYPT_ALG_HANDLE, - pbbuffer: *mut u8, - cbbuffer: u32, - dwflags: BCRYPTGENRANDOM_FLAGS, - ) -> NTSTATUS; -} #[link(name = "kernel32")] extern "system" { pub fn AcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> (); @@ -889,9 +880,6 @@ impl ::core::clone::Clone for ARM64_NT_NEON128_0 { *self } } -pub type BCRYPTGENRANDOM_FLAGS = u32; -pub type BCRYPT_ALG_HANDLE = *mut ::core::ffi::c_void; -pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: BCRYPTGENRANDOM_FLAGS = 2u32; pub const BELOW_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 16384u32; pub type BOOL = i32; pub type BOOLEAN = u8; diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs index bd1ae6b06076e..e427546222aea 100644 --- a/library/std/src/sys/pal/windows/rand.rs +++ b/library/std/src/sys/pal/windows/rand.rs @@ -1,42 +1,27 @@ -use crate::mem; -use crate::ptr; use crate::sys::c; +use core::mem; +use core::ptr; +#[cfg(not(target_vendor = "win7"))] +#[inline] pub fn hashmap_random_keys() -> (u64, u64) { let mut v = (0, 0); - let ret = unsafe { - c::BCryptGenRandom( - ptr::null_mut(), - core::ptr::addr_of_mut!(v) as *mut u8, - mem::size_of_val(&v) as c::ULONG, - c::BCRYPT_USE_SYSTEM_PREFERRED_RNG, - ) - }; - if c::nt_success(ret) { v } else { fallback_rng() } + let ret = unsafe { c::ProcessPrng(ptr::addr_of_mut!(v).cast::(), mem::size_of_val(&v)) }; + // ProcessPrng is documented as always returning `TRUE`. + // https://learn.microsoft.com/en-us/windows/win32/seccng/processprng#return-value + debug_assert_eq!(ret, c::TRUE); + v } -/// Generate random numbers using the fallback RNG function (RtlGenRandom) -/// -/// This is necessary because of a failure to load the SysWOW64 variant of the -/// bcryptprimitives.dll library from code that lives in bcrypt.dll -/// See -#[cfg(not(target_vendor = "uwp"))] -#[inline(never)] -fn fallback_rng() -> (u64, u64) { +#[cfg(target_vendor = "win7")] +pub fn hashmap_random_keys() -> (u64, u64) { use crate::ffi::c_void; use crate::io; let mut v = (0, 0); let ret = unsafe { - c::RtlGenRandom(core::ptr::addr_of_mut!(v) as *mut c_void, mem::size_of_val(&v) as c::ULONG) + c::RtlGenRandom(ptr::addr_of_mut!(v).cast::(), mem::size_of_val(&v) as c::ULONG) }; - if ret != 0 { v } else { panic!("fallback RNG broken: {}", io::Error::last_os_error()) } -} - -/// We can't use RtlGenRandom with UWP, so there is no fallback -#[cfg(target_vendor = "uwp")] -#[inline(never)] -fn fallback_rng() -> (u64, u64) { - panic!("fallback RNG broken: RtlGenRandom() not supported on UWP"); + if ret != 0 { v } else { panic!("RNG broken: {}", io::Error::last_os_error()) } } From 8f89cbd796fe54b3454175193d6c2be245376161 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 20 Feb 2024 08:51:24 -0300 Subject: [PATCH 308/417] Add ProcessPrng shim to Miri This is essentially the same as SystemFunction036 (aka RtlGenRandom) except that the given length is a usize instead of a u32 --- src/tools/miri/src/shims/windows/foreign_items.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index bddc30b8379b2..fdd7fc5fad4e8 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -427,6 +427,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.gen_random(ptr, len.into())?; this.write_scalar(Scalar::from_bool(true), dest)?; } + "ProcessPrng" => { + let [ptr, len] = + this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; + let ptr = this.read_pointer(ptr)?; + let len = this.read_target_usize(len)?; + this.gen_random(ptr, len.into())?; + this.write_scalar(Scalar::from_i32(1), dest)?; + } "BCryptGenRandom" => { let [algorithm, ptr, len, flags] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; From 9ac6125e1d034bdc84e9a8508fd96fa55cdf8209 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 17:16:07 +0400 Subject: [PATCH 309/417] add extra variant because no more than 3 bools --- clippy_lints/src/doc/mod.rs | 53 +++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index be6748bdb7d35..78d46928f35eb 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -400,11 +400,15 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { + let Some(DocInfo { + empty, + doc_headers: headers, + }) = check_attrs(cx, &self.valid_idents, attrs) + else { return; }; - if headers.empty && !item.span.is_dummy() { + if empty && !item.span.is_dummy() { empty_docs::check(cx, attrs); } @@ -455,7 +459,11 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { + let Some(DocInfo { + empty: _, + doc_headers: headers, + }) = check_attrs(cx, &self.valid_idents, attrs) + else { return; }; if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind { @@ -467,7 +475,11 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { + let Some(DocInfo { + empty: _, + doc_headers: headers, + }) = check_attrs(cx, &self.valid_idents, attrs) + else { return; }; if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) { @@ -507,7 +519,12 @@ struct DocHeaders { safety: bool, errors: bool, panics: bool, +} + +#[derive(Copy, Clone, Default)] +struct DocInfo { empty: bool, + doc_headers: DocHeaders, } /// Does some pre-processing on raw, desugared `#[doc]` attributes such as parsing them and @@ -517,7 +534,7 @@ struct DocHeaders { /// Others are checked elsewhere, e.g. in `check_doc` if they need access to markdown, or /// back in the various late lint pass methods if they need the final doc headers, like "Safety" or /// "Panics" sections. -fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[Attribute]) -> Option { +fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[Attribute]) -> Option { /// We don't want the parser to choke on intra doc links. Since we don't /// actually care about rendering them, just pretend that all broken links /// point to a fake address. @@ -542,11 +559,10 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ .trim() .to_string(); doc.pop(); - if doc.is_empty() { - return Some(DocHeaders { + return Some(DocInfo { empty: true, - ..DocHeaders::default() + doc_headers: DocHeaders::default(), }); } @@ -556,15 +572,18 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ let opts = main_body_opts() - Options::ENABLE_SMART_PUNCTUATION; let parser = pulldown_cmark::Parser::new_with_broken_link_callback(&doc, opts, Some(&mut cb)); - Some(check_doc( - cx, - valid_idents, - parser.into_offset_iter(), - Fragments { - fragments: &fragments, - doc: &doc, - }, - )) + Some(DocInfo { + empty: false, + doc_headers: check_doc( + cx, + valid_idents, + parser.into_offset_iter(), + Fragments { + fragments: &fragments, + doc: &doc, + }, + ), + }) } const RUST_CODE: &[&str] = &["rust", "no_run", "should_panic", "compile_fail"]; From 843eaf2e71f9a1ae564c5d24ec69c7a0c29e4e53 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 20 Feb 2024 16:09:49 -0300 Subject: [PATCH 310/417] Cranelift: Don't use raw-dylib in std --- .../0029-stdlib-rawdylib-processprng.patch | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch diff --git a/compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch b/compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch new file mode 100644 index 0000000000000..6af11e54d88af --- /dev/null +++ b/compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch @@ -0,0 +1,47 @@ +From 9f65e742ba3e41474e6126c6c4469c48eaa6ca7e Mon Sep 17 00:00:00 2001 +From: Chris Denton +Date: Tue, 20 Feb 2024 16:01:40 -0300 +Subject: [PATCH] Don't use raw-dylib in std + +--- + library/std/src/sys/pal/windows/c.rs | 2 +- + library/std/src/sys/pal/windows/rand.rs | 3 +-- + 2 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs +index ad8e01bfa9b..9ca8e4c16ce 100644 +--- a/library/std/src/sys/pal/windows/c.rs ++++ b/library/std/src/sys/pal/windows/c.rs +@@ -323,7 +323,7 @@ pub unsafe fn NtWriteFile( + + // Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. + cfg_if::cfg_if! { +-if #[cfg(not(target_vendor = "win7"))] { ++if #[cfg(any())] { + #[cfg(target_arch = "x86")] + #[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] + extern "system" { +diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs +index e427546222a..f2fe42a4d51 100644 +--- a/library/std/src/sys/pal/windows/rand.rs ++++ b/library/std/src/sys/pal/windows/rand.rs +@@ -2,7 +2,7 @@ + use core::mem; + use core::ptr; + +-#[cfg(not(target_vendor = "win7"))] ++#[cfg(any())] + #[inline] + pub fn hashmap_random_keys() -> (u64, u64) { + let mut v = (0, 0); +@@ -13,7 +13,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { + v + } + +-#[cfg(target_vendor = "win7")] + pub fn hashmap_random_keys() -> (u64, u64) { + use crate::ffi::c_void; + use crate::io; +-- +2.42.0.windows.2 + From 0ea449597e0d0c06dbfa5eccb2c7a785b7cec77e Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 17:23:15 +0400 Subject: [PATCH 311/417] pop before trimming --- clippy_lints/src/doc/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 78d46928f35eb..7b085a36ea5ec 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -550,15 +550,13 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ suspicious_doc_comments::check(cx, attrs); let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true); - let mut doc = fragments - .iter() - .fold(String::new(), |mut acc, fragment| { - add_doc_fragment(&mut acc, fragment); - acc - }) - .trim() - .to_string(); + let mut doc = fragments.iter().fold(String::new(), |mut acc, fragment| { + add_doc_fragment(&mut acc, fragment); + acc + }); doc.pop(); + let doc = doc.trim().to_string(); + if doc.is_empty() { return Some(DocInfo { empty: true, From ee0cbeaa77dd2c1c25d2da3df35df837efc6cd66 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 17:41:41 +0400 Subject: [PATCH 312/417] ignore empty comment in semicolon_if_nothing_returned --- tests/ui/semicolon_if_nothing_returned.fixed | 7 ++++++- tests/ui/semicolon_if_nothing_returned.rs | 7 ++++++- tests/ui/semicolon_if_nothing_returned.stderr | 10 +++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/ui/semicolon_if_nothing_returned.fixed b/tests/ui/semicolon_if_nothing_returned.fixed index cdfa5d9cc7804..6c8c835d0e0e3 100644 --- a/tests/ui/semicolon_if_nothing_returned.fixed +++ b/tests/ui/semicolon_if_nothing_returned.fixed @@ -1,7 +1,12 @@ //@aux-build:proc_macro_attr.rs #![warn(clippy::semicolon_if_nothing_returned)] -#![allow(clippy::redundant_closure, clippy::uninlined_format_args, clippy::needless_late_init)] +#![allow( + clippy::redundant_closure, + clippy::uninlined_format_args, + clippy::needless_late_init, + clippy::empty_docs +)] #[macro_use] extern crate proc_macro_attr; diff --git a/tests/ui/semicolon_if_nothing_returned.rs b/tests/ui/semicolon_if_nothing_returned.rs index 315b7e4f38399..2c2e4c0241904 100644 --- a/tests/ui/semicolon_if_nothing_returned.rs +++ b/tests/ui/semicolon_if_nothing_returned.rs @@ -1,7 +1,12 @@ //@aux-build:proc_macro_attr.rs #![warn(clippy::semicolon_if_nothing_returned)] -#![allow(clippy::redundant_closure, clippy::uninlined_format_args, clippy::needless_late_init)] +#![allow( + clippy::redundant_closure, + clippy::uninlined_format_args, + clippy::needless_late_init, + clippy::empty_docs +)] #[macro_use] extern crate proc_macro_attr; diff --git a/tests/ui/semicolon_if_nothing_returned.stderr b/tests/ui/semicolon_if_nothing_returned.stderr index 286cf512ed0b2..69e434b142cf4 100644 --- a/tests/ui/semicolon_if_nothing_returned.stderr +++ b/tests/ui/semicolon_if_nothing_returned.stderr @@ -1,5 +1,5 @@ error: consider adding a `;` to the last statement for consistent formatting - --> tests/ui/semicolon_if_nothing_returned.rs:13:5 + --> tests/ui/semicolon_if_nothing_returned.rs:18:5 | LL | println!("Hello") | ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");` @@ -8,25 +8,25 @@ LL | println!("Hello") = help: to override `-D warnings` add `#[allow(clippy::semicolon_if_nothing_returned)]` error: consider adding a `;` to the last statement for consistent formatting - --> tests/ui/semicolon_if_nothing_returned.rs:17:5 + --> tests/ui/semicolon_if_nothing_returned.rs:22:5 | LL | get_unit() | ^^^^^^^^^^ help: add a `;` here: `get_unit();` error: consider adding a `;` to the last statement for consistent formatting - --> tests/ui/semicolon_if_nothing_returned.rs:22:5 + --> tests/ui/semicolon_if_nothing_returned.rs:27:5 | LL | y = x + 1 | ^^^^^^^^^ help: add a `;` here: `y = x + 1;` error: consider adding a `;` to the last statement for consistent formatting - --> tests/ui/semicolon_if_nothing_returned.rs:28:9 + --> tests/ui/semicolon_if_nothing_returned.rs:33:9 | LL | hello() | ^^^^^^^ help: add a `;` here: `hello();` error: consider adding a `;` to the last statement for consistent formatting - --> tests/ui/semicolon_if_nothing_returned.rs:39:9 + --> tests/ui/semicolon_if_nothing_returned.rs:44:9 | LL | ptr::drop_in_place(s.as_mut_ptr()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` From 97e4c57f24d82d2bd938496b4a1af10372714ef7 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 17:51:58 +0400 Subject: [PATCH 313/417] fix lint doc --- clippy_lints/src/doc/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 7b085a36ea5ec..2984c5c15199d 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -345,13 +345,14 @@ declare_clippy_lint! { /// ### Why is this bad? /// It is unlikely that there is any reason to have empty documentation for an item /// ### Example - /// ```rust + /// ```rs /// /// /// fn returns_true() -> bool { /// true /// } + /// ``` /// Use instead: - /// ```rust + /// ```rs /// fn returns_true() -> bool { /// true /// } From 5a50cede295bc27768a970ec1a30f3bf8e95df74 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 18:01:53 +0400 Subject: [PATCH 314/417] add single letter test --- tests/ui/empty_docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/empty_docs.rs b/tests/ui/empty_docs.rs index 30b1f0ed2e2ce..77564c1c33df9 100644 --- a/tests/ui/empty_docs.rs +++ b/tests/ui/empty_docs.rs @@ -44,7 +44,7 @@ fn warn_about_this_as_well() { /// fn warn_inner_outer() { - //! what + //!w } fn this_is_ok() { From 3af67bba18f7a204a93831f3eafa26a73de11721 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 25 Feb 2024 16:28:38 +0100 Subject: [PATCH 315/417] Correctly handle if rustdoc JS script hash changed --- src/librustdoc/html/static/js/main.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index b26efb75ff657..b9a769a7c6da4 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -185,9 +185,12 @@ function preLoadCss(cssUrl) { (function() { const isHelpPage = window.location.pathname.endsWith("/help.html"); - function loadScript(url) { + function loadScript(url, errorCallback) { const script = document.createElement("script"); script.src = url; + if (errorCallback !== undefined) { + script.onerror = errorCallback; + } document.head.append(script); } @@ -292,11 +295,16 @@ function preLoadCss(cssUrl) { return; } let searchLoaded = false; + // If you're browsing the nightly docs, the page might need to be refreshed for the + // search to work because the hash of the JS scripts might have changed. + function sendSearchForm() { + document.getElementsByClassName("search-form")[0].submit(); + } function loadSearch() { if (!searchLoaded) { searchLoaded = true; - loadScript(getVar("static-root-path") + getVar("search-js")); - loadScript(resourcePath("search-index", ".js")); + loadScript(getVar("static-root-path") + getVar("search-js"), sendSearchForm); + loadScript(resourcePath("search-index", ".js"), sendSearchForm); } } From 9a56153c5ee0624c09cce2aaf6757407e17a1264 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 21 Jan 2024 16:40:06 +0100 Subject: [PATCH 316/417] [`single_call_fn`]: merge post-crate visitor into lint pass --- clippy_lints/src/lib.rs | 2 +- clippy_lints/src/single_call_fn.rs | 130 ++++++++++++++++------------- tests/ui/single_call_fn.rs | 22 +++++ tests/ui/single_call_fn.stderr | 72 ++++++++++------ 4 files changed, 141 insertions(+), 85 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 77b6775eb776a..76e759683145e 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1068,7 +1068,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { store.register_late_pass(move |_| { Box::new(single_call_fn::SingleCallFn { avoid_breaking_exported_api, - def_id_to_usage: rustc_data_structures::fx::FxHashMap::default(), + def_id_to_usage: rustc_data_structures::fx::FxIndexMap::default(), }) }); store.register_early_pass(move || { diff --git a/clippy_lints/src/single_call_fn.rs b/clippy_lints/src/single_call_fn.rs index 0387742077447..223cbb3fae106 100644 --- a/clippy_lints/src/single_call_fn.rs +++ b/clippy_lints/src/single_call_fn.rs @@ -1,11 +1,10 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::{is_from_proc_macro, is_in_test_function}; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; +use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; -use rustc_hir::{Body, Expr, ExprKind, FnDecl}; +use rustc_hir::{Expr, ExprKind, HirId, Node}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; use rustc_span::Span; @@ -54,82 +53,93 @@ declare_clippy_lint! { } impl_lint_pass!(SingleCallFn => [SINGLE_CALL_FN]); +#[derive(Debug, Clone)] +pub enum CallState { + Once { call_site: Span }, + Multiple, +} + #[derive(Clone)] pub struct SingleCallFn { pub avoid_breaking_exported_api: bool, - pub def_id_to_usage: FxHashMap)>, + pub def_id_to_usage: FxIndexMap, +} + +impl SingleCallFn { + fn is_function_allowed( + &self, + cx: &LateContext<'_>, + fn_def_id: LocalDefId, + fn_hir_id: HirId, + fn_span: Span, + ) -> bool { + (self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(fn_def_id)) + || in_external_macro(cx.sess(), fn_span) + || cx + .tcx + .hir() + .maybe_body_owned_by(fn_def_id) + .map(|body| cx.tcx.hir().body(body)) + .map_or(true, |body| is_in_test_function(cx.tcx, body.value.hir_id)) + || match cx.tcx.hir_node(fn_hir_id) { + Node::Item(item) => is_from_proc_macro(cx, item), + Node::ImplItem(item) => is_from_proc_macro(cx, item), + Node::TraitItem(item) => is_from_proc_macro(cx, item), + _ => true, + } + } +} + +/// Whether a called function is a kind of item that the lint cares about. +/// For example, calling an `extern "C" { fn fun(); }` only once is totally fine and does not +/// to be considered. +fn is_valid_item_kind(cx: &LateContext<'_>, def_id: LocalDefId) -> bool { + matches!( + cx.tcx.hir_node(cx.tcx.local_def_id_to_hir_id(def_id)), + Node::Item(_) | Node::ImplItem(_) | Node::TraitItem(_) + ) } impl<'tcx> LateLintPass<'tcx> for SingleCallFn { - fn check_fn( - &mut self, - cx: &LateContext<'tcx>, - kind: FnKind<'tcx>, - _: &'tcx FnDecl<'_>, - body: &'tcx Body<'_>, - span: Span, - def_id: LocalDefId, - ) { - if self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(def_id) - || in_external_macro(cx.sess(), span) - || is_in_test_function(cx.tcx, body.value.hir_id) - || is_from_proc_macro(cx, &(&kind, body, cx.tcx.local_def_id_to_hir_id(def_id), span)) + fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) { + if let ExprKind::Path(qpath) = expr.kind + && let res = cx.qpath_res(&qpath, expr.hir_id) + && let Some(call_def_id) = res.opt_def_id() + && let Some(def_id) = call_def_id.as_local() + && let DefKind::Fn | DefKind::AssocFn = cx.tcx.def_kind(def_id) + && is_valid_item_kind(cx, def_id) { - return; + match self.def_id_to_usage.entry(def_id) { + IndexEntry::Occupied(mut entry) => { + if let CallState::Once { .. } = entry.get() { + entry.insert(CallState::Multiple); + } + }, + IndexEntry::Vacant(entry) => { + entry.insert(CallState::Once { call_site: expr.span }); + }, + } } - - self.def_id_to_usage.insert(def_id, (span, vec![])); } fn check_crate_post(&mut self, cx: &LateContext<'tcx>) { - let mut v = FnUsageVisitor { - cx, - def_id_to_usage: &mut self.def_id_to_usage, - }; - cx.tcx.hir().visit_all_item_likes_in_crate(&mut v); - for (&def_id, usage) in &self.def_id_to_usage { - let single_call_fn_span = usage.0; - if let [caller_span] = *usage.1 { + if let CallState::Once { call_site } = *usage + && let fn_hir_id = cx.tcx.local_def_id_to_hir_id(def_id) + && let fn_span = cx.tcx.hir().span_with_body(fn_hir_id) + && !self.is_function_allowed(cx, def_id, fn_hir_id, fn_span) + { span_lint_hir_and_then( cx, SINGLE_CALL_FN, - cx.tcx.local_def_id_to_hir_id(def_id), - single_call_fn_span, + fn_hir_id, + fn_span, "this function is only used once", |diag| { - diag.span_help(caller_span, "used here"); + diag.span_note(call_site, "used here"); }, ); } } } } - -struct FnUsageVisitor<'a, 'tcx> { - cx: &'a LateContext<'tcx>, - def_id_to_usage: &'a mut FxHashMap)>, -} - -impl<'a, 'tcx> Visitor<'tcx> for FnUsageVisitor<'a, 'tcx> { - type NestedFilter = OnlyBodies; - - fn nested_visit_map(&mut self) -> Self::Map { - self.cx.tcx.hir() - } - - fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { - let Self { cx, .. } = *self; - - if let ExprKind::Path(qpath) = expr.kind - && let res = cx.qpath_res(&qpath, expr.hir_id) - && let Some(call_def_id) = res.opt_def_id() - && let Some(def_id) = call_def_id.as_local() - && let Some(usage) = self.def_id_to_usage.get_mut(&def_id) - { - usage.1.push(expr.span); - } - - walk_expr(self, expr); - } -} diff --git a/tests/ui/single_call_fn.rs b/tests/ui/single_call_fn.rs index c20214fecccea..55e7508a9573a 100644 --- a/tests/ui/single_call_fn.rs +++ b/tests/ui/single_call_fn.rs @@ -84,3 +84,25 @@ mod issue12182 { fn l() { k(); } + +trait Trait { + fn default() {} + fn foo(&self); +} +extern "C" { + // test some kind of foreign item + fn rand() -> std::ffi::c_int; +} +fn m(v: T) { + const NOT_A_FUNCTION: i32 = 1; + let _ = NOT_A_FUNCTION; + + struct S; + impl S { + fn foo() {} + } + T::default(); + S::foo(); + v.foo(); + unsafe { rand() }; +} diff --git a/tests/ui/single_call_fn.stderr b/tests/ui/single_call_fn.stderr index f48b78c94e9a4..14529beac616a 100644 --- a/tests/ui/single_call_fn.stderr +++ b/tests/ui/single_call_fn.stderr @@ -1,3 +1,29 @@ +error: this function is only used once + --> tests/ui/single_call_fn.rs:13:1 + | +LL | fn i() {} + | ^^^^^^^^^ + | +note: used here + --> tests/ui/single_call_fn.rs:18:13 + | +LL | let a = i; + | ^ + = note: `-D clippy::single-call-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_call_fn)]` + +error: this function is only used once + --> tests/ui/single_call_fn.rs:14:1 + | +LL | fn j() {} + | ^^^^^^^^^ + | +note: used here + --> tests/ui/single_call_fn.rs:25:9 + | +LL | j(); + | ^ + error: this function is only used once --> tests/ui/single_call_fn.rs:34:1 | @@ -8,25 +34,11 @@ LL | | println!("function..."); LL | | } | |_^ | -help: used here +note: used here --> tests/ui/single_call_fn.rs:41:5 | LL | c(); | ^ - = note: `-D clippy::single-call-fn` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::single_call_fn)]` - -error: this function is only used once - --> tests/ui/single_call_fn.rs:13:1 - | -LL | fn i() {} - | ^^^^^^^^^ - | -help: used here - --> tests/ui/single_call_fn.rs:18:13 - | -LL | let a = i; - | ^ error: this function is only used once --> tests/ui/single_call_fn.rs:44:1 @@ -34,23 +46,35 @@ error: this function is only used once LL | fn a() {} | ^^^^^^^^^ | -help: used here +note: used here --> tests/ui/single_call_fn.rs:47:5 | LL | a(); | ^ error: this function is only used once - --> tests/ui/single_call_fn.rs:14:1 + --> tests/ui/single_call_fn.rs:89:5 | -LL | fn j() {} - | ^^^^^^^^^ +LL | fn default() {} + | ^^^^^^^^^^^^^^^ | -help: used here - --> tests/ui/single_call_fn.rs:25:9 +note: used here + --> tests/ui/single_call_fn.rs:104:5 | -LL | j(); - | ^ +LL | T::default(); + | ^^^^^^^^^^ + +error: this function is only used once + --> tests/ui/single_call_fn.rs:102:9 + | +LL | fn foo() {} + | ^^^^^^^^^^^ + | +note: used here + --> tests/ui/single_call_fn.rs:105:5 + | +LL | S::foo(); + | ^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 6 previous errors From bee4111a610dc8adb04543f32fad18f5b85f1051 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sun, 25 Feb 2024 16:32:54 +0000 Subject: [PATCH 317/417] Remove `clippy_utils::get_parent_node` --- clippy_lints/src/box_default.rs | 4 ++-- clippy_lints/src/casts/unnecessary_cast.rs | 4 ++-- clippy_lints/src/collection_is_never_read.rs | 8 ++++---- clippy_lints/src/dereference.rs | 6 ++---- clippy_lints/src/drop_forget_ref.rs | 4 ++-- clippy_lints/src/iter_not_returning_iterator.rs | 3 +-- clippy_lints/src/matches/needless_match.rs | 4 ++-- clippy_lints/src/methods/clone_on_copy.rs | 3 +-- clippy_lints/src/methods/needless_collect.rs | 6 +++--- clippy_lints/src/needless_bool.rs | 5 ++--- clippy_lints/src/needless_pass_by_ref_mut.rs | 4 ++-- clippy_lints/src/no_effect.rs | 4 ++-- clippy_lints/src/non_canonical_impls.rs | 4 ++-- clippy_lints/src/only_used_in_recursion.rs | 6 +++--- clippy_lints/src/question_mark.rs | 8 ++++---- clippy_lints/src/redundant_closure_call.rs | 4 ++-- clippy_lints/src/strlen_on_c_strings.rs | 4 ++-- clippy_lints/src/undocumented_unsafe_blocks.rs | 12 ++++++------ clippy_lints/src/unit_types/let_unit_value.rs | 3 +-- clippy_utils/src/lib.rs | 9 ++------- 20 files changed, 47 insertions(+), 58 deletions(-) diff --git a/clippy_lints/src/box_default.rs b/clippy_lints/src/box_default.rs index d71cca6aa4f42..d9e63f0d047f3 100644 --- a/clippy_lints/src/box_default.rs +++ b/clippy_lints/src/box_default.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::macros::macro_backtrace; use clippy_utils::ty::expr_sig; -use clippy_utils::{get_parent_node, is_default_equivalent, path_def_id}; +use clippy_utils::{is_default_equivalent, path_def_id}; use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::intravisit::{walk_ty, Visitor}; @@ -100,7 +100,7 @@ impl<'tcx> Visitor<'tcx> for InferVisitor { } fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - match get_parent_node(cx.tcx, expr.hir_id) { + match cx.tcx.parent_hir_node(expr.hir_id) { Node::Local(Local { ty: Some(ty), .. }) => { let mut v = InferVisitor::default(); v.visit_ty(ty); diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index 3800d32eedc7c..cc513d46bf4ec 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::numeric_literal::NumericLiteral; use clippy_utils::source::snippet_opt; use clippy_utils::visitors::{for_each_expr, Visitable}; -use clippy_utils::{get_parent_expr, get_parent_node, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; +use clippy_utils::{get_parent_expr, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; use rustc_ast::{LitFloatType, LitIntType, LitKind}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; @@ -264,7 +264,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx } // Local usage } else if let Res::Local(hir_id) = res - && let Node::Local(l) = get_parent_node(cx.tcx, hir_id) + && let Node::Local(l) = cx.tcx.parent_hir_node(hir_id) { if let Some(e) = l.init && is_cast_from_ty_alias(cx, e, cast_from) diff --git a/clippy_lints/src/collection_is_never_read.rs b/clippy_lints/src/collection_is_never_read.rs index 5ab52312843e0..d820413e11129 100644 --- a/clippy_lints/src/collection_is_never_read.rs +++ b/clippy_lints/src/collection_is_never_read.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use clippy_utils::visitors::for_each_expr_with_closures; -use clippy_utils::{get_enclosing_block, get_parent_node, path_to_local_id}; +use clippy_utils::{get_enclosing_block, path_to_local_id}; use core::ops::ControlFlow; use rustc_hir::{Block, ExprKind, HirId, LangItem, Local, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -94,7 +94,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc // `id` appearing in the left-hand side of an assignment is not a read access: // // id = ...; // Not reading `id`. - if let Node::Expr(parent) = get_parent_node(cx.tcx, expr.hir_id) + if let Node::Expr(parent) = cx.tcx.parent_hir_node(expr.hir_id) && let ExprKind::Assign(lhs, ..) = parent.kind && path_to_local_id(lhs, id) { @@ -108,7 +108,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc // Only assuming this for "official" methods defined on the type. For methods defined in extension // traits (identified as local, based on the orphan rule), pessimistically assume that they might // have side effects, so consider them a read. - if let Node::Expr(parent) = get_parent_node(cx.tcx, expr.hir_id) + if let Node::Expr(parent) = cx.tcx.parent_hir_node(expr.hir_id) && let ExprKind::MethodCall(_, receiver, _, _) = parent.kind && path_to_local_id(receiver, id) && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id) @@ -117,7 +117,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc // The method call is a statement, so the return value is not used. That's not a read access: // // id.foo(args); - if let Node::Stmt(..) = get_parent_node(cx.tcx, parent.hir_id) { + if let Node::Stmt(..) = cx.tcx.parent_hir_node(parent.hir_id) { return ControlFlow::Continue(()); } diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index e6eb5088c2b28..560b2acc1c702 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -2,9 +2,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then}; use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::sugg::has_enclosing_paren; use clippy_utils::ty::{implements_trait, is_manually_drop, peel_mid_ty_refs}; -use clippy_utils::{ - expr_use_ctxt, get_parent_expr, get_parent_node, is_lint_allowed, path_to_local, DefinedTy, ExprUseNode, -}; +use clippy_utils::{expr_use_ctxt, get_parent_expr, is_lint_allowed, path_to_local, DefinedTy, ExprUseNode}; use core::mem; use rustc_ast::util::parser::{PREC_POSTFIX, PREC_PREFIX}; use rustc_data_structures::fx::FxIndexMap; @@ -1008,7 +1006,7 @@ fn report<'tcx>( data.first_expr.span, state.msg, |diag| { - let (precedence, calls_field) = match get_parent_node(cx.tcx, data.first_expr.hir_id) { + let (precedence, calls_field) = match cx.tcx.parent_hir_node(data.first_expr.hir_id) { Node::Expr(e) => match e.kind { ExprKind::Call(callee, _) if callee.hir_id != data.first_expr.hir_id => (0, false), ExprKind::Call(..) => (PREC_POSTFIX, matches!(expr.kind, ExprKind::Field(..))), diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index da1dcba7d339c..bf6f54c1e72a3 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::is_must_use_func_call; use clippy_utils::ty::{is_copy, is_must_use_ty, is_type_lang_item}; -use clippy_utils::{get_parent_node, is_must_use_func_call}; use rustc_hir::{Arm, Expr, ExprKind, LangItem, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { // } fn is_single_call_in_arm<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'_>, drop_expr: &'tcx Expr<'_>) -> bool { if matches!(arg.kind, ExprKind::Call(..) | ExprKind::MethodCall(..)) { - if let Node::Arm(Arm { body, .. }) = get_parent_node(cx.tcx, drop_expr.hir_id) { + if let Node::Arm(Arm { body, .. }) = cx.tcx.parent_hir_node(drop_expr.hir_id) { return body.hir_id == drop_expr.hir_id; } } diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index 2344f040522ba..32ae6be568735 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint; -use clippy_utils::get_parent_node; use clippy_utils::ty::implements_trait; use rustc_hir::def_id::LocalDefId; use rustc_hir::{FnSig, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind}; @@ -56,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator { let name = item.ident.name.as_str(); if matches!(name, "iter" | "iter_mut") && !matches!( - get_parent_node(cx.tcx, item.hir_id()), + cx.tcx.parent_hir_node(item.hir_id()), Node::Item(Item { kind: ItemKind::Impl(i), .. }) if i.of_trait.is_some() ) { diff --git a/clippy_lints/src/matches/needless_match.rs b/clippy_lints/src/matches/needless_match.rs index 2ee7bce99623c..3d3f29e5fc6c0 100644 --- a/clippy_lints/src/matches/needless_match.rs +++ b/clippy_lints/src/matches/needless_match.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, same_type_and_consts}; use clippy_utils::{ - eq_expr_value, get_parent_expr_for_hir, get_parent_node, higher, is_else_clause, is_res_lang_ctor, over, path_res, + eq_expr_value, get_parent_expr_for_hir, higher, is_else_clause, is_res_lang_ctor, over, path_res, peel_blocks_with_stmt, }; use rustc_errors::Applicability; @@ -123,7 +123,7 @@ fn strip_return<'hir>(expr: &'hir Expr<'hir>) -> &'hir Expr<'hir> { /// Manually check for coercion casting by checking if the type of the match operand or let expr /// differs with the assigned local variable or the function return type. fn expr_ty_matches_p_ty(cx: &LateContext<'_>, expr: &Expr<'_>, p_expr: &Expr<'_>) -> bool { - match get_parent_node(cx.tcx, p_expr.hir_id) { + match cx.tcx.parent_hir_node(p_expr.hir_id) { // Compare match_expr ty with local in `let local = match match_expr {..}` Node::Local(local) => { let results = cx.typeck_results(); diff --git a/clippy_lints/src/methods/clone_on_copy.rs b/clippy_lints/src/methods/clone_on_copy.rs index 8736341f6feef..fb5c0c544a95b 100644 --- a/clippy_lints/src/methods/clone_on_copy.rs +++ b/clippy_lints/src/methods/clone_on_copy.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::get_parent_node; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::is_copy; use rustc_errors::Applicability; @@ -48,7 +47,7 @@ pub(super) fn check( } if is_copy(cx, ty) { - let parent_is_suffix_expr = match get_parent_node(cx.tcx, expr.hir_id) { + let parent_is_suffix_expr = match cx.tcx.parent_hir_node(expr.hir_id) { Node::Expr(parent) => match parent.kind { // &*x is a nop, &x.clone() is not ExprKind::AddrOf(..) => return, diff --git a/clippy_lints/src/methods/needless_collect.rs b/clippy_lints/src/methods/needless_collect.rs index 8363b57169f35..55050ae693e76 100644 --- a/clippy_lints/src/methods/needless_collect.rs +++ b/clippy_lints/src/methods/needless_collect.rs @@ -4,8 +4,8 @@ use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::sugg::Sugg; use clippy_utils::ty::{is_type_diagnostic_item, make_normalized_projection, make_projection}; use clippy_utils::{ - can_move_expr_to_closure, fn_def_id, get_enclosing_block, get_parent_node, higher, is_trait_method, path_to_local, - path_to_local_id, CaptureKind, + can_move_expr_to_closure, fn_def_id, get_enclosing_block, higher, is_trait_method, path_to_local, path_to_local_id, + CaptureKind, }; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Applicability, MultiSpan}; @@ -28,7 +28,7 @@ pub(super) fn check<'tcx>( iter_expr: &'tcx Expr<'tcx>, call_span: Span, ) { - match get_parent_node(cx.tcx, collect_expr.hir_id) { + match cx.tcx.parent_hir_node(collect_expr.hir_id) { Node::Expr(parent) => { check_collect_into_intoiterator(cx, parent, collect_expr, call_span, iter_expr); diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 99917213bc3dd..166a7f71d695b 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -6,8 +6,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sugg::Sugg; use clippy_utils::{ - get_parent_node, higher, is_else_clause, is_expn_of, peel_blocks, peel_blocks_with_stmt, span_extract_comment, - SpanlessEq, + higher, is_else_clause, is_expn_of, peel_blocks, peel_blocks_with_stmt, span_extract_comment, SpanlessEq, }; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; @@ -138,7 +137,7 @@ fn condition_needs_parentheses(e: &Expr<'_>) -> bool { fn is_parent_stmt(cx: &LateContext<'_>, id: HirId) -> bool { matches!( - get_parent_node(cx.tcx, id), + cx.tcx.parent_hir_node(id), Node::Stmt(..) | Node::Block(Block { stmts: &[], .. }) ) } diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index f8b321c31a866..a5b58f9910ad5 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -2,7 +2,7 @@ use super::needless_pass_by_value::requires_exact_signature; use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::source::snippet; use clippy_utils::visitors::for_each_expr_with_closures; -use clippy_utils::{get_parent_node, inherits_cfg, is_from_proc_macro, is_self}; +use clippy_utils::{inherits_cfg, is_from_proc_macro, is_self}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; @@ -239,7 +239,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> { && let ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(expr).kind() && let Some(def_id) = def_id.as_local() { - if let Node::Expr(e) = get_parent_node(cx.tcx, expr.hir_id) + if let Node::Expr(e) = cx.tcx.parent_hir_node(expr.hir_id) && let ExprKind::Call(call, _) = e.kind && call.hir_id == expr.hir_id { diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 5014445843f8d..cac34c8ce06e9 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::has_drop; -use clippy_utils::{any_parent_is_automatically_derived, get_parent_node, is_lint_allowed, path_to_local, peel_blocks}; +use clippy_utils::{any_parent_is_automatically_derived, is_lint_allowed, path_to_local, peel_blocks}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{ @@ -140,7 +140,7 @@ impl NoEffect { for parent in cx.tcx.hir().parent_iter(stmt.hir_id) { if let Node::Item(item) = parent.1 && let ItemKind::Fn(..) = item.kind - && let Node::Block(block) = get_parent_node(cx.tcx, stmt.hir_id) + && let Node::Block(block) = cx.tcx.parent_hir_node(stmt.hir_id) && let [.., final_stmt] = block.stmts && final_stmt.hir_id == stmt.hir_id { diff --git a/clippy_lints/src/non_canonical_impls.rs b/clippy_lints/src/non_canonical_impls.rs index 35c43a5b649b3..fd3985a5dafcf 100644 --- a/clippy_lints/src/non_canonical_impls.rs +++ b/clippy_lints/src/non_canonical_impls.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::ty::implements_trait; -use clippy_utils::{get_parent_node, is_res_lang_ctor, last_path_segment, path_res, std_or_core}; +use clippy_utils::{is_res_lang_ctor, last_path_segment, path_res, std_or_core}; use rustc_errors::Applicability; use rustc_hir::def_id::LocalDefId; use rustc_hir::{Expr, ExprKind, ImplItem, ImplItemKind, LangItem, Node, UnOp}; @@ -112,7 +112,7 @@ declare_lint_pass!(NonCanonicalImpls => [NON_CANONICAL_CLONE_IMPL, NON_CANONICAL impl LateLintPass<'_> for NonCanonicalImpls { #[expect(clippy::too_many_lines)] fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &ImplItem<'_>) { - let Node::Item(item) = get_parent_node(cx.tcx, impl_item.hir_id()) else { + let Node::Item(item) = cx.tcx.parent_hir_node(impl_item.hir_id()) else { return; }; let Some(trait_impl) = cx.tcx.impl_trait_ref(item.owner_id).map(EarlyBinder::skip_binder) else { diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index 9fa0edb10c568..b3ff5ecae862c 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{get_expr_use_or_unification_node, get_parent_node, path_def_id, path_to_local, path_to_local_id}; +use clippy_utils::{get_expr_use_or_unification_node, path_def_id, path_to_local, path_to_local_id}; use core::cell::Cell; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; @@ -227,7 +227,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion { } // `skip_params` is either `0` or `1` to skip the `self` parameter in trait functions. // It can't be renamed, and it can't be removed without removing it from multiple functions. - let (fn_id, fn_kind, skip_params) = match get_parent_node(cx.tcx, body.value.hir_id) { + let (fn_id, fn_kind, skip_params) = match cx.tcx.parent_hir_node(body.value.hir_id) { Node::Item(i) => (i.owner_id.to_def_id(), FnKind::Fn, 0), Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(ref sig, _), @@ -244,7 +244,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion { .. }) => { #[allow(trivial_casts)] - if let Node::Item(item) = get_parent_node(cx.tcx, owner_id.into()) + if let Node::Item(item) = cx.tcx.parent_hir_node(owner_id.into()) && let Some(trait_ref) = cx .tcx .impl_trait_ref(item.owner_id) diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index b5da27d7993b8..27ed5458ce28c 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -6,9 +6,9 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{ - eq_expr_value, get_parent_node, higher, in_constant, is_else_clause, is_lint_allowed, is_path_lang_item, - is_res_lang_ctor, pat_and_expr_can_be_question_mark, path_to_local, path_to_local_id, peel_blocks, - peel_blocks_with_stmt, span_contains_comment, + eq_expr_value, higher, in_constant, is_else_clause, is_lint_allowed, is_path_lang_item, is_res_lang_ctor, + pat_and_expr_can_be_question_mark, path_to_local, path_to_local_id, peel_blocks, peel_blocks_with_stmt, + span_contains_comment, }; use rustc_errors::Applicability; use rustc_hir::def::Res; @@ -289,7 +289,7 @@ impl QuestionMark { { let mut applicability = Applicability::MachineApplicable; let receiver_str = snippet_with_applicability(cx, let_expr.span, "..", &mut applicability); - let requires_semi = matches!(get_parent_node(cx.tcx, expr.hir_id), Node::Stmt(_)); + let requires_semi = matches!(cx.tcx.parent_hir_node(expr.hir_id), Node::Stmt(_)); let sugg = format!( "{receiver_str}{}?{}", if by_ref == ByRef::Yes { ".as_ref()" } else { "" }, diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 8d5b3ca21dcff..e3f0ce2a92206 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -1,7 +1,7 @@ use crate::rustc_lint::LintContext; use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; +use clippy_utils::get_parent_expr; use clippy_utils::sugg::Sugg; -use clippy_utils::{get_parent_expr, get_parent_node}; use hir::Param; use rustc_errors::Applicability; use rustc_hir as hir; @@ -200,7 +200,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall { hint = hint.asyncify(); } - let is_in_fn_call_arg = if let Node::Expr(expr) = get_parent_node(cx.tcx, expr.hir_id) { + let is_in_fn_call_arg = if let Node::Expr(expr) = cx.tcx.parent_hir_node(expr.hir_id) { matches!(expr.kind, hir::ExprKind::Call(_, _)) } else { false diff --git a/clippy_lints/src/strlen_on_c_strings.rs b/clippy_lints/src/strlen_on_c_strings.rs index 8cb59caa5736d..1ada7094dc550 100644 --- a/clippy_lints/src/strlen_on_c_strings.rs +++ b/clippy_lints/src/strlen_on_c_strings.rs @@ -1,8 +1,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::match_libc_symbol; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use clippy_utils::visitors::is_expr_unsafe; -use clippy_utils::{get_parent_node, match_libc_symbol}; use rustc_errors::Applicability; use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, LangItem, Node, UnsafeSource}; use rustc_lint::{LateContext, LateLintPass}; @@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for StrlenOnCStrings { && path.ident.name == sym::as_ptr { let ctxt = expr.span.ctxt(); - let span = match get_parent_node(cx.tcx, expr.hir_id) { + let span = match cx.tcx.parent_hir_node(expr.hir_id) { Node::Block(&Block { rules: BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided), span, diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index 86882cc374bf6..559d7ace40edc 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -1,9 +1,9 @@ use std::ops::ControlFlow; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_lint_allowed; use clippy_utils::source::walk_span_to_context; use clippy_utils::visitors::{for_each_expr_with_closures, Descend}; -use clippy_utils::{get_parent_node, is_lint_allowed}; use hir::HirId; use rustc_data_structures::sync::Lrc; use rustc_hir as hir; @@ -340,8 +340,8 @@ fn block_parents_have_safety_comment( cx: &LateContext<'_>, id: hir::HirId, ) -> bool { - let (span, hir_id) = match get_parent_node(cx.tcx, id) { - Node::Expr(expr) => match get_parent_node(cx.tcx, expr.hir_id) { + let (span, hir_id) = match cx.tcx.parent_hir_node(id) { + Node::Expr(expr) => match cx.tcx.parent_hir_node(expr.hir_id) { Node::Local(hir::Local { span, hir_id, .. }) => (*span, *hir_id), Node::Item(hir::Item { kind: hir::ItemKind::Const(..) | ItemKind::Static(..), @@ -445,7 +445,7 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> HasSaf if item.span.ctxt() != SyntaxContext::root() { return HasSafetyComment::No; } - let comment_start = match get_parent_node(cx.tcx, item.hir_id()) { + let comment_start = match cx.tcx.parent_hir_node(item.hir_id()) { Node::Crate(parent_mod) => comment_start_before_item_in_mod(cx, parent_mod, parent_mod.spans.inner_span, item), Node::Item(parent_item) => { if let ItemKind::Mod(parent_mod) = &parent_item.kind { @@ -456,7 +456,7 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> HasSaf } }, Node::Stmt(stmt) => { - if let Node::Block(block) = get_parent_node(cx.tcx, stmt.hir_id) { + if let Node::Block(block) = cx.tcx.parent_hir_node(stmt.hir_id) { walk_span_to_context(block.span, SyntaxContext::root()).map(Span::lo) } else { // Problem getting the parent node. Pretend a comment was found. @@ -504,7 +504,7 @@ fn stmt_has_safety_comment(cx: &LateContext<'_>, span: Span, hir_id: HirId) -> H return HasSafetyComment::No; } - let comment_start = match get_parent_node(cx.tcx, hir_id) { + let comment_start = match cx.tcx.parent_hir_node(hir_id) { Node::Block(block) => walk_span_to_context(block.span, SyntaxContext::root()).map(Span::lo), _ => return HasSafetyComment::Maybe, }; diff --git a/clippy_lints/src/unit_types/let_unit_value.rs b/clippy_lints/src/unit_types/let_unit_value.rs index 1b10169a3f27a..9406d16076957 100644 --- a/clippy_lints/src/unit_types/let_unit_value.rs +++ b/clippy_lints/src/unit_types/let_unit_value.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::get_parent_node; use clippy_utils::source::snippet_with_context; use clippy_utils::visitors::{for_each_local_assignment, for_each_value_source}; use core::ops::ControlFlow; @@ -103,7 +102,7 @@ fn expr_needs_inferred_result<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) - return false; } while let Some(id) = locals_to_check.pop() { - if let Node::Local(l) = get_parent_node(cx.tcx, id) { + if let Node::Local(l) = cx.tcx.parent_hir_node(id) { if !l.ty.map_or(true, |ty| matches!(ty.kind, TyKind::Infer)) { return false; } diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index b130322701e6d..708037a465558 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1307,11 +1307,6 @@ pub fn contains_return<'tcx>(expr: impl Visitable<'tcx>) -> bool { .is_some() } -/// Gets the parent node, if any. -pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Node<'_> { - tcx.parent_hir_node(id) -} - /// Gets the parent expression, if any –- this is useful to constrain a lint. pub fn get_parent_expr<'tcx>(cx: &LateContext<'tcx>, e: &Expr<'_>) -> Option<&'tcx Expr<'tcx>> { get_parent_expr_for_hir(cx, e.hir_id) @@ -1320,7 +1315,7 @@ pub fn get_parent_expr<'tcx>(cx: &LateContext<'tcx>, e: &Expr<'_>) -> Option<&'t /// This retrieves the parent for the given `HirId` if it's an expression. This is useful for /// constraint lints pub fn get_parent_expr_for_hir<'tcx>(cx: &LateContext<'tcx>, hir_id: hir::HirId) -> Option<&'tcx Expr<'tcx>> { - match get_parent_node(cx.tcx, hir_id) { + match cx.tcx.parent_hir_node(hir_id) { Node::Expr(parent) => Some(parent), _ => None, } @@ -2182,7 +2177,7 @@ pub fn is_expr_used_or_unified(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { /// Checks if the expression is the final expression returned from a block. pub fn is_expr_final_block_expr(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { - matches!(get_parent_node(tcx, expr.hir_id), Node::Block(..)) + matches!(tcx.parent_hir_node(expr.hir_id), Node::Block(..)) } pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> { From f32e92cdc9a1a33bf82fe4c4b77ec52169b45701 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 21:18:38 +0400 Subject: [PATCH 318/417] add 1 more test and dont trim other code --- clippy_lints/src/doc/mod.rs | 5 ++--- tests/ui/empty_docs.rs | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 2984c5c15199d..8b6256a50f4fd 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -17,7 +17,7 @@ use rustc_hir::{AnonConst, Expr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; -use rustc_middle::ty; +use rustc_middle::ty::{self}; use rustc_resolve::rustdoc::{ add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, DocFragment, }; @@ -556,9 +556,8 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ acc }); doc.pop(); - let doc = doc.trim().to_string(); - if doc.is_empty() { + if doc.trim().is_empty() { return Some(DocInfo { empty: true, doc_headers: DocHeaders::default(), diff --git a/tests/ui/empty_docs.rs b/tests/ui/empty_docs.rs index 77564c1c33df9..f5b4bb6736d13 100644 --- a/tests/ui/empty_docs.rs +++ b/tests/ui/empty_docs.rs @@ -59,3 +59,5 @@ fn warn() { fn dont_warn() { /*! dont warn me */ } + +trait NoDoc {} From d7ad85f521d94bed54ca74e9f14f327904fa6fe2 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 21:26:43 +0400 Subject: [PATCH 319/417] move the the check into check_atr function --- clippy_lints/src/doc/empty_docs.rs | 1 - clippy_lints/src/doc/mod.rs | 57 ++++++++---------------------- 2 files changed, 15 insertions(+), 43 deletions(-) diff --git a/clippy_lints/src/doc/empty_docs.rs b/clippy_lints/src/doc/empty_docs.rs index bd5aeba922b59..b0be711396166 100644 --- a/clippy_lints/src/doc/empty_docs.rs +++ b/clippy_lints/src/doc/empty_docs.rs @@ -7,7 +7,6 @@ use super::EMPTY_DOCS; // TODO: Adjust the parameters as necessary pub(super) fn check(cx: &LateContext<'_>, attrs: &[Attribute]) { let doc_attrs: Vec<_> = attrs.iter().filter(|attr| attr.doc_str().is_some()).collect(); - let span; if let Some(first) = doc_attrs.first() && let Some(last) = doc_attrs.last() diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 8b6256a50f4fd..5690bd1d1ba30 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -401,18 +401,10 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - let Some(DocInfo { - empty, - doc_headers: headers, - }) = check_attrs(cx, &self.valid_idents, attrs) - else { + let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return; }; - if empty && !item.span.is_dummy() { - empty_docs::check(cx, attrs); - } - match item.kind { hir::ItemKind::Fn(ref sig, _, body_id) => { if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) { @@ -460,11 +452,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - let Some(DocInfo { - empty: _, - doc_headers: headers, - }) = check_attrs(cx, &self.valid_idents, attrs) - else { + let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return; }; if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind { @@ -476,11 +464,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - let Some(DocInfo { - empty: _, - doc_headers: headers, - }) = check_attrs(cx, &self.valid_idents, attrs) - else { + let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return; }; if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) { @@ -522,12 +506,6 @@ struct DocHeaders { panics: bool, } -#[derive(Copy, Clone, Default)] -struct DocInfo { - empty: bool, - doc_headers: DocHeaders, -} - /// Does some pre-processing on raw, desugared `#[doc]` attributes such as parsing them and /// then delegates to `check_doc`. /// Some lints are already checked here if they can work with attributes directly and don't need @@ -535,7 +513,7 @@ struct DocInfo { /// Others are checked elsewhere, e.g. in `check_doc` if they need access to markdown, or /// back in the various late lint pass methods if they need the final doc headers, like "Safety" or /// "Panics" sections. -fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[Attribute]) -> Option { +fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[Attribute]) -> Option { /// We don't want the parser to choke on intra doc links. Since we don't /// actually care about rendering them, just pretend that all broken links /// point to a fake address. @@ -558,10 +536,8 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ doc.pop(); if doc.trim().is_empty() { - return Some(DocInfo { - empty: true, - doc_headers: DocHeaders::default(), - }); + empty_docs::check(cx, attrs); + return Some(DocHeaders::default()); } let mut cb = fake_broken_link_callback; @@ -570,18 +546,15 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ let opts = main_body_opts() - Options::ENABLE_SMART_PUNCTUATION; let parser = pulldown_cmark::Parser::new_with_broken_link_callback(&doc, opts, Some(&mut cb)); - Some(DocInfo { - empty: false, - doc_headers: check_doc( - cx, - valid_idents, - parser.into_offset_iter(), - Fragments { - fragments: &fragments, - doc: &doc, - }, - ), - }) + Some(check_doc( + cx, + valid_idents, + parser.into_offset_iter(), + Fragments { + fragments: &fragments, + doc: &doc, + }, + )) } const RUST_CODE: &[&str] = &["rust", "no_run", "should_panic", "compile_fail"]; From f066be7e1ed36e173edaf008c695420112966c8f Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 21:31:46 +0400 Subject: [PATCH 320/417] use span of fragments --- clippy_lints/src/doc/empty_docs.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/doc/empty_docs.rs b/clippy_lints/src/doc/empty_docs.rs index b0be711396166..84cbc3207f345 100644 --- a/clippy_lints/src/doc/empty_docs.rs +++ b/clippy_lints/src/doc/empty_docs.rs @@ -1,17 +1,13 @@ +use super::EMPTY_DOCS; use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::Attribute; use rustc_lint::LateContext; - -use super::EMPTY_DOCS; +use rustc_resolve::rustdoc::{attrs_to_doc_fragments, span_of_fragments}; // TODO: Adjust the parameters as necessary pub(super) fn check(cx: &LateContext<'_>, attrs: &[Attribute]) { - let doc_attrs: Vec<_> = attrs.iter().filter(|attr| attr.doc_str().is_some()).collect(); - let span; - if let Some(first) = doc_attrs.first() - && let Some(last) = doc_attrs.last() - { - span = first.span.with_hi(last.span.hi()); + let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true); + if let Some(span) = span_of_fragments(&fragments) { span_lint_and_help( cx, EMPTY_DOCS, From d84d9d32f13baf4414430314d849ac051bff4468 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 22:33:16 +0400 Subject: [PATCH 321/417] lint on variant and fields as well --- clippy_lints/src/doc/mod.rs | 10 ++++ tests/ui/empty_docs.rs | 98 +++++++++++++++++++------------------ tests/ui/empty_docs.stderr | 64 ++++++++++++++++++------ 3 files changed, 109 insertions(+), 63 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 5690bd1d1ba30..76fd900bff3ee 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -399,6 +399,16 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { check_attrs(cx, &self.valid_idents, attrs); } + fn check_variant(&mut self, cx: &LateContext<'tcx>, variant: &'tcx hir::Variant<'tcx>) { + let attrs = cx.tcx.hir().attrs(variant.hir_id); + check_attrs(cx, &self.valid_idents, attrs); + } + + fn check_field_def(&mut self, cx: &LateContext<'tcx>, variant: &'tcx hir::FieldDef<'tcx>) { + let attrs = cx.tcx.hir().attrs(variant.hir_id); + check_attrs(cx, &self.valid_idents, attrs); + } + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { diff --git a/tests/ui/empty_docs.rs b/tests/ui/empty_docs.rs index f5b4bb6736d13..c47a603e71b43 100644 --- a/tests/ui/empty_docs.rs +++ b/tests/ui/empty_docs.rs @@ -1,63 +1,67 @@ #![allow(unused)] #![warn(clippy::empty_docs)] +mod outer { + //! -/// this is a struct -struct Bananas { - /// count - count: usize, -} + /// this is a struct + struct Bananas { + /// count + count: usize, + } -/// -enum Warn { /// - A, - /// - B, -} + enum Warn { + /// + A, + B, + } -enum WarnA { - /// - A, - B, -} + enum DontWarn { + /// i + A, + B, + } -enum DontWarn { - /// it's ok - A, - /// - B, -} + #[doc = ""] + fn warn_about_this() {} -#[doc = ""] -fn warn_about_this() {} + #[doc = ""] + #[doc = ""] + fn this_doesn_warn() {} -#[doc = ""] -#[doc = ""] -fn this_doesn_warn() {} + #[doc = "a fine function"] + fn this_is_fine() {} -#[doc = "a fine function"] -fn this_is_fine() {} + /// + mod inner { + /// + fn dont_warn_inner_outer() { + //!w + } -fn warn_about_this_as_well() { - //! -} + fn this_is_ok() { + //! + //! inside the function + } -/// -fn warn_inner_outer() { - //!w -} + fn warn() { + /*! */ + } -fn this_is_ok() { - //! - //! inside the function -} + fn dont_warn() { + /*! dont warn me */ + } -fn warn() { - /*! */ -} + trait NoDoc { + /// + fn some() {} + } + } -fn dont_warn() { - /*! dont warn me */ + union Unite { + /// lint y + x: i32, + /// + y: i32, + } } - -trait NoDoc {} diff --git a/tests/ui/empty_docs.stderr b/tests/ui/empty_docs.stderr index a2d8b986bf06d..3f1d071fb13ce 100644 --- a/tests/ui/empty_docs.stderr +++ b/tests/ui/empty_docs.stderr @@ -1,45 +1,77 @@ error: empty doc comment - --> tests/ui/empty_docs.rs:10:1 + --> tests/ui/empty_docs.rs:4:5 | -LL | /// - | ^^^ +LL | //! + | ^^^ | = help: consider removing or filling it = note: `-D clippy::empty-docs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::empty_docs)]` error: empty doc comment - --> tests/ui/empty_docs.rs:31:1 + --> tests/ui/empty_docs.rs:12:5 | -LL | #[doc = ""] - | ^^^^^^^^^^^ +LL | /// + | ^^^ | = help: consider removing or filling it error: empty doc comment - --> tests/ui/empty_docs.rs:34:1 + --> tests/ui/empty_docs.rs:14:9 | -LL | / #[doc = ""] -LL | | #[doc = ""] - | |___________^ +LL | /// + | ^^^ | = help: consider removing or filling it error: empty doc comment - --> tests/ui/empty_docs.rs:42:5 + --> tests/ui/empty_docs.rs:25:5 | -LL | //! +LL | #[doc = ""] + | ^^^^^^^^^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:28:5 + | +LL | / #[doc = ""] +LL | | #[doc = ""] + | |_______________^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:35:5 + | +LL | /// | ^^^ | = help: consider removing or filling it error: empty doc comment - --> tests/ui/empty_docs.rs:56:5 + --> tests/ui/empty_docs.rs:48:13 + | +LL | /*! */ + | ^^^^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:56:13 + | +LL | /// + | ^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:64:9 | -LL | /*! */ - | ^^^^^^ +LL | /// + | ^^^ | = help: consider removing or filling it -error: aborting due to 5 previous errors +error: aborting due to 9 previous errors From ee50d5df90dc6cdeb266bf0965daf14799e0977b Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 22:52:44 +0400 Subject: [PATCH 322/417] correct wrong doc syntax --- clippy_lints/src/manual_is_ascii_check.rs | 2 +- clippy_lints/src/methods/filter_map.rs | 2 +- clippy_lints/src/question_mark.rs | 6 +++--- clippy_lints/src/slow_vector_initialization.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/manual_is_ascii_check.rs b/clippy_lints/src/manual_is_ascii_check.rs index e433c5a3b32b6..338a299740a87 100644 --- a/clippy_lints/src/manual_is_ascii_check.rs +++ b/clippy_lints/src/manual_is_ascii_check.rs @@ -74,7 +74,7 @@ enum CharRange { LowerChar, /// 'A'..='Z' | b'A'..=b'Z' UpperChar, - /// AsciiLower | AsciiUpper + /// `AsciiLower` | `AsciiUpper` FullChar, /// '0..=9' Digit, diff --git a/clippy_lints/src/methods/filter_map.rs b/clippy_lints/src/methods/filter_map.rs index e489899c19e34..9b656531957fc 100644 --- a/clippy_lints/src/methods/filter_map.rs +++ b/clippy_lints/src/methods/filter_map.rs @@ -75,7 +75,7 @@ enum OffendingFilterExpr<'tcx> { }, /// `.filter(|enum| matches!(enum, Enum::A(_)))` Matches { - /// The DefId of the variant being matched + /// The `DefId` of the variant being matched variant_def_id: hir::def_id::DefId, }, } diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index b5da27d7993b8..6bd90ebd97ae0 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -74,12 +74,12 @@ impl QuestionMark { enum IfBlockType<'hir> { /// An `if x.is_xxx() { a } else { b } ` expression. /// - /// Contains: caller (x), caller_type, call_sym (is_xxx), if_then (a), if_else (b) + /// Contains: `caller (x), caller_type, call_sym (is_xxx), if_then (a), if_else (b)` IfIs(&'hir Expr<'hir>, Ty<'hir>, Symbol, &'hir Expr<'hir>), /// An `if let Xxx(a) = b { c } else { d }` expression. /// - /// Contains: let_pat_qpath (Xxx), let_pat_type, let_pat_sym (a), let_expr (b), if_then (c), - /// if_else (d) + /// Contains: `let_pat_qpath (Xxx), let_pat_type, let_pat_sym (a), let_expr (b), if_then (c), + /// if_else (d)` IfLet( Res, Ty<'hir>, diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index c4a5e48e855e6..4837f2858a669 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -62,7 +62,7 @@ declare_lint_pass!(SlowVectorInit => [SLOW_VECTOR_INITIALIZATION]); /// assigned to a variable. For example, `let mut vec = Vec::with_capacity(0)` or /// `vec = Vec::with_capacity(0)` struct VecAllocation<'tcx> { - /// HirId of the variable + /// `HirId` of the variable local_id: HirId, /// Reference to the expression which allocates the vector From 5152050c5f8d1aa18f43b32dad5f1364ecb859a5 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 23:17:03 +0400 Subject: [PATCH 323/417] move lint directly into check_attrs --- clippy_lints/src/doc/empty_docs.rs | 20 -------------------- clippy_lints/src/doc/mod.rs | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 23 deletions(-) delete mode 100644 clippy_lints/src/doc/empty_docs.rs diff --git a/clippy_lints/src/doc/empty_docs.rs b/clippy_lints/src/doc/empty_docs.rs deleted file mode 100644 index 84cbc3207f345..0000000000000 --- a/clippy_lints/src/doc/empty_docs.rs +++ /dev/null @@ -1,20 +0,0 @@ -use super::EMPTY_DOCS; -use clippy_utils::diagnostics::span_lint_and_help; -use rustc_ast::Attribute; -use rustc_lint::LateContext; -use rustc_resolve::rustdoc::{attrs_to_doc_fragments, span_of_fragments}; - -// TODO: Adjust the parameters as necessary -pub(super) fn check(cx: &LateContext<'_>, attrs: &[Attribute]) { - let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true); - if let Some(span) = span_of_fragments(&fragments) { - span_lint_and_help( - cx, - EMPTY_DOCS, - span, - "empty doc comment", - None, - "consider removing or filling it", - ); - } -} diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 76fd900bff3ee..4a253e9fd6cf0 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -19,7 +19,8 @@ use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self}; use rustc_resolve::rustdoc::{ - add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, DocFragment, + add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, span_of_fragments, + DocFragment, }; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; @@ -27,7 +28,6 @@ use rustc_span::{sym, Span}; use std::ops::Range; use url::Url; -mod empty_docs; mod link_with_quotes; mod markdown; mod missing_headers; @@ -546,7 +546,16 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ doc.pop(); if doc.trim().is_empty() { - empty_docs::check(cx, attrs); + if let Some(span) = span_of_fragments(&fragments) { + span_lint_and_help( + cx, + EMPTY_DOCS, + span, + "empty doc comment", + None, + "consider removing or filling it", + ); + } return Some(DocHeaders::default()); } From 30ee7af2cae70796f37d5cab68276657c6e97bb6 Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Sun, 25 Feb 2024 12:54:46 -0800 Subject: [PATCH 324/417] style: sync GitHub Corner colors --- util/gh-pages/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/gh-pages/index.html b/util/gh-pages/index.html index a5274eeb349d1..fe13318b05b6a 100644 --- a/util/gh-pages/index.html +++ b/util/gh-pages/index.html @@ -605,8 +605,8 @@

} } .github-corner svg { - fill: var(--theme-background-color); - color: var(--theme-foreground-color); + fill: var(--fg); + color: var(--bg); } .github-corner:hover .octo-arm { animation: octocat-wave 560ms ease-in-out; From a3fce72a27ee41077c3752851ff778f886f0a4fa Mon Sep 17 00:00:00 2001 From: Lieselotte <52315535+she3py@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:22:09 +0100 Subject: [PATCH 325/417] Add `ast::ExprKind::Dummy` --- compiler/rustc_ast/src/ast.rs | 18 ++++-------------- compiler/rustc_ast/src/mut_visit.rs | 4 ++-- compiler/rustc_ast/src/util/classify.rs | 3 ++- compiler/rustc_ast/src/visit.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 6 ++++++ compiler/rustc_ast_lowering/src/pat.rs | 3 ++- .../rustc_ast_pretty/src/pprust/state/expr.rs | 5 +++++ .../rustc_builtin_macros/src/assert/context.rs | 1 + compiler/rustc_builtin_macros/src/concat.rs | 1 + .../rustc_builtin_macros/src/concat_bytes.rs | 1 + compiler/rustc_expand/src/base.rs | 3 +++ compiler/rustc_parse/src/parser/expr.rs | 3 ++- compiler/rustc_parse/src/parser/pat.rs | 2 +- compiler/rustc_passes/src/hir_stats.rs | 2 +- src/tools/clippy/clippy_utils/src/ast_utils.rs | 1 + src/tools/clippy/clippy_utils/src/sugg.rs | 3 ++- src/tools/rustfmt/src/expr.rs | 2 +- src/tools/rustfmt/src/utils.rs | 1 + 18 files changed, 37 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 3fdb2a2225a58..b30324c766675 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1296,23 +1296,10 @@ impl Expr { ExprKind::Yeet(..) => ExprPrecedence::Yeet, ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs, ExprKind::Become(..) => ExprPrecedence::Become, - ExprKind::Err => ExprPrecedence::Err, + ExprKind::Err | ExprKind::Dummy => ExprPrecedence::Err, } } - pub fn take(&mut self) -> Self { - mem::replace( - self, - Expr { - id: DUMMY_NODE_ID, - kind: ExprKind::Err, - span: DUMMY_SP, - attrs: AttrVec::new(), - tokens: None, - }, - ) - } - /// To a first-order approximation, is this a pattern? pub fn is_approximately_pattern(&self) -> bool { matches!( @@ -1532,6 +1519,9 @@ pub enum ExprKind { /// Placeholder for an expression that wasn't syntactically well formed in some way. Err, + + /// Acts as a null expression. Lowering it will always emit a bug. + Dummy, } /// Used to differentiate between `for` loops and `for await` loops. diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index c42c41999732c..b2f3bb303de6c 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1526,7 +1526,7 @@ pub fn noop_visit_expr( } ExprKind::Try(expr) => vis.visit_expr(expr), ExprKind::TryBlock(body) => vis.visit_block(body), - ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err => {} + ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err | ExprKind::Dummy => {} } vis.visit_id(id); vis.visit_span(span); @@ -1642,7 +1642,7 @@ impl DummyAstNode for Expr { fn dummy() -> Self { Expr { id: DUMMY_NODE_ID, - kind: ExprKind::Err, + kind: ExprKind::Dummy, span: Default::default(), attrs: Default::default(), tokens: Default::default(), diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs index 098b8f2d6d038..e70a75622e631 100644 --- a/compiler/rustc_ast/src/util/classify.rs +++ b/compiler/rustc_ast/src/util/classify.rs @@ -89,7 +89,8 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> { | Paren(_) | Try(_) | Yeet(None) - | Err => break None, + | Err + | Dummy => break None, } } } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index ecf379cc2408a..ab3d9b496333d 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -1063,7 +1063,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V } ExprKind::Try(subexpression) => try_visit!(visitor.visit_expr(subexpression)), ExprKind::TryBlock(body) => try_visit!(visitor.visit_block(body)), - ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err => {} + ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err | ExprKind::Dummy => {} } visitor.visit_expr_post(expression) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index aafa99b3aa6fb..5d33a7a91427f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -14,6 +14,7 @@ use rustc_ast::*; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; +use rustc_middle::span_bug; use rustc_session::errors::report_lit_error; use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -331,6 +332,11 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::Err => { hir::ExprKind::Err(self.dcx().span_delayed_bug(e.span, "lowered ExprKind::Err")) } + + ExprKind::Dummy => { + span_bug!(e.span, "lowered ExprKind::Dummy") + } + ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr), ExprKind::Paren(_) | ExprKind::ForLoop { .. } => { diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index c097feb6b3476..755b073b2c37b 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -331,7 +331,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ExprKind::Lit(..) | ExprKind::ConstBlock(..) | ExprKind::IncludedBytes(..) - | ExprKind::Err => {} + | ExprKind::Err + | ExprKind::Dummy => {} ExprKind::Path(..) if allow_paths => {} ExprKind::Unary(UnOp::Neg, inner) if matches!(inner.kind, ExprKind::Lit(_)) => {} _ => { diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index ff154a009ed05..0f9fe89402b13 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -898,6 +898,11 @@ impl<'a> State<'a> { self.word("/*ERROR*/"); self.pclose() } + ast::ExprKind::Dummy => { + self.popen(); + self.word("/*DUMMY*/"); + self.pclose(); + } } self.ann.post(self, AnnNode::Expr(expr)); diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index 01821ee833f1b..7737041090b05 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -303,6 +303,7 @@ impl<'cx, 'a> Context<'cx, 'a> { | ExprKind::Closure(_) | ExprKind::ConstBlock(_) | ExprKind::Continue(_) + | ExprKind::Dummy | ExprKind::Err | ExprKind::Field(_, _) | ExprKind::ForLoop { .. } diff --git a/compiler/rustc_builtin_macros/src/concat.rs b/compiler/rustc_builtin_macros/src/concat.rs index 795161e65d81e..691142c03edd0 100644 --- a/compiler/rustc_builtin_macros/src/concat.rs +++ b/compiler/rustc_builtin_macros/src/concat.rs @@ -68,6 +68,7 @@ pub fn expand_concat( ast::ExprKind::Err => { has_errors = true; } + ast::ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { missing_literal.push(e.span); } diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs index 3ef8cb7bffef2..8ce004586ce84 100644 --- a/compiler/rustc_builtin_macros/src/concat_bytes.rs +++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs @@ -176,6 +176,7 @@ pub fn expand_concat_bytes( ast::ExprKind::Err => { has_errors = true; } + ast::ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { missing_literals.push(e.span); } diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 1c8d18bec65cb..762d6745341ae 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1279,6 +1279,9 @@ pub fn expr_to_spanned_string<'a>( _ => Some((cx.dcx().struct_span_err(expr.span, err_msg), false)), }, ast::ExprKind::Err => None, + ast::ExprKind::Dummy => { + cx.dcx().span_bug(expr.span, "tried to get a string literal from `ExprKind::Dummy`") + } _ => Some((cx.dcx().struct_span_err(expr.span, err_msg), false)), }) } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 1ad637451b191..89f28777bffb9 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3949,7 +3949,8 @@ impl MutVisitor for CondChecker<'_> { | ExprKind::Become(_) | ExprKind::IncludedBytes(_) | ExprKind::FormatArgs(_) - | ExprKind::Err => { + | ExprKind::Err + | ExprKind::Dummy => { // These would forbid any let expressions they contain already. } } diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 2ede19b11e049..c82b44ac6e100 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -388,7 +388,7 @@ impl<'a> Parser<'a> { // Parse `?`, `.f`, `(arg0, arg1, ...)` or `[expr]` until they've all been eaten. if let Ok(expr) = snapshot .parse_expr_dot_or_call_with( - self.mk_expr_err(pat_span), // equivalent to transforming the parsed pattern into an `Expr` + self.mk_expr(pat_span, ExprKind::Dummy), // equivalent to transforming the parsed pattern into an `Expr` pat_span, AttrVec::new(), ) diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 96429bb778882..be6ba585d2004 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -589,7 +589,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { If, While, ForLoop, Loop, Match, Closure, Block, Await, TryBlock, Assign, AssignOp, Field, Index, Range, Underscore, Path, AddrOf, Break, Continue, Ret, InlineAsm, FormatArgs, OffsetOf, MacCall, Struct, Repeat, Paren, Try, Yield, Yeet, - Become, IncludedBytes, Gen, Err + Become, IncludedBytes, Gen, Err, Dummy ] ); ast_visit::walk_expr(self, e) diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index 0467a8a65709a..81a26a12009d1 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -144,6 +144,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool { (Paren(l), _) => eq_expr(l, r), (_, Paren(r)) => eq_expr(l, r), (Err, Err) => true, + (Dummy, _) | (_, Dummy) => unreachable!("comparing `ExprKind::Dummy`"), (Try(l), Try(r)) | (Await(l, _), Await(r, _)) => eq_expr(l, r), (Array(l), Array(r)) => over(l, r, |l, r| eq_expr(l, r)), (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)), diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index b355e66b7b12a..7b1b0388b29f3 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -222,7 +222,8 @@ impl<'a> Sugg<'a> { | ast::ExprKind::Array(..) | ast::ExprKind::While(..) | ast::ExprKind::Await(..) - | ast::ExprKind::Err => Sugg::NonParen(snippet_with_context(cx, expr.span, ctxt, default, app).0), + | ast::ExprKind::Err + | ast::ExprKind::Dummy => Sugg::NonParen(snippet_with_context(cx, expr.span, ctxt, default, app).0), ast::ExprKind::Range(ref lhs, ref rhs, RangeLimits::HalfOpen) => Sugg::BinOp( AssocOp::DotDot, lhs.as_ref().map_or("".into(), |lhs| { diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 4b86c2acdc538..d46d7c53bdb47 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -404,7 +404,7 @@ pub(crate) fn format_expr( // These do not occur in the AST because macros aren't expanded. unreachable!() } - ast::ExprKind::Err => None, + ast::ExprKind::Err | ast::ExprKind::Dummy => None, }; expr_rw diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index 642b6603b1e9a..b6b37e492e92f 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -497,6 +497,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr | ast::ExprKind::Break(..) | ast::ExprKind::Cast(..) | ast::ExprKind::Continue(..) + | ast::ExprKind::Dummy | ast::ExprKind::Err | ast::ExprKind::Field(..) | ast::ExprKind::IncludedBytes(..) From c440a5b814005c85ec903f9b9e44e25bf5c9c565 Mon Sep 17 00:00:00 2001 From: Lieselotte <52315535+she3py@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:22:11 +0100 Subject: [PATCH 326/417] Add `ErrorGuaranteed` to `ast::ExprKind::Err` --- compiler/rustc_ast/src/ast.rs | 4 +- compiler/rustc_ast/src/mut_visit.rs | 2 +- compiler/rustc_ast/src/util/classify.rs | 2 +- compiler/rustc_ast/src/visit.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 4 +- compiler/rustc_ast_lowering/src/pat.rs | 2 +- .../rustc_ast_pretty/src/pprust/state/expr.rs | 2 +- compiler/rustc_builtin_macros/src/asm.rs | 71 ++++---- compiler/rustc_builtin_macros/src/assert.rs | 4 +- .../src/assert/context.rs | 2 +- compiler/rustc_builtin_macros/src/cfg.rs | 4 +- .../rustc_builtin_macros/src/compile_error.rs | 14 +- compiler/rustc_builtin_macros/src/concat.rs | 35 ++-- .../rustc_builtin_macros/src/concat_bytes.rs | 131 +++++++------- .../rustc_builtin_macros/src/concat_idents.rs | 12 +- .../src/deriving/default.rs | 53 +++--- compiler/rustc_builtin_macros/src/env.rs | 36 ++-- compiler/rustc_builtin_macros/src/format.rs | 90 +++++----- compiler/rustc_builtin_macros/src/lib.rs | 1 + .../rustc_builtin_macros/src/source_util.rs | 43 ++--- .../rustc_builtin_macros/src/type_ascribe.rs | 4 +- compiler/rustc_expand/src/base.rs | 99 ++++++----- compiler/rustc_expand/src/expand.rs | 82 +++++---- compiler/rustc_expand/src/mbe/diagnostics.rs | 18 +- compiler/rustc_expand/src/mbe/macro_check.rs | 62 +++---- compiler/rustc_expand/src/mbe/macro_rules.rs | 132 +++++++------- compiler/rustc_lint/src/unused.rs | 2 +- .../rustc_parse/src/parser/diagnostics.rs | 90 +++++----- compiler/rustc_parse/src/parser/expr.rs | 165 ++++++++++-------- compiler/rustc_parse/src/parser/item.rs | 4 +- compiler/rustc_parse/src/parser/pat.rs | 18 +- compiler/rustc_parse/src/parser/stmt.rs | 64 ++++--- compiler/rustc_parse/src/validate_attr.rs | 2 +- .../clippy/clippy_utils/src/ast_utils.rs | 2 +- src/tools/clippy/clippy_utils/src/sugg.rs | 2 +- src/tools/rustfmt/src/expr.rs | 2 +- src/tools/rustfmt/src/utils.rs | 2 +- 37 files changed, 661 insertions(+), 603 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index b30324c766675..8ba2f222fcfaa 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1296,7 +1296,7 @@ impl Expr { ExprKind::Yeet(..) => ExprPrecedence::Yeet, ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs, ExprKind::Become(..) => ExprPrecedence::Become, - ExprKind::Err | ExprKind::Dummy => ExprPrecedence::Err, + ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err, } } @@ -1518,7 +1518,7 @@ pub enum ExprKind { FormatArgs(P), /// Placeholder for an expression that wasn't syntactically well formed in some way. - Err, + Err(ErrorGuaranteed), /// Acts as a null expression. Lowering it will always emit a bug. Dummy, diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index b2f3bb303de6c..60bc21c6441fc 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1526,7 +1526,7 @@ pub fn noop_visit_expr( } ExprKind::Try(expr) => vis.visit_expr(expr), ExprKind::TryBlock(body) => vis.visit_block(body), - ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err | ExprKind::Dummy => {} + ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err(_) | ExprKind::Dummy => {} } vis.visit_id(id); vis.visit_span(span); diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs index e70a75622e631..f21a9cabb81be 100644 --- a/compiler/rustc_ast/src/util/classify.rs +++ b/compiler/rustc_ast/src/util/classify.rs @@ -89,7 +89,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> { | Paren(_) | Try(_) | Yeet(None) - | Err + | Err(_) | Dummy => break None, } } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index ab3d9b496333d..f29022386a9d3 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -1063,7 +1063,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V } ExprKind::Try(subexpression) => try_visit!(visitor.visit_expr(subexpression)), ExprKind::TryBlock(body) => try_visit!(visitor.visit_block(body)), - ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err | ExprKind::Dummy => {} + ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err(_) | ExprKind::Dummy => {} } visitor.visit_expr_post(expression) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 5d33a7a91427f..9950db4784b9c 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -329,9 +329,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ) } ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()), - ExprKind::Err => { - hir::ExprKind::Err(self.dcx().span_delayed_bug(e.span, "lowered ExprKind::Err")) - } + ExprKind::Err(guar) => hir::ExprKind::Err(*guar), ExprKind::Dummy => { span_bug!(e.span, "lowered ExprKind::Dummy") diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index 755b073b2c37b..469cdac11e439 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -331,7 +331,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ExprKind::Lit(..) | ExprKind::ConstBlock(..) | ExprKind::IncludedBytes(..) - | ExprKind::Err + | ExprKind::Err(_) | ExprKind::Dummy => {} ExprKind::Path(..) if allow_paths => {} ExprKind::Unary(UnOp::Neg, inner) if matches!(inner.kind, ExprKind::Lit(_)) => {} diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 0f9fe89402b13..433ef03b6e544 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -893,7 +893,7 @@ impl<'a> State<'a> { self.word_nbsp("try"); self.print_block_with_attrs(blk, attrs) } - ast::ExprKind::Err => { + ast::ExprKind::Err(_) => { self.popen(); self.word("/*ERROR*/"); self.pclose() diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 263081ea19ead..29bf5e9f30493 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -13,7 +13,7 @@ use rustc_session::lint; use rustc_session::parse::ParseSess; use rustc_span::symbol::Ident; use rustc_span::symbol::{kw, sym, Symbol}; -use rustc_span::{InnerSpan, Span}; +use rustc_span::{ErrorGuaranteed, InnerSpan, Span}; use rustc_target::asm::InlineAsmArch; use smallvec::smallvec; @@ -433,7 +433,10 @@ fn parse_reg<'a>( Ok(result) } -fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option { +fn expand_preparsed_asm( + ecx: &mut ExtCtxt<'_>, + args: AsmArgs, +) -> Result { let mut template = vec![]; // Register operands are implicitly used since they are not allowed to be // referenced in the template string. @@ -459,10 +462,10 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option template_part, Err(err) => { - if let Some((err, _)) = err { - err.emit(); - } - return None; + return Err(match err { + Ok((err, _)) => err.emit(), + Err(guar) => guar, + }); } }; @@ -551,8 +554,8 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option, args: AsmArgs) -> Option( ) -> Box { match parse_args(ecx, sp, tts, false) { Ok(args) => { - let expr = if let Some(inline_asm) = expand_preparsed_asm(ecx, args) { - P(ast::Expr { + let expr = match expand_preparsed_asm(ecx, args) { + Ok(inline_asm) => P(ast::Expr { id: ast::DUMMY_NODE_ID, kind: ast::ExprKind::InlineAsm(P(inline_asm)), span: sp, attrs: ast::AttrVec::new(), tokens: None, - }) - } else { - DummyResult::raw_expr(sp, true) + }), + Err(guar) => DummyResult::raw_expr(sp, Some(guar)), }; MacEager::expr(expr) } Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } @@ -762,28 +764,25 @@ pub(super) fn expand_global_asm<'cx>( tts: TokenStream, ) -> Box { match parse_args(ecx, sp, tts, true) { - Ok(args) => { - if let Some(inline_asm) = expand_preparsed_asm(ecx, args) { - MacEager::items(smallvec![P(ast::Item { - ident: Ident::empty(), - attrs: ast::AttrVec::new(), - id: ast::DUMMY_NODE_ID, - kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)), - vis: ast::Visibility { - span: sp.shrink_to_lo(), - kind: ast::VisibilityKind::Inherited, - tokens: None, - }, - span: sp, + Ok(args) => match expand_preparsed_asm(ecx, args) { + Ok(inline_asm) => MacEager::items(smallvec![P(ast::Item { + ident: Ident::empty(), + attrs: ast::AttrVec::new(), + id: ast::DUMMY_NODE_ID, + kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)), + vis: ast::Visibility { + span: sp.shrink_to_lo(), + kind: ast::VisibilityKind::Inherited, tokens: None, - })]) - } else { - DummyResult::any(sp) - } - } + }, + span: sp, + tokens: None, + })]), + Err(guar) => DummyResult::any(sp, guar), + }, Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs index 501d557f3ab8a..613ce43dec2d6 100644 --- a/compiler/rustc_builtin_macros/src/assert.rs +++ b/compiler/rustc_builtin_macros/src/assert.rs @@ -23,8 +23,8 @@ pub fn expand_assert<'cx>( let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) { Ok(assert) => assert, Err(err) => { - err.emit(); - return DummyResult::any(span); + let guar = err.emit(); + return DummyResult::any(span, guar); } }; diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index 7737041090b05..56c56b2704b00 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -304,7 +304,7 @@ impl<'cx, 'a> Context<'cx, 'a> { | ExprKind::ConstBlock(_) | ExprKind::Continue(_) | ExprKind::Dummy - | ExprKind::Err + | ExprKind::Err(_) | ExprKind::Field(_, _) | ExprKind::ForLoop { .. } | ExprKind::FormatArgs(_) diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index 581d390992adc..ca66bc0da0cc7 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -29,8 +29,8 @@ pub fn expand_cfg( MacEager::expr(cx.expr_bool(sp, matches_cfg)) } Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/compile_error.rs b/compiler/rustc_builtin_macros/src/compile_error.rs index f157575da79bc..6650035127296 100644 --- a/compiler/rustc_builtin_macros/src/compile_error.rs +++ b/compiler/rustc_builtin_macros/src/compile_error.rs @@ -9,16 +9,14 @@ pub fn expand_compile_error<'cx>( sp: Span, tts: TokenStream, ) -> Box { - let Some(var) = get_single_str_from_tts(cx, sp, tts, "compile_error!") else { - return DummyResult::any(sp); + let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") { + Ok(var) => var, + Err(guar) => return DummyResult::any(sp, guar), }; - #[expect( - rustc::diagnostic_outside_of_impl, - reason = "diagnostic message is specified by user" - )] + #[expect(rustc::diagnostic_outside_of_impl, reason = "diagnostic message is specified by user")] #[expect(rustc::untranslatable_diagnostic, reason = "diagnostic message is specified by user")] - cx.dcx().span_err(sp, var.to_string()); + let guar = cx.dcx().span_err(sp, var.to_string()); - DummyResult::any(sp) + DummyResult::any(sp, guar) } diff --git a/compiler/rustc_builtin_macros/src/concat.rs b/compiler/rustc_builtin_macros/src/concat.rs index 691142c03edd0..dd4a0e7f22869 100644 --- a/compiler/rustc_builtin_macros/src/concat.rs +++ b/compiler/rustc_builtin_macros/src/concat.rs @@ -11,12 +11,13 @@ pub fn expand_concat( sp: rustc_span::Span, tts: TokenStream, ) -> Box { - let Some(es) = base::get_exprs_from_tts(cx, tts) else { - return DummyResult::any(sp); + let es = match base::get_exprs_from_tts(cx, tts) { + Ok(es) => es, + Err(guar) => return DummyResult::any(sp, guar), }; let mut accumulator = String::new(); let mut missing_literal = vec![]; - let mut has_errors = false; + let mut guar = None; for e in es { match e.kind { ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { @@ -33,19 +34,16 @@ pub fn expand_concat( accumulator.push_str(&b.to_string()); } Ok(ast::LitKind::CStr(..)) => { - cx.dcx().emit_err(errors::ConcatCStrLit { span: e.span }); - has_errors = true; + guar = Some(cx.dcx().emit_err(errors::ConcatCStrLit { span: e.span })); } Ok(ast::LitKind::Byte(..) | ast::LitKind::ByteStr(..)) => { - cx.dcx().emit_err(errors::ConcatBytestr { span: e.span }); - has_errors = true; + guar = Some(cx.dcx().emit_err(errors::ConcatBytestr { span: e.span })); } - Ok(ast::LitKind::Err(_)) => { - has_errors = true; + Ok(ast::LitKind::Err(guarantee)) => { + guar = Some(guarantee); } Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span); - has_errors = true; + guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span)); } }, // We also want to allow negative numeric literals. @@ -56,8 +54,7 @@ pub fn expand_concat( Ok(ast::LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")), Ok(ast::LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")), Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span); - has_errors = true; + guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span)); } _ => missing_literal.push(e.span), } @@ -65,8 +62,8 @@ pub fn expand_concat( ast::ExprKind::IncludedBytes(..) => { cx.dcx().emit_err(errors::ConcatBytestr { span: e.span }); } - ast::ExprKind::Err => { - has_errors = true; + ast::ExprKind::Err(guarantee) => { + guar = Some(guarantee); } ast::ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { @@ -76,10 +73,10 @@ pub fn expand_concat( } if !missing_literal.is_empty() { - cx.dcx().emit_err(errors::ConcatMissingLiteral { spans: missing_literal }); - return DummyResult::any(sp); - } else if has_errors { - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatMissingLiteral { spans: missing_literal }); + return DummyResult::any(sp, guar); + } else if let Some(guar) = guar { + return DummyResult::any(sp, guar); } let sp = cx.with_def_site_ctxt(sp); base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator))) diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs index 8ce004586ce84..32e17112d8c45 100644 --- a/compiler/rustc_builtin_macros/src/concat_bytes.rs +++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs @@ -2,7 +2,7 @@ use rustc_ast as ast; use rustc_ast::{ptr::P, tokenstream::TokenStream}; use rustc_expand::base::{self, DummyResult}; use rustc_session::errors::report_lit_error; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; use crate::errors; @@ -12,7 +12,7 @@ fn invalid_type_err( token_lit: ast::token::Lit, span: Span, is_nested: bool, -) { +) -> ErrorGuaranteed { use errors::{ ConcatBytesInvalid, ConcatBytesInvalidSuggestion, ConcatBytesNonU8, ConcatBytesOob, }; @@ -22,12 +22,12 @@ fn invalid_type_err( Ok(ast::LitKind::CStr(_, _)) => { // Avoid ambiguity in handling of terminal `NUL` by refusing to // concatenate C string literals as bytes. - dcx.emit_err(errors::ConcatCStrLit { span: span }); + dcx.emit_err(errors::ConcatCStrLit { span }) } Ok(ast::LitKind::Char(_)) => { let sugg = snippet.map(|snippet| ConcatBytesInvalidSuggestion::CharLit { span, snippet }); - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "character", sugg }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "character", sugg }) } Ok(ast::LitKind::Str(_, _)) => { // suggestion would be invalid if we are nested @@ -36,86 +36,79 @@ fn invalid_type_err( } else { None }; - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "string", sugg }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "string", sugg }) } Ok(ast::LitKind::Float(_, _)) => { - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "float", sugg: None }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "float", sugg: None }) } Ok(ast::LitKind::Bool(_)) => { - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "boolean", sugg: None }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "boolean", sugg: None }) } - Ok(ast::LitKind::Err(_)) => {} Ok(ast::LitKind::Int(_, _)) if !is_nested => { let sugg = snippet.map(|snippet| ConcatBytesInvalidSuggestion::IntLit { span: span, snippet }); - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "numeric", sugg }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "numeric", sugg }) } Ok(ast::LitKind::Int( val, ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), )) => { assert!(val.get() > u8::MAX.into()); // must be an error - dcx.emit_err(ConcatBytesOob { span }); - } - Ok(ast::LitKind::Int(_, _)) => { - dcx.emit_err(ConcatBytesNonU8 { span }); + dcx.emit_err(ConcatBytesOob { span }) } + Ok(ast::LitKind::Int(_, _)) => dcx.emit_err(ConcatBytesNonU8 { span }), Ok(ast::LitKind::ByteStr(..) | ast::LitKind::Byte(_)) => unreachable!(), - Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, span); - } + Ok(ast::LitKind::Err(guar)) => guar, + Err(err) => report_lit_error(&cx.sess.parse_sess, err, token_lit, span), } } +/// Returns `expr` as a *single* byte literal if applicable. +/// +/// Otherwise, returns `None`, and either pushes the `expr`'s span to `missing_literals` or +/// updates `guar` accordingly. fn handle_array_element( cx: &mut base::ExtCtxt<'_>, - has_errors: &mut bool, + guar: &mut Option, missing_literals: &mut Vec, expr: &P, ) -> Option { let dcx = cx.dcx(); - match expr.kind { - ast::ExprKind::Array(_) | ast::ExprKind::Repeat(_, _) => { - if !*has_errors { - dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }); - } - *has_errors = true; - None - } - ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Int( - val, - ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), - )) if val.get() <= u8::MAX.into() => Some(val.get() as u8), - Ok(ast::LitKind::Byte(val)) => Some(val), - Ok(ast::LitKind::ByteStr(..)) => { - if !*has_errors { - dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: true }); + match expr.kind { + ast::ExprKind::Lit(token_lit) => { + match ast::LitKind::from_token_lit(token_lit) { + Ok(ast::LitKind::Int( + val, + ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), + )) if let Ok(val) = u8::try_from(val.get()) => { + return Some(val); } - *has_errors = true; - None - } - _ => { - if !*has_errors { - invalid_type_err(cx, token_lit, expr.span, true); + Ok(ast::LitKind::Byte(val)) => return Some(val), + Ok(ast::LitKind::ByteStr(..)) => { + guar.get_or_insert_with(|| { + dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: true }) + }); } - *has_errors = true; - None - } - }, - ast::ExprKind::IncludedBytes(..) => { - if !*has_errors { - dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }); - } - *has_errors = true; - None + _ => { + guar.get_or_insert_with(|| invalid_type_err(cx, token_lit, expr.span, true)); + } + }; } - _ => { - missing_literals.push(expr.span); - None + ast::ExprKind::Array(_) | ast::ExprKind::Repeat(_, _) => { + guar.get_or_insert_with(|| { + dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }) + }); + } + ast::ExprKind::IncludedBytes(..) => { + guar.get_or_insert_with(|| { + dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }) + }); } + _ => missing_literals.push(expr.span), } + + None } pub fn expand_concat_bytes( @@ -123,18 +116,19 @@ pub fn expand_concat_bytes( sp: rustc_span::Span, tts: TokenStream, ) -> Box { - let Some(es) = base::get_exprs_from_tts(cx, tts) else { - return DummyResult::any(sp); + let es = match base::get_exprs_from_tts(cx, tts) { + Ok(es) => es, + Err(guar) => return DummyResult::any(sp, guar), }; let mut accumulator = Vec::new(); let mut missing_literals = vec![]; - let mut has_errors = false; + let mut guar = None; for e in es { match &e.kind { ast::ExprKind::Array(exprs) => { for expr in exprs { if let Some(elem) = - handle_array_element(cx, &mut has_errors, &mut missing_literals, expr) + handle_array_element(cx, &mut guar, &mut missing_literals, expr) { accumulator.push(elem); } @@ -146,14 +140,16 @@ pub fn expand_concat_bytes( ast::LitKind::from_token_lit(token_lit) { if let Some(elem) = - handle_array_element(cx, &mut has_errors, &mut missing_literals, expr) + handle_array_element(cx, &mut guar, &mut missing_literals, expr) { for _ in 0..count_val.get() { accumulator.push(elem); } } } else { - cx.dcx().emit_err(errors::ConcatBytesBadRepeat { span: count.value.span }); + guar = Some( + cx.dcx().emit_err(errors::ConcatBytesBadRepeat { span: count.value.span }), + ); } } &ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { @@ -164,17 +160,14 @@ pub fn expand_concat_bytes( accumulator.extend_from_slice(bytes); } _ => { - if !has_errors { - invalid_type_err(cx, token_lit, e.span, false); - } - has_errors = true; + guar.get_or_insert_with(|| invalid_type_err(cx, token_lit, e.span, false)); } }, ast::ExprKind::IncludedBytes(bytes) => { accumulator.extend_from_slice(bytes); } - ast::ExprKind::Err => { - has_errors = true; + ast::ExprKind::Err(guarantee) => { + guar = Some(*guarantee); } ast::ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { @@ -183,10 +176,10 @@ pub fn expand_concat_bytes( } } if !missing_literals.is_empty() { - cx.dcx().emit_err(errors::ConcatBytesMissingLiteral { spans: missing_literals }); - return base::MacEager::expr(DummyResult::raw_expr(sp, true)); - } else if has_errors { - return base::MacEager::expr(DummyResult::raw_expr(sp, true)); + let guar = cx.dcx().emit_err(errors::ConcatBytesMissingLiteral { spans: missing_literals }); + return base::MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); + } else if let Some(guar) = guar { + return base::MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); } let sp = cx.with_def_site_ctxt(sp); base::MacEager::expr(cx.expr_byte_str(sp, accumulator)) diff --git a/compiler/rustc_builtin_macros/src/concat_idents.rs b/compiler/rustc_builtin_macros/src/concat_idents.rs index 17fd3901cc6bc..29d3f6164aa16 100644 --- a/compiler/rustc_builtin_macros/src/concat_idents.rs +++ b/compiler/rustc_builtin_macros/src/concat_idents.rs @@ -14,8 +14,8 @@ pub fn expand_concat_idents<'cx>( tts: TokenStream, ) -> Box { if tts.is_empty() { - cx.dcx().emit_err(errors::ConcatIdentsMissingArgs { span: sp }); - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingArgs { span: sp }); + return DummyResult::any(sp, guar); } let mut res_str = String::new(); @@ -24,8 +24,8 @@ pub fn expand_concat_idents<'cx>( match e { TokenTree::Token(Token { kind: token::Comma, .. }, _) => {} _ => { - cx.dcx().emit_err(errors::ConcatIdentsMissingComma { span: sp }); - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingComma { span: sp }); + return DummyResult::any(sp, guar); } } } else { @@ -36,8 +36,8 @@ pub fn expand_concat_idents<'cx>( } } - cx.dcx().emit_err(errors::ConcatIdentsIdentArgs { span: sp }); - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatIdentsIdentArgs { span: sp }); + return DummyResult::any(sp, guar); } } diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs index 0bd2d423a294f..386d4a54b655b 100644 --- a/compiler/rustc_builtin_macros/src/deriving/default.rs +++ b/compiler/rustc_builtin_macros/src/deriving/default.rs @@ -6,7 +6,7 @@ use rustc_ast::{attr, walk_list, EnumDef, VariantData}; use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt}; use rustc_span::symbol::Ident; use rustc_span::symbol::{kw, sym}; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; use smallvec::SmallVec; use thin_vec::{thin_vec, ThinVec}; @@ -83,16 +83,19 @@ fn default_enum_substructure( trait_span: Span, enum_def: &EnumDef, ) -> BlockOrExpr { - let expr = if let Ok(default_variant) = extract_default_variant(cx, enum_def, trait_span) - && let Ok(_) = validate_default_attribute(cx, default_variant) - { - // We now know there is exactly one unit variant with exactly one `#[default]` attribute. - cx.expr_path(cx.path( - default_variant.span, - vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident], - )) - } else { - DummyResult::raw_expr(trait_span, true) + let expr = match try { + let default_variant = extract_default_variant(cx, enum_def, trait_span)?; + validate_default_attribute(cx, default_variant)?; + default_variant + } { + Ok(default_variant) => { + // We now know there is exactly one unit variant with exactly one `#[default]` attribute. + cx.expr_path(cx.path( + default_variant.span, + vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident], + )) + } + Err(guar) => DummyResult::raw_expr(trait_span, Some(guar)), }; BlockOrExpr::new_expr(expr) } @@ -101,7 +104,7 @@ fn extract_default_variant<'a>( cx: &mut ExtCtxt<'_>, enum_def: &'a EnumDef, trait_span: Span, -) -> Result<&'a rustc_ast::Variant, ()> { +) -> Result<&'a rustc_ast::Variant, ErrorGuaranteed> { let default_variants: SmallVec<[_; 1]> = enum_def .variants .iter() @@ -120,9 +123,9 @@ fn extract_default_variant<'a>( let suggs = possible_defaults .map(|v| errors::NoDefaultVariantSugg { span: v.span, ident: v.ident }) .collect(); - cx.dcx().emit_err(errors::NoDefaultVariant { span: trait_span, suggs }); + let guar = cx.dcx().emit_err(errors::NoDefaultVariant { span: trait_span, suggs }); - return Err(()); + return Err(guar); } [first, rest @ ..] => { let suggs = default_variants @@ -140,28 +143,28 @@ fn extract_default_variant<'a>( .then_some(errors::MultipleDefaultsSugg { spans, ident: variant.ident }) }) .collect(); - cx.dcx().emit_err(errors::MultipleDefaults { + let guar = cx.dcx().emit_err(errors::MultipleDefaults { span: trait_span, first: first.span, additional: rest.iter().map(|v| v.span).collect(), suggs, }); - return Err(()); + return Err(guar); } }; if !matches!(variant.data, VariantData::Unit(..)) { - cx.dcx().emit_err(errors::NonUnitDefault { span: variant.ident.span }); - return Err(()); + let guar = cx.dcx().emit_err(errors::NonUnitDefault { span: variant.ident.span }); + return Err(guar); } if let Some(non_exhaustive_attr) = attr::find_by_name(&variant.attrs, sym::non_exhaustive) { - cx.dcx().emit_err(errors::NonExhaustiveDefault { + let guar = cx.dcx().emit_err(errors::NonExhaustiveDefault { span: variant.ident.span, non_exhaustive: non_exhaustive_attr.span, }); - return Err(()); + return Err(guar); } Ok(variant) @@ -170,7 +173,7 @@ fn extract_default_variant<'a>( fn validate_default_attribute( cx: &mut ExtCtxt<'_>, default_variant: &rustc_ast::Variant, -) -> Result<(), ()> { +) -> Result<(), ErrorGuaranteed> { let attrs: SmallVec<[_; 1]> = attr::filter_by_name(&default_variant.attrs, kw::Default).collect(); @@ -183,7 +186,7 @@ fn validate_default_attribute( let sugg = errors::MultipleDefaultAttrsSugg { spans: rest.iter().map(|attr| attr.span).collect(), }; - cx.dcx().emit_err(errors::MultipleDefaultAttrs { + let guar = cx.dcx().emit_err(errors::MultipleDefaultAttrs { span: default_variant.ident.span, first: first.span, first_rest: rest[0].span, @@ -192,13 +195,13 @@ fn validate_default_attribute( sugg, }); - return Err(()); + return Err(guar); } }; if !attr.is_word() { - cx.dcx().emit_err(errors::DefaultHasArg { span: attr.span }); + let guar = cx.dcx().emit_err(errors::DefaultHasArg { span: attr.span }); - return Err(()); + return Err(guar); } Ok(()) } diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs index a0fd0e3f9be08..67ace546ad042 100644 --- a/compiler/rustc_builtin_macros/src/env.rs +++ b/compiler/rustc_builtin_macros/src/env.rs @@ -28,8 +28,9 @@ pub fn expand_option_env<'cx>( sp: Span, tts: TokenStream, ) -> Box { - let Some(var) = get_single_str_from_tts(cx, sp, tts, "option_env!") else { - return DummyResult::any(sp); + let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") { + Ok(var) => var, + Err(guar) => return DummyResult::any(sp, guar), }; let sp = cx.with_def_site_ctxt(sp); @@ -65,24 +66,25 @@ pub fn expand_env<'cx>( tts: TokenStream, ) -> Box { let mut exprs = match get_exprs_from_tts(cx, tts) { - Some(exprs) if exprs.is_empty() || exprs.len() > 2 => { - cx.dcx().emit_err(errors::EnvTakesArgs { span: sp }); - return DummyResult::any(sp); + Ok(exprs) if exprs.is_empty() || exprs.len() > 2 => { + let guar = cx.dcx().emit_err(errors::EnvTakesArgs { span: sp }); + return DummyResult::any(sp, guar); } - None => return DummyResult::any(sp), - Some(exprs) => exprs.into_iter(), + Err(guar) => return DummyResult::any(sp, guar), + Ok(exprs) => exprs.into_iter(), }; let var_expr = exprs.next().unwrap(); - let Some((var, _)) = expr_to_string(cx, var_expr.clone(), "expected string literal") else { - return DummyResult::any(sp); + let var = match expr_to_string(cx, var_expr.clone(), "expected string literal") { + Ok((var, _)) => var, + Err(guar) => return DummyResult::any(sp, guar), }; let custom_msg = match exprs.next() { None => None, Some(second) => match expr_to_string(cx, second, "expected string literal") { - None => return DummyResult::any(sp), - Some((s, _)) => Some(s), + Ok((s, _)) => Some(s), + Err(guar) => return DummyResult::any(sp, guar), }, }; @@ -100,23 +102,23 @@ pub fn expand_env<'cx>( unreachable!("`expr_to_string` ensures this is a string lit") }; - if let Some(msg_from_user) = custom_msg { - cx.dcx().emit_err(errors::EnvNotDefinedWithUserMessage { span, msg_from_user }); + let guar = if let Some(msg_from_user) = custom_msg { + cx.dcx().emit_err(errors::EnvNotDefinedWithUserMessage { span, msg_from_user }) } else if is_cargo_env_var(var.as_str()) { cx.dcx().emit_err(errors::EnvNotDefined::CargoEnvVar { span, var: *symbol, var_expr: var_expr.ast_deref(), - }); + }) } else { cx.dcx().emit_err(errors::EnvNotDefined::CustomEnvVar { span, var: *symbol, var_expr: var_expr.ast_deref(), - }); - } + }) + }; - return DummyResult::any(sp); + return DummyResult::any(sp, guar); } Some(value) => cx.expr_str(span, value), }; diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index 3366378d38da8..06c2b6177068a 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -13,7 +13,7 @@ use rustc_expand::base::{self, *}; use rustc_parse::parser::Recovered; use rustc_parse_format as parse; use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{BytePos, InnerSpan, Span}; +use rustc_span::{BytePos, ErrorGuaranteed, InnerSpan, Span}; use rustc_lint_defs::builtin::NAMED_ARGUMENTS_USED_POSITIONALLY; use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, LintId}; @@ -160,7 +160,7 @@ fn make_format_args( ecx: &mut ExtCtxt<'_>, input: MacroInput, append_newline: bool, -) -> Result { +) -> Result { let msg = "format argument must be a string literal"; let unexpanded_fmt_span = input.fmtstr.span; @@ -173,38 +173,41 @@ fn make_format_args( } Ok(fmt) => fmt, Err(err) => { - if let Some((mut err, suggested)) = err { - if !suggested { - if let ExprKind::Block(block, None) = &efmt.kind - && block.stmts.len() == 1 - && let StmtKind::Expr(expr) = &block.stmts[0].kind - && let ExprKind::Path(None, path) = &expr.kind - && path.is_potential_trivial_const_arg() - { - err.multipart_suggestion( - "quote your inlined format argument to use as string literal", - vec![ - (unexpanded_fmt_span.shrink_to_hi(), "\"".to_string()), - (unexpanded_fmt_span.shrink_to_lo(), "\"".to_string()), - ], - Applicability::MaybeIncorrect, - ); - } else { - let sugg_fmt = match args.explicit_args().len() { - 0 => "{}".to_string(), - _ => format!("{}{{}}", "{} ".repeat(args.explicit_args().len())), - }; - err.span_suggestion( - unexpanded_fmt_span.shrink_to_lo(), - "you might be missing a string literal to format with", - format!("\"{sugg_fmt}\", "), - Applicability::MaybeIncorrect, - ); + let guar = match err { + Ok((mut err, suggested)) => { + if !suggested { + if let ExprKind::Block(block, None) = &efmt.kind + && block.stmts.len() == 1 + && let StmtKind::Expr(expr) = &block.stmts[0].kind + && let ExprKind::Path(None, path) = &expr.kind + && path.is_potential_trivial_const_arg() + { + err.multipart_suggestion( + "quote your inlined format argument to use as string literal", + vec![ + (unexpanded_fmt_span.shrink_to_hi(), "\"".to_string()), + (unexpanded_fmt_span.shrink_to_lo(), "\"".to_string()), + ], + Applicability::MaybeIncorrect, + ); + } else { + let sugg_fmt = match args.explicit_args().len() { + 0 => "{}".to_string(), + _ => format!("{}{{}}", "{} ".repeat(args.explicit_args().len())), + }; + err.span_suggestion( + unexpanded_fmt_span.shrink_to_lo(), + "you might be missing a string literal to format with", + format!("\"{sugg_fmt}\", "), + Applicability::MaybeIncorrect, + ); + } } + err.emit() } - err.emit(); - } - return Err(()); + Err(guar) => guar, + }; + return Err(guar); } }; @@ -293,8 +296,8 @@ fn make_format_args( } } } - ecx.dcx().emit_err(e); - return Err(()); + let guar = ecx.dcx().emit_err(e); + return Err(guar); } let to_span = |inner_span: rustc_parse_format::InnerSpan| { @@ -353,9 +356,9 @@ fn make_format_args( } else { // For the moment capturing variables from format strings expanded from macros is // disabled (see RFC #2795) - ecx.dcx().emit_err(errors::FormatNoArgNamed { span, name }); + let guar = ecx.dcx().emit_err(errors::FormatNoArgNamed { span, name }); unnamed_arg_after_named_arg = true; - DummyResult::raw_expr(span, true) + DummyResult::raw_expr(span, Some(guar)) }; Ok(args.add(FormatArgument { kind: FormatArgumentKind::Captured(ident), expr })) } @@ -972,16 +975,13 @@ fn expand_format_args_impl<'cx>( ) -> Box { sp = ecx.with_def_site_ctxt(sp); match parse_args(ecx, sp, tts) { - Ok(input) => { - if let Ok(format_args) = make_format_args(ecx, input, nl) { - MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(P(format_args)))) - } else { - MacEager::expr(DummyResult::raw_expr(sp, true)) - } - } + Ok(input) => match make_format_args(ecx, input, nl) { + Ok(format_args) => MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(P(format_args)))), + Err(guar) => MacEager::expr(DummyResult::raw_expr(sp, Some(guar))), + }, Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index d30ccab239437..f344dbcd10c06 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -15,6 +15,7 @@ #![feature(lint_reasons)] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] +#![feature(try_blocks)] extern crate proc_macro; diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 43d13569d1ee1..3860057e1d412 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -103,15 +103,16 @@ pub fn expand_include<'cx>( tts: TokenStream, ) -> Box { let sp = cx.with_def_site_ctxt(sp); - let Some(file) = get_single_str_from_tts(cx, sp, tts, "include!") else { - return DummyResult::any(sp); + let file = match get_single_str_from_tts(cx, sp, tts, "include!") { + Ok(file) => file, + Err(guar) => return DummyResult::any(sp, guar), }; // The file will be added to the code map by the parser let file = match resolve_path(&cx.sess, file.as_str(), sp) { Ok(f) => f, Err(err) => { - err.emit(); - return DummyResult::any(sp); + let guar = err.emit(); + return DummyResult::any(sp, guar); } }; let p = new_parser_from_file(cx.parse_sess(), &file, Some(sp)); @@ -130,7 +131,7 @@ pub fn expand_include<'cx>( } impl<'a> base::MacResult for ExpandResult<'a> { fn make_expr(mut self: Box>) -> Option> { - let r = base::parse_expr(&mut self.p)?; + let expr = base::parse_expr(&mut self.p).ok()?; if self.p.token != token::Eof { self.p.sess.buffer_lint( INCOMPLETE_INCLUDE, @@ -139,7 +140,7 @@ pub fn expand_include<'cx>( "include macro expected single expression in source", ); } - Some(r) + Some(expr) } fn make_items(mut self: Box>) -> Option; 1]>> { @@ -176,14 +177,15 @@ pub fn expand_include_str( tts: TokenStream, ) -> Box { let sp = cx.with_def_site_ctxt(sp); - let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_str!") else { - return DummyResult::any(sp); + let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") { + Ok(file) => file, + Err(guar) => return DummyResult::any(sp, guar), }; let file = match resolve_path(&cx.sess, file.as_str(), sp) { Ok(f) => f, Err(err) => { - err.emit(); - return DummyResult::any(sp); + let guar = err.emit(); + return DummyResult::any(sp, guar); } }; match cx.source_map().load_binary_file(&file) { @@ -193,13 +195,13 @@ pub fn expand_include_str( base::MacEager::expr(cx.expr_str(sp, interned_src)) } Err(_) => { - cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display())); - DummyResult::any(sp) + let guar = cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display())); + DummyResult::any(sp, guar) } }, Err(e) => { - cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); - DummyResult::any(sp) + let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); + DummyResult::any(sp, guar) } } } @@ -210,14 +212,15 @@ pub fn expand_include_bytes( tts: TokenStream, ) -> Box { let sp = cx.with_def_site_ctxt(sp); - let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else { - return DummyResult::any(sp); + let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") { + Ok(file) => file, + Err(guar) => return DummyResult::any(sp, guar), }; let file = match resolve_path(&cx.sess, file.as_str(), sp) { Ok(f) => f, Err(err) => { - err.emit(); - return DummyResult::any(sp); + let guar = err.emit(); + return DummyResult::any(sp, guar); } }; match cx.source_map().load_binary_file(&file) { @@ -226,8 +229,8 @@ pub fn expand_include_bytes( base::MacEager::expr(expr) } Err(e) => { - cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); - DummyResult::any(sp) + let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/type_ascribe.rs b/compiler/rustc_builtin_macros/src/type_ascribe.rs index 564797012ae26..e8b8fe75338cb 100644 --- a/compiler/rustc_builtin_macros/src/type_ascribe.rs +++ b/compiler/rustc_builtin_macros/src/type_ascribe.rs @@ -13,8 +13,8 @@ pub fn expand_type_ascribe( let (expr, ty) = match parse_ascribe(cx, tts) { Ok(parsed) => parsed, Err(err) => { - err.emit(); - return DummyResult::any(span); + let guar = err.emit(); + return DummyResult::any(span, guar); } }; diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 762d6745341ae..7ece46523dbfe 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -532,7 +532,7 @@ impl MacResult for MacEager { /// after hitting errors. #[derive(Copy, Clone)] pub struct DummyResult { - is_error: bool, + guar: Option, span: Span, } @@ -541,20 +541,24 @@ impl DummyResult { /// /// Use this as a return value after hitting any errors and /// calling `span_err`. - pub fn any(span: Span) -> Box { - Box::new(DummyResult { is_error: true, span }) + pub fn any(span: Span, guar: ErrorGuaranteed) -> Box { + Box::new(DummyResult { guar: Some(guar), span }) } /// Same as `any`, but must be a valid fragment, not error. pub fn any_valid(span: Span) -> Box { - Box::new(DummyResult { is_error: false, span }) + Box::new(DummyResult { guar: None, span }) } /// A plain dummy expression. - pub fn raw_expr(sp: Span, is_error: bool) -> P { + pub fn raw_expr(sp: Span, guar: Option) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(ThinVec::new()) }, + kind: if let Some(guar) = guar { + ast::ExprKind::Err(guar) + } else { + ast::ExprKind::Tup(ThinVec::new()) + }, span: sp, attrs: ast::AttrVec::new(), tokens: None, @@ -582,7 +586,7 @@ impl DummyResult { impl MacResult for DummyResult { fn make_expr(self: Box) -> Option> { - Some(DummyResult::raw_expr(self.span, self.is_error)) + Some(DummyResult::raw_expr(self.span, self.guar)) } fn make_pat(self: Box) -> Option> { @@ -608,7 +612,7 @@ impl MacResult for DummyResult { fn make_stmts(self: Box) -> Option> { Some(smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, - kind: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)), + kind: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.guar)), span: self.span, }]) } @@ -884,17 +888,19 @@ impl SyntaxExtension { } } + /// A dummy bang macro `foo!()`. pub fn dummy_bang(edition: Edition) -> SyntaxExtension { fn expander<'cx>( - _: &'cx mut ExtCtxt<'_>, + cx: &'cx mut ExtCtxt<'_>, span: Span, _: TokenStream, ) -> Box { - DummyResult::any(span) + DummyResult::any(span, cx.dcx().span_delayed_bug(span, "expanded a dummy bang macro")) } SyntaxExtension::default(SyntaxExtensionKind::LegacyBang(Box::new(expander)), edition) } + /// A dummy derive macro `#[derive(Foo)]`. pub fn dummy_derive(edition: Edition) -> SyntaxExtension { fn expander( _: &mut ExtCtxt<'_>, @@ -1066,7 +1072,7 @@ pub struct ExtCtxt<'a> { pub sess: &'a Session, pub ecfg: expand::ExpansionConfig<'a>, pub num_standard_library_imports: usize, - pub reduced_recursion_limit: Option, + pub reduced_recursion_limit: Option<(Limit, ErrorGuaranteed)>, pub root_path: PathBuf, pub resolver: &'a mut dyn ResolverExpand, pub current_expansion: ExpansionData, @@ -1244,7 +1250,7 @@ pub fn resolve_path( /// Extracts a string literal from the macro expanded version of `expr`, /// returning a diagnostic error of `err_msg` if `expr` is not a string literal. /// The returned bool indicates whether an applicable suggestion has already been -/// added to the diagnostic to avoid emitting multiple suggestions. `Err(None)` +/// added to the diagnostic to avoid emitting multiple suggestions. `Err(Err(ErrorGuaranteed))` /// indicates that an ast error was encountered. // FIXME(Nilstrieb) Make this function setup translatable #[allow(rustc::untranslatable_diagnostic)] @@ -1252,7 +1258,10 @@ pub fn expr_to_spanned_string<'a>( cx: &'a mut ExtCtxt<'_>, expr: P, err_msg: &'static str, -) -> Result<(Symbol, ast::StrStyle, Span), Option<(DiagnosticBuilder<'a>, bool)>> { +) -> Result< + (Symbol, ast::StrStyle, Span), + Result<(DiagnosticBuilder<'a>, bool /* has_suggestions */), ErrorGuaranteed>, +> { // Perform eager expansion on the expression. // We want to be able to handle e.g., `concat!("foo", "bar")`. let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); @@ -1269,38 +1278,33 @@ pub fn expr_to_spanned_string<'a>( "", Applicability::MaybeIncorrect, ); - Some((err, true)) - } - Ok(ast::LitKind::Err(_)) => None, - Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, expr.span); - None + Ok((err, true)) } - _ => Some((cx.dcx().struct_span_err(expr.span, err_msg), false)), + Ok(ast::LitKind::Err(guar)) => Err(guar), + Err(err) => Err(report_lit_error(&cx.sess.parse_sess, err, token_lit, expr.span)), + _ => Ok((cx.dcx().struct_span_err(expr.span, err_msg), false)), }, - ast::ExprKind::Err => None, + ast::ExprKind::Err(guar) => Err(guar), ast::ExprKind::Dummy => { cx.dcx().span_bug(expr.span, "tried to get a string literal from `ExprKind::Dummy`") } - _ => Some((cx.dcx().struct_span_err(expr.span, err_msg), false)), + _ => Ok((cx.dcx().struct_span_err(expr.span, err_msg), false)), }) } /// Extracts a string literal from the macro expanded version of `expr`, /// emitting `err_msg` if `expr` is not a string literal. This does not stop -/// compilation on error, merely emits a non-fatal error and returns `None`. +/// compilation on error, merely emits a non-fatal error and returns `Err`. pub fn expr_to_string( cx: &mut ExtCtxt<'_>, expr: P, err_msg: &'static str, -) -> Option<(Symbol, ast::StrStyle)> { +) -> Result<(Symbol, ast::StrStyle), ErrorGuaranteed> { expr_to_spanned_string(cx, expr, err_msg) - .map_err(|err| { - err.map(|(err, _)| { - err.emit(); - }) + .map_err(|err| match err { + Ok((err, _)) => err.emit(), + Err(guar) => guar, }) - .ok() .map(|(symbol, style, _)| (symbol, style)) } @@ -1314,32 +1318,30 @@ pub fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str } } -/// Parse an expression. On error, emit it, advancing to `Eof`, and return `None`. -pub fn parse_expr(p: &mut parser::Parser<'_>) -> Option> { - match p.parse_expr() { - Ok(e) => return Some(e), - Err(err) => { - err.emit(); - } - } +/// Parse an expression. On error, emit it, advancing to `Eof`, and return `Err`. +pub fn parse_expr(p: &mut parser::Parser<'_>) -> Result, ErrorGuaranteed> { + let guar = match p.parse_expr() { + Ok(expr) => return Ok(expr), + Err(err) => err.emit(), + }; while p.token != token::Eof { p.bump(); } - None + Err(guar) } /// Interpreting `tts` as a comma-separated sequence of expressions, -/// expect exactly one string literal, or emit an error and return `None`. +/// expect exactly one string literal, or emit an error and return `Err`. pub fn get_single_str_from_tts( cx: &mut ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str, -) -> Option { +) -> Result { let mut p = cx.new_parser_from_tts(tts); if p.token == token::Eof { - cx.dcx().emit_err(errors::OnlyOneArgument { span, name }); - return None; + let guar = cx.dcx().emit_err(errors::OnlyOneArgument { span, name }); + return Err(guar); } let ret = parse_expr(&mut p)?; let _ = p.eat(&token::Comma); @@ -1351,8 +1353,11 @@ pub fn get_single_str_from_tts( } /// Extracts comma-separated expressions from `tts`. -/// On error, emit it, and return `None`. -pub fn get_exprs_from_tts(cx: &mut ExtCtxt<'_>, tts: TokenStream) -> Option>> { +/// On error, emit it, and return `Err`. +pub fn get_exprs_from_tts( + cx: &mut ExtCtxt<'_>, + tts: TokenStream, +) -> Result>, ErrorGuaranteed> { let mut p = cx.new_parser_from_tts(tts); let mut es = Vec::new(); while p.token != token::Eof { @@ -1367,11 +1372,11 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt<'_>, tts: TokenStream) -> Option AstFragment { - self.make_from(DummyResult::any(span)).expect("couldn't create a dummy AST fragment") + pub(crate) fn dummy(self, span: Span, guar: ErrorGuaranteed) -> AstFragment { + self.make_from(DummyResult::any(span, guar)).expect("couldn't create a dummy AST fragment") } pub fn supports_macro_expansion(self) -> SupportsMacroExpansion { @@ -604,14 +604,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { (fragment, invocations) } - fn error_recursion_limit_reached(&mut self) { + fn error_recursion_limit_reached(&mut self) -> ErrorGuaranteed { let expn_data = self.cx.current_expansion.id.expn_data(); let suggested_limit = match self.cx.ecfg.recursion_limit { Limit(0) => Limit(2), limit => limit * 2, }; - self.cx.dcx().emit_err(RecursionLimitReached { + let guar = self.cx.dcx().emit_err(RecursionLimitReached { span: expn_data.call_site, descr: expn_data.kind.descr(), suggested_limit, @@ -619,14 +619,21 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }); self.cx.trace_macros_diag(); + guar } /// A macro's expansion does not fit in this fragment kind. /// For example, a non-type macro in a type position. - fn error_wrong_fragment_kind(&mut self, kind: AstFragmentKind, mac: &ast::MacCall, span: Span) { - self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path }); - + fn error_wrong_fragment_kind( + &mut self, + kind: AstFragmentKind, + mac: &ast::MacCall, + span: Span, + ) -> ErrorGuaranteed { + let guar = + self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path }); self.cx.trace_macros_diag(); + guar } fn expand_invoc( @@ -634,36 +641,41 @@ impl<'a, 'b> MacroExpander<'a, 'b> { invoc: Invocation, ext: &SyntaxExtensionKind, ) -> ExpandResult { - let recursion_limit = - self.cx.reduced_recursion_limit.unwrap_or(self.cx.ecfg.recursion_limit); + let recursion_limit = match self.cx.reduced_recursion_limit { + Some((limit, _)) => limit, + None => self.cx.ecfg.recursion_limit, + }; + if !recursion_limit.value_within_limit(self.cx.current_expansion.depth) { - if self.cx.reduced_recursion_limit.is_none() { - self.error_recursion_limit_reached(); - } + let guar = match self.cx.reduced_recursion_limit { + Some((_, guar)) => guar, + None => self.error_recursion_limit_reached(), + }; // Reduce the recursion limit by half each time it triggers. - self.cx.reduced_recursion_limit = Some(recursion_limit / 2); + self.cx.reduced_recursion_limit = Some((recursion_limit / 2, guar)); - return ExpandResult::Ready(invoc.fragment_kind.dummy(invoc.span())); + return ExpandResult::Ready(invoc.fragment_kind.dummy(invoc.span(), guar)); } let (fragment_kind, span) = (invoc.fragment_kind, invoc.span()); ExpandResult::Ready(match invoc.kind { InvocationKind::Bang { mac, .. } => match ext { SyntaxExtensionKind::Bang(expander) => { - let Ok(tok_result) = expander.expand(self.cx, span, mac.args.tokens.clone()) - else { - return ExpandResult::Ready(fragment_kind.dummy(span)); - }; - self.parse_ast_fragment(tok_result, fragment_kind, &mac.path, span) + match expander.expand(self.cx, span, mac.args.tokens.clone()) { + Ok(tok_result) => { + self.parse_ast_fragment(tok_result, fragment_kind, &mac.path, span) + } + Err(guar) => return ExpandResult::Ready(fragment_kind.dummy(span, guar)), + } } SyntaxExtensionKind::LegacyBang(expander) => { let tok_result = expander.expand(self.cx, span, mac.args.tokens.clone()); let result = if let Some(result) = fragment_kind.make_from(tok_result) { result } else { - self.error_wrong_fragment_kind(fragment_kind, &mac, span); - fragment_kind.dummy(span) + let guar = self.error_wrong_fragment_kind(fragment_kind, &mac, span); + fragment_kind.dummy(span, guar) }; result } @@ -705,11 +717,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.cx.dcx().emit_err(UnsupportedKeyValue { span }); } let inner_tokens = attr_item.args.inner_tokens(); - let Ok(tok_result) = expander.expand(self.cx, span, inner_tokens, tokens) - else { - return ExpandResult::Ready(fragment_kind.dummy(span)); - }; - self.parse_ast_fragment(tok_result, fragment_kind, &attr_item.path, span) + match expander.expand(self.cx, span, inner_tokens, tokens) { + Ok(tok_result) => self.parse_ast_fragment( + tok_result, + fragment_kind, + &attr_item.path, + span, + ), + Err(guar) => return ExpandResult::Ready(fragment_kind.dummy(span, guar)), + } } SyntaxExtensionKind::LegacyAttr(expander) => { match validate_attr::parse_meta(&self.cx.sess.parse_sess, &attr) { @@ -729,15 +745,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> { AstFragmentKind::Expr | AstFragmentKind::MethodReceiverExpr ) && items.is_empty() { - self.cx.dcx().emit_err(RemoveExprNotSupported { span }); - fragment_kind.dummy(span) + let guar = self.cx.dcx().emit_err(RemoveExprNotSupported { span }); + fragment_kind.dummy(span, guar) } else { fragment_kind.expect_from_annotatables(items) } } Err(err) => { - err.emit(); - fragment_kind.dummy(span) + let guar = err.emit(); + fragment_kind.dummy(span, guar) } } } @@ -857,9 +873,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { err.span(span); } annotate_err_with_kind(&mut err, kind, span); - err.emit(); + let guar = err.emit(); self.cx.trace_macros_diag(); - kind.dummy(span) + kind.dummy(span, guar) } } } diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index 25af974d3266c..5629c5ef5fa06 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -11,7 +11,7 @@ use rustc_errors::{Applicability, DiagCtxt, DiagnosticBuilder, DiagnosticMessage use rustc_parse::parser::{Parser, Recovery}; use rustc_span::source_map::SourceMap; use rustc_span::symbol::Ident; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; use std::borrow::Cow; use super::macro_rules::{parser_from_cx, NoopTracker}; @@ -47,7 +47,7 @@ pub(super) fn failed_to_match_macro<'cx>( let Some(BestFailure { token, msg: label, remaining_matcher, .. }) = tracker.best_failure else { - return DummyResult::any(sp); + return DummyResult::any(sp, cx.dcx().span_delayed_bug(sp, "failed to match a macro")); }; let span = token.span.substitute_dummy(sp); @@ -106,9 +106,9 @@ pub(super) fn failed_to_match_macro<'cx>( } } } - err.emit(); + let guar = err.emit(); cx.trace_macros_diag(); - DummyResult::any(sp) + DummyResult::any(sp, guar) } /// The tracker used for the slow error path that collects useful info for diagnostics. @@ -180,10 +180,10 @@ impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx, } Error(err_sp, msg) => { let span = err_sp.substitute_dummy(self.root_span); - self.cx.dcx().span_err(span, msg.clone()); - self.result = Some(DummyResult::any(span)); + let guar = self.cx.dcx().span_err(span, msg.clone()); + self.result = Some(DummyResult::any(span, guar)); } - ErrorReported(_) => self.result = Some(DummyResult::any(self.root_span)), + ErrorReported(guar) => self.result = Some(DummyResult::any(self.root_span, *guar)), } } @@ -224,7 +224,7 @@ pub(super) fn emit_frag_parse_err( site_span: Span, arm_span: Span, kind: AstFragmentKind, -) { +) -> ErrorGuaranteed { // FIXME(davidtwco): avoid depending on the error message text if parser.token == token::Eof && let DiagnosticMessage::Str(message) = &e.messages[0].0 @@ -282,7 +282,7 @@ pub(super) fn emit_frag_parse_err( }, _ => annotate_err_with_kind(&mut e, kind, site_span), }; - e.emit(); + e.emit() } pub(crate) fn annotate_err_with_kind( diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index ffc8f782fd344..8174cb03d337b 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -114,7 +114,7 @@ use rustc_errors::{DiagnosticMessage, MultiSpan}; use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER}; use rustc_session::parse::ParseSess; use rustc_span::symbol::kw; -use rustc_span::{symbol::MacroRulesNormalizedIdent, Span}; +use rustc_span::{symbol::MacroRulesNormalizedIdent, ErrorGuaranteed, Span}; use smallvec::SmallVec; @@ -203,17 +203,17 @@ pub(super) fn check_meta_variables( span: Span, lhses: &[TokenTree], rhses: &[TokenTree], -) -> bool { +) -> Result<(), ErrorGuaranteed> { if lhses.len() != rhses.len() { sess.dcx.span_bug(span, "length mismatch between LHSes and RHSes") } - let mut valid = true; + let mut guar = None; for (lhs, rhs) in iter::zip(lhses, rhses) { let mut binders = Binders::default(); - check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut valid); - check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut valid); + check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut guar); + check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut guar); } - valid + guar.map_or(Ok(()), Err) } /// Checks `lhs` as part of the LHS of a macro definition, extends `binders` with new binders, and @@ -226,7 +226,7 @@ pub(super) fn check_meta_variables( /// - `macros` is the stack of possible outer macros /// - `binders` contains the binders of the LHS /// - `ops` is the stack of Kleene operators from the LHS -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_binders( sess: &ParseSess, node_id: NodeId, @@ -234,7 +234,7 @@ fn check_binders( macros: &Stack<'_, MacroState<'_>>, binders: &mut Binders, ops: &Stack<'_, KleeneToken>, - valid: &mut bool, + guar: &mut Option, ) { match *lhs { TokenTree::Token(..) => {} @@ -258,7 +258,7 @@ fn check_binders( binders.insert(name, BinderInfo { span, ops: ops.into() }); } else { // 3. The meta-variable is bound: This is an occurrence. - check_occurrences(sess, node_id, lhs, macros, binders, ops, valid); + check_occurrences(sess, node_id, lhs, macros, binders, ops, guar); } } // Similarly, this can only happen when checking a toplevel macro. @@ -281,8 +281,10 @@ fn check_binders( if let Some(prev_info) = get_binder_info(macros, binders, name) { // Duplicate binders at the top-level macro definition are errors. The lint is only // for nested macro definitions. - sess.dcx.emit_err(errors::DuplicateMatcherBinding { span, prev: prev_info.span }); - *valid = false; + *guar = Some( + sess.dcx + .emit_err(errors::DuplicateMatcherBinding { span, prev: prev_info.span }), + ); } else { binders.insert(name, BinderInfo { span, ops: ops.into() }); } @@ -291,13 +293,13 @@ fn check_binders( TokenTree::MetaVarExpr(..) => {} TokenTree::Delimited(.., ref del) => { for tt in &del.tts { - check_binders(sess, node_id, tt, macros, binders, ops, valid); + check_binders(sess, node_id, tt, macros, binders, ops, guar); } } TokenTree::Sequence(_, ref seq) => { let ops = ops.push(seq.kleene); for tt in &seq.tts { - check_binders(sess, node_id, tt, macros, binders, &ops, valid); + check_binders(sess, node_id, tt, macros, binders, &ops, guar); } } } @@ -327,7 +329,7 @@ fn get_binder_info<'a>( /// - `macros` is the stack of possible outer macros /// - `binders` contains the binders of the associated LHS /// - `ops` is the stack of Kleene operators from the RHS -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_occurrences( sess: &ParseSess, node_id: NodeId, @@ -335,7 +337,7 @@ fn check_occurrences( macros: &Stack<'_, MacroState<'_>>, binders: &Binders, ops: &Stack<'_, KleeneToken>, - valid: &mut bool, + guar: &mut Option, ) { match *rhs { TokenTree::Token(..) => {} @@ -353,11 +355,11 @@ fn check_occurrences( check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name); } TokenTree::Delimited(.., ref del) => { - check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid); + check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, guar); } TokenTree::Sequence(_, ref seq) => { let ops = ops.push(seq.kleene); - check_nested_occurrences(sess, node_id, &seq.tts, macros, binders, &ops, valid); + check_nested_occurrences(sess, node_id, &seq.tts, macros, binders, &ops, guar); } } } @@ -392,7 +394,7 @@ enum NestedMacroState { /// - `macros` is the stack of possible outer macros /// - `binders` contains the binders of the associated LHS /// - `ops` is the stack of Kleene operators from the RHS -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_nested_occurrences( sess: &ParseSess, node_id: NodeId, @@ -400,7 +402,7 @@ fn check_nested_occurrences( macros: &Stack<'_, MacroState<'_>>, binders: &Binders, ops: &Stack<'_, KleeneToken>, - valid: &mut bool, + guar: &mut Option, ) { let mut state = NestedMacroState::Empty; let nested_macros = macros.push(MacroState { binders, ops: ops.into() }); @@ -432,7 +434,7 @@ fn check_nested_occurrences( (NestedMacroState::MacroRulesNot, &TokenTree::MetaVar(..)) => { state = NestedMacroState::MacroRulesNotName; // We check that the meta-variable is correctly used. - check_occurrences(sess, node_id, tt, macros, binders, ops, valid); + check_occurrences(sess, node_id, tt, macros, binders, ops, guar); } (NestedMacroState::MacroRulesNotName, TokenTree::Delimited(.., del)) | (NestedMacroState::MacroName, TokenTree::Delimited(.., del)) @@ -441,7 +443,7 @@ fn check_nested_occurrences( let macro_rules = state == NestedMacroState::MacroRulesNotName; state = NestedMacroState::Empty; let rest = - check_nested_macro(sess, node_id, macro_rules, &del.tts, &nested_macros, valid); + check_nested_macro(sess, node_id, macro_rules, &del.tts, &nested_macros, guar); // If we did not check the whole macro definition, then check the rest as if outside // the macro definition. check_nested_occurrences( @@ -451,7 +453,7 @@ fn check_nested_occurrences( macros, binders, ops, - valid, + guar, ); } ( @@ -463,7 +465,7 @@ fn check_nested_occurrences( (NestedMacroState::Macro, &TokenTree::MetaVar(..)) => { state = NestedMacroState::MacroName; // We check that the meta-variable is correctly used. - check_occurrences(sess, node_id, tt, macros, binders, ops, valid); + check_occurrences(sess, node_id, tt, macros, binders, ops, guar); } (NestedMacroState::MacroName, TokenTree::Delimited(.., del)) if del.delim == Delimiter::Parenthesis => @@ -477,7 +479,7 @@ fn check_nested_occurrences( &nested_macros, &mut nested_binders, &Stack::Empty, - valid, + guar, ); } (NestedMacroState::MacroNameParen, TokenTree::Delimited(.., del)) @@ -491,12 +493,12 @@ fn check_nested_occurrences( &nested_macros, &nested_binders, &Stack::Empty, - valid, + guar, ); } (_, tt) => { state = NestedMacroState::Empty; - check_occurrences(sess, node_id, tt, macros, binders, ops, valid); + check_occurrences(sess, node_id, tt, macros, binders, ops, guar); } } } @@ -515,14 +517,14 @@ fn check_nested_occurrences( /// - `macro_rules` specifies whether the macro is `macro_rules` /// - `tts` is checked as a list of (LHS) => {RHS} /// - `macros` is the stack of outer macros -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_nested_macro( sess: &ParseSess, node_id: NodeId, macro_rules: bool, tts: &[TokenTree], macros: &Stack<'_, MacroState<'_>>, - valid: &mut bool, + guar: &mut Option, ) -> usize { let n = tts.len(); let mut i = 0; @@ -539,8 +541,8 @@ fn check_nested_macro( let lhs = &tts[i]; let rhs = &tts[i + 2]; let mut binders = Binders::default(); - check_binders(sess, node_id, lhs, macros, &mut binders, &Stack::Empty, valid); - check_occurrences(sess, node_id, rhs, macros, &binders, &Stack::Empty, valid); + check_binders(sess, node_id, lhs, macros, &mut binders, &Stack::Empty, guar); + check_occurrences(sess, node_id, rhs, macros, &binders, &Stack::Empty, guar); // Since the last semicolon is optional for `macro_rules` macros and decl_macro are not terminated, // we increment our checked position by how many token trees we already checked (the 3 // above) before checking for the separator. diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index bf99e9e6d5cc8..c11d538048aa9 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -66,8 +66,10 @@ impl<'a> ParserAnyMacro<'a> { let fragment = match parse_ast_fragment(parser, kind) { Ok(f) => f, Err(err) => { - diagnostics::emit_frag_parse_err(err, parser, snapshot, site_span, arm_span, kind); - return kind.dummy(site_span); + let guar = diagnostics::emit_frag_parse_err( + err, parser, snapshot, site_span, arm_span, kind, + ); + return kind.dummy(site_span, guar); } }; @@ -101,7 +103,6 @@ struct MacroRulesMacroExpander { transparency: Transparency, lhses: Vec>, rhses: Vec, - valid: bool, } impl TTMacroExpander for MacroRulesMacroExpander { @@ -111,9 +112,6 @@ impl TTMacroExpander for MacroRulesMacroExpander { sp: Span, input: TokenStream, ) -> Box { - if !self.valid { - return DummyResult::any(sp); - } expand_macro( cx, sp, @@ -128,12 +126,17 @@ impl TTMacroExpander for MacroRulesMacroExpander { } } -fn macro_rules_dummy_expander<'cx>( - _: &'cx mut ExtCtxt<'_>, - span: Span, - _: TokenStream, -) -> Box { - DummyResult::any(span) +struct DummyExpander(ErrorGuaranteed); + +impl TTMacroExpander for DummyExpander { + fn expand<'cx>( + &self, + _: &'cx mut ExtCtxt<'_>, + span: Span, + _: TokenStream, + ) -> Box { + DummyResult::any(span, self.0) + } } fn trace_macros_note(cx_expansions: &mut FxIndexMap>, sp: Span, message: String) { @@ -217,8 +220,8 @@ fn expand_macro<'cx>( let tts = match transcribe(cx, &named_matches, rhs, rhs_span, transparency) { Ok(tts) => tts, Err(err) => { - err.emit(); - return DummyResult::any(arm_span); + let guar = err.emit(); + return DummyResult::any(arm_span, guar); } }; @@ -249,9 +252,9 @@ fn expand_macro<'cx>( is_local, }) } - Err(CanRetry::No(_)) => { + Err(CanRetry::No(guar)) => { debug!("Will not retry matching as an error was emitted already"); - DummyResult::any(sp) + DummyResult::any(sp, guar) } Err(CanRetry::Yes) => { // Retry and emit a better error. @@ -371,7 +374,7 @@ pub fn compile_declarative_macro( def.id != DUMMY_NODE_ID, ) }; - let dummy_syn_ext = || (mk_syn_ext(Box::new(macro_rules_dummy_expander)), Vec::new()); + let dummy_syn_ext = |guar| (mk_syn_ext(Box::new(DummyExpander(guar))), Vec::new()); let dcx = &sess.parse_sess.dcx; let lhs_nm = Ident::new(sym::lhs, def.span); @@ -456,19 +459,20 @@ pub fn compile_declarative_macro( let mut err = sess.dcx().struct_span_err(sp, s); err.span_label(sp, msg); annotate_doc_comment(sess.dcx(), &mut err, sess.source_map(), sp); - err.emit(); - return dummy_syn_ext(); + let guar = err.emit(); + return dummy_syn_ext(guar); } Error(sp, msg) => { - sess.dcx().span_err(sp.substitute_dummy(def.span), msg); - return dummy_syn_ext(); + let guar = sess.dcx().span_err(sp.substitute_dummy(def.span), msg); + return dummy_syn_ext(guar); } - ErrorReported(_) => { - return dummy_syn_ext(); + ErrorReported(guar) => { + return dummy_syn_ext(guar); } }; - let mut valid = true; + let mut guar = None; + let mut check_emission = |ret: Result<(), ErrorGuaranteed>| guar = guar.or(ret.err()); // Extract the arguments: let lhses = match &argument_map[&MacroRulesNormalizedIdent::new(lhs_nm)] { @@ -488,7 +492,7 @@ pub fn compile_declarative_macro( .unwrap(); // We don't handle errors here, the driver will abort // after parsing/expansion. we can report every error in every macro this way. - valid &= check_lhs_nt_follows(sess, def, &tt).is_ok(); + check_emission(check_lhs_nt_follows(sess, def, &tt)); return tt; } sess.dcx().span_bug(def.span, "wrong-structured lhs") @@ -520,15 +524,21 @@ pub fn compile_declarative_macro( }; for rhs in &rhses { - valid &= check_rhs(sess, rhs); + check_emission(check_rhs(sess, rhs)); } // don't abort iteration early, so that errors for multiple lhses can be reported for lhs in &lhses { - valid &= check_lhs_no_empty_seq(sess, slice::from_ref(lhs)); + check_emission(check_lhs_no_empty_seq(sess, slice::from_ref(lhs))); } - valid &= macro_check::check_meta_variables(&sess.parse_sess, def.id, def.span, &lhses, &rhses); + check_emission(macro_check::check_meta_variables( + &sess.parse_sess, + def.id, + def.span, + &lhses, + &rhses, + )); let (transparency, transparency_error) = attr::find_transparency(&def.attrs, macro_rules); match transparency_error { @@ -541,11 +551,15 @@ pub fn compile_declarative_macro( None => {} } + if let Some(guar) = guar { + // To avoid warning noise, only consider the rules of this + // macro for the lint, if all rules are valid. + return dummy_syn_ext(guar); + } + // Compute the spans of the macro rules for unused rule linting. - // To avoid warning noise, only consider the rules of this - // macro for the lint, if all rules are valid. // Also, we are only interested in non-foreign macros. - let rule_spans = if valid && def.id != DUMMY_NODE_ID { + let rule_spans = if def.id != DUMMY_NODE_ID { lhses .iter() .zip(rhses.iter()) @@ -562,23 +576,19 @@ pub fn compile_declarative_macro( }; // Convert the lhses into `MatcherLoc` form, which is better for doing the - // actual matching. Unless the matcher is invalid. - let lhses = if valid { - lhses - .iter() - .map(|lhs| { - // Ignore the delimiters around the matcher. - match lhs { - mbe::TokenTree::Delimited(.., delimited) => { - mbe::macro_parser::compute_locs(&delimited.tts) - } - _ => sess.dcx().span_bug(def.span, "malformed macro lhs"), + // actual matching. + let lhses = lhses + .iter() + .map(|lhs| { + // Ignore the delimiters around the matcher. + match lhs { + mbe::TokenTree::Delimited(.., delimited) => { + mbe::macro_parser::compute_locs(&delimited.tts) } - }) - .collect() - } else { - vec![] - }; + _ => sess.dcx().span_bug(def.span, "malformed macro lhs"), + } + }) + .collect(); let expander = Box::new(MacroRulesMacroExpander { name: def.ident, @@ -587,7 +597,6 @@ pub fn compile_declarative_macro( transparency, lhses, rhses, - valid, }); (mk_syn_ext(expander), rule_spans) } @@ -640,7 +649,7 @@ fn is_empty_token_tree(sess: &Session, seq: &mbe::SequenceRepetition) -> bool { /// Checks that the lhs contains no repetition which could match an empty token /// tree, because then the matcher would hang indefinitely. -fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> bool { +fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> Result<(), ErrorGuaranteed> { use mbe::TokenTree; for tt in tts { match tt { @@ -648,35 +657,26 @@ fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> bool { | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) | TokenTree::MetaVarExpr(..) => (), - TokenTree::Delimited(.., del) => { - if !check_lhs_no_empty_seq(sess, &del.tts) { - return false; - } - } + TokenTree::Delimited(.., del) => check_lhs_no_empty_seq(sess, &del.tts)?, TokenTree::Sequence(span, seq) => { if is_empty_token_tree(sess, seq) { let sp = span.entire(); - sess.dcx().span_err(sp, "repetition matches empty token tree"); - return false; - } - if !check_lhs_no_empty_seq(sess, &seq.tts) { - return false; + let guar = sess.dcx().span_err(sp, "repetition matches empty token tree"); + return Err(guar); } + check_lhs_no_empty_seq(sess, &seq.tts)? } } } - true + Ok(()) } -fn check_rhs(sess: &Session, rhs: &mbe::TokenTree) -> bool { +fn check_rhs(sess: &Session, rhs: &mbe::TokenTree) -> Result<(), ErrorGuaranteed> { match *rhs { - mbe::TokenTree::Delimited(..) => return true, - _ => { - sess.dcx().span_err(rhs.span(), "macro rhs must be delimited"); - } + mbe::TokenTree::Delimited(..) => Ok(()), + _ => Err(sess.dcx().span_err(rhs.span(), "macro rhs must be delimited")), } - false } fn check_matcher( diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 35ee0c530463b..3481c66da702e 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -758,7 +758,7 @@ trait UnusedDelimLint { } impl<'ast> Visitor<'ast> for ErrExprVisitor { fn visit_expr(&mut self, expr: &'ast ast::Expr) { - if let ExprKind::Err = expr.kind { + if let ExprKind::Err(_) = expr.kind { self.has_error = true; return; } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 517e3d827876b..cc1f7c8ac7d58 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -744,7 +744,8 @@ impl<'a> Parser<'a> { Err(err) } - pub(super) fn attr_on_non_tail_expr(&self, expr: &Expr) { + /// The user has written `#[attr] expr` which is unsupported. (#106020) + pub(super) fn attr_on_non_tail_expr(&self, expr: &Expr) -> ErrorGuaranteed { // Missing semicolon typo error. let span = self.prev_token.span.shrink_to_hi(); let mut err = self.dcx().create_err(ExpectedSemi { @@ -787,6 +788,8 @@ impl<'a> Parser<'a> { ], Applicability::MachineApplicable, ); + + // Special handling for `#[cfg(...)]` chains let mut snapshot = self.create_snapshot_for_diagnostic(); if let [attr] = &expr.attrs[..] && let ast::AttrKind::Normal(attr_kind) = &attr.kind @@ -799,7 +802,7 @@ impl<'a> Parser<'a> { Err(inner_err) => { err.cancel(); inner_err.cancel(); - return; + return self.dcx().span_delayed_bug(expr.span, "not a tail expression"); } } && let ast::AttrKind::Normal(next_attr_kind) = next_attr.kind @@ -812,7 +815,7 @@ impl<'a> Parser<'a> { Err(inner_err) => { err.cancel(); inner_err.cancel(); - return; + return self.dcx().span_delayed_bug(expr.span, "not a tail expression"); } }; // We have for sure @@ -845,7 +848,7 @@ impl<'a> Parser<'a> { ); } } - err.emit(); + err.emit() } fn check_too_many_raw_str_terminators(&mut self, err: &mut DiagnosticBuilder<'_>) -> bool { @@ -921,10 +924,10 @@ impl<'a> Parser<'a> { // fn foo() -> Foo { Path { // field: value, // } } - err.delay_as_bug(); + let guar = err.delay_as_bug(); self.restore_snapshot(snapshot); let mut tail = self.mk_block( - thin_vec![self.mk_stmt_err(expr.span)], + thin_vec![self.mk_stmt_err(expr.span, guar)], s, lo.to(self.prev_token.span), ); @@ -990,7 +993,7 @@ impl<'a> Parser<'a> { decl_hi: Span, ) -> PResult<'a, P> { err.span_label(lo.to(decl_hi), "while parsing the body of this closure"); - match before.kind { + let guar = match before.kind { token::OpenDelim(Delimiter::Brace) if !matches!(token.kind, token::OpenDelim(Delimiter::Brace)) => { @@ -1004,8 +1007,9 @@ impl<'a> Parser<'a> { ], Applicability::MaybeIncorrect, ); - err.emit(); + let guar = err.emit(); self.eat_to_tokens(&[&token::CloseDelim(Delimiter::Brace)]); + guar } token::OpenDelim(Delimiter::Parenthesis) if !matches!(token.kind, token::OpenDelim(Delimiter::Brace)) => @@ -1022,7 +1026,7 @@ impl<'a> Parser<'a> { ], Applicability::MaybeIncorrect, ); - err.emit(); + err.emit() } _ if !matches!(token.kind, token::OpenDelim(Delimiter::Brace)) => { // We don't have a heuristic to correctly identify where the block @@ -1035,8 +1039,8 @@ impl<'a> Parser<'a> { return Err(err); } _ => return Err(err), - } - Ok(self.mk_expr_err(lo.to(self.token.span))) + }; + Ok(self.mk_expr_err(lo.to(self.token.span), guar)) } /// Eats and discards tokens until one of `kets` is encountered. Respects token trees, @@ -1214,7 +1218,7 @@ impl<'a> Parser<'a> { &mut self, mut e: DiagnosticBuilder<'a>, expr: &mut P, - ) -> PResult<'a, ()> { + ) -> PResult<'a, ErrorGuaranteed> { if let ExprKind::Binary(binop, _, _) = &expr.kind && let ast::BinOpKind::Lt = binop.node && self.eat(&token::Comma) @@ -1239,9 +1243,9 @@ impl<'a> Parser<'a> { // The subsequent expression is valid. Mark // `expr` as erroneous and emit `e` now, but // return `Ok` so parsing can continue. - e.emit(); - *expr = self.mk_expr_err(expr.span.to(self.prev_token.span)); - return Ok(()); + let guar = e.emit(); + *expr = self.mk_expr_err(expr.span.to(self.prev_token.span), guar); + return Ok(guar); } Err(err) => { err.cancel(); @@ -1393,7 +1397,8 @@ impl<'a> Parser<'a> { outer_op.node, ); - let mk_err_expr = |this: &Self, span| Ok(Some(this.mk_expr(span, ExprKind::Err))); + let mk_err_expr = + |this: &Self, span, guar| Ok(Some(this.mk_expr(span, ExprKind::Err(guar)))); match &inner_op.kind { ExprKind::Binary(op, l1, r1) if op.node.is_comparison() => { @@ -1443,11 +1448,11 @@ impl<'a> Parser<'a> { match self.parse_expr() { Ok(_) => { // 99% certain that the suggestion is correct, continue parsing. - self.dcx().emit_err(err); + let guar = self.dcx().emit_err(err); // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, inner_op.span.to(self.prev_token.span)) + mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar) } Err(expr_err) => { expr_err.cancel(); @@ -1471,11 +1476,11 @@ impl<'a> Parser<'a> { match self.consume_fn_args() { Err(()) => Err(self.dcx().create_err(err)), Ok(()) => { - self.dcx().emit_err(err); + let guar = self.dcx().emit_err(err); // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, inner_op.span.to(self.prev_token.span)) + mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar) } } } else { @@ -1492,8 +1497,8 @@ impl<'a> Parser<'a> { let recovered = self .attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); if matches!(recovered, Recovered::Yes) { - self.dcx().emit_err(err); - mk_err_expr(self, inner_op.span.to(self.prev_token.span)) + let guar = self.dcx().emit_err(err); + mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar) } else { // These cases cause too many knock-down errors, bail out (#61329). Err(self.dcx().create_err(err)) @@ -1502,9 +1507,9 @@ impl<'a> Parser<'a> { } let recover = self.attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); - self.dcx().emit_err(err); + let guar = self.dcx().emit_err(err); if matches!(recover, Recovered::Yes) { - return mk_err_expr(self, inner_op.span.to(self.prev_token.span)); + return mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar); } } _ => {} @@ -1925,8 +1930,8 @@ impl<'a> Parser<'a> { } else { self.recover_await_prefix(await_sp)? }; - let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question); - let expr = self.mk_expr(lo.to(sp), ExprKind::Err); + let (sp, guar) = self.error_on_incorrect_await(lo, hi, &expr, is_question); + let expr = self.mk_expr_err(lo.to(sp), guar); self.maybe_recover_from_bad_qpath(expr) } @@ -1955,21 +1960,27 @@ impl<'a> Parser<'a> { Ok((expr.span, expr, is_question)) } - fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question: bool) -> Span { + fn error_on_incorrect_await( + &self, + lo: Span, + hi: Span, + expr: &Expr, + is_question: bool, + ) -> (Span, ErrorGuaranteed) { let span = lo.to(hi); let applicability = match expr.kind { ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await ?` _ => Applicability::MachineApplicable, }; - self.dcx().emit_err(IncorrectAwait { + let guar = self.dcx().emit_err(IncorrectAwait { span, sugg_span: (span, applicability), expr: self.span_to_snippet(expr.span).unwrap_or_else(|_| pprust::expr_to_string(expr)), question_mark: if is_question { "?" } else { "" }, }); - span + (span, guar) } /// If encountering `future.await()`, consumes and emits an error. @@ -2013,8 +2024,8 @@ impl<'a> Parser<'a> { ); } err.span_suggestion(lo.shrink_to_lo(), format!("{prefix}you can still access the deprecated `try!()` macro using the \"raw identifier\" syntax"), "r#", Applicability::MachineApplicable); - err.emit(); - Ok(self.mk_expr_err(lo.to(hi))) + let guar = err.emit(); + Ok(self.mk_expr_err(lo.to(hi), guar)) } else { Err(self.expected_expression_found()) // The user isn't trying to invoke the try! macro } @@ -2059,10 +2070,10 @@ impl<'a> Parser<'a> { lo: Span, err: PErr<'a>, ) -> P { - err.emit(); + let guar = err.emit(); // Recover from parse error, callers expect the closing delim to be consumed. self.consume_block(delim, ConsumeClosingDelim::Yes); - self.mk_expr(lo.to(self.prev_token.span), ExprKind::Err) + self.mk_expr(lo.to(self.prev_token.span), ExprKind::Err(guar)) } /// Eats tokens until we can be relatively sure we reached the end of the @@ -2549,9 +2560,10 @@ impl<'a> Parser<'a> { } _ => None, }; - self.dcx().emit_err(UnexpectedConstParamDeclaration { span: param.span(), sugg }); + let guar = + self.dcx().emit_err(UnexpectedConstParamDeclaration { span: param.span(), sugg }); - let value = self.mk_expr_err(param.span()); + let value = self.mk_expr_err(param.span(), guar); Some(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })) } @@ -2630,8 +2642,8 @@ impl<'a> Parser<'a> { "=", Applicability::MaybeIncorrect, ); - let value = self.mk_expr_err(start.to(expr.span)); - err.emit(); + let guar = err.emit(); + let value = self.mk_expr_err(start.to(expr.span), guar); return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })); } else if token::Colon == snapshot.token.kind && expr.span.lo() == snapshot.token.span.hi() @@ -2701,8 +2713,8 @@ impl<'a> Parser<'a> { vec![(span.shrink_to_lo(), "{ ".to_string()), (span.shrink_to_hi(), " }".to_string())], Applicability::MaybeIncorrect, ); - let value = self.mk_expr_err(span); - err.emit(); + let guar = err.emit(); + let value = self.mk_expr_err(span, guar); GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value }) } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 89f28777bffb9..e1a5e17004f6a 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -34,7 +34,7 @@ use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::source_map::{self, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{BytePos, Pos, Span}; +use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span}; use thin_vec::{thin_vec, ThinVec}; /// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression @@ -131,9 +131,9 @@ impl<'a> Parser<'a> { if self.may_recover() && self.look_ahead(1, |t| t == &token::Comma) => { // Special-case handling of `foo(_, _, _)` - err.emit(); + let guar = err.emit(); self.bump(); - Ok(self.mk_expr(self.prev_token.span, ExprKind::Err)) + Ok(self.mk_expr(self.prev_token.span, ExprKind::Err(guar))) } _ => Err(err), }, @@ -667,8 +667,8 @@ impl<'a> Parser<'a> { let (span, _) = self.parse_expr_prefix_common(box_kw)?; let inner_span = span.with_lo(box_kw.hi()); let code = self.sess.source_map().span_to_snippet(inner_span).unwrap(); - self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() }); - Ok((span, ExprKind::Err)) + let guar = self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() }); + Ok((span, ExprKind::Err(guar))) } fn is_mistaken_not_ident_negation(&self) -> bool { @@ -860,7 +860,7 @@ impl<'a> Parser<'a> { ExprKind::MethodCall(_) => "a method call", ExprKind::Call(_, _) => "a function call", ExprKind::Await(_, _) => "`.await`", - ExprKind::Err => return Ok(with_postfix), + ExprKind::Err(_) => return Ok(with_postfix), _ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"), } ); @@ -1315,7 +1315,7 @@ impl<'a> Parser<'a> { let fields: Vec<_> = fields.into_iter().filter(|field| !field.is_shorthand).collect(); - if !fields.is_empty() && + let guar = if !fields.is_empty() && // `token.kind` should not be compared here. // This is because the `snapshot.token.kind` is treated as the same as // that of the open delim in `TokenTreesReader::parse_token_tree`, even @@ -1338,11 +1338,11 @@ impl<'a> Parser<'a> { .collect(), }, }) - .emit(); + .emit() } else { - err.emit(); - } - Ok(self.mk_expr_err(span)) + err.emit() + }; + Ok(self.mk_expr_err(span, guar)) } Ok(_) => Err(err), Err(err2) => { @@ -1684,13 +1684,13 @@ impl<'a> Parser<'a> { && (self.check_noexpect(&TokenKind::Comma) || self.check_noexpect(&TokenKind::Gt)) { // We're probably inside of a `Path<'a>` that needs a turbofish - self.dcx().emit_err(errors::UnexpectedTokenAfterLabel { + let guar = self.dcx().emit_err(errors::UnexpectedTokenAfterLabel { span: self.token.span, remove_label: None, enclose_in_block: None, }); consume_colon = false; - Ok(self.mk_expr_err(lo)) + Ok(self.mk_expr_err(lo, guar)) } else { let mut err = errors::UnexpectedTokenAfterLabel { span: self.token.span, @@ -2039,7 +2039,7 @@ impl<'a> Parser<'a> { ) -> PResult<'a, L> { if let token::Interpolated(nt) = &self.token.kind && let token::NtExpr(e) | token::NtLiteral(e) = &nt.0 - && matches!(e.kind, ExprKind::Err) + && matches!(e.kind, ExprKind::Err(_)) { let mut err = self .dcx() @@ -2207,7 +2207,7 @@ impl<'a> Parser<'a> { let mut snapshot = self.create_snapshot_for_diagnostic(); match snapshot.parse_expr_array_or_repeat(Delimiter::Brace) { Ok(arr) => { - self.dcx().emit_err(errors::ArrayBracketsInsteadOfSpaces { + let guar = self.dcx().emit_err(errors::ArrayBracketsInsteadOfSpaces { span: arr.span, sub: errors::ArrayBracketsInsteadOfSpacesSugg { left: lo, @@ -2216,7 +2216,7 @@ impl<'a> Parser<'a> { }); self.restore_snapshot(snapshot); - Some(self.mk_expr_err(arr.span)) + Some(self.mk_expr_err(arr.span, guar)) } Err(e) => { e.cancel(); @@ -2370,7 +2370,10 @@ impl<'a> Parser<'a> { // It is likely that the closure body is a block but where the // braces have been removed. We will recover and eat the next // statements later in the parsing process. - body = self.mk_expr_err(body.span); + body = self.mk_expr_err( + body.span, + self.dcx().span_delayed_bug(body.span, "recovered a closure body as a block"), + ); } let body_span = body.span; @@ -2485,7 +2488,7 @@ impl<'a> Parser<'a> { ExprKind::Binary(Spanned { span: binop_span, .. }, _, right) if let ExprKind::Block(_, None) = right.kind => { - this.dcx().emit_err(errors::IfExpressionMissingThenBlock { + let guar = this.dcx().emit_err(errors::IfExpressionMissingThenBlock { if_span: lo, missing_then_block_sub: errors::IfExpressionMissingThenBlockSub::UnfinishedCondition( @@ -2493,14 +2496,14 @@ impl<'a> Parser<'a> { ), let_else_sub: None, }); - std::mem::replace(right, this.mk_expr_err(binop_span.shrink_to_hi())) + std::mem::replace(right, this.mk_expr_err(binop_span.shrink_to_hi(), guar)) } ExprKind::Block(_, None) => { - this.dcx().emit_err(errors::IfExpressionMissingCondition { + let guar = this.dcx().emit_err(errors::IfExpressionMissingCondition { if_span: lo.with_neighbor(cond.span).shrink_to_hi(), block_span: self.sess.source_map().start_point(cond_span), }); - std::mem::replace(&mut cond, this.mk_expr_err(cond_span.shrink_to_hi())) + std::mem::replace(&mut cond, this.mk_expr_err(cond_span.shrink_to_hi(), guar)) } _ => { return None; @@ -2520,14 +2523,14 @@ impl<'a> Parser<'a> { let let_else_sub = matches!(cond.kind, ExprKind::Let(..)) .then(|| errors::IfExpressionLetSomeSub { if_span: lo.until(cond_span) }); - self.dcx().emit_err(errors::IfExpressionMissingThenBlock { + let guar = self.dcx().emit_err(errors::IfExpressionMissingThenBlock { if_span: lo, missing_then_block_sub: errors::IfExpressionMissingThenBlockSub::AddThenBlock( cond_span.shrink_to_hi(), ), let_else_sub, }); - self.mk_block_err(cond_span.shrink_to_hi()) + self.mk_block_err(cond_span.shrink_to_hi(), guar) } } else { let attrs = self.parse_outer_attributes()?; // For recovery. @@ -2797,9 +2800,10 @@ impl<'a> Parser<'a> { && !matches!(self.token.kind, token::OpenDelim(Delimiter::Brace)) && self.may_recover() { - self.dcx() + let guar = self + .dcx() .emit_err(errors::MissingExpressionInForLoop { span: expr.span.shrink_to_lo() }); - let err_expr = self.mk_expr(expr.span, ExprKind::Err); + let err_expr = self.mk_expr(expr.span, ExprKind::Err(guar)); let block = self.mk_block(thin_vec![], BlockCheckMode::Default, self.prev_token.span); return Ok(self.mk_expr( lo.to(self.prev_token.span), @@ -2924,7 +2928,7 @@ impl<'a> Parser<'a> { attrs: Default::default(), pat: self.mk_pat(span, ast::PatKind::Err(guar)), guard: None, - body: Some(self.mk_expr_err(span)), + body: Some(self.mk_expr_err(span, guar)), span, id: DUMMY_NODE_ID, is_placeholder: false, @@ -2959,7 +2963,7 @@ impl<'a> Parser<'a> { let err = |this: &Parser<'_>, stmts: Vec| { let span = stmts[0].span.to(stmts[stmts.len() - 1].span); - this.dcx().emit_err(errors::MatchArmBodyWithoutBraces { + let guar = this.dcx().emit_err(errors::MatchArmBodyWithoutBraces { statements: span, arrow: arrow_span, num_statements: stmts.len(), @@ -2972,7 +2976,7 @@ impl<'a> Parser<'a> { errors::MatchArmBodyWithoutBracesSugg::UseComma { semicolon: semi_sp } }, }); - this.mk_expr_err(span) + this.mk_expr_err(span, guar) }; // We might have either a `,` -> `;` typo, or a block without braces. We need // a more subtle parsing strategy. @@ -3433,14 +3437,20 @@ impl<'a> Parser<'a> { pth: ast::Path, recover: bool, close_delim: Delimiter, - ) -> PResult<'a, (ThinVec, ast::StructRest, bool)> { + ) -> PResult< + 'a, + ( + ThinVec, + ast::StructRest, + Option, /* async blocks are forbidden in Rust 2015 */ + ), + > { let mut fields = ThinVec::new(); let mut base = ast::StructRest::None; - let mut recover_async = false; + let mut recovered_async = None; let in_if_guard = self.restrictions.contains(Restrictions::IN_IF_GUARD); - let mut async_block_err = |e: &mut DiagnosticBuilder<'_>, span: Span| { - recover_async = true; + let async_block_err = |e: &mut DiagnosticBuilder<'_>, span: Span| { errors::AsyncBlockIn2015 { span }.add_to_diagnostic(e); errors::HelpUseLatestEdition::new().add_to_diagnostic(e); }; @@ -3465,9 +3475,34 @@ impl<'a> Parser<'a> { break; } - let recovery_field = self.find_struct_error_after_field_looking_code(); + // Peek the field's ident before parsing its expr in order to emit better diagnostics. + let peek = self + .token + .ident() + .filter(|(ident, is_raw)| { + (!ident.is_reserved() || matches!(is_raw, IdentIsRaw::Yes)) + && self.look_ahead(1, |tok| *tok == token::Colon) + }) + .map(|(ident, _)| ident); + + // We still want a field even if its expr didn't parse. + let field_ident = |this: &Self, guar: ErrorGuaranteed| { + peek.map(|ident| { + let span = ident.span; + ExprField { + ident, + span, + expr: this.mk_expr_err(span, guar), + is_shorthand: false, + attrs: AttrVec::new(), + id: DUMMY_NODE_ID, + is_placeholder: false, + } + }) + }; + let parsed_field = match self.parse_expr_field() { - Ok(f) => Some(f), + Ok(f) => Ok(f), Err(mut e) => { if pth == kw::Async { async_block_err(&mut e, pth.span); @@ -3499,7 +3534,10 @@ impl<'a> Parser<'a> { return Err(e); } - e.emit(); + let guar = e.emit(); + if pth == kw::Async { + recovered_async = Some(guar); + } // If the next token is a comma, then try to parse // what comes next as additional fields, rather than @@ -3511,18 +3549,20 @@ impl<'a> Parser<'a> { } } - None + Err(guar) } }; - let is_shorthand = parsed_field.as_ref().is_some_and(|f| f.is_shorthand); + let is_shorthand = parsed_field.as_ref().is_ok_and(|f| f.is_shorthand); // A shorthand field can be turned into a full field with `:`. // We should point this out. self.check_or_expected(!is_shorthand, TokenType::Token(token::Colon)); match self.expect_one_of(&[token::Comma], &[token::CloseDelim(close_delim)]) { Ok(_) => { - if let Some(f) = parsed_field.or(recovery_field) { + if let Some(f) = + parsed_field.or_else(|guar| field_ident(self, guar).ok_or(guar)).ok() + { // Only include the field if there's no parse error for the field name. fields.push(f); } @@ -3532,8 +3572,7 @@ impl<'a> Parser<'a> { async_block_err(&mut e, pth.span); } else { e.span_label(pth.span, "while parsing this struct"); - if let Some(f) = recovery_field { - fields.push(f); + if peek.is_some() { e.span_suggestion( self.prev_token.span.shrink_to_hi(), "try adding a comma", @@ -3545,13 +3584,18 @@ impl<'a> Parser<'a> { if !recover { return Err(e); } - e.emit(); + let guar = e.emit(); + if pth == kw::Async { + recovered_async = Some(guar); + } else if let Some(f) = field_ident(self, guar) { + fields.push(f); + } self.recover_stmt_(SemiColonMode::Comma, BlockMode::Ignore); self.eat(&token::Comma); } } } - Ok((fields, base, recover_async)) + Ok((fields, base, recovered_async)) } /// Precondition: already parsed the '{'. @@ -3562,39 +3606,18 @@ impl<'a> Parser<'a> { recover: bool, ) -> PResult<'a, P> { let lo = pth.span; - let (fields, base, recover_async) = + let (fields, base, recovered_async) = self.parse_struct_fields(pth.clone(), recover, Delimiter::Brace)?; let span = lo.to(self.token.span); self.expect(&token::CloseDelim(Delimiter::Brace))?; - let expr = if recover_async { - ExprKind::Err + let expr = if let Some(guar) = recovered_async { + ExprKind::Err(guar) } else { ExprKind::Struct(P(ast::StructExpr { qself, path: pth, fields, rest: base })) }; Ok(self.mk_expr(span, expr)) } - /// Use in case of error after field-looking code: `S { foo: () with a }`. - fn find_struct_error_after_field_looking_code(&self) -> Option { - match self.token.ident() { - Some((ident, is_raw)) - if (matches!(is_raw, IdentIsRaw::Yes) || !ident.is_reserved()) - && self.look_ahead(1, |t| *t == token::Colon) => - { - Some(ast::ExprField { - ident, - span: self.token.span, - expr: self.mk_expr_err(self.token.span), - is_shorthand: false, - attrs: AttrVec::new(), - id: DUMMY_NODE_ID, - is_placeholder: false, - }) - } - _ => None, - } - } - fn recover_struct_comma_after_dotdot(&mut self, span: Span) { if self.token != token::Comma { return; @@ -3718,8 +3741,8 @@ impl<'a> Parser<'a> { limits: RangeLimits, ) -> ExprKind { if end.is_none() && limits == RangeLimits::Closed { - self.inclusive_range_with_incorrect_end(); - ExprKind::Err + let guar = self.inclusive_range_with_incorrect_end(); + ExprKind::Err(guar) } else { ExprKind::Range(start, end, limits) } @@ -3756,8 +3779,8 @@ impl<'a> Parser<'a> { self.mk_expr_with_attrs(span, kind, AttrVec::new()) } - pub(super) fn mk_expr_err(&self, span: Span) -> P { - self.mk_expr(span, ExprKind::Err) + pub(super) fn mk_expr_err(&self, span: Span, guar: ErrorGuaranteed) -> P { + self.mk_expr(span, ExprKind::Err(guar)) } /// Create expression span ensuring the span of the parent node @@ -3949,7 +3972,7 @@ impl MutVisitor for CondChecker<'_> { | ExprKind::Become(_) | ExprKind::IncludedBytes(_) | ExprKind::FormatArgs(_) - | ExprKind::Err + | ExprKind::Err(_) | ExprKind::Dummy => { // These would forbid any let expressions they contain already. } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 2e049ca908fd4..a678194372e9b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2328,11 +2328,11 @@ impl<'a> Parser<'a> { let _ = self.parse_expr()?; self.expect_semi()?; // `;` let span = eq_sp.to(self.prev_token.span); - self.dcx().emit_err(errors::FunctionBodyEqualsExpr { + let guar = self.dcx().emit_err(errors::FunctionBodyEqualsExpr { span, sugg: errors::FunctionBodyEqualsExprSugg { eq: eq_sp, semi: self.prev_token.span }, }); - (AttrVec::new(), Some(self.mk_block_err(span))) + (AttrVec::new(), Some(self.mk_block_err(span, guar))) } else { let expected = if req_body { &[token::OpenDelim(Delimiter::Brace)][..] diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index c82b44ac6e100..9bff5b9309250 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -566,7 +566,7 @@ impl<'a> Parser<'a> { match self.parse_literal_maybe_minus() { Ok(begin) => { let begin = match self.maybe_recover_trailing_expr(begin.span, false) { - Some(_) => self.mk_expr_err(begin.span), + Some(guar) => self.mk_expr_err(begin.span, guar), None => begin, }; @@ -719,7 +719,7 @@ impl<'a> Parser<'a> { self.parse_pat_range_begin_with(begin.clone(), form) } // recover ranges with parentheses around the `(start)..` - PatKind::Err(_) + PatKind::Err(guar) if self.may_recover() && let Some(form) = self.parse_range_end() => { @@ -731,7 +731,7 @@ impl<'a> Parser<'a> { }, }); - self.parse_pat_range_begin_with(self.mk_expr(pat.span, ExprKind::Err), form) + self.parse_pat_range_begin_with(self.mk_expr_err(pat.span, *guar), form) } // (pat) with optional parentheses @@ -886,7 +886,7 @@ impl<'a> Parser<'a> { Ok(PatKind::Range(Some(begin), end, re)) } - pub(super) fn inclusive_range_with_incorrect_end(&mut self) { + pub(super) fn inclusive_range_with_incorrect_end(&mut self) -> ErrorGuaranteed { let tok = &self.token; let span = self.prev_token.span; // If the user typed "..==" instead of "..=", we want to give them @@ -905,15 +905,13 @@ impl<'a> Parser<'a> { let _ = self.parse_pat_range_end().map_err(|e| e.cancel()); } - self.dcx().emit_err(InclusiveRangeExtraEquals { span: span_with_eq }); + self.dcx().emit_err(InclusiveRangeExtraEquals { span: span_with_eq }) } token::Gt if no_space => { let after_pat = span.with_hi(span.hi() - rustc_span::BytePos(1)).shrink_to_hi(); - self.dcx().emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat }); - } - _ => { - self.dcx().emit_err(InclusiveRangeNoEnd { span }); + self.dcx().emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat }) } + _ => self.dcx().emit_err(InclusiveRangeNoEnd { span }), } } @@ -987,7 +985,7 @@ impl<'a> Parser<'a> { } Ok(match recovered { - Some(_) => self.mk_expr_err(bound.span), + Some(guar) => self.mk_expr_err(bound.span, guar), None => bound, }) } diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index ee02b69c6140d..15f8124823fb0 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -22,7 +22,7 @@ use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Stmt}; use rustc_ast::{StmtKind, DUMMY_NODE_ID}; use rustc_errors::{Applicability, DiagnosticBuilder, PResult}; use rustc_span::symbol::{kw, sym, Ident}; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, ErrorGuaranteed, Span}; use std::borrow::Cow; use std::mem; @@ -610,9 +610,9 @@ impl<'a> Parser<'a> { } } - err.emit(); + let guar = err.emit(); self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); - Some(self.mk_stmt_err(self.token.span)) + Some(self.mk_stmt_err(self.token.span, guar)) } Ok(stmt) => stmt, Err(err) => return Err(err), @@ -651,10 +651,10 @@ impl<'a> Parser<'a> { .contains(&self.token.kind) => { // The user has written `#[attr] expr` which is unsupported. (#106020) - self.attr_on_non_tail_expr(&expr); + let guar = self.attr_on_non_tail_expr(&expr); // We already emitted an error, so don't emit another type error let sp = expr.span.to(self.prev_token.span); - *expr = self.mk_expr_err(sp); + *expr = self.mk_expr_err(sp, guar); } // Expression without semicolon. @@ -666,10 +666,18 @@ impl<'a> Parser<'a> { let expect_result = self.expect_one_of(&[], &[token::Semi, token::CloseDelim(Delimiter::Brace)]); + // Try to both emit a better diagnostic, and avoid further errors by replacing + // the `expr` with `ExprKind::Err`. let replace_with_err = 'break_recover: { match expect_result { - // Recover from parser, skip type error to avoid extra errors. - Ok(Recovered::Yes) => true, + Ok(Recovered::No) => None, + Ok(Recovered::Yes) => { + // Skip type error to avoid extra errors. + let guar = self + .dcx() + .span_delayed_bug(self.prev_token.span, "expected `;` or `}`"); + Some(guar) + } Err(e) => { if self.recover_colon_as_semi() { // recover_colon_as_semi has already emitted a nicer error. @@ -677,7 +685,7 @@ impl<'a> Parser<'a> { add_semi_to_stmt = true; eat_semi = false; - break 'break_recover false; + break 'break_recover None; } match &expr.kind { @@ -705,13 +713,13 @@ impl<'a> Parser<'a> { }; match self.parse_expr_labeled(label, false) { Ok(labeled_expr) => { - e.delay_as_bug(); + e.cancel(); self.dcx().emit_err(MalformedLoopLabel { span: label.ident.span, correct_label: label.ident, }); *expr = labeled_expr; - break 'break_recover false; + break 'break_recover None; } Err(err) => { err.cancel(); @@ -723,26 +731,26 @@ impl<'a> Parser<'a> { _ => {} } - if let Err(e) = - self.check_mistyped_turbofish_with_multiple_type_params(e, expr) - { - if recover.no() { - return Err(e); - } - e.emit(); - self.recover_stmt(); - } - - true + let res = + self.check_mistyped_turbofish_with_multiple_type_params(e, expr); + + Some(if recover.no() { + res? + } else { + res.unwrap_or_else(|e| { + let guar = e.emit(); + self.recover_stmt(); + guar + }) + }) } - Ok(Recovered::No) => false, } }; - if replace_with_err { + if let Some(guar) = replace_with_err { // We already emitted an error, so don't emit another type error let sp = expr.span.to(self.prev_token.span); - *expr = self.mk_expr_err(sp); + *expr = self.mk_expr_err(sp, guar); } } StmtKind::Expr(_) | StmtKind::MacCall(_) => {} @@ -791,11 +799,11 @@ impl<'a> Parser<'a> { Stmt { id: DUMMY_NODE_ID, kind, span } } - pub(super) fn mk_stmt_err(&self, span: Span) -> Stmt { - self.mk_stmt(span, StmtKind::Expr(self.mk_expr_err(span))) + pub(super) fn mk_stmt_err(&self, span: Span, guar: ErrorGuaranteed) -> Stmt { + self.mk_stmt(span, StmtKind::Expr(self.mk_expr_err(span, guar))) } - pub(super) fn mk_block_err(&self, span: Span) -> P { - self.mk_block(thin_vec![self.mk_stmt_err(span)], BlockCheckMode::Default, span) + pub(super) fn mk_block_err(&self, span: Span, guar: ErrorGuaranteed) -> P { + self.mk_block(thin_vec![self.mk_stmt_err(span, guar)], BlockCheckMode::Default, span) } } diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index 5d46581f646cc..73c92708eb39c 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -90,7 +90,7 @@ pub fn parse_meta<'a>(sess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Meta // been reported. let msg = "attribute value must be a literal"; let mut err = sess.dcx.struct_span_err(expr.span, msg); - if let ast::ExprKind::Err = expr.kind { + if let ast::ExprKind::Err(_) = expr.kind { err.downgrade_to_delayed_bug(); } return Err(err); diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index 81a26a12009d1..c52a4e0d8b7c7 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -143,7 +143,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool { match (&l.kind, &r.kind) { (Paren(l), _) => eq_expr(l, r), (_, Paren(r)) => eq_expr(l, r), - (Err, Err) => true, + (Err(_), Err(_)) => true, (Dummy, _) | (_, Dummy) => unreachable!("comparing `ExprKind::Dummy`"), (Try(l), Try(r)) | (Await(l, _), Await(r, _)) => eq_expr(l, r), (Array(l), Array(r)) => over(l, r, |l, r| eq_expr(l, r)), diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index 7b1b0388b29f3..1f6446b8746e6 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -222,7 +222,7 @@ impl<'a> Sugg<'a> { | ast::ExprKind::Array(..) | ast::ExprKind::While(..) | ast::ExprKind::Await(..) - | ast::ExprKind::Err + | ast::ExprKind::Err(_) | ast::ExprKind::Dummy => Sugg::NonParen(snippet_with_context(cx, expr.span, ctxt, default, app).0), ast::ExprKind::Range(ref lhs, ref rhs, RangeLimits::HalfOpen) => Sugg::BinOp( AssocOp::DotDot, diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index d46d7c53bdb47..c500b30b99826 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -404,7 +404,7 @@ pub(crate) fn format_expr( // These do not occur in the AST because macros aren't expanded. unreachable!() } - ast::ExprKind::Err | ast::ExprKind::Dummy => None, + ast::ExprKind::Err(_) | ast::ExprKind::Dummy => None, }; expr_rw diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index b6b37e492e92f..d4218cff75aaa 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -498,7 +498,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr | ast::ExprKind::Cast(..) | ast::ExprKind::Continue(..) | ast::ExprKind::Dummy - | ast::ExprKind::Err + | ast::ExprKind::Err(_) | ast::ExprKind::Field(..) | ast::ExprKind::IncludedBytes(..) | ast::ExprKind::InlineAsm(..) From 34eae07ee52ea0c79b07babc39ae9f139a930091 Mon Sep 17 00:00:00 2001 From: Lieselotte <52315535+she3py@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:25:26 +0100 Subject: [PATCH 327/417] Remove `ast::` & `base::` prefixes from some builtin macros --- compiler/rustc_builtin_macros/src/cfg.rs | 4 +- .../rustc_builtin_macros/src/compile_error.rs | 4 +- compiler/rustc_builtin_macros/src/concat.rs | 44 +++++---- .../rustc_builtin_macros/src/concat_bytes.rs | 89 +++++++++---------- .../rustc_builtin_macros/src/concat_idents.rs | 26 +++--- compiler/rustc_builtin_macros/src/env.rs | 20 +++-- .../rustc_builtin_macros/src/source_util.rs | 47 +++++----- 7 files changed, 116 insertions(+), 118 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index ca66bc0da0cc7..04bf7dceeff49 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -8,14 +8,14 @@ use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_attr as attr; use rustc_errors::PResult; -use rustc_expand::base::{self, *}; +use rustc_expand::base::{DummyResult, ExtCtxt, MacEager, MacResult}; use rustc_span::Span; pub fn expand_cfg( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); match parse_cfg(cx, sp, tts) { diff --git a/compiler/rustc_builtin_macros/src/compile_error.rs b/compiler/rustc_builtin_macros/src/compile_error.rs index 6650035127296..b4455d7823f35 100644 --- a/compiler/rustc_builtin_macros/src/compile_error.rs +++ b/compiler/rustc_builtin_macros/src/compile_error.rs @@ -1,14 +1,14 @@ // The compiler code necessary to support the compile_error! extension. use rustc_ast::tokenstream::TokenStream; -use rustc_expand::base::{self, *}; +use rustc_expand::base::{get_single_str_from_tts, DummyResult, ExtCtxt, MacResult}; use rustc_span::Span; pub fn expand_compile_error<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") { Ok(var) => var, Err(guar) => return DummyResult::any(sp, guar), diff --git a/compiler/rustc_builtin_macros/src/concat.rs b/compiler/rustc_builtin_macros/src/concat.rs index dd4a0e7f22869..abfaa9b006edb 100644 --- a/compiler/rustc_builtin_macros/src/concat.rs +++ b/compiler/rustc_builtin_macros/src/concat.rs @@ -1,17 +1,17 @@ -use rustc_ast as ast; use rustc_ast::tokenstream::TokenStream; -use rustc_expand::base::{self, DummyResult}; +use rustc_ast::{ExprKind, LitKind, UnOp}; +use rustc_expand::base::{get_exprs_from_tts, DummyResult, ExtCtxt, MacEager, MacResult}; use rustc_session::errors::report_lit_error; use rustc_span::symbol::Symbol; use crate::errors; pub fn expand_concat( - cx: &mut base::ExtCtxt<'_>, + cx: &mut ExtCtxt<'_>, sp: rustc_span::Span, tts: TokenStream, -) -> Box { - let es = match base::get_exprs_from_tts(cx, tts) { +) -> Box { + let es = match get_exprs_from_tts(cx, tts) { Ok(es) => es, Err(guar) => return DummyResult::any(sp, guar), }; @@ -20,26 +20,26 @@ pub fn expand_concat( let mut guar = None; for e in es { match e.kind { - ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Str(s, _) | ast::LitKind::Float(s, _)) => { + ExprKind::Lit(token_lit) => match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Str(s, _) | LitKind::Float(s, _)) => { accumulator.push_str(s.as_str()); } - Ok(ast::LitKind::Char(c)) => { + Ok(LitKind::Char(c)) => { accumulator.push(c); } - Ok(ast::LitKind::Int(i, _)) => { + Ok(LitKind::Int(i, _)) => { accumulator.push_str(&i.to_string()); } - Ok(ast::LitKind::Bool(b)) => { + Ok(LitKind::Bool(b)) => { accumulator.push_str(&b.to_string()); } - Ok(ast::LitKind::CStr(..)) => { + Ok(LitKind::CStr(..)) => { guar = Some(cx.dcx().emit_err(errors::ConcatCStrLit { span: e.span })); } - Ok(ast::LitKind::Byte(..) | ast::LitKind::ByteStr(..)) => { + Ok(LitKind::Byte(..) | LitKind::ByteStr(..)) => { guar = Some(cx.dcx().emit_err(errors::ConcatBytestr { span: e.span })); } - Ok(ast::LitKind::Err(guarantee)) => { + Ok(LitKind::Err(guarantee)) => { guar = Some(guarantee); } Err(err) => { @@ -47,25 +47,23 @@ pub fn expand_concat( } }, // We also want to allow negative numeric literals. - ast::ExprKind::Unary(ast::UnOp::Neg, ref expr) - if let ast::ExprKind::Lit(token_lit) = expr.kind => - { - match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")), - Ok(ast::LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")), + ExprKind::Unary(UnOp::Neg, ref expr) if let ExprKind::Lit(token_lit) = expr.kind => { + match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")), + Ok(LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")), Err(err) => { guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span)); } _ => missing_literal.push(e.span), } } - ast::ExprKind::IncludedBytes(..) => { + ExprKind::IncludedBytes(..) => { cx.dcx().emit_err(errors::ConcatBytestr { span: e.span }); } - ast::ExprKind::Err(guarantee) => { + ExprKind::Err(guarantee) => { guar = Some(guarantee); } - ast::ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), + ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { missing_literal.push(e.span); } @@ -79,5 +77,5 @@ pub fn expand_concat( return DummyResult::any(sp, guar); } let sp = cx.with_def_site_ctxt(sp); - base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator))) + MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator))) } diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs index 32e17112d8c45..3fb0b50f41756 100644 --- a/compiler/rustc_builtin_macros/src/concat_bytes.rs +++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs @@ -1,6 +1,5 @@ -use rustc_ast as ast; -use rustc_ast::{ptr::P, tokenstream::TokenStream}; -use rustc_expand::base::{self, DummyResult}; +use rustc_ast::{ptr::P, token, tokenstream::TokenStream, ExprKind, LitIntType, LitKind, UintTy}; +use rustc_expand::base::{get_exprs_from_tts, DummyResult, ExtCtxt, MacEager, MacResult}; use rustc_session::errors::report_lit_error; use rustc_span::{ErrorGuaranteed, Span}; @@ -8,8 +7,8 @@ use crate::errors; /// Emits errors for literal expressions that are invalid inside and outside of an array. fn invalid_type_err( - cx: &mut base::ExtCtxt<'_>, - token_lit: ast::token::Lit, + cx: &mut ExtCtxt<'_>, + token_lit: token::Lit, span: Span, is_nested: bool, ) -> ErrorGuaranteed { @@ -18,18 +17,18 @@ fn invalid_type_err( }; let snippet = cx.sess.source_map().span_to_snippet(span).ok(); let dcx = cx.dcx(); - match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::CStr(_, _)) => { + match LitKind::from_token_lit(token_lit) { + Ok(LitKind::CStr(_, _)) => { // Avoid ambiguity in handling of terminal `NUL` by refusing to // concatenate C string literals as bytes. dcx.emit_err(errors::ConcatCStrLit { span }) } - Ok(ast::LitKind::Char(_)) => { + Ok(LitKind::Char(_)) => { let sugg = snippet.map(|snippet| ConcatBytesInvalidSuggestion::CharLit { span, snippet }); dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "character", sugg }) } - Ok(ast::LitKind::Str(_, _)) => { + Ok(LitKind::Str(_, _)) => { // suggestion would be invalid if we are nested let sugg = if !is_nested { snippet.map(|snippet| ConcatBytesInvalidSuggestion::StrLit { span, snippet }) @@ -38,27 +37,24 @@ fn invalid_type_err( }; dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "string", sugg }) } - Ok(ast::LitKind::Float(_, _)) => { + Ok(LitKind::Float(_, _)) => { dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "float", sugg: None }) } - Ok(ast::LitKind::Bool(_)) => { + Ok(LitKind::Bool(_)) => { dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "boolean", sugg: None }) } - Ok(ast::LitKind::Int(_, _)) if !is_nested => { + Ok(LitKind::Int(_, _)) if !is_nested => { let sugg = - snippet.map(|snippet| ConcatBytesInvalidSuggestion::IntLit { span: span, snippet }); + snippet.map(|snippet| ConcatBytesInvalidSuggestion::IntLit { span, snippet }); dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "numeric", sugg }) } - Ok(ast::LitKind::Int( - val, - ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), - )) => { + Ok(LitKind::Int(val, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::U8))) => { assert!(val.get() > u8::MAX.into()); // must be an error dcx.emit_err(ConcatBytesOob { span }) } - Ok(ast::LitKind::Int(_, _)) => dcx.emit_err(ConcatBytesNonU8 { span }), - Ok(ast::LitKind::ByteStr(..) | ast::LitKind::Byte(_)) => unreachable!(), - Ok(ast::LitKind::Err(guar)) => guar, + Ok(LitKind::Int(_, _)) => dcx.emit_err(ConcatBytesNonU8 { span }), + Ok(LitKind::ByteStr(..) | LitKind::Byte(_)) => unreachable!(), + Ok(LitKind::Err(guar)) => guar, Err(err) => report_lit_error(&cx.sess.parse_sess, err, token_lit, span), } } @@ -68,7 +64,7 @@ fn invalid_type_err( /// Otherwise, returns `None`, and either pushes the `expr`'s span to `missing_literals` or /// updates `guar` accordingly. fn handle_array_element( - cx: &mut base::ExtCtxt<'_>, + cx: &mut ExtCtxt<'_>, guar: &mut Option, missing_literals: &mut Vec, expr: &P, @@ -76,16 +72,16 @@ fn handle_array_element( let dcx = cx.dcx(); match expr.kind { - ast::ExprKind::Lit(token_lit) => { - match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Int( + ExprKind::Lit(token_lit) => { + match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Int( val, - ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), + LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::U8), )) if let Ok(val) = u8::try_from(val.get()) => { return Some(val); } - Ok(ast::LitKind::Byte(val)) => return Some(val), - Ok(ast::LitKind::ByteStr(..)) => { + Ok(LitKind::Byte(val)) => return Some(val), + Ok(LitKind::ByteStr(..)) => { guar.get_or_insert_with(|| { dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: true }) }); @@ -95,12 +91,12 @@ fn handle_array_element( } }; } - ast::ExprKind::Array(_) | ast::ExprKind::Repeat(_, _) => { + ExprKind::Array(_) | ExprKind::Repeat(_, _) => { guar.get_or_insert_with(|| { dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }) }); } - ast::ExprKind::IncludedBytes(..) => { + ExprKind::IncludedBytes(..) => { guar.get_or_insert_with(|| { dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }) }); @@ -112,11 +108,11 @@ fn handle_array_element( } pub fn expand_concat_bytes( - cx: &mut base::ExtCtxt<'_>, - sp: rustc_span::Span, + cx: &mut ExtCtxt<'_>, + sp: Span, tts: TokenStream, -) -> Box { - let es = match base::get_exprs_from_tts(cx, tts) { +) -> Box { + let es = match get_exprs_from_tts(cx, tts) { Ok(es) => es, Err(guar) => return DummyResult::any(sp, guar), }; @@ -125,7 +121,7 @@ pub fn expand_concat_bytes( let mut guar = None; for e in es { match &e.kind { - ast::ExprKind::Array(exprs) => { + ExprKind::Array(exprs) => { for expr in exprs { if let Some(elem) = handle_array_element(cx, &mut guar, &mut missing_literals, expr) @@ -134,10 +130,9 @@ pub fn expand_concat_bytes( } } } - ast::ExprKind::Repeat(expr, count) => { - if let ast::ExprKind::Lit(token_lit) = count.value.kind - && let Ok(ast::LitKind::Int(count_val, _)) = - ast::LitKind::from_token_lit(token_lit) + ExprKind::Repeat(expr, count) => { + if let ExprKind::Lit(token_lit) = count.value.kind + && let Ok(LitKind::Int(count_val, _)) = LitKind::from_token_lit(token_lit) { if let Some(elem) = handle_array_element(cx, &mut guar, &mut missing_literals, expr) @@ -152,24 +147,24 @@ pub fn expand_concat_bytes( ); } } - &ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Byte(val)) => { + &ExprKind::Lit(token_lit) => match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Byte(val)) => { accumulator.push(val); } - Ok(ast::LitKind::ByteStr(ref bytes, _)) => { + Ok(LitKind::ByteStr(ref bytes, _)) => { accumulator.extend_from_slice(bytes); } _ => { guar.get_or_insert_with(|| invalid_type_err(cx, token_lit, e.span, false)); } }, - ast::ExprKind::IncludedBytes(bytes) => { + ExprKind::IncludedBytes(bytes) => { accumulator.extend_from_slice(bytes); } - ast::ExprKind::Err(guarantee) => { + ExprKind::Err(guarantee) => { guar = Some(*guarantee); } - ast::ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), + ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { missing_literals.push(e.span); } @@ -177,10 +172,10 @@ pub fn expand_concat_bytes( } if !missing_literals.is_empty() { let guar = cx.dcx().emit_err(errors::ConcatBytesMissingLiteral { spans: missing_literals }); - return base::MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); + return MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); } else if let Some(guar) = guar { - return base::MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); + return MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); } let sp = cx.with_def_site_ctxt(sp); - base::MacEager::expr(cx.expr_byte_str(sp, accumulator)) + MacEager::expr(cx.expr_byte_str(sp, accumulator)) } diff --git a/compiler/rustc_builtin_macros/src/concat_idents.rs b/compiler/rustc_builtin_macros/src/concat_idents.rs index 29d3f6164aa16..fffcddc5325bd 100644 --- a/compiler/rustc_builtin_macros/src/concat_idents.rs +++ b/compiler/rustc_builtin_macros/src/concat_idents.rs @@ -1,8 +1,8 @@ -use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; -use rustc_expand::base::{self, *}; +use rustc_ast::{AttrVec, Expr, ExprKind, Path, Ty, TyKind, DUMMY_NODE_ID}; +use rustc_expand::base::{DummyResult, ExtCtxt, MacResult}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -12,7 +12,7 @@ pub fn expand_concat_idents<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { if tts.is_empty() { let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingArgs { span: sp }); return DummyResult::any(sp, guar); @@ -47,21 +47,21 @@ pub fn expand_concat_idents<'cx>( ident: Ident, } - impl base::MacResult for ConcatIdentsResult { - fn make_expr(self: Box) -> Option> { - Some(P(ast::Expr { - id: ast::DUMMY_NODE_ID, - kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), + impl MacResult for ConcatIdentsResult { + fn make_expr(self: Box) -> Option> { + Some(P(Expr { + id: DUMMY_NODE_ID, + kind: ExprKind::Path(None, Path::from_ident(self.ident)), span: self.ident.span, - attrs: ast::AttrVec::new(), + attrs: AttrVec::new(), tokens: None, })) } - fn make_ty(self: Box) -> Option> { - Some(P(ast::Ty { - id: ast::DUMMY_NODE_ID, - kind: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)), + fn make_ty(self: Box) -> Option> { + Some(P(Ty { + id: DUMMY_NODE_ID, + kind: TyKind::Path(None, Path::from_ident(self.ident)), span: self.ident.span, tokens: None, })) diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs index 67ace546ad042..f057d44bf710a 100644 --- a/compiler/rustc_builtin_macros/src/env.rs +++ b/compiler/rustc_builtin_macros/src/env.rs @@ -3,9 +3,13 @@ // interface. // +use rustc_ast::token::{self, LitKind}; use rustc_ast::tokenstream::TokenStream; -use rustc_ast::{self as ast, AstDeref, GenericArg}; -use rustc_expand::base::{self, *}; +use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability}; +use rustc_expand::base::{ + expr_to_string, get_exprs_from_tts, get_single_str_from_tts, DummyResult, ExtCtxt, MacEager, + MacResult, +}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use std::env; @@ -27,7 +31,7 @@ pub fn expand_option_env<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") { Ok(var) => var, Err(guar) => return DummyResult::any(sp, guar), @@ -47,7 +51,7 @@ pub fn expand_option_env<'cx>( sp, cx.ty_ident(sp, Ident::new(sym::str, sp)), Some(lt), - ast::Mutability::Not, + Mutability::Not, ))], )) } @@ -64,7 +68,7 @@ pub fn expand_env<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let mut exprs = match get_exprs_from_tts(cx, tts) { Ok(exprs) if exprs.is_empty() || exprs.len() > 2 => { let guar = cx.dcx().emit_err(errors::EnvTakesArgs { span: sp }); @@ -93,10 +97,8 @@ pub fn expand_env<'cx>( cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value)); let e = match value { None => { - let ast::ExprKind::Lit(ast::token::Lit { - kind: ast::token::LitKind::Str | ast::token::LitKind::StrRaw(..), - symbol, - .. + let ExprKind::Lit(token::Lit { + kind: LitKind::Str | LitKind::StrRaw(..), symbol, .. }) = &var_expr.kind else { unreachable!("`expr_to_string` ensures this is a string lit") diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 3860057e1d412..8e0978de23748 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -3,7 +3,10 @@ use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_ast_pretty::pprust; -use rustc_expand::base::{self, *}; +use rustc_expand::base::{ + check_zero_tts, get_single_str_from_tts, parse_expr, resolve_path, DummyResult, ExtCtxt, + MacEager, MacResult, +}; use rustc_expand::module::DirOwnership; use rustc_parse::new_parser_from_file; use rustc_parse::parser::{ForceCollect, Parser}; @@ -23,14 +26,14 @@ pub fn expand_line( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "line!"); + check_zero_tts(cx, sp, tts, "line!"); let topmost = cx.expansion_cause().unwrap_or(sp); let loc = cx.source_map().lookup_char_pos(topmost.lo()); - base::MacEager::expr(cx.expr_u32(topmost, loc.line as u32)) + MacEager::expr(cx.expr_u32(topmost, loc.line as u32)) } /* column!(): expands to the current column number */ @@ -38,14 +41,14 @@ pub fn expand_column( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "column!"); + check_zero_tts(cx, sp, tts, "column!"); let topmost = cx.expansion_cause().unwrap_or(sp); let loc = cx.source_map().lookup_char_pos(topmost.lo()); - base::MacEager::expr(cx.expr_u32(topmost, loc.col.to_usize() as u32 + 1)) + MacEager::expr(cx.expr_u32(topmost, loc.col.to_usize() as u32 + 1)) } /// file!(): expands to the current filename */ @@ -55,15 +58,15 @@ pub fn expand_file( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "file!"); + check_zero_tts(cx, sp, tts, "file!"); let topmost = cx.expansion_cause().unwrap_or(sp); let loc = cx.source_map().lookup_char_pos(topmost.lo()); use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; - base::MacEager::expr(cx.expr_str( + MacEager::expr(cx.expr_str( topmost, Symbol::intern( &loc.file.name.for_scope(cx.sess, RemapPathScopeComponents::MACRO).to_string_lossy(), @@ -75,23 +78,23 @@ pub fn expand_stringify( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); let s = pprust::tts_to_string(&tts); - base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s))) + MacEager::expr(cx.expr_str(sp, Symbol::intern(&s))) } pub fn expand_mod( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "module_path!"); + check_zero_tts(cx, sp, tts, "module_path!"); let mod_path = &cx.current_expansion.module.mod_path; let string = mod_path.iter().map(|x| x.to_string()).collect::>().join("::"); - base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&string))) + MacEager::expr(cx.expr_str(sp, Symbol::intern(&string))) } /// include! : parse the given file as an expr @@ -101,7 +104,7 @@ pub fn expand_include<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); let file = match get_single_str_from_tts(cx, sp, tts, "include!") { Ok(file) => file, @@ -129,9 +132,9 @@ pub fn expand_include<'cx>( p: Parser<'a>, node_id: ast::NodeId, } - impl<'a> base::MacResult for ExpandResult<'a> { + impl<'a> MacResult for ExpandResult<'a> { fn make_expr(mut self: Box>) -> Option> { - let expr = base::parse_expr(&mut self.p).ok()?; + let expr = parse_expr(&mut self.p).ok()?; if self.p.token != token::Eof { self.p.sess.buffer_lint( INCOMPLETE_INCLUDE, @@ -175,7 +178,7 @@ pub fn expand_include_str( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") { Ok(file) => file, @@ -192,7 +195,7 @@ pub fn expand_include_str( Ok(bytes) => match std::str::from_utf8(&bytes) { Ok(src) => { let interned_src = Symbol::intern(src); - base::MacEager::expr(cx.expr_str(sp, interned_src)) + MacEager::expr(cx.expr_str(sp, interned_src)) } Err(_) => { let guar = cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display())); @@ -210,7 +213,7 @@ pub fn expand_include_bytes( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") { Ok(file) => file, @@ -226,7 +229,7 @@ pub fn expand_include_bytes( match cx.source_map().load_binary_file(&file) { Ok(bytes) => { let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes)); - base::MacEager::expr(expr) + MacEager::expr(expr) } Err(e) => { let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); From ec29b0d6b819bc88c4a411a8104e684032324b9e Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sat, 17 Feb 2024 21:35:16 +0100 Subject: [PATCH 328/417] lint implied bounds in *all* opaque `impl Trait` types --- clippy_lints/src/implied_bounds_in_impls.rs | 107 ++++++++------------ tests/ui/implied_bounds_in_impls.fixed | 23 +++++ tests/ui/implied_bounds_in_impls.rs | 23 +++++ tests/ui/implied_bounds_in_impls.stderr | 76 ++++++++++---- 4 files changed, 145 insertions(+), 84 deletions(-) diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index 174db30a7cd49..9efe3993ca595 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -2,16 +2,11 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_errors::{Applicability, SuggestionStyle}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::FnKind; -use rustc_hir::{ - Body, FnDecl, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind, ItemKind, OpaqueTy, TraitBoundModifier, - TraitItem, TraitItemKind, TyKind, TypeBinding, -}; +use rustc_hir::{GenericArg, GenericBound, GenericBounds, ItemKind, TraitBoundModifier, TyKind, TypeBinding}; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, ClauseKind, Generics, Ty, TyCtxt}; use rustc_session::declare_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; declare_clippy_lint! { @@ -54,7 +49,7 @@ declare_lint_pass!(ImpliedBoundsInImpls => [IMPLIED_BOUNDS_IN_IMPLS]); fn emit_lint( cx: &LateContext<'_>, poly_trait: &rustc_hir::PolyTraitRef<'_>, - opaque_ty: &rustc_hir::OpaqueTy<'_>, + bounds: GenericBounds<'_>, index: usize, // The bindings that were implied, used for suggestion purposes since removing a bound with associated types // means we might need to then move it to a different bound @@ -73,10 +68,10 @@ fn emit_lint( // to include the `+` token that is ahead or behind, // so we don't end up with something like `impl + B` or `impl A + ` - let implied_span_extended = if let Some(next_bound) = opaque_ty.bounds.get(index + 1) { + let implied_span_extended = if let Some(next_bound) = bounds.get(index + 1) { poly_trait.span.to(next_bound.span().shrink_to_lo()) } else if index > 0 - && let Some(prev_bound) = opaque_ty.bounds.get(index - 1) + && let Some(prev_bound) = bounds.get(index - 1) { prev_bound.span().shrink_to_hi().to(poly_trait.span.shrink_to_hi()) } else { @@ -240,9 +235,8 @@ struct ImplTraitBound<'tcx> { /// For `impl Deref + DerefMut + Eq` this returns `[Deref, PartialEq]`. /// The `Deref` comes from `DerefMut` because `trait DerefMut: Deref {}`, and `PartialEq` comes from /// `Eq`. -fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, opaque_ty: &OpaqueTy<'tcx>) -> Vec> { - opaque_ty - .bounds +fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) -> Vec> { + bounds .iter() .filter_map(|bound| { if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound @@ -295,64 +289,49 @@ fn find_bound_in_supertraits<'a, 'tcx>( }) } -fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { - if let FnRetTy::Return(ty) = decl.output - && let TyKind::OpaqueDef(item_id, ..) = ty.kind - && let item = cx.tcx.hir().item(item_id) - && let ItemKind::OpaqueTy(opaque_ty) = item.kind +fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) { + if bounds.len() == 1 { // Very often there is only a single bound, e.g. `impl Deref<..>`, in which case - // we can avoid doing a bunch of stuff unnecessarily. - && opaque_ty.bounds.len() > 1 - { - let supertraits = collect_supertrait_bounds(cx, opaque_ty); + // we can avoid doing a bunch of stuff unnecessarily; there will trivially be + // no duplicate bounds + return; + } - // Lint all bounds in the `impl Trait` type that we've previously also seen in the set of - // supertraits of each of the bounds. - // This involves some extra logic when generic arguments are present, since - // simply comparing trait `DefId`s won't be enough. We also need to compare the generics. - for (index, bound) in opaque_ty.bounds.iter().enumerate() { - if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound - && let [.., path] = poly_trait.trait_ref.path.segments - && let implied_args = path.args.map_or([].as_slice(), |a| a.args) - && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) - && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() - && let Some(bound) = find_bound_in_supertraits(cx, def_id, implied_args, &supertraits) - // If the implied bound has a type binding that also exists in the implied-by trait, - // then we shouldn't lint. See #11880 for an example. - && let assocs = cx.tcx.associated_items(bound.trait_def_id) - && !implied_bindings.iter().any(|binding| { - assocs - .filter_by_name_unhygienic(binding.ident.name) - .next() - .is_some_and(|assoc| assoc.kind == ty::AssocKind::Type) - }) - { - emit_lint(cx, poly_trait, opaque_ty, index, implied_bindings, bound); - } + let supertraits = collect_supertrait_bounds(cx, bounds); + + // Lint all bounds in the `impl Trait` type that we've previously also seen in the set of + // supertraits of each of the bounds. + // This involves some extra logic when generic arguments are present, since + // simply comparing trait `DefId`s won't be enough. We also need to compare the generics. + for (index, bound) in bounds.iter().enumerate() { + if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound + && let [.., path] = poly_trait.trait_ref.path.segments + && let implied_args = path.args.map_or([].as_slice(), |a| a.args) + && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) + && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() + && let Some(bound) = find_bound_in_supertraits(cx, def_id, implied_args, &supertraits) + // If the implied bound has a type binding that also exists in the implied-by trait, + // then we shouldn't lint. See #11880 for an example. + && let assocs = cx.tcx.associated_items(bound.trait_def_id) + && !implied_bindings.iter().any(|binding| { + assocs + .filter_by_name_unhygienic(binding.ident.name) + .next() + .is_some_and(|assoc| assoc.kind == ty::AssocKind::Type) + }) + { + emit_lint(cx, poly_trait, bounds, index, implied_bindings, bound); } } } -impl LateLintPass<'_> for ImpliedBoundsInImpls { - fn check_fn( - &mut self, - cx: &LateContext<'_>, - _: FnKind<'_>, - decl: &FnDecl<'_>, - _: &Body<'_>, - _: Span, - _: LocalDefId, - ) { - check(cx, decl); - } - fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) { - if let TraitItemKind::Fn(sig, ..) = &item.kind { - check(cx, sig.decl); - } - } - fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &ImplItem<'_>) { - if let ImplItemKind::Fn(sig, ..) = &item.kind { - check(cx, sig.decl); +impl<'tcx> LateLintPass<'tcx> for ImpliedBoundsInImpls { + fn check_ty(&mut self, cx: &LateContext<'_>, ty: &rustc_hir::Ty<'_>) { + if let TyKind::OpaqueDef(item_id, ..) = ty.kind + && let item = cx.tcx.hir().item(item_id) + && let ItemKind::OpaqueTy(opaque_ty) = item.kind + { + check(cx, opaque_ty.bounds); } } } diff --git a/tests/ui/implied_bounds_in_impls.fixed b/tests/ui/implied_bounds_in_impls.fixed index 18f29e900c15f..d65fc97ebbfdb 100644 --- a/tests/ui/implied_bounds_in_impls.fixed +++ b/tests/ui/implied_bounds_in_impls.fixed @@ -1,5 +1,6 @@ #![warn(clippy::implied_bounds_in_impls)] #![allow(dead_code)] +#![feature(impl_trait_in_assoc_type, type_alias_impl_trait)] use std::ops::{Deref, DerefMut}; @@ -150,4 +151,26 @@ fn issue11880() { fn f5() -> impl Y {} } +fn apit(_: impl Deref + DerefMut) {} + +trait Rpitit { + fn f() -> impl DerefMut; +} + +trait Atpit { + type Assoc; + fn define() -> Self::Assoc; +} +impl Atpit for () { + type Assoc = impl DerefMut; + fn define() -> Self::Assoc { + &mut [] as &mut [()] + } +} + +type Tait = impl DerefMut; +fn define() -> Tait { + &mut [] as &mut [()] +} + fn main() {} diff --git a/tests/ui/implied_bounds_in_impls.rs b/tests/ui/implied_bounds_in_impls.rs index b7951e7dfba8b..52076c9f998ef 100644 --- a/tests/ui/implied_bounds_in_impls.rs +++ b/tests/ui/implied_bounds_in_impls.rs @@ -1,5 +1,6 @@ #![warn(clippy::implied_bounds_in_impls)] #![allow(dead_code)] +#![feature(impl_trait_in_assoc_type, type_alias_impl_trait)] use std::ops::{Deref, DerefMut}; @@ -150,4 +151,26 @@ fn issue11880() { fn f5() -> impl X + Y {} } +fn apit(_: impl Deref + DerefMut) {} + +trait Rpitit { + fn f() -> impl Deref + DerefMut; +} + +trait Atpit { + type Assoc; + fn define() -> Self::Assoc; +} +impl Atpit for () { + type Assoc = impl Deref + DerefMut; + fn define() -> Self::Assoc { + &mut [] as &mut [()] + } +} + +type Tait = impl Deref + DerefMut; +fn define() -> Tait { + &mut [] as &mut [()] +} + fn main() {} diff --git a/tests/ui/implied_bounds_in_impls.stderr b/tests/ui/implied_bounds_in_impls.stderr index fa1938f77d9df..9505deee35144 100644 --- a/tests/ui/implied_bounds_in_impls.stderr +++ b/tests/ui/implied_bounds_in_impls.stderr @@ -1,5 +1,5 @@ error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:12:36 + --> tests/ui/implied_bounds_in_impls.rs:13:36 | LL | fn deref_derefmut(x: T) -> impl Deref + DerefMut { | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + fn deref_derefmut(x: T) -> impl DerefMut { | error: this bound is already specified as the supertrait of `GenericSubtrait` - --> tests/ui/implied_bounds_in_impls.rs:29:37 + --> tests/ui/implied_bounds_in_impls.rs:30:37 | LL | fn generics_implied() -> impl GenericTrait + GenericSubtrait | ^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + fn generics_implied() -> impl GenericSubtrait | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, V>` - --> tests/ui/implied_bounds_in_impls.rs:35:40 + --> tests/ui/implied_bounds_in_impls.rs:36:40 | LL | fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + fn generics_implied_multi() -> impl GenericTrait2 + GenericSubtrait<( | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, V>` - --> tests/ui/implied_bounds_in_impls.rs:35:60 + --> tests/ui/implied_bounds_in_impls.rs:36:60 | LL | fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + fn generics_implied_multi() -> impl GenericTrait + GenericSubtrait< | error: this bound is already specified as the supertrait of `GenericSubtrait<(), T, V>` - --> tests/ui/implied_bounds_in_impls.rs:37:44 + --> tests/ui/implied_bounds_in_impls.rs:38:44 | LL | fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> | ^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + fn generics_implied_multi2() -> impl GenericTrait2 + GenericSubtra | error: this bound is already specified as the supertrait of `GenericSubtrait<(), T, V>` - --> tests/ui/implied_bounds_in_impls.rs:37:62 + --> tests/ui/implied_bounds_in_impls.rs:38:62 | LL | fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + fn generics_implied_multi2() -> impl GenericTrait + GenericSubtrai | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, ()>` - --> tests/ui/implied_bounds_in_impls.rs:47:28 + --> tests/ui/implied_bounds_in_impls.rs:48:28 | LL | fn generics_same() -> impl GenericTrait + GenericSubtrait<(), i32, ()> {} | ^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + fn generics_same() -> impl GenericSubtrait<(), i32, ()> {} | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:51:20 + --> tests/ui/implied_bounds_in_impls.rs:52:20 | LL | fn f() -> impl Deref + DerefMut; | ^^^^^ @@ -97,7 +97,7 @@ LL + fn f() -> impl DerefMut; | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:56:20 + --> tests/ui/implied_bounds_in_impls.rs:57:20 | LL | fn f() -> impl Deref + DerefMut { | ^^^^^ @@ -109,7 +109,7 @@ LL + fn f() -> impl DerefMut { | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:62:20 + --> tests/ui/implied_bounds_in_impls.rs:63:20 | LL | fn f() -> impl Deref + DerefMut { | ^^^^^ @@ -121,7 +121,7 @@ LL + fn f() -> impl DerefMut { | error: this bound is already specified as the supertrait of `PartialOrd` - --> tests/ui/implied_bounds_in_impls.rs:73:41 + --> tests/ui/implied_bounds_in_impls.rs:74:41 | LL | fn default_generic_param1() -> impl PartialEq + PartialOrd + Debug {} | ^^^^^^^^^ @@ -133,7 +133,7 @@ LL + fn default_generic_param1() -> impl PartialOrd + Debug {} | error: this bound is already specified as the supertrait of `PartialOrd` - --> tests/ui/implied_bounds_in_impls.rs:74:54 + --> tests/ui/implied_bounds_in_impls.rs:75:54 | LL | fn default_generic_param2() -> impl PartialOrd + PartialEq + Debug {} | ^^^^^^^^^ @@ -145,7 +145,7 @@ LL + fn default_generic_param2() -> impl PartialOrd + Debug {} | error: this bound is already specified as the supertrait of `DoubleEndedIterator` - --> tests/ui/implied_bounds_in_impls.rs:87:26 + --> tests/ui/implied_bounds_in_impls.rs:88:26 | LL | fn my_iter() -> impl Iterator + DoubleEndedIterator { | ^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + fn my_iter() -> impl DoubleEndedIterator { | error: this bound is already specified as the supertrait of `Copy` - --> tests/ui/implied_bounds_in_impls.rs:92:27 + --> tests/ui/implied_bounds_in_impls.rs:93:27 | LL | fn f() -> impl Copy + Clone { | ^^^^^ @@ -169,7 +169,7 @@ LL + fn f() -> impl Copy { | error: this bound is already specified as the supertrait of `Trait2` - --> tests/ui/implied_bounds_in_impls.rs:106:21 + --> tests/ui/implied_bounds_in_impls.rs:107:21 | LL | fn f2() -> impl Trait1 + Trait2 {} | ^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + fn f2() -> impl Trait2 {} | error: this bound is already specified as the supertrait of `Trait4` - --> tests/ui/implied_bounds_in_impls.rs:121:21 + --> tests/ui/implied_bounds_in_impls.rs:122:21 | LL | fn f3() -> impl Trait3 + Trait4 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL + fn f3() -> impl Trait4 {} | error: this bound is already specified as the supertrait of `Y` - --> tests/ui/implied_bounds_in_impls.rs:148:21 + --> tests/ui/implied_bounds_in_impls.rs:149:21 | LL | fn f3() -> impl X + Y {} | ^ @@ -205,7 +205,7 @@ LL + fn f3() -> impl Y {} | error: this bound is already specified as the supertrait of `Y` - --> tests/ui/implied_bounds_in_impls.rs:149:21 + --> tests/ui/implied_bounds_in_impls.rs:150:21 | LL | fn f4() -> impl X + Y {} | ^ @@ -217,7 +217,7 @@ LL + fn f4() -> impl Y {} | error: this bound is already specified as the supertrait of `Y` - --> tests/ui/implied_bounds_in_impls.rs:150:21 + --> tests/ui/implied_bounds_in_impls.rs:151:21 | LL | fn f5() -> impl X + Y {} | ^^^^^^^^^^^^^ @@ -228,5 +228,41 @@ LL - fn f5() -> impl X + Y {} LL + fn f5() -> impl Y {} | -error: aborting due to 19 previous errors +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:157:20 + | +LL | fn f() -> impl Deref + DerefMut; + | ^^^^^ + | +help: try removing this bound + | +LL - fn f() -> impl Deref + DerefMut; +LL + fn f() -> impl DerefMut; + | + +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:165:23 + | +LL | type Assoc = impl Deref + DerefMut; + | ^^^^^ + | +help: try removing this bound + | +LL - type Assoc = impl Deref + DerefMut; +LL + type Assoc = impl DerefMut; + | + +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:171:18 + | +LL | type Tait = impl Deref + DerefMut; + | ^^^^^ + | +help: try removing this bound + | +LL - type Tait = impl Deref + DerefMut; +LL + type Tait = impl DerefMut; + | + +error: aborting due to 22 previous errors From bbfe1c1ec3bcaaa51446f89e66641561751f38f8 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sat, 17 Feb 2024 21:40:23 +0100 Subject: [PATCH 329/417] lint implied bounds in APIT --- clippy_lints/src/implied_bounds_in_impls.rs | 18 +++++++++++++++++- tests/ui/implied_bounds_in_impls.fixed | 2 +- tests/ui/implied_bounds_in_impls.stderr | 14 +++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index 9efe3993ca595..74582f7f1de23 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -2,7 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_errors::{Applicability, SuggestionStyle}; use rustc_hir::def_id::DefId; -use rustc_hir::{GenericArg, GenericBound, GenericBounds, ItemKind, TraitBoundModifier, TyKind, TypeBinding}; +use rustc_hir::{ + GenericArg, GenericBound, GenericBounds, ItemKind, PredicateOrigin, TraitBoundModifier, TyKind, TypeBinding, + WherePredicate, +}; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, ClauseKind, Generics, Ty, TyCtxt}; @@ -326,6 +329,19 @@ fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) { } impl<'tcx> LateLintPass<'tcx> for ImpliedBoundsInImpls { + fn check_generics(&mut self, cx: &LateContext<'tcx>, generics: &rustc_hir::Generics<'tcx>) { + for predicate in generics.predicates { + if let WherePredicate::BoundPredicate(predicate) = predicate + // In theory, the origin doesn't really matter, + // we *could* also lint on explicit where clauses written out by the user, + // not just impl trait desugared ones, but that contradicts with the lint name... + && let PredicateOrigin::ImplTrait = predicate.origin + { + check(cx, predicate.bounds); + } + } + } + fn check_ty(&mut self, cx: &LateContext<'_>, ty: &rustc_hir::Ty<'_>) { if let TyKind::OpaqueDef(item_id, ..) = ty.kind && let item = cx.tcx.hir().item(item_id) diff --git a/tests/ui/implied_bounds_in_impls.fixed b/tests/ui/implied_bounds_in_impls.fixed index d65fc97ebbfdb..6fd4cbd80fe4e 100644 --- a/tests/ui/implied_bounds_in_impls.fixed +++ b/tests/ui/implied_bounds_in_impls.fixed @@ -151,7 +151,7 @@ fn issue11880() { fn f5() -> impl Y {} } -fn apit(_: impl Deref + DerefMut) {} +fn apit(_: impl DerefMut) {} trait Rpitit { fn f() -> impl DerefMut; diff --git a/tests/ui/implied_bounds_in_impls.stderr b/tests/ui/implied_bounds_in_impls.stderr index 9505deee35144..805532a568020 100644 --- a/tests/ui/implied_bounds_in_impls.stderr +++ b/tests/ui/implied_bounds_in_impls.stderr @@ -228,6 +228,18 @@ LL - fn f5() -> impl X + Y {} LL + fn f5() -> impl Y {} | +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:154:17 + | +LL | fn apit(_: impl Deref + DerefMut) {} + | ^^^^^ + | +help: try removing this bound + | +LL - fn apit(_: impl Deref + DerefMut) {} +LL + fn apit(_: impl DerefMut) {} + | + error: this bound is already specified as the supertrait of `DerefMut` --> tests/ui/implied_bounds_in_impls.rs:157:20 | @@ -264,5 +276,5 @@ LL - type Tait = impl Deref + DerefMut; LL + type Tait = impl DerefMut; | -error: aborting due to 22 previous errors +error: aborting due to 23 previous errors From bf7d1b54e8a3195a0f52516d48659d9f1270436d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 26 Feb 2024 09:24:03 +1100 Subject: [PATCH 330/417] Move `emit_stashed_diagnostic` call in rustfmt. This call was added to `parse_crate_mod` in #121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the `build` call in `parse_crate_inner` fails before `parse_crate_mod` is reached. So this commit moves the `emit_stashed_diagnostic` call outwards, from `parse_crate_mod` to `format_project`, just after the `Parser::parse_crate` call. This should be far out enough to catch any parsing errors. Fixes #121517. --- src/tools/rustfmt/src/formatting.rs | 22 ++++++++++++++----- src/tools/rustfmt/src/parse/parser.rs | 16 ++++---------- src/tools/rustfmt/src/parse/session.rs | 6 ++++- src/tools/rustfmt/src/test/parser.rs | 7 ++++++ .../rustfmt/tests/parser/stashed-diag2.rs | 3 +++ 5 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 src/tools/rustfmt/tests/parser/stashed-diag2.rs diff --git a/src/tools/rustfmt/src/formatting.rs b/src/tools/rustfmt/src/formatting.rs index cd57a025b6726..323ae83fe6ede 100644 --- a/src/tools/rustfmt/src/formatting.rs +++ b/src/tools/rustfmt/src/formatting.rs @@ -109,7 +109,7 @@ fn format_project( let main_file = input.file_name(); let input_is_stdin = main_file == FileName::Stdin; - let parse_session = ParseSess::new(config)?; + let mut parse_session = ParseSess::new(config)?; if config.skip_children() && parse_session.ignore_file(&main_file) { return Ok(FormatReport::new()); } @@ -117,11 +117,21 @@ fn format_project( // Parse the crate. let mut report = FormatReport::new(); let directory_ownership = input.to_directory_ownership(); - let krate = match Parser::parse_crate(input, &parse_session) { - Ok(krate) => krate, - // Surface parse error via Session (errors are merged there from report) - Err(e) => { - let forbid_verbose = input_is_stdin || e != ParserError::ParsePanicError; + + // rustfmt doesn't use `run_compiler` like other tools, so it must emit any + // stashed diagnostics itself, otherwise the `DiagCtxt` will assert when + // dropped. The final result here combines the parsing result and the + // `emit_stashed_diagnostics` result. + let parse_res = Parser::parse_crate(input, &parse_session); + let stashed_res = parse_session.emit_stashed_diagnostics(); + let krate = match (parse_res, stashed_res) { + (Ok(krate), None) => krate, + (parse_res, _) => { + // Surface parse error via Session (errors are merged there from report). + let forbid_verbose = match parse_res { + Err(e) if e != ParserError::ParsePanicError => true, + _ => input_is_stdin, + }; should_emit_verbose(forbid_verbose, config, || { eprintln!("The Rust parser panicked"); }); diff --git a/src/tools/rustfmt/src/parse/parser.rs b/src/tools/rustfmt/src/parse/parser.rs index cca14353b5c18..3269fe7c7c706 100644 --- a/src/tools/rustfmt/src/parse/parser.rs +++ b/src/tools/rustfmt/src/parse/parser.rs @@ -162,22 +162,14 @@ impl<'a> Parser<'a> { fn parse_crate_mod(&mut self) -> Result { let mut parser = AssertUnwindSafe(&mut self.parser); - - // rustfmt doesn't use `run_compiler` like other tools, so it must emit - // any stashed diagnostics itself, otherwise the `DiagCtxt` will assert - // when dropped. The final result here combines the parsing result and - // the `emit_stashed_diagnostics` result. - let parse_res = catch_unwind(move || parser.parse_crate_mod()); - let stashed_res = self.parser.dcx().emit_stashed_diagnostics(); let err = Err(ParserError::ParsePanicError); - match (parse_res, stashed_res) { - (Ok(Ok(k)), None) => Ok(k), - (Ok(Ok(_)), Some(_guar)) => err, - (Ok(Err(db)), _) => { + match catch_unwind(move || parser.parse_crate_mod()) { + Ok(Ok(k)) => Ok(k), + Ok(Err(db)) => { db.emit(); err } - (Err(_), _) => err, + Err(_) => err, } } } diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index cff025cf2ab3a..decd3b167e0a5 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -6,7 +6,7 @@ use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; use rustc_errors::emitter::{DynEmitter, Emitter, HumanEmitter}; use rustc_errors::translation::Translate; use rustc_errors::{ - ColorConfig, DiagCtxt, Diagnostic, DiagnosticBuilder, Level as DiagnosticLevel, + ColorConfig, DiagCtxt, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Level as DiagnosticLevel, }; use rustc_session::parse::ParseSess as RawParseSess; use rustc_span::{ @@ -230,6 +230,10 @@ impl ParseSess { self.ignore_path_set.as_ref().is_match(path) } + pub(crate) fn emit_stashed_diagnostics(&mut self) -> Option { + self.parse_sess.dcx.emit_stashed_diagnostics() + } + pub(crate) fn set_silent_emitter(&mut self) { self.parse_sess.dcx = DiagCtxt::with_emitter(silent_emitter()); } diff --git a/src/tools/rustfmt/src/test/parser.rs b/src/tools/rustfmt/src/test/parser.rs index da2a2ba62e009..d951c8469e661 100644 --- a/src/tools/rustfmt/src/test/parser.rs +++ b/src/tools/rustfmt/src/test/parser.rs @@ -62,3 +62,10 @@ fn crate_parsing_stashed_diag() { let filename = "tests/parser/stashed-diag.rs"; assert_parser_error(filename); } + +#[test] +fn crate_parsing_stashed_diag2() { + // See also https://github.com/rust-lang/rust/issues/121517 + let filename = "tests/parser/stashed-diag2.rs"; + assert_parser_error(filename); +} diff --git a/src/tools/rustfmt/tests/parser/stashed-diag2.rs b/src/tools/rustfmt/tests/parser/stashed-diag2.rs new file mode 100644 index 0000000000000..579a69def1633 --- /dev/null +++ b/src/tools/rustfmt/tests/parser/stashed-diag2.rs @@ -0,0 +1,3 @@ +trait Trait<'1> { s> {} + +fn main() {} From edda2a7d3e7e541097285c03c0a8f68ad9b2fbc4 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 26 Feb 2024 08:40:51 +1100 Subject: [PATCH 331/417] Revert some `span_bug`s to `span_delayed_bug`. Fixes #121503. Fixes #121597. --- .../src/collect/resolve_bound_vars.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 3 +- .../trait-bounds/span-bug-issue-121597.rs | 20 ++++++++ .../trait-bounds/span-bug-issue-121597.stderr | 49 +++++++++++++++++++ .../could-not-resolve-issue-121503.rs | 13 +++++ .../could-not-resolve-issue-121503.stderr | 28 +++++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr create mode 100644 tests/ui/lifetimes/could-not-resolve-issue-121503.rs create mode 100644 tests/ui/lifetimes/could-not-resolve-issue-121503.stderr diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index efde4e11c79dd..22beac14b24db 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -1331,7 +1331,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { } } - self.tcx.dcx().span_bug( + self.tcx.dcx().span_delayed_bug( lifetime_ref.ident.span, format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,), ); diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 7117a59c40987..bdc796aca3a46 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -804,10 +804,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let trait_ref = principal.with_self_ty(self.tcx, self_ty); self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| { if new_trait_ref.has_non_region_bound_vars() { - this.dcx().span_bug( + this.dcx().span_delayed_bug( this.span, "tried to select method from HRTB with non-lifetime bound vars", ); + return; } let new_trait_ref = this.instantiate_bound_regions_with_erased(new_trait_ref); diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs new file mode 100644 index 0000000000000..aeace9f2158ae --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs @@ -0,0 +1,20 @@ +#![allow(incomplete_features)] +#![feature(non_lifetime_binders)] + +trait Foo: for Bar {} + +trait Bar { + fn method(&self) {} +} + +struct Type2; +fn needs_bar(_: *mut Type2) {} + +fn main() { + let x: &dyn Foo = &(); + //~^ ERROR the trait `Foo` cannot be made into an object + //~| ERROR the trait `Foo` cannot be made into an object + + needs_bar(x); + //~^ ERROR mismatched types +} diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr new file mode 100644 index 0000000000000..27f82563aae7d --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr @@ -0,0 +1,49 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/span-bug-issue-121597.rs:14:23 + | +LL | let x: &dyn Foo = &(); + | ^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/span-bug-issue-121597.rs:4:12 + | +LL | trait Foo: for Bar {} + | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables + | | + | this trait cannot be made into an object... + = note: required for the cast from `&()` to `&dyn Foo` + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/span-bug-issue-121597.rs:14:12 + | +LL | let x: &dyn Foo = &(); + | ^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/span-bug-issue-121597.rs:4:12 + | +LL | trait Foo: for Bar {} + | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables + | | + | this trait cannot be made into an object... + +error[E0308]: mismatched types + --> $DIR/span-bug-issue-121597.rs:18:15 + | +LL | needs_bar(x); + | --------- ^ types differ in mutability + | | + | arguments to this function are incorrect + | + = note: expected raw pointer `*mut Type2` + found reference `&dyn Foo` +note: function defined here + --> $DIR/span-bug-issue-121597.rs:11:4 + | +LL | fn needs_bar(_: *mut Type2) {} + | ^^^^^^^^^ ------------- + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0038, E0308. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/lifetimes/could-not-resolve-issue-121503.rs b/tests/ui/lifetimes/could-not-resolve-issue-121503.rs new file mode 100644 index 0000000000000..6bc70a907d9e9 --- /dev/null +++ b/tests/ui/lifetimes/could-not-resolve-issue-121503.rs @@ -0,0 +1,13 @@ +//@ edition:2018 + +#![feature(allocator_api)] +struct Struct; +impl Struct { + async fn box_ref_Struct(self: Box) -> &u32 { + //~^ ERROR the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied + //~| ERROR Box` cannot be used as the type of `self` without + &1 + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/could-not-resolve-issue-121503.stderr b/tests/ui/lifetimes/could-not-resolve-issue-121503.stderr new file mode 100644 index 0000000000000..a5d8239a2df05 --- /dev/null +++ b/tests/ui/lifetimes/could-not-resolve-issue-121503.stderr @@ -0,0 +1,28 @@ +error[E0277]: the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied + --> $DIR/could-not-resolve-issue-121503.rs:6:5 + | +LL | async fn box_ref_Struct(self: Box) -> &u32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `impl FnMut(&mut Self)` + | +note: required by a bound in `Box` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL +help: consider further restricting this bound + | +LL | async fn box_ref_Struct(self: Box) -> &u32 { + | +++++++++++++++++++++++ + +error[E0658]: `Box` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/could-not-resolve-issue-121503.rs:6:35 + | +LL | async fn box_ref_Struct(self: Box) -> &u32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #44874 for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin

` (where P is one of the previous types except `Self`) + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0658. +For more information about an error, try `rustc --explain E0277`. From 35421c74616e44e1001be852d9255a593195f66c Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sun, 25 Feb 2024 22:28:30 -0300 Subject: [PATCH 332/417] Add synchronization library to run-make flags --- tests/run-make/tools.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run-make/tools.mk b/tests/run-make/tools.mk index 1d4e911138920..b1e872a202af5 100644 --- a/tests/run-make/tools.mk +++ b/tests/run-make/tools.mk @@ -134,9 +134,9 @@ endif # Extra flags needed to compile a working executable with the standard library ifdef IS_WINDOWS ifdef IS_MSVC - EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib + EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib synchronization.lib else - EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll + EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll -lsynchronization EXTRACXXFLAGS := -lstdc++ # So this is a bit hacky: we can't use the DLL version of libstdc++ because # it pulls in the DLL version of libgcc, which means that we end up with 2 From ff07f55db500dafb2d6570b5de7928bcc10a955f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 26 Feb 2024 01:36:08 +0000 Subject: [PATCH 333/417] Actually use the right closure kind when checking async Fn goals --- .../src/traits/select/confirmation.rs | 5 ++-- .../async-closures/wrong-fn-kind.rs | 8 ++++-- .../async-closures/wrong-fn-kind.stderr | 27 ++++++++++++++++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index f76be87694886..d316149731e14 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -934,7 +934,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn)) } ty::Closure(_, args) => { - let sig = args.as_closure().sig(); + let args = args.as_closure(); + let sig = args.sig(); let trait_ref = sig.map_bound(|sig| { ty::TraitRef::new( self.tcx(), @@ -950,7 +951,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::TraitRef::new(tcx, future_trait_def_id, [sig.output()]) }), )); - (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn)) + (trait_ref, args.kind_ty()) } _ => bug!("expected callable type for AsyncFn candidate"), }; diff --git a/tests/ui/async-await/async-closures/wrong-fn-kind.rs b/tests/ui/async-await/async-closures/wrong-fn-kind.rs index 7c3c7337e2ef0..8502bb6e2d45d 100644 --- a/tests/ui/async-await/async-closures/wrong-fn-kind.rs +++ b/tests/ui/async-await/async-closures/wrong-fn-kind.rs @@ -1,7 +1,5 @@ //@ edition:2021 -// FIXME(async_closures): This needs a better error message! - #![feature(async_closure)] fn main() { @@ -12,4 +10,10 @@ fn main() { //~^ ERROR expected a closure that implements the `async Fn` trait, but this closure only implements `async FnMut` x += 1; }); + + let x = String::new(); + needs_async_fn(move || async move { + //~^ ERROR expected a closure that implements the `async Fn` trait, but this closure only implements `async FnOnce` + println!("{x}"); + }); } diff --git a/tests/ui/async-await/async-closures/wrong-fn-kind.stderr b/tests/ui/async-await/async-closures/wrong-fn-kind.stderr index 34a6b3a485a60..d0f1948e48f83 100644 --- a/tests/ui/async-await/async-closures/wrong-fn-kind.stderr +++ b/tests/ui/async-await/async-closures/wrong-fn-kind.stderr @@ -1,5 +1,5 @@ error[E0525]: expected a closure that implements the `async Fn` trait, but this closure only implements `async FnMut` - --> $DIR/wrong-fn-kind.rs:11:20 + --> $DIR/wrong-fn-kind.rs:9:20 | LL | needs_async_fn(async || { | -------------- -^^^^^^^ @@ -14,11 +14,32 @@ LL | | }); | |_____- the requirement to implement `async Fn` derives from here | note: required by a bound in `needs_async_fn` - --> $DIR/wrong-fn-kind.rs:8:31 + --> $DIR/wrong-fn-kind.rs:6:31 | LL | fn needs_async_fn(_: impl async Fn()) {} | ^^^^^^^^^^ required by this bound in `needs_async_fn` -error: aborting due to 1 previous error +error[E0525]: expected a closure that implements the `async Fn` trait, but this closure only implements `async FnOnce` + --> $DIR/wrong-fn-kind.rs:15:20 + | +LL | needs_async_fn(move || async move { + | -------------- -^^^^^^ + | | | + | _____|______________this closure implements `async FnOnce`, not `async Fn` + | | | + | | required by a bound introduced by this call +LL | | +LL | | println!("{x}"); + | | - closure is `async FnOnce` because it moves the variable `x` out of its environment +LL | | }); + | |_____- the requirement to implement `async Fn` derives from here + | +note: required by a bound in `needs_async_fn` + --> $DIR/wrong-fn-kind.rs:6:31 + | +LL | fn needs_async_fn(_: impl async Fn()) {} + | ^^^^^^^^^^ required by this bound in `needs_async_fn` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0525`. From 8bccceb8fc588d60dd25e6f13beea69aa5fc6b63 Mon Sep 17 00:00:00 2001 From: "HTGAzureX1212." <39023054+HTGAzureX1212@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:26:30 +0800 Subject: [PATCH 334/417] separate messages for individual categories --- compiler/rustc_lint/messages.ftl | 23 ++++++++- compiler/rustc_lint/src/lib.rs | 1 + compiler/rustc_lint/src/lints.rs | 2 + compiler/rustc_lint/src/non_ascii_idents.rs | 47 +++++++++++++++---- tests/ui/lexer/lex-emoji-identifiers.rs | 2 +- tests/ui/lexer/lex-emoji-identifiers.stderr | 3 +- .../lint-uncommon-codepoints.rs | 7 +-- .../lint-uncommon-codepoints.stderr | 13 +++-- 8 files changed, 79 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 785895e0ab823..c08ff0fef3c26 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -241,9 +241,28 @@ lint_hidden_unicode_codepoints = unicode codepoint changing visible direction of lint_identifier_non_ascii_char = identifier contains non-ASCII characters lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len -> - [one] an uncommon Unicode codepoint - *[other] uncommon Unicode codepoints + [one] { $identifier_type -> + [Exclusion] a character from an archaic script + [Technical] a character that is for non-linguistic, specialized usage + [Limited_Use] a character from a script in limited use + [Not_NFKC] a non normalized (NFKC) character + *[other] an uncommon character + } + *[other] { $identifier_type -> + [Exclusion] {$codepoints_len} characters from archaic scripts + [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage + [Limited_Use] {$codepoints_len} characters from scripts in limited use + [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters + *[other] uncommon characters + } }: {$codepoints} + .note = {$codepoints_len -> + [one] this character is + *[other] these characters are + } included in the{$identifier_type -> + [Restricted] {""} + *[other] {" "}{$identifier_type} + } Unicode general security profile lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 85f9d3bd63ec7..6c4e717faa6c4 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -31,6 +31,7 @@ #![feature(array_windows)] #![feature(box_patterns)] #![feature(control_flow_enum)] +#![feature(extract_if)] #![feature(generic_nonzero)] #![feature(if_let_guard)] #![feature(iter_order_by)] diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index c204c67fc1f7c..70d30611e8fcf 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1098,9 +1098,11 @@ pub struct IdentifierNonAsciiChar; #[derive(LintDiagnostic)] #[diag(lint_identifier_uncommon_codepoints)] +#[note] pub struct IdentifierUncommonCodepoints { pub codepoints: Vec, pub codepoints_len: usize, + pub identifier_type: &'static str, } #[derive(LintDiagnostic)] diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index e112cd6915c35..5e66ade035774 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -7,6 +7,7 @@ use rustc_ast as ast; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::unord::UnordMap; use rustc_span::symbol::Symbol; +use unicode_security::general_security_profile::IdentifierType; declare_lint! { /// The `non_ascii_idents` lint detects non-ASCII identifiers. @@ -189,17 +190,47 @@ impl EarlyLintPass for NonAsciiIdents { if check_uncommon_codepoints && !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed) { - let codepoints: Vec<_> = symbol_str + let mut chars: Vec<_> = symbol_str .chars() - .filter(|c| !GeneralSecurityProfile::identifier_allowed(*c)) + .map(|c| (c, GeneralSecurityProfile::identifier_type(c))) .collect(); - let codepoints_len = codepoints.len(); - cx.emit_span_lint( - UNCOMMON_CODEPOINTS, - sp, - IdentifierUncommonCodepoints { codepoints, codepoints_len }, - ); + for (id_ty, id_ty_descr) in [ + (IdentifierType::Exclusion, "Exclusion"), + (IdentifierType::Technical, "Technical"), + (IdentifierType::Limited_Use, "Limited_Use"), + (IdentifierType::Not_NFKC, "Not_NFKC"), + ] { + let codepoints: Vec<_> = + chars.extract_if(|(_, ty)| *ty == Some(id_ty)).collect(); + if codepoints.is_empty() { + continue; + } + cx.emit_span_lint( + UNCOMMON_CODEPOINTS, + sp, + IdentifierUncommonCodepoints { + codepoints_len: codepoints.len(), + codepoints: codepoints.into_iter().map(|(c, _)| c).collect(), + identifier_type: id_ty_descr, + }, + ); + } + + let remaining = chars + .extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c)) + .collect::>(); + if !remaining.is_empty() { + cx.emit_span_lint( + UNCOMMON_CODEPOINTS, + sp, + IdentifierUncommonCodepoints { + codepoints_len: remaining.len(), + codepoints: remaining.into_iter().map(|(c, _)| c).collect(), + identifier_type: "Restricted", + }, + ); + } } } diff --git a/tests/ui/lexer/lex-emoji-identifiers.rs b/tests/ui/lexer/lex-emoji-identifiers.rs index bbc088521b7bd..4fcd102018beb 100644 --- a/tests/ui/lexer/lex-emoji-identifiers.rs +++ b/tests/ui/lexer/lex-emoji-identifiers.rs @@ -4,7 +4,7 @@ fn invalid_emoji_usages() { let wireless🛜 = "basic emoji"; //~ ERROR: identifiers cannot contain emoji // FIXME let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token - //~^ WARN: identifier contains an uncommon Unicode codepoint + //~^ WARN: identifier contains an uncommon character: '\u{fe0f}' let flag🇺🇳 = "flag sequence"; //~ ERROR: identifiers cannot contain emoji let wales🏴 = "tag sequence"; //~ ERROR: identifiers cannot contain emoji let folded🙏🏿 = "modifier sequence"; //~ ERROR: identifiers cannot contain emoji diff --git a/tests/ui/lexer/lex-emoji-identifiers.stderr b/tests/ui/lexer/lex-emoji-identifiers.stderr index 679b7422bc150..8e2daa6d1d38f 100644 --- a/tests/ui/lexer/lex-emoji-identifiers.stderr +++ b/tests/ui/lexer/lex-emoji-identifiers.stderr @@ -40,12 +40,13 @@ error: identifiers cannot contain emoji: `folded🙏🏿` LL | let folded🙏🏿 = "modifier sequence"; | ^^^^^^^^^^ -warning: identifier contains an uncommon Unicode codepoint: '\u{fe0f}' +warning: identifier contains an uncommon character: '\u{fe0f}' --> $DIR/lex-emoji-identifiers.rs:6:9 | LL | let key1️⃣ = "keycap sequence"; | ^^^^ | + = note: this character is included in the Unicode general security profile = note: `#[warn(uncommon_codepoints)]` on by default error: aborting due to 7 previous errors; 1 warning emitted diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs index c3459930a94c0..a51452f069590 100644 --- a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs +++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs @@ -1,12 +1,13 @@ #![deny(uncommon_codepoints)] -const µ: f64 = 0.000001; //~ ERROR identifier contains an uncommon Unicode codepoint +const µ: f64 = 0.000001; //~ identifier contains a non normalized (NFKC) character: 'µ' //~| WARNING should have an upper case name -fn dijkstra() {} //~ ERROR identifier contains an uncommon Unicode codepoint +fn dijkstra() {} +//~^ ERROR identifier contains a non normalized (NFKC) character: 'ij' fn main() { - let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon Unicode codepoints + let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon characters: 'ㇻ', 'ㇲ', and 'ㇳ' // using the same identifier the second time won't trigger the lint. println!("{}", ㇻㇲㇳ); diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr index bae5ac654d354..000545a060075 100644 --- a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr +++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr @@ -1,26 +1,31 @@ -error: identifier contains an uncommon Unicode codepoint: 'µ' +error: identifier contains a non normalized (NFKC) character: 'µ' --> $DIR/lint-uncommon-codepoints.rs:3:7 | LL | const µ: f64 = 0.000001; | ^ | + = note: this character is included in the Not_NFKC Unicode general security profile note: the lint level is defined here --> $DIR/lint-uncommon-codepoints.rs:1:9 | LL | #![deny(uncommon_codepoints)] | ^^^^^^^^^^^^^^^^^^^ -error: identifier contains an uncommon Unicode codepoint: 'ij' +error: identifier contains a non normalized (NFKC) character: 'ij' --> $DIR/lint-uncommon-codepoints.rs:6:4 | LL | fn dijkstra() {} | ^^^^^^^ + | + = note: this character is included in the Not_NFKC Unicode general security profile -error: identifier contains uncommon Unicode codepoints: 'ㇻ', 'ㇲ', and 'ㇳ' - --> $DIR/lint-uncommon-codepoints.rs:9:9 +error: identifier contains uncommon characters: 'ㇻ', 'ㇲ', and 'ㇳ' + --> $DIR/lint-uncommon-codepoints.rs:10:9 | LL | let ㇻㇲㇳ = "rust"; | ^^^^^^ + | + = note: these characters are included in the Unicode general security profile warning: constant `µ` should have an upper case name --> $DIR/lint-uncommon-codepoints.rs:3:7 From 93deced5531562a43048f59f853307749574a631 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Mon, 26 Feb 2024 07:02:40 +0400 Subject: [PATCH 335/417] change rs doc to no_run --- clippy_lints/src/doc/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 4a253e9fd6cf0..639179a070dbd 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -345,14 +345,14 @@ declare_clippy_lint! { /// ### Why is this bad? /// It is unlikely that there is any reason to have empty documentation for an item /// ### Example - /// ```rs + /// ```no_run /// /// /// fn returns_true() -> bool { /// true /// } /// ``` /// Use instead: - /// ```rs + /// ```no_run /// fn returns_true() -> bool { /// true /// } From 3ef693c55522ca16c8c4444ff71572fa12824b39 Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Mon, 26 Feb 2024 00:00:33 -0800 Subject: [PATCH 336/417] refactor: remove CSS variables that are now unused --- util/gh-pages/index.html | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/util/gh-pages/index.html b/util/gh-pages/index.html index fe13318b05b6a..c88c298d5d787 100644 --- a/util/gh-pages/index.html +++ b/util/gh-pages/index.html @@ -594,16 +594,6 @@

>