Skip to content

Commit b557321

Browse files
committed
Fix Rust 1.89 Lints
1 parent 3d44dc4 commit b557321

File tree

8 files changed

+87
-86
lines changed

8 files changed

+87
-86
lines changed

bevy_widgets/bevy_text_editing/src/editable_text_line/input.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ pub fn on_key_input(
8888
// Process modifier key combinations
8989
match &input.key_code {
9090
KeyCode::KeyC => {
91-
if let Some(selected_text) = text_field.get_selected_text() {
92-
if let Err(e) = clipboard.set_text(selected_text) {
93-
warn!("Clipboard error: {}", e);
94-
}
91+
if let Some(selected_text) = text_field.get_selected_text()
92+
&& let Err(e) = clipboard.set_text(selected_text)
93+
{
94+
warn!("Clipboard error: {}", e);
9595
}
9696
}
9797
KeyCode::KeyV => match clipboard.get_text() {
@@ -114,10 +114,10 @@ pub fn on_key_input(
114114
}
115115
},
116116
KeyCode::KeyX => {
117-
if let Some(selected_text) = text_field.get_selected_text() {
118-
if let Err(e) = clipboard.set_text(selected_text) {
119-
warn!("Clipboard error: {}", e);
120-
}
117+
if let Some(selected_text) = text_field.get_selected_text()
118+
&& let Err(e) = clipboard.set_text(selected_text)
119+
{
120+
warn!("Clipboard error: {}", e);
121121
}
122122
if let Some(selected_range) = text_field.selection_range() {
123123
text_change = TextChange::remove_change(selected_range);
@@ -137,10 +137,10 @@ pub fn on_key_input(
137137
// Process regular (non-modifier) key press
138138
match &input.logical_key {
139139
Key::Space => {
140-
if let Some(allowed_chars) = &text_field.allowed_chars {
141-
if !allowed_chars.contains(&' ') {
142-
return;
143-
}
140+
if let Some(allowed_chars) = &text_field.allowed_chars
141+
&& !allowed_chars.contains(&' ')
142+
{
143+
return;
144144
}
145145

146146
if let Some((start, end)) = text_field.selection_range() {
@@ -269,11 +269,11 @@ pub fn update_has_focus(
269269
// Gained focus
270270
commands.entity(entity).insert(HasFocus(true));
271271

272-
if let Ok(mut text_field) = q_editable_texts.get_mut(entity) {
273-
if text_field.cursor_position.is_none() {
274-
text_field.cursor_position = Some(CharPosition(0));
275-
commands.trigger_targets(RenderWidget::show_cursor(), entity);
276-
}
272+
if let Ok(mut text_field) = q_editable_texts.get_mut(entity)
273+
&& text_field.cursor_position.is_none()
274+
{
275+
text_field.cursor_position = Some(CharPosition(0));
276+
commands.trigger_targets(RenderWidget::show_cursor(), entity);
277277
}
278278
}
279279
} else if has_focus.0 {

crates/bevy_editor_settings/src/file_system/de/mod.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,15 @@ pub fn load_preferences(world: &mut World, table: toml::Table, settings_type: Se
241241
.map(|key| key.0.to_string())
242242
.unwrap_or_else(|| enm.reflect_type_ident().unwrap().to_snake_case());
243243

244-
if let Some(table) = table.get(&name).and_then(|v| v.as_table()) {
245-
if let Some(value) = table.get("variant") {
246-
LoadEnum {
247-
enum_info,
248-
enm,
249-
toml_value: value,
250-
}
251-
.load_enum();
244+
if let Some(table) = table.get(&name).and_then(|v| v.as_table())
245+
&& let Some(value) = table.get("variant")
246+
{
247+
LoadEnum {
248+
enum_info,
249+
enm,
250+
toml_value: value,
252251
}
252+
.load_enum();
253253
}
254254
}
255255
}
@@ -274,17 +274,16 @@ pub fn load_preferences(world: &mut World, table: toml::Table, settings_type: Se
274274
tuple_struct.reflect_type_ident().unwrap().to_snake_case()
275275
});
276276

277-
if let Some(table) = table.get(&name).and_then(|v| v.as_table()) {
278-
if let Some(array_value) =
277+
if let Some(table) = table.get(&name).and_then(|v| v.as_table())
278+
&& let Some(array_value) =
279279
table.get("fields").and_then(|v| v.as_array())
280-
{
281-
LoadTupleStruct {
282-
tuple_struct_info,
283-
table: array_value,
284-
tuple_struct,
285-
}
286-
.load_tuple_struct();
280+
{
281+
LoadTupleStruct {
282+
tuple_struct_info,
283+
table: array_value,
284+
tuple_struct,
287285
}
286+
.load_tuple_struct();
288287
}
289288
}
290289
}

crates/bevy_editor_settings/src/file_system/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ pub fn global_settings_path() -> Option<PathBuf> {
1414
let config_dir = path.config_dir();
1515
let path = config_dir.join(SETTINGS_BASE_DIR);
1616

17-
if !path.exists() {
18-
if let Err(e) = std::fs::create_dir_all(&path) {
19-
error!("Failed to create global settings directory: {}", e);
20-
return None;
21-
}
17+
if !path.exists()
18+
&& let Err(e) = std::fs::create_dir_all(&path)
19+
{
20+
error!("Failed to create global settings directory: {}", e);
21+
return None;
2222
}
2323
Some(path)
2424
}

crates/bevy_proto_bsn/src/bsn_asset.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ impl TryFrom<&ExprUnary> for BsnValue {
321321
type Error = BsnLoaderError;
322322

323323
fn try_from(value: &ExprUnary) -> Result<Self, Self::Error> {
324-
if let UnOp::Neg(_) = value.op {
325-
if let Expr::Lit(lit) = value.expr.as_ref() {
326-
let mut bsn_value: BsnValue = lit.into();
327-
if let BsnValue::Number(ref mut f) = bsn_value {
328-
f.insert(0, '-');
329-
return Ok(bsn_value);
330-
}
324+
if let UnOp::Neg(_) = value.op
325+
&& let Expr::Lit(lit) = value.expr.as_ref()
326+
{
327+
let mut bsn_value: BsnValue = lit.into();
328+
if let BsnValue::Number(ref mut f) = bsn_value {
329+
f.insert(0, '-');
330+
return Ok(bsn_value);
331331
}
332332
}
333333

crates/bevy_proto_bsn/src/bsn_reflect.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -362,22 +362,21 @@ impl<'a, 'b> BsnReflector<'a, 'b> {
362362
) -> ReflectResult<Box<dyn PartialReflect>> {
363363
// HACK: Allows constructing Handles from asset paths in BSN assets by triggering loads during reflection.
364364
// This should be removed when we have an upstream Construct implementation for Handle.
365-
if ty.type_path().starts_with("bevy_asset::handle::Handle<") && self.asset_loader.is_some()
365+
if ty.type_path().starts_with("bevy_asset::handle::Handle<")
366+
&& self.asset_loader.is_some()
367+
&& let BsnProp::Props(BsnValue::String(asset_path)) = prop
366368
{
367-
if let BsnProp::Props(BsnValue::String(asset_path)) = prop {
368-
let Some(reflect_handle_load) = self
369-
.registry
370-
.get_type_data::<ReflectHandleLoad>(ty.type_id())
371-
else {
372-
return Err(ReflectError::MissingTypeData(
373-
"ReflectHandleLoad".into(),
374-
ty.type_path().into(),
375-
));
376-
};
377-
let handle =
378-
reflect_handle_load.load(asset_path, self.asset_loader.as_ref().unwrap());
379-
return Ok(handle.into_partial_reflect());
380-
}
369+
let Some(reflect_handle_load) = self
370+
.registry
371+
.get_type_data::<ReflectHandleLoad>(ty.type_id())
372+
else {
373+
return Err(ReflectError::MissingTypeData(
374+
"ReflectHandleLoad".into(),
375+
ty.type_path().into(),
376+
));
377+
};
378+
let handle = reflect_handle_load.load(asset_path, self.asset_loader.as_ref().unwrap());
379+
return Ok(handle.into_partial_reflect());
381380
}
382381

383382
// This is fine : )

crates/bevy_proto_bsn/src/construct.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ impl<'a> ConstructContext<'a> {
130130
/// Construct extension
131131
pub trait ConstructEntityCommandsExt {
132132
/// Construct a bundle using the given props and insert it onto the entity.
133-
fn construct<T: Construct + Bundle>(&mut self, props: impl Into<T::Props>) -> EntityCommands
133+
fn construct<T: Construct + Bundle>(
134+
&mut self,
135+
props: impl Into<T::Props>,
136+
) -> EntityCommands<'_>
134137
where
135138
<T as Construct>::Props: Send;
136139
}
137140

138141
impl ConstructEntityCommandsExt for EntityCommands<'_> {
139-
fn construct<T: Construct + Bundle>(&mut self, props: impl Into<T::Props>) -> EntityCommands
142+
fn construct<T: Construct + Bundle>(&mut self, props: impl Into<T::Props>) -> EntityCommands<'_>
140143
where
141144
<T as Construct>::Props: Send,
142145
{

crates/bevy_proto_bsn/src/entity_patch.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ where
221221
/// Extension trait implementing [`Scene`] utilities for [`EntityCommands`].
222222
pub trait EntityCommandsSceneExt {
223223
/// Constructs a [`Scene`] and applies it to the entity.
224-
fn construct_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands;
224+
fn construct_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands<'_>;
225225
}
226226

227227
impl EntityCommandsSceneExt for EntityCommands<'_> {
228228
// type Out = EntityCommands;
229-
fn construct_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands {
229+
fn construct_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands<'_> {
230230
self.queue(ConstructSceneCommand(scene));
231231
self.reborrow()
232232
}
@@ -235,20 +235,20 @@ impl EntityCommandsSceneExt for EntityCommands<'_> {
235235
/// Scene spawning extension.
236236
pub trait SpawnSceneExt {
237237
/// Spawn the given [`Scene`].
238-
fn spawn_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands;
238+
fn spawn_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands<'_>;
239239
}
240240

241241
impl SpawnSceneExt for Commands<'_, '_> {
242242
/// Spawn the given [`Scene`].
243-
fn spawn_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands {
243+
fn spawn_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands<'_> {
244244
let mut entity = self.spawn_empty();
245245
entity.queue(ConstructSceneCommand(scene));
246246
entity
247247
}
248248
}
249249

250250
impl SpawnSceneExt for ChildSpawnerCommands<'_> {
251-
fn spawn_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands {
251+
fn spawn_scene(&mut self, scene: impl Scene + Send + 'static) -> EntityCommands<'_> {
252252
let mut entity = self.spawn_empty();
253253
entity.queue(ConstructSceneCommand(scene));
254254
entity

crates/bevy_undo/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,15 +1407,15 @@ fn auto_undo_remove_detect<T: Component + Clone>(
14071407
ignore_storage: ResMut<UndoIgnoreStorage>,
14081408
) {
14091409
for e in removed_query.read() {
1410-
if !ignore_storage.storage.contains_key(&e) {
1411-
if let Some(prev_value) = storage.storage.remove(&e) {
1412-
new_changes.write(NewChange {
1413-
change: Arc::new(RemovedComponent {
1414-
old_value: prev_value,
1415-
entity: e,
1416-
}),
1417-
});
1418-
}
1410+
if !ignore_storage.storage.contains_key(&e)
1411+
&& let Some(prev_value) = storage.storage.remove(&e)
1412+
{
1413+
new_changes.write(NewChange {
1414+
change: Arc::new(RemovedComponent {
1415+
old_value: prev_value,
1416+
entity: e,
1417+
}),
1418+
});
14191419
}
14201420
}
14211421
}
@@ -1428,15 +1428,15 @@ fn auto_undo_reflected_remove_detect<T: Component + Reflect + FromReflect>(
14281428
ignore_storage: ResMut<UndoIgnoreStorage>,
14291429
) {
14301430
for e in removed_query.read() {
1431-
if !ignore_storage.storage.contains_key(&e) {
1432-
if let Some(prev_value) = storage.storage.remove(&e) {
1433-
new_changes.write(NewChange {
1434-
change: Arc::new(ReflectedRemovedComponent {
1435-
old_value: prev_value,
1436-
entity: e,
1437-
}),
1438-
});
1439-
}
1431+
if !ignore_storage.storage.contains_key(&e)
1432+
&& let Some(prev_value) = storage.storage.remove(&e)
1433+
{
1434+
new_changes.write(NewChange {
1435+
change: Arc::new(ReflectedRemovedComponent {
1436+
old_value: prev_value,
1437+
entity: e,
1438+
}),
1439+
});
14401440
}
14411441
}
14421442
}

0 commit comments

Comments
 (0)