Skip to content

Commit

Permalink
Apply `#[deny(clippy::allow_attributes, clippy::allow_attributes_with…
Browse files Browse the repository at this point in the history
…out_reason)]` to bevy_audio
  • Loading branch information
LikeLakers2 committed Jan 3, 2025
1 parent 0403948 commit 90e53b4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
26 changes: 25 additions & 1 deletion crates/bevy_audio/src/audio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![expect(deprecated)]
#![expect(
deprecated,
reason = "See the NOTE comment attached to AudioSourceBundle."
)]

use crate::{AudioSource, Decodable, Volume};
use bevy_asset::{Asset, Handle};
Expand Down Expand Up @@ -212,6 +215,10 @@ pub struct DefaultSpatialScale(pub SpatialScale);
since = "0.15.0",
note = "Use the `AudioPlayer` component instead. Inserting it will now also insert a `PlaybackSettings` component automatically."
)]
#[expect(
deprecated,
reason = "This is a deprecated alias for a deprecated item."
)]
pub type AudioBundle = AudioSourceBundle<AudioSource>;

/// A component for playing a sound.
Expand Down Expand Up @@ -267,6 +274,15 @@ impl AudioPlayer<AudioSource> {
since = "0.15.0",
note = "Use the `AudioPlayer` component instead. Inserting it will now also insert a `PlaybackSettings` component automatically."
)]
// NOTE: When removing this, please remove the `#[expect(deprecated)]` at the top of this file.
//
// For whatever reason, this struct counts as a use of itself, causing rustc to lint about a use of
// a deprecated struct. However, adding an `#[expect(deprecated)]` to this strict causes rustc to
// say that the lint expectation is unfulfilled.
//
// The only solution I could find to this was to mark the whole module as expecting a deprecated
// lint. So, if this item is ever removed, please remove the `#[expect(deprecated)]` at the top of
// this file.
pub struct AudioSourceBundle<Source = AudioSource>
where
Source: Asset + Decodable,
Expand All @@ -280,6 +296,10 @@ where
pub settings: PlaybackSettings,
}

#[expect(
deprecated,
reason = "This is an impl for a deprecated item; rustc should not be complaining about this being a use of a deprecated item."
)]
impl<T: Asset + Decodable> Clone for AudioSourceBundle<T> {
fn clone(&self) -> Self {
Self {
Expand All @@ -289,6 +309,10 @@ impl<T: Asset + Decodable> Clone for AudioSourceBundle<T> {
}
}

#[expect(
deprecated,
reason = "This is an impl for a deprecated item; rustc should not be complaining about this being a use of a deprecated item."
)]
impl<T: Decodable + Asset> Default for AudioSourceBundle<T> {
fn default() -> Self {
Self {
Expand Down
10 changes: 9 additions & 1 deletion crates/bevy_audio/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![forbid(unsafe_code)]
#![deny(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
Expand Down Expand Up @@ -39,7 +44,10 @@ mod volume;
/// The audio prelude.
///
/// This includes the most common types in this crate, re-exported for your convenience.
#[expect(deprecated)]
#[expect(
deprecated,
reason = "Items here are part of a prelude meant for consumers of this crate, not for us."
)]
pub mod prelude {
#[doc(hidden)]
pub use crate::{
Expand Down
10 changes: 8 additions & 2 deletions crates/bevy_audio/src/pitch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![expect(deprecated)]

#[expect(
deprecated,
reason = "The deprecated item here (AudioSourceBundle) is only used by a type alias (which itself is deprecated)."
)]
use crate::{AudioSourceBundle, Decodable};
use bevy_asset::Asset;
use bevy_reflect::TypePath;
Expand Down Expand Up @@ -41,4 +43,8 @@ impl Decodable for Pitch {
since = "0.15.0",
note = "Use the `AudioPlayer<Pitch>` component instead. Inserting it will now also insert a `PlaybackSettings` component automatically."
)]
#[expect(
deprecated,
reason = "This is a deprecated alias for a deprecated item."
)]
pub type PitchBundle = AudioSourceBundle<Pitch>;

0 comments on commit 90e53b4

Please sign in to comment.