Prepare for upcoming rustlang by fixing upcoming clippy warnings (#6376)
# Objective - Proactive changing of code to comply with warnings generated by beta of rustlang version of cargo clippy. ## Solution - Code changed as recommended by `rustup update`, `rustup default beta`, `cargo run -p ci -- clippy`. - Tested using `beta` and `stable`. No clippy warnings in either after changes made. --- ## Changelog - Warnings fixed were: `clippy::explicit-auto-deref` (present in 11 files), `clippy::needless-borrow` (present in 2 files), and `clippy::only-used-in-recursion` (only 1 file).
This commit is contained in:
parent
a083882cb2
commit
c18b1a839b
@ -788,7 +788,7 @@ mod test {
|
|||||||
|
|
||||||
fn create_dir_and_file(file: impl AsRef<Path>) -> tempfile::TempDir {
|
fn create_dir_and_file(file: impl AsRef<Path>) -> tempfile::TempDir {
|
||||||
let asset_dir = tempfile::tempdir().unwrap();
|
let asset_dir = tempfile::tempdir().unwrap();
|
||||||
std::fs::write(asset_dir.path().join(file), &[]).unwrap();
|
std::fs::write(asset_dir.path().join(file), []).unwrap();
|
||||||
asset_dir
|
asset_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ pub fn play_queued_audio_system<Source: Asset + Decodable>(
|
|||||||
mut sinks: ResMut<Assets<AudioSink>>,
|
mut sinks: ResMut<Assets<AudioSink>>,
|
||||||
) {
|
) {
|
||||||
if let Some(audio_sources) = audio_sources {
|
if let Some(audio_sources) = audio_sources {
|
||||||
audio_output.try_play_queued(&*audio_sources, &mut *audio, &mut *sinks);
|
audio_output.try_play_queued(&*audio_sources, &mut *audio, &mut sinks);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ impl<'a, 'b> BundleInserter<'a, 'b> {
|
|||||||
// redundant copies
|
// redundant copies
|
||||||
let move_result = self
|
let move_result = self
|
||||||
.table
|
.table
|
||||||
.move_to_superset_unchecked(result.table_row, *new_table);
|
.move_to_superset_unchecked(result.table_row, new_table);
|
||||||
let new_location = new_archetype.allocate(entity, move_result.new_row);
|
let new_location = new_archetype.allocate(entity, move_result.new_row);
|
||||||
self.entities.meta[entity.id as usize].location = new_location;
|
self.entities.meta[entity.id as usize].location = new_location;
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ impl<'w, T> Deref for WorldBorrowMut<'w, T> {
|
|||||||
|
|
||||||
impl<'w, T> DerefMut for WorldBorrowMut<'w, T> {
|
impl<'w, T> DerefMut for WorldBorrowMut<'w, T> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut *self.value
|
&mut self.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +472,6 @@ async fn load_gltf<'a, 'b>(
|
|||||||
&node,
|
&node,
|
||||||
parent,
|
parent,
|
||||||
load_context,
|
load_context,
|
||||||
&buffer_data,
|
|
||||||
&mut node_index_to_entity_map,
|
&mut node_index_to_entity_map,
|
||||||
&mut entity_to_skin_index_map,
|
&mut entity_to_skin_index_map,
|
||||||
&mut active_camera_found,
|
&mut active_camera_found,
|
||||||
@ -697,7 +696,6 @@ fn load_node(
|
|||||||
gltf_node: &gltf::Node,
|
gltf_node: &gltf::Node,
|
||||||
world_builder: &mut WorldChildBuilder,
|
world_builder: &mut WorldChildBuilder,
|
||||||
load_context: &mut LoadContext,
|
load_context: &mut LoadContext,
|
||||||
buffer_data: &[Vec<u8>],
|
|
||||||
node_index_to_entity_map: &mut HashMap<usize, Entity>,
|
node_index_to_entity_map: &mut HashMap<usize, Entity>,
|
||||||
entity_to_skin_index_map: &mut HashMap<Entity, usize>,
|
entity_to_skin_index_map: &mut HashMap<Entity, usize>,
|
||||||
active_camera_found: &mut bool,
|
active_camera_found: &mut bool,
|
||||||
@ -893,7 +891,6 @@ fn load_node(
|
|||||||
&child,
|
&child,
|
||||||
parent,
|
parent,
|
||||||
load_context,
|
load_context,
|
||||||
buffer_data,
|
|
||||||
node_index_to_entity_map,
|
node_index_to_entity_map,
|
||||||
entity_to_skin_index_map,
|
entity_to_skin_index_map,
|
||||||
active_camera_found,
|
active_camera_found,
|
||||||
|
@ -48,7 +48,7 @@ pub fn extract_resource<R: ExtractResource>(
|
|||||||
) {
|
) {
|
||||||
if let Some(mut target_resource) = target_resource {
|
if let Some(mut target_resource) = target_resource {
|
||||||
if main_resource.is_changed() {
|
if main_resource.is_changed() {
|
||||||
*target_resource = R::extract_resource(&*main_resource);
|
*target_resource = R::extract_resource(&main_resource);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
@ -60,6 +60,6 @@ pub fn extract_resource<R: ExtractResource>(
|
|||||||
std::any::type_name::<R>()
|
std::any::type_name::<R>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
commands.insert_resource(R::extract_resource(&*main_resource));
|
commands.insert_resource(R::extract_resource(&main_resource));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,6 @@ impl From<Vec<Mat4>> for SkinnedMeshInverseBindposes {
|
|||||||
impl Deref for SkinnedMeshInverseBindposes {
|
impl Deref for SkinnedMeshInverseBindposes {
|
||||||
type Target = [Mat4];
|
type Target = [Mat4];
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&*self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ impl AssetLoader for SceneLoader {
|
|||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut deserializer = ron::de::Deserializer::from_bytes(bytes)?;
|
let mut deserializer = ron::de::Deserializer::from_bytes(bytes)?;
|
||||||
let scene_deserializer = SceneDeserializer {
|
let scene_deserializer = SceneDeserializer {
|
||||||
type_registry: &*self.type_registry.read(),
|
type_registry: &self.type_registry.read(),
|
||||||
};
|
};
|
||||||
let scene = scene_deserializer.deserialize(&mut deserializer)?;
|
let scene = scene_deserializer.deserialize(&mut deserializer)?;
|
||||||
load_context.set_default_asset(LoadedAsset::new(scene));
|
load_context.set_default_asset(LoadedAsset::new(scene));
|
||||||
|
@ -102,10 +102,8 @@ impl<'a> Serialize for ComponentsSerializer<'a> {
|
|||||||
{
|
{
|
||||||
let mut state = serializer.serialize_seq(Some(self.components.len()))?;
|
let mut state = serializer.serialize_seq(Some(self.components.len()))?;
|
||||||
for component in self.components {
|
for component in self.components {
|
||||||
state.serialize_element(&ReflectSerializer::new(
|
state
|
||||||
&**component,
|
.serialize_element(&ReflectSerializer::new(&**component, &self.registry.read()))?;
|
||||||
&*self.registry.read(),
|
|
||||||
))?;
|
|
||||||
}
|
}
|
||||||
state.end()
|
state.end()
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ impl TaskPool {
|
|||||||
// This is guaranteed because we drive all the futures spawned onto the Scope
|
// This is guaranteed because we drive all the futures spawned onto the Scope
|
||||||
// to completion in this function. However, rust has no way of knowing this so we
|
// to completion in this function. However, rust has no way of knowing this so we
|
||||||
// transmute the lifetimes to 'env here to appease the compiler as it is unable to validate safety.
|
// transmute the lifetimes to 'env here to appease the compiler as it is unable to validate safety.
|
||||||
let executor: &async_executor::Executor = &*self.executor;
|
let executor: &async_executor::Executor = &self.executor;
|
||||||
let executor: &'env async_executor::Executor = unsafe { mem::transmute(executor) };
|
let executor: &'env async_executor::Executor = unsafe { mem::transmute(executor) };
|
||||||
let task_scope_executor = &async_executor::Executor::default();
|
let task_scope_executor = &async_executor::Executor::default();
|
||||||
let task_scope_executor: &'env async_executor::Executor =
|
let task_scope_executor: &'env async_executor::Executor =
|
||||||
|
@ -189,9 +189,9 @@ pub fn update_text2d_layout(
|
|||||||
scale_factor,
|
scale_factor,
|
||||||
text.alignment,
|
text.alignment,
|
||||||
text_bounds,
|
text_bounds,
|
||||||
&mut *font_atlas_set_storage,
|
&mut font_atlas_set_storage,
|
||||||
&mut *texture_atlases,
|
&mut texture_atlases,
|
||||||
&mut *textures,
|
&mut textures,
|
||||||
text_settings.as_ref(),
|
text_settings.as_ref(),
|
||||||
YAxisOrientation::BottomToTop,
|
YAxisOrientation::BottomToTop,
|
||||||
) {
|
) {
|
||||||
|
@ -237,9 +237,9 @@ pub fn flex_node_system(
|
|||||||
let scale_factor = logical_to_physical_factor * ui_scale.scale;
|
let scale_factor = logical_to_physical_factor * ui_scale.scale;
|
||||||
|
|
||||||
if scale_factor_events.iter().next_back().is_some() || ui_scale.is_changed() {
|
if scale_factor_events.iter().next_back().is_some() || ui_scale.is_changed() {
|
||||||
update_changed(&mut *flex_surface, scale_factor, full_node_query);
|
update_changed(&mut flex_surface, scale_factor, full_node_query);
|
||||||
} else {
|
} else {
|
||||||
update_changed(&mut *flex_surface, scale_factor, node_query);
|
update_changed(&mut flex_surface, scale_factor, node_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_changed<F: ReadOnlyWorldQuery>(
|
fn update_changed<F: ReadOnlyWorldQuery>(
|
||||||
|
@ -117,9 +117,9 @@ pub fn text_system(
|
|||||||
scale_factor,
|
scale_factor,
|
||||||
text.alignment,
|
text.alignment,
|
||||||
node_size,
|
node_size,
|
||||||
&mut *font_atlas_set_storage,
|
&mut font_atlas_set_storage,
|
||||||
&mut *texture_atlases,
|
&mut texture_atlases,
|
||||||
&mut *textures,
|
&mut textures,
|
||||||
text_settings.as_ref(),
|
text_settings.as_ref(),
|
||||||
YAxisOrientation::TopToBottom,
|
YAxisOrientation::TopToBottom,
|
||||||
) {
|
) {
|
||||||
|
@ -324,7 +324,7 @@ fn contributors() -> Result<Contributors, LoadContributorsError> {
|
|||||||
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").map_err(LoadContributorsError::Var)?;
|
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").map_err(LoadContributorsError::Var)?;
|
||||||
|
|
||||||
let mut cmd = std::process::Command::new("git")
|
let mut cmd = std::process::Command::new("git")
|
||||||
.args(&["--no-pager", "log", "--pretty=format:%an"])
|
.args(["--no-pager", "log", "--pretty=format:%an"])
|
||||||
.current_dir(manifest_dir)
|
.current_dir(manifest_dir)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
|
Loading…
Reference in New Issue
Block a user