Skip to content

Commit

Permalink
Simpler lint fixes: makes ci lints work but disables a lint for now (
Browse files Browse the repository at this point in the history
…#15376)

Takes the first two commits from #15375 and adds suggestions from this
comment:
#15375 (comment)

See #15375 for more reasoning/motivation.

## Rebasing (rerunning)

```rust
git switch simpler-lint-fixes
git reset --hard main
cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate
cargo fmt --all
git add --update
git commit --message "rustfmt"
cargo clippy --workspace --all-targets --all-features --fix
cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate
cargo fmt --all
git add --update
git commit --message "clippy"
git cherry-pick e6c0b94
```
  • Loading branch information
clarfonthey authored Sep 24, 2024
1 parent 1d9ee56 commit efda7f3
Show file tree
Hide file tree
Showing 373 changed files with 1,616 additions and 1,346 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"

# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219
too_long_first_doc_paragraph = "allow"

[workspace.lints.rust]
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_a11y/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use bevy_ecs::{
schedule::SystemSet,
system::Resource,
};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};

/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
#[derive(Event, Deref, DerefMut)]
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_animation/src/graph.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! The animation graph, which allows animations to be blended together.

use std::io::{self, Write};
use std::ops::{Index, IndexMut};
use std::{
io::{self, Write},
ops::{Index, IndexMut},
};

use bevy_asset::{io::Reader, Asset, AssetId, AssetLoader, AssetPath, Handle, LoadContext};
use bevy_reflect::{Reflect, ReflectSerialize};
Expand Down
21 changes: 14 additions & 7 deletions crates/bevy_animation/src/keyframes.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
//! Keyframes of animation clips.

use std::any::TypeId;
use std::fmt::{self, Debug, Formatter};
use std::{
any::TypeId,
fmt::{self, Debug, Formatter},
};

use bevy_asset::Handle;
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::component::Component;
use bevy_ecs::world::{EntityMutExcept, Mut};
use bevy_ecs::{
component::Component,
world::{EntityMutExcept, Mut},
};
use bevy_math::{Quat, Vec3};
use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath, Typed};
use bevy_render::mesh::morph::MorphWeights;
use bevy_transform::prelude::Transform;

use crate::graph::AnimationGraph;
use crate::prelude::{Animatable, GetKeyframe};
use crate::{animatable, AnimationEvaluationError, AnimationPlayer, Interpolation};
use crate::{
animatable,
graph::AnimationGraph,
prelude::{Animatable, GetKeyframe},
AnimationEvaluationError, AnimationPlayer, Interpolation,
};

/// A value on a component that Bevy can animate.
///
Expand Down
35 changes: 17 additions & 18 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,33 @@ pub mod keyframes;
pub mod transition;
mod util;

use std::any::{Any, TypeId};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::iter;
use std::{
any::{Any, TypeId},
cell::RefCell,
collections::BTreeMap,
fmt::Debug,
hash::{Hash, Hasher},
iter,
};

use bevy_app::{App, Plugin, PostUpdate};
use bevy_asset::{Asset, AssetApp, Assets, Handle};
use bevy_core::Name;
use bevy_ecs::entity::MapEntities;
use bevy_ecs::prelude::*;
use bevy_ecs::reflect::ReflectMapEntities;
use bevy_ecs::world::EntityMutExcept;
use bevy_ecs::{
entity::MapEntities, prelude::*, reflect::ReflectMapEntities, world::EntityMutExcept,
};
use bevy_math::FloatExt;
use bevy_reflect::utility::NonGenericTypeInfoCell;
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_reflect::{
ApplyError, DynamicStruct, FieldIter, FromReflect, FromType, GetTypeRegistration, NamedField,
PartialReflect, ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct,
StructInfo, TypeInfo, TypePath, TypeRegistration, Typed,
prelude::ReflectDefault, utility::NonGenericTypeInfoCell, ApplyError, DynamicStruct, FieldIter,
FromReflect, FromType, GetTypeRegistration, NamedField, PartialReflect, Reflect,
ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct, StructInfo,
TypeInfo, TypePath, TypeRegistration, Typed,
};
use bevy_time::Time;
use bevy_transform::prelude::Transform;
use bevy_transform::TransformSystem;
use bevy_transform::{prelude::Transform, TransformSystem};
use bevy_ui::UiSystem;
use bevy_utils::hashbrown::HashMap;
use bevy_utils::{
hashbrown::HashMap,
tracing::{trace, warn},
NoOpHash,
};
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ use bevy_utils::tracing::info_span;
use bevy_utils::{tracing::debug, HashMap};
use std::{
fmt::Debug,
process::{ExitCode, Termination},
};
use std::{
num::NonZero,
panic::{catch_unwind, resume_unwind, AssertUnwindSafe},
process::{ExitCode, Termination},
};
use thiserror::Error;

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_app/src/main_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub struct First;
pub struct PreUpdate;

/// Runs the [`FixedMain`] schedule in a loop according until all relevant elapsed time has been "consumed".
///
/// If you need to order your variable timestep systems
/// before or after the fixed update logic, use the [`RunFixedMainLoopSystem`] system set.
///
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_app/src/panic_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
//! For more fine-tuned control over panic behavior, disable the [`PanicHandlerPlugin`] or
//! `DefaultPlugins` during app initialization.

use crate::App;
use crate::Plugin;
use crate::{App, Plugin};

/// Adds sensible panic handlers to Apps. This plugin is part of the `DefaultPlugins`. Adding
/// this plugin will setup a panic hook appropriate to your target platform:
Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_app/src/plugin_group.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::{App, AppError, Plugin};
use bevy_utils::{tracing::debug, tracing::warn, TypeIdMap};
use bevy_utils::{
tracing::{debug, warn},
TypeIdMap,
};
use std::any::TypeId;

/// A macro for generating a well-documented [`PluginGroup`] from a list of [`Plugin`] paths.
Expand Down Expand Up @@ -185,6 +188,7 @@ fn type_id_of_val<T: 'static>(_: &T) -> TypeId {
}

/// Facilitates the creation and configuration of a [`PluginGroup`].
///
/// Provides a build ordering to ensure that [`Plugin`]s which produce/require a [`Resource`](bevy_ecs::system::Resource)
/// are built before/after dependent/depending [`Plugin`]s. [`Plugin`]s inside the group
/// can be disabled, enabled or reordered.
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_asset/src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{self as bevy_asset};
use crate::{Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle, UntypedHandle};
use crate::{
self as bevy_asset, Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle,
UntypedHandle,
};
use bevy_ecs::{
prelude::EventWriter,
system::{Res, ResMut, Resource},
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_asset/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ impl PartialOrd for UntypedAssetId {
}

/// An asset id without static or dynamic types associated with it.
///
/// This exist to support efficient type erased id drop tracking. We
/// could use [`UntypedAssetId`] for this, but the [`TypeId`] is unnecessary.
///
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_asset/src/io/embedded/embedded_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::io::{
memory::Dir,
AssetSourceEvent, AssetWatcher,
};
use bevy_utils::tracing::warn;
use bevy_utils::{Duration, HashMap};
use bevy_utils::{tracing::warn, Duration, HashMap};
use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, FileIdMap};
use parking_lot::RwLock;
use std::{
Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_asset/src/io/file/file_watcher.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::io::{AssetSourceEvent, AssetWatcher};
use crate::path::normalize_path;
use bevy_utils::tracing::error;
use bevy_utils::Duration;
use crate::{
io::{AssetSourceEvent, AssetWatcher},
path::normalize_path,
};
use bevy_utils::{tracing::error, Duration};
use crossbeam_channel::Sender;
use notify_debouncer_full::{
new_debouncer,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use bevy_utils::HashMap;
use futures_io::{AsyncRead, AsyncSeek};
use futures_lite::{ready, Stream};
use parking_lot::RwLock;
use std::io::SeekFrom;
use std::{
io::SeekFrom,
path::{Path, PathBuf},
pin::Pin,
sync::Arc,
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_asset/src/io/processor_gated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use crate::{
use async_lock::RwLockReadGuardArc;
use bevy_utils::tracing::trace;
use futures_io::{AsyncRead, AsyncSeek};
use std::io::SeekFrom;
use std::task::Poll;
use std::{path::Path, pin::Pin, sync::Arc};
use std::{io::SeekFrom, path::Path, pin::Pin, sync::Arc, task::Poll};

use super::ErasedAssetReader;

Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_asset/src/io/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use crate::{
};
use atomicow::CowArc;
use bevy_ecs::system::Resource;
use bevy_utils::tracing::{error, warn};
use bevy_utils::{Duration, HashMap};
use bevy_utils::{
tracing::{error, warn},
Duration, HashMap,
};
use std::{fmt::Display, hash::Hash, sync::Arc};
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ mod tests {
};
use bevy_app::{App, Update};
use bevy_core::TaskPoolPlugin;
use bevy_ecs::prelude::*;
use bevy_ecs::{
event::EventCursor,
prelude::*,
schedule::{LogLevel, ScheduleBuildSettings},
};
use bevy_log::LogPlugin;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ pub enum DeserializeMetaError {
}

/// A context that provides access to assets in [`AssetLoader`]s, tracks dependencies, and collects asset load state.
///
/// Any asset state accessed by [`LoadContext`] will be tracked and stored for use in dependency events and asset preprocessing.
pub struct LoadContext<'a> {
pub(crate) asset_server: &'a AssetServer,
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_asset/src/loader_builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crate::{
Asset, AssetLoadError, AssetPath, ErasedAssetLoader, ErasedLoadedAsset, Handle, LoadContext,
LoadDirectError, LoadedAsset, LoadedUntypedAsset,
};
use std::any::TypeId;
use std::sync::Arc;
use std::{any::TypeId, sync::Arc};

// Utility type for handling the sources of reader references
enum ReaderRef<'a> {
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_asset/src/meta.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{self as bevy_asset, DeserializeMetaError, VisitAssetDependencies};
use crate::{loader::AssetLoader, processor::Process, Asset, AssetPath};
use crate::{
self as bevy_asset, loader::AssetLoader, processor::Process, Asset, AssetPath,
DeserializeMetaError, VisitAssetDependencies,
};
use bevy_utils::tracing::error;
use downcast_rs::{impl_downcast, Downcast};
use ron::ser::PrettyConfig;
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/processor/log.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::AssetPath;
use async_fs::File;
use bevy_utils::tracing::error;
use bevy_utils::HashSet;
use bevy_utils::{tracing::error, HashSet};
use futures_lite::{AsyncReadExt, AsyncWriteExt};
use std::path::PathBuf;
use thiserror::Error;
Expand All @@ -15,6 +14,7 @@ pub(crate) enum LogEntry {
}

/// A "write ahead" logger that helps ensure asset importing is transactional.
///
/// Prior to processing an asset, we write to the log to indicate it has started
/// After processing an asset, we write to the log to indicate it has finished.
/// On startup, the log can be read to determine if any transactions were incomplete.
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ use crate::{
};
use bevy_ecs::prelude::*;
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{debug, error, trace, warn};
use bevy_utils::{
tracing::{debug, error, trace, warn},
HashMap, HashSet,
};
#[cfg(feature = "trace")]
use bevy_utils::{
tracing::{info_span, instrument::Instrument},
ConditionalSendFuture,
};
use bevy_utils::{HashMap, HashSet};
use futures_io::ErrorKind;
use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt};
use parking_lot::RwLock;
Expand Down
6 changes: 2 additions & 4 deletions crates/bevy_asset/src/processor/process.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use crate::io::SliceReader;
use crate::transformer::IdentityAssetTransformer;
use crate::{
io::{
AssetReaderError, AssetWriterError, MissingAssetWriterError,
MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, Writer,
MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, SliceReader, Writer,
},
meta::{AssetAction, AssetMeta, AssetMetaDyn, ProcessDependencyInfo, ProcessedInfo, Settings},
processor::AssetProcessor,
saver::{AssetSaver, SavedAsset},
transformer::{AssetTransformer, TransformedAsset},
transformer::{AssetTransformer, IdentityAssetTransformer, TransformedAsset},
AssetLoadError, AssetLoader, AssetPath, DeserializeMetaError, ErasedLoadedAsset,
MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError,
};
Expand Down
7 changes: 4 additions & 3 deletions crates/bevy_asset/src/saver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::transformer::TransformedAsset;
use crate::{io::Writer, meta::Settings, Asset, ErasedLoadedAsset};
use crate::{AssetLoader, Handle, LabeledAsset, UntypedHandle};
use crate::{
io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader,
ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle,
};
use atomicow::CowArc;
use bevy_utils::{BoxedFuture, ConditionalSendFuture, HashMap};
use serde::{Deserialize, Serialize};
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_asset/src/server/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use crate::{
};
use bevy_ecs::world::World;
use bevy_tasks::Task;
use bevy_utils::tracing::warn;
use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap};
use bevy_utils::{tracing::warn, Entry, HashMap, HashSet, TypeIdMap};
use crossbeam_channel::Sender;
use std::{
any::TypeId,
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_asset/src/server/loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ use crate::{
};
use async_broadcast::RecvError;
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{error, warn};
use bevy_utils::{
tracing::{error, warn},
HashMap, TypeIdMap,
};
#[cfg(feature = "trace")]
use bevy_utils::{
tracing::{info_span, instrument::Instrument},
ConditionalSendFuture,
};
use bevy_utils::{HashMap, TypeIdMap};
use std::{any::TypeId, sync::Arc};
use thiserror::Error;

Expand Down
Loading

0 comments on commit efda7f3

Please sign in to comment.