Skip to content

Apply unused_qualifications lint #14828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,26 @@ members = [
]

[workspace.lints.clippy]
type_complexity = "allow"
doc_markdown = "warn"
manual_let_else = "warn"
undocumented_unsafe_blocks = "warn"
redundant_else = "warn"
match_same_arms = "warn"
semicolon_if_nothing_returned = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
semicolon_if_nothing_returned = "warn"
type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"

ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"

[workspace.lints.rust]
unsafe_op_in_unsafe_fn = "warn"
missing_docs = "warn"
unsafe_code = "deny"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_code = "deny"
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"

[lints]
workspace = true
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/bevy_ecs/world/commands.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::mem::size_of;
use bevy_ecs::{
component::Component,
entity::Entity,
Expand Down Expand Up @@ -184,8 +185,7 @@ impl Default for LargeStruct {
}

pub fn sized_commands_impl<T: Default + Command>(criterion: &mut Criterion) {
let mut group =
criterion.benchmark_group(format!("sized_commands_{}_bytes", std::mem::size_of::<T>()));
let mut group = criterion.benchmark_group(format!("sized_commands_{}_bytes", size_of::<T>()));
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(4));

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_animation/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl AnimationGraph {
) -> impl Iterator<Item = AnimationNodeIndex> + 'a
where
I: IntoIterator<Item = Handle<AnimationClip>>,
<I as std::iter::IntoIterator>::IntoIter: 'a,
<I as IntoIterator>::IntoIter: 'a,
{
clips
.into_iter()
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ impl From<u8> for AppExit {
}

impl Termination for AppExit {
fn report(self) -> std::process::ExitCode {
fn report(self) -> ExitCode {
match self {
AppExit::Success => ExitCode::SUCCESS,
// We leave logging an error to our users
Expand All @@ -1085,7 +1085,7 @@ impl Termination for AppExit {

#[cfg(test)]
mod tests {
use std::{iter, marker::PhantomData, mem, sync::Mutex};
use std::{iter, marker::PhantomData, mem::size_of, sync::Mutex};

use bevy_ecs::{
change_detection::{DetectChanges, ResMut},
Expand Down Expand Up @@ -1411,7 +1411,7 @@ mod tests {
fn app_exit_size() {
// There wont be many of them so the size isn't a issue but
// it's nice they're so small let's keep it that way.
assert_eq!(mem::size_of::<AppExit>(), mem::size_of::<u8>());
assert_eq!(size_of::<AppExit>(), size_of::<u8>());
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_asset/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub use source::*;
use bevy_utils::{BoxedFuture, ConditionalSendFuture};
use futures_io::{AsyncRead, AsyncSeek, AsyncWrite};
use futures_lite::{ready, Stream};
use std::io::SeekFrom;
use std::task::Context;
use std::{
io::SeekFrom,
mem::size_of,
path::{Path, PathBuf},
pin::Pin,
sync::Arc,
task::Poll,
task::{Context, Poll},
};
use thiserror::Error;

Expand Down Expand Up @@ -77,7 +77,7 @@ impl From<std::io::Error> for AssetReaderError {
// Ideally this would be even smaller (ReadToEndFuture only needs space for two references based on its definition),
// but compiler optimizations can apparently inflate the stack size of futures due to inlining, which makes
// a higher maximum necessary.
pub const STACK_FUTURE_SIZE: usize = 10 * std::mem::size_of::<&()>();
pub const STACK_FUTURE_SIZE: usize = 10 * size_of::<&()>();

pub use stackfuture::StackFuture;

Expand Down Expand Up @@ -520,7 +520,7 @@ impl VecReader {
impl AsyncRead for VecReader {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<futures_io::Result<usize>> {
if self.bytes_read >= self.bytes.len() {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/processor_gated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl AsyncRead for TransactionLockedReader<'_> {
mut self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
buf: &mut [u8],
) -> std::task::Poll<futures_io::Result<usize>> {
) -> Poll<futures_io::Result<usize>> {
Pin::new(&mut self.reader).poll_read(cx, buf)
}
}
Expand Down
7 changes: 2 additions & 5 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,10 @@ mod tests {
async fn read_meta<'a>(
&'a self,
path: &'a Path,
) -> Result<impl bevy_asset::io::Reader + 'a, AssetReaderError> {
) -> Result<impl Reader + 'a, AssetReaderError> {
self.memory_reader.read_meta(path).await
}
async fn read<'a>(
&'a self,
path: &'a Path,
) -> Result<impl bevy_asset::io::Reader + 'a, bevy_asset::io::AssetReaderError> {
async fn read<'a>(&'a self, path: &'a Path) -> Result<impl Reader + 'a, AssetReaderError> {
let attempt_number = {
let mut attempt_counters = self.attempt_counters.lock().unwrap();
if let Some(existing) = attempt_counters.get_mut(path) {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use thiserror::Error;
/// should be loaded.
pub trait AssetLoader: Send + Sync + 'static {
/// The top level [`Asset`] loaded by this [`AssetLoader`].
type Asset: crate::Asset;
type Asset: Asset;
/// The settings type used by this [`AssetLoader`].
type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>;
/// The type of [error](`std::error::Error`) which could be encountered by this loader.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ impl AssetServer {
.data
.infos
.write()
.create_loading_handle_untyped(std::any::TypeId::of::<A>(), std::any::type_name::<A>());
.create_loading_handle_untyped(TypeId::of::<A>(), std::any::type_name::<A>());
let id = handle.id();

let event_sender = self.data.asset_event_sender.clone();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_color/src/color_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod tests {

#[test]
fn test_gray() {
verify_gray::<crate::Hsla>();
verify_gray::<Hsla>();
verify_gray::<crate::Hsva>();
verify_gray::<crate::Hwba>();
verify_gray::<crate::Laba>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bevy_time::{Real, Time};
pub struct FrameTimeDiagnosticsPlugin;

impl Plugin for FrameTimeDiagnosticsPlugin {
fn build(&self, app: &mut bevy_app::App) {
fn build(&self, app: &mut App) {
app.register_diagnostic(Diagnostic::new(Self::FRAME_TIME).with_suffix("ms"))
.register_diagnostic(Diagnostic::new(Self::FPS))
.register_diagnostic(Diagnostic::new(Self::FRAME_COUNT).with_smoothing_factor(0.0))
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_diagnostic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Plugin for DiagnosticsPlugin {
app.init_resource::<DiagnosticsStore>();

#[cfg(feature = "sysinfo_plugin")]
app.init_resource::<system_information_diagnostics_plugin::SystemInfo>();
app.init_resource::<SystemInfo>();
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
});
}
None => {
let index = syn::Index::from(i);
let index = Index::from(i);
field_get_components.push(quote! {
self.#index.get_components(&mut *func);
});
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/macros/src/query_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
struct QueryDataAttributes {
pub is_mutable: bool,

pub derive_args: Punctuated<Meta, syn::token::Comma>,
pub derive_args: Punctuated<Meta, Comma>,
}

static MUTABLE_ATTRIBUTE_NAME: &str = "mutable";
Expand Down Expand Up @@ -48,7 +48,7 @@ pub fn derive_query_data_impl(input: TokenStream) -> TokenStream {
}

attr.parse_args_with(|input: ParseStream| {
let meta = input.parse_terminated(syn::Meta::parse, Comma)?;
let meta = input.parse_terminated(Meta::parse, Comma)?;
for meta in meta {
let ident = meta.path().get_ident().unwrap_or_else(|| {
panic!(
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ impl<'w> BundleInserter<'w> {
location: EntityLocation,
bundle: T,
insert_mode: InsertMode,
#[cfg(feature = "track_change_detection")] caller: &'static core::panic::Location<'static>,
#[cfg(feature = "track_change_detection")] caller: &'static Location<'static>,
) -> EntityLocation {
let bundle_info = self.bundle_info.as_ref();
let add_bundle = self.add_bundle.as_ref();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ pub struct MutUntyped<'w> {
pub(crate) value: PtrMut<'w>,
pub(crate) ticks: TicksMut<'w>,
#[cfg(feature = "track_change_detection")]
pub(crate) changed_by: &'w mut &'static core::panic::Location<'static>,
pub(crate) changed_by: &'w mut &'static Location<'static>,
}

impl<'w> MutUntyped<'w> {
Expand Down
8 changes: 3 additions & 5 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<'de> Deserialize<'de> for Entity {
D: serde::Deserializer<'de>,
{
use serde::de::Error;
let id: u64 = serde::de::Deserialize::deserialize(deserializer)?;
let id: u64 = Deserialize::deserialize(deserializer)?;
Entity::try_from_bits(id).map_err(D::Error::custom)
}
}
Expand Down Expand Up @@ -1004,13 +1004,11 @@ impl EntityLocation {
#[cfg(test)]
mod tests {
use super::*;
use std::mem::size_of;

#[test]
fn entity_niche_optimization() {
assert_eq!(
std::mem::size_of::<Entity>(),
std::mem::size_of::<Option<Entity>>()
);
assert_eq!(size_of::<Entity>(), size_of::<Option<Entity>>());
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/query/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a, T: SparseSetIndex> FormattedBitSet<'a, T> {
}
}

impl<'a, T: SparseSetIndex + fmt::Debug> fmt::Debug for FormattedBitSet<'a, T> {
impl<'a, T: SparseSetIndex + Debug> Debug for FormattedBitSet<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list()
.entries(self.bit_set.ones().map(T::get_sparse_set_index))
Expand Down Expand Up @@ -106,7 +106,7 @@ impl<T: SparseSetIndex> Clone for Access<T> {
}
}

impl<T: SparseSetIndex + fmt::Debug> fmt::Debug for Access<T> {
impl<T: SparseSetIndex + Debug> Debug for Access<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Access")
.field(
Expand Down Expand Up @@ -907,7 +907,7 @@ impl<T: SparseSetIndex> Clone for AccessFilters<T> {
}
}

impl<T: SparseSetIndex + fmt::Debug> fmt::Debug for AccessFilters<T> {
impl<T: SparseSetIndex + Debug> Debug for AccessFilters<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AccessFilters")
.field("with", &FormattedBitSet::<T>::new(&self.with))
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
.map(|index| index.keys())
})
// select the component with the fewest archetypes
.min_by_key(std::iter::ExactSizeIterator::len);
.min_by_key(ExactSizeIterator::len);
if let Some(archetypes) = potential_archetypes {
for archetype_id in archetypes {
// exclude archetypes that have already been processed
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/storage/blob_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ mod tests {
use crate::{component::Component, ptr::OwningPtr, world::World};

use super::BlobVec;
use std::{alloc::Layout, cell::RefCell, mem, rc::Rc};
use std::{alloc::Layout, cell::RefCell, mem::align_of, rc::Rc};

unsafe fn drop_ptr<T>(x: OwningPtr<'_>) {
// SAFETY: The pointer points to a valid value of type `T` and it is safe to drop this value.
Expand Down Expand Up @@ -722,7 +722,7 @@ mod tests {
for zst in q.iter(&world) {
// Ensure that the references returned are properly aligned.
assert_eq!(
std::ptr::from_ref::<Zst>(zst) as usize % mem::align_of::<Zst>(),
std::ptr::from_ref::<Zst>(zst) as usize % align_of::<Zst>(),
0
);
count += 1;
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/storage/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<const SEND: bool> ResourceData<SEND> {
&mut self,
value: OwningPtr<'_>,
change_tick: Tick,
#[cfg(feature = "track_change_detection")] caller: &'static core::panic::Location,
#[cfg(feature = "track_change_detection")] caller: &'static Location,
) {
if self.is_present() {
self.validate_access();
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<const SEND: bool> ResourceData<SEND> {
&mut self,
value: OwningPtr<'_>,
change_ticks: ComponentTicks,
#[cfg(feature = "track_change_detection")] caller: &'static core::panic::Location,
#[cfg(feature = "track_change_detection")] caller: &'static Location,
) {
if self.is_present() {
self.validate_access();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/storage/sparse_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl ComponentSparseSet {
pub fn get_changed_by(
&self,
entity: Entity,
) -> Option<&UnsafeCell<&'static core::panic::Location<'static>>> {
) -> Option<&UnsafeCell<&'static Location<'static>>> {
let dense_index = *self.sparse.get(entity.index())?;
#[cfg(debug_assertions)]
assert_eq!(entity, self.entities[dense_index.as_usize()]);
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const _: () = {
type State = FetchState;
type Item<'w, 's> = Commands<'w, 's>;
fn init_state(
world: &mut bevy_ecs::world::World,
world: &mut World,
system_meta: &mut bevy_ecs::system::SystemMeta,
) -> Self::State {
FetchState {
Expand All @@ -114,7 +114,7 @@ const _: () = {
fn apply(
state: &mut Self::State,
system_meta: &bevy_ecs::system::SystemMeta,
world: &mut bevy_ecs::world::World,
world: &mut World,
) {
<__StructFieldsAlias<'_, '_> as bevy_ecs::system::SystemParam>::apply(
&mut state.state,
Expand Down Expand Up @@ -1319,7 +1319,7 @@ where
B: Bundle,
{
#[cfg(feature = "track_change_detection")]
let caller = core::panic::Location::caller();
let caller = Location::caller();
move |world: &mut World| {
if let Err(invalid_entities) = world.insert_or_spawn_batch_with_caller(
bundles_iter,
Expand Down Expand Up @@ -1353,7 +1353,7 @@ fn despawn() -> impl EntityCommand {
/// An [`EntityCommand`] that adds the components in a [`Bundle`] to an entity.
#[track_caller]
fn insert<T: Bundle>(bundle: T, mode: InsertMode) -> impl EntityCommand {
let caller = core::panic::Location::caller();
let caller = Location::caller();
move |entity: Entity, world: &mut World| {
if let Some(mut entity) = world.get_entity_mut(entity) {
entity.insert_with_caller(
Expand All @@ -1373,7 +1373,7 @@ fn insert<T: Bundle>(bundle: T, mode: InsertMode) -> impl EntityCommand {
#[track_caller]
fn try_insert(bundle: impl Bundle, mode: InsertMode) -> impl EntityCommand {
#[cfg(feature = "track_change_detection")]
let caller = core::panic::Location::caller();
let caller = Location::caller();
move |entity, world: &mut World| {
if let Some(mut entity) = world.get_entity_mut(entity) {
entity.insert_with_caller(
Expand Down
Loading