Skip to content

Commit 8e52194

Browse files
james7132alice-i-cecilehymm
authored
CI fixes for Rust 1.89 (#20462)
Adopted from #20456 Notes: * The origin of the `dead_code` lints were coming from the `ShaderType ` derive macro. This has been reported as teoxoy/encase#102, and a temporary workspace-wide `allow` added to the top level Cargo.toml. * One of the lints pointed out that `PartialEq` and `Eq` may not work as expected for function pointers, so `CloneBehavior` no longer implements either trait, and pattern matching is used in instead. Original PR Description: ># Objective > >Unbreak CI. > > ## Solution > > Fix the lints. > >I've opted for anonymous lifetimes in every revealed case so far; please let me know if you think I should used named lifetimes in specific cases and why. > >## Testing > >Is CI green? > >## Context > > This lint originally had a much larger splash damage, with fairly negative effects on Bevy. See rust-lang/rust#131725. > > The more restricted former is much more helpful, despite the large diff in this PR. Bevy is a large code base! > >## TODO > >- [x] discuss proposed lifetime lint fixes >,- [x] use cargo clippy --fix to fix newly uncovered docs misformatting >- [x] fix newly revealed dead code issues >- [x] ensure CI is green --------- Co-authored-by: Alice Cecile <[email protected]> Co-authored-by: Mike <[email protected]>
1 parent 40b6940 commit 8e52194

File tree

166 files changed

+1395
-1419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+1395
-1419
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ jobs:
263263
run: cargo check --target wasm32-unknown-unknown
264264

265265
build-wasm-atomics:
266+
if: ${{ false }} # Disabled temporarily due to https://github.com/rust-lang/rust/issues/145101
266267
runs-on: ubuntu-latest
267268
timeout-minutes: 30
268269
needs: build

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ allow_attributes = "warn"
7373
allow_attributes_without_reason = "warn"
7474

7575
[workspace.lints.rust]
76+
# Strictly temporary until encase fixes dead code generation from ShaderType macros
77+
dead_code = "allow"
7678
missing_docs = "warn"
7779
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
7880
unsafe_code = "deny"
@@ -118,6 +120,8 @@ allow_attributes = "warn"
118120
allow_attributes_without_reason = "warn"
119121

120122
[lints.rust]
123+
# Strictly temporary until encase fixes dead code generation from ShaderType macros
124+
dead_code = "allow"
121125
missing_docs = "warn"
122126
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
123127
unsafe_code = "deny"

crates/bevy_animation/src/animation_curves.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub trait AnimatableProperty: Send + Sync + 'static {
199199

200200
/// The [`EvaluatorId`] used to look up the [`AnimationCurveEvaluator`] for this [`AnimatableProperty`].
201201
/// For a given animated property, this ID should always be the same to allow things like animation blending to occur.
202-
fn evaluator_id(&self) -> EvaluatorId;
202+
fn evaluator_id(&self) -> EvaluatorId<'_>;
203203
}
204204

205205
/// A [`Component`] field that can be animated, defined by a function that reads the component and returns
@@ -236,7 +236,7 @@ where
236236
Ok((self.func)(c.into_inner()))
237237
}
238238

239-
fn evaluator_id(&self) -> EvaluatorId {
239+
fn evaluator_id(&self) -> EvaluatorId<'_> {
240240
EvaluatorId::ComponentField(&self.evaluator_id)
241241
}
242242
}
@@ -357,7 +357,7 @@ where
357357
self.curve.domain()
358358
}
359359

360-
fn evaluator_id(&self) -> EvaluatorId {
360+
fn evaluator_id(&self) -> EvaluatorId<'_> {
361361
self.property.evaluator_id()
362362
}
363363

@@ -476,7 +476,7 @@ where
476476
self.0.domain()
477477
}
478478

479-
fn evaluator_id(&self) -> EvaluatorId {
479+
fn evaluator_id(&self) -> EvaluatorId<'_> {
480480
EvaluatorId::Type(TypeId::of::<WeightsCurveEvaluator>())
481481
}
482482

@@ -768,7 +768,7 @@ pub trait AnimationCurve: Debug + Send + Sync + 'static {
768768
///
769769
/// This must match the type returned by [`Self::create_evaluator`]. It must
770770
/// be a single type that doesn't depend on the type of the curve.
771-
fn evaluator_id(&self) -> EvaluatorId;
771+
fn evaluator_id(&self) -> EvaluatorId<'_>;
772772

773773
/// Returns a newly-instantiated [`AnimationCurveEvaluator`] for use with
774774
/// this curve.

crates/bevy_animation/src/lib.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ struct CurrentEvaluators {
772772
}
773773

774774
impl CurrentEvaluators {
775-
pub(crate) fn keys(&self) -> impl Iterator<Item = EvaluatorId> {
775+
pub(crate) fn keys(&self) -> impl Iterator<Item = EvaluatorId<'_>> {
776776
self.component_properties
777777
.keys()
778778
.map(EvaluatorId::ComponentField)
@@ -1007,12 +1007,11 @@ pub fn advance_animations(
10071007

10081008
if let Some(active_animation) = active_animations.get_mut(&node_index) {
10091009
// Tick the animation if necessary.
1010-
if !active_animation.paused {
1011-
if let AnimationNodeType::Clip(ref clip_handle) = node.node_type {
1012-
if let Some(clip) = animation_clips.get(clip_handle) {
1013-
active_animation.update(delta_seconds, clip.duration);
1014-
}
1015-
}
1010+
if !active_animation.paused
1011+
&& let AnimationNodeType::Clip(ref clip_handle) = node.node_type
1012+
&& let Some(clip) = animation_clips.get(clip_handle)
1013+
{
1014+
active_animation.update(delta_seconds, clip.duration);
10161015
}
10171016
}
10181017
}
@@ -1158,21 +1157,20 @@ pub fn animate_targets(
11581157
AnimationEventTarget::Node(target_id),
11591158
clip,
11601159
active_animation,
1161-
) {
1162-
if !triggered_events.is_empty() {
1163-
par_commands.command_scope(move |mut commands| {
1164-
for TimedAnimationEvent { time, event } in
1165-
triggered_events.iter()
1166-
{
1167-
event.trigger(
1168-
&mut commands,
1169-
entity,
1170-
*time,
1171-
active_animation.weight,
1172-
);
1173-
}
1174-
});
1175-
}
1160+
) && !triggered_events.is_empty()
1161+
{
1162+
par_commands.command_scope(move |mut commands| {
1163+
for TimedAnimationEvent { time, event } in
1164+
triggered_events.iter()
1165+
{
1166+
event.trigger(
1167+
&mut commands,
1168+
entity,
1169+
*time,
1170+
active_animation.weight,
1171+
);
1172+
}
1173+
});
11761174
}
11771175
}
11781176

@@ -1462,7 +1460,7 @@ impl<'a> TriggeredEvents<'a> {
14621460
self.lower.is_empty() && self.upper.is_empty()
14631461
}
14641462

1465-
fn iter(&self) -> TriggeredEventsIter {
1463+
fn iter(&self) -> TriggeredEventsIter<'_> {
14661464
match self.direction {
14671465
TriggeredEventsDir::Forward => TriggeredEventsIter::Forward(self.lower.iter()),
14681466
TriggeredEventsDir::Reverse => TriggeredEventsIter::Reverse(self.lower.iter().rev()),

crates/bevy_animation/src/transition.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,15 @@ impl AnimationTransitions {
8181
new_animation: AnimationNodeIndex,
8282
transition_duration: Duration,
8383
) -> &'p mut ActiveAnimation {
84-
if let Some(old_animation_index) = self.main_animation.replace(new_animation) {
85-
if let Some(old_animation) = player.animation_mut(old_animation_index) {
86-
if !old_animation.is_paused() {
87-
self.transitions.push(AnimationTransition {
88-
current_weight: old_animation.weight,
89-
weight_decline_per_sec: 1.0 / transition_duration.as_secs_f32(),
90-
animation: old_animation_index,
91-
});
92-
}
93-
}
84+
if let Some(old_animation_index) = self.main_animation.replace(new_animation)
85+
&& let Some(old_animation) = player.animation_mut(old_animation_index)
86+
&& !old_animation.is_paused()
87+
{
88+
self.transitions.push(AnimationTransition {
89+
current_weight: old_animation.weight,
90+
weight_decline_per_sec: 1.0 / transition_duration.as_secs_f32(),
91+
animation: old_animation_index,
92+
});
9493
}
9594

9695
// If already transitioning away from this animation, cancel the transition.
@@ -135,10 +134,10 @@ pub fn advance_transitions(
135134
remaining_weight -= animation.weight;
136135
}
137136

138-
if let Some(main_animation_index) = animation_transitions.main_animation {
139-
if let Some(ref mut animation) = player.animation_mut(main_animation_index) {
140-
animation.weight = remaining_weight;
141-
}
137+
if let Some(main_animation_index) = animation_transitions.main_animation
138+
&& let Some(ref mut animation) = player.animation_mut(main_animation_index)
139+
{
140+
animation.weight = remaining_weight;
142141
}
143142
}
144143
}

crates/bevy_anti_aliasing/src/taa/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,17 @@ fn extract_taa_settings(mut commands: Commands, mut main_world: ResMut<MainWorld
350350
Option<&mut TemporalAntiAliasing>,
351351
)>();
352352

353-
for (entity, camera, camera_projection, mut taa_settings) in
354-
cameras_3d.iter_mut(&mut main_world)
355-
{
353+
for (entity, camera, camera_projection, taa_settings) in cameras_3d.iter_mut(&mut main_world) {
356354
let has_perspective_projection = matches!(camera_projection, Projection::Perspective(_));
357355
let mut entity_commands = commands
358356
.get_entity(entity)
359357
.expect("Camera entity wasn't synced.");
360-
if taa_settings.is_some() && camera.is_active && has_perspective_projection {
361-
entity_commands.insert(taa_settings.as_deref().unwrap().clone());
362-
taa_settings.as_mut().unwrap().reset = false;
358+
if let Some(mut taa_settings) = taa_settings
359+
&& camera.is_active
360+
&& has_perspective_projection
361+
{
362+
entity_commands.insert(taa_settings.clone());
363+
taa_settings.reset = false;
363364
} else {
364365
entity_commands.remove::<(
365366
TemporalAntiAliasing,

crates/bevy_app/src/plugin_group.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,18 +517,18 @@ impl PluginGroupBuilder {
517517
#[track_caller]
518518
pub fn finish(mut self, app: &mut App) {
519519
for ty in &self.order {
520-
if let Some(entry) = self.plugins.remove(ty) {
521-
if entry.enabled {
522-
debug!("added plugin: {}", entry.plugin.name());
523-
if let Err(AppError::DuplicatePlugin { plugin_name }) =
524-
app.add_boxed_plugin(entry.plugin)
525-
{
526-
panic!(
527-
"Error adding plugin {} in group {}: plugin was already added in application",
528-
plugin_name,
529-
self.group_name
530-
);
531-
}
520+
if let Some(entry) = self.plugins.remove(ty)
521+
&& entry.enabled
522+
{
523+
debug!("added plugin: {}", entry.plugin.name());
524+
if let Err(AppError::DuplicatePlugin { plugin_name }) =
525+
app.add_boxed_plugin(entry.plugin)
526+
{
527+
panic!(
528+
"Error adding plugin {} in group {}: plugin was already added in application",
529+
plugin_name,
530+
self.group_name
531+
);
532532
}
533533
}
534534
}

crates/bevy_asset/src/io/embedded/embedded_watcher.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ impl FilesystemEventHandler for EmbeddedEventHandler {
7373

7474
fn handle(&mut self, absolute_paths: &[PathBuf], event: AssetSourceEvent) {
7575
if self.last_event.as_ref() != Some(&event) {
76-
if let AssetSourceEvent::ModifiedAsset(path) = &event {
77-
if let Ok(file) = File::open(&absolute_paths[0]) {
78-
let mut reader = BufReader::new(file);
79-
let mut buffer = Vec::new();
76+
if let AssetSourceEvent::ModifiedAsset(path) = &event
77+
&& let Ok(file) = File::open(&absolute_paths[0])
78+
{
79+
let mut reader = BufReader::new(file);
80+
let mut buffer = Vec::new();
8081

81-
// Read file into vector.
82-
if reader.read_to_end(&mut buffer).is_ok() {
83-
self.dir.insert_asset(path, buffer);
84-
}
82+
// Read file into vector.
83+
if reader.read_to_end(&mut buffer).is_ok() {
84+
self.dir.insert_asset(path, buffer);
8585
}
8686
}
8787
self.last_event = Some(event.clone());

crates/bevy_asset/src/io/file/file_asset.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ impl AssetReader for FileAssetReader {
6969
f.ok().and_then(|dir_entry| {
7070
let path = dir_entry.path();
7171
// filter out meta files as they are not considered assets
72-
if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
73-
if ext.eq_ignore_ascii_case("meta") {
74-
return None;
75-
}
72+
if let Some(ext) = path.extension().and_then(|e| e.to_str())
73+
&& ext.eq_ignore_ascii_case("meta")
74+
{
75+
return None;
7676
}
7777
// filter out hidden files. they are not listed by default but are directly targetable
7878
if path

crates/bevy_asset/src/io/file/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ impl FileAssetWriter {
7575
/// watching for changes.
7676
pub fn new<P: AsRef<Path> + core::fmt::Debug>(path: P, create_root: bool) -> Self {
7777
let root_path = get_base_path().join(path.as_ref());
78-
if create_root {
79-
if let Err(e) = std::fs::create_dir_all(&root_path) {
80-
error!(
81-
"Failed to create root directory {} for file asset writer: {}",
82-
root_path.display(),
83-
e
84-
);
85-
}
78+
if create_root && let Err(e) = std::fs::create_dir_all(&root_path) {
79+
error!(
80+
"Failed to create root directory {} for file asset writer: {}",
81+
root_path.display(),
82+
e
83+
);
8684
}
8785
Self { root_path }
8886
}

0 commit comments

Comments
 (0)