Fix some nightly clippy lints (#2522)

on nightly these two clippy lints fail:
- [needless_borrow](https://rust-lang.github.io/rust-clippy/master/#needless_borrow)
- [unused_unit](https://rust-lang.github.io/rust-clippy/master/#unused_unit)
This commit is contained in:
Boxy 2021-07-29 20:52:15 +00:00
parent 86cc70b902
commit 5ffff03b33
34 changed files with 104 additions and 101 deletions

View file

@ -478,7 +478,7 @@ impl AssetServer {
.expect("Asset should exist at this point.");
if let Some(asset_lifecycle) = asset_lifecycles.get(&asset_value.type_uuid()) {
let asset_path =
AssetPath::new_ref(&load_context.path, label.as_ref().map(|l| l.as_str()));
AssetPath::new_ref(load_context.path, label.as_ref().map(|l| l.as_str()));
asset_lifecycle.create_asset(asset_path.into(), asset_value, load_context.version);
} else {
panic!(

View file

@ -101,7 +101,7 @@ impl<'a> LoadContext<'a> {
}
pub fn path(&self) -> &Path {
&self.path
self.path
}
pub fn has_labeled_asset(&self, label: &str) -> bool {

View file

@ -45,7 +45,7 @@ where
{
fn play_source(&self, audio_source: &P) {
if let Some(stream_handle) = &self.stream_handle {
let sink = Sink::try_new(&stream_handle).unwrap();
let sink = Sink::try_new(stream_handle).unwrap();
sink.append(audio_source.decoder());
sink.detach();
}

View file

@ -107,7 +107,7 @@ pub(crate) fn entity_labels_system(
}
}
for added_label in labels.labels.difference(&current_labels) {
for added_label in labels.labels.difference(current_labels) {
entity_labels
.label_entities
.entry(added_label.clone())

View file

@ -72,6 +72,7 @@ macro_rules! tuple_impl {
}
#[allow(unused_variables, unused_mut)]
#[allow(clippy::unused_unit)]
unsafe fn from_components(mut func: impl FnMut() -> *mut u8) -> Self {
#[allow(non_snake_case)]
let ($(mut $name,)*) = (

View file

@ -737,7 +737,7 @@ mod tests {
fn get_added<Com: Component>(world: &mut World) -> Vec<Entity> {
world
.query_filtered::<Entity, Added<Com>>()
.iter(&world)
.iter(world)
.collect::<Vec<Entity>>()
}
@ -781,7 +781,7 @@ mod tests {
{
world
.query_filtered::<Entity, F>()
.iter(&world)
.iter(world)
.collect::<Vec<Entity>>()
}
@ -868,7 +868,7 @@ mod tests {
fn get_changed(world: &mut World) -> Vec<Entity> {
world
.query_filtered::<Entity, Changed<A>>()
.iter(&world)
.iter(world)
.collect::<Vec<Entity>>()
}
assert_eq!(get_changed(&mut world), vec![e1]);

View file

@ -197,7 +197,7 @@ impl<T: SparseSetIndex> FilteredAccessSet<T> {
// compatibility
if !filtered_access.access.is_compatible(&self.combined_access) {
for current_filtered_access in self.filtered_accesses.iter() {
if !current_filtered_access.is_compatible(&filtered_access) {
if !current_filtered_access.is_compatible(filtered_access) {
return current_filtered_access
.access
.get_conflicts(&filtered_access.access);

View file

@ -917,6 +917,7 @@ macro_rules! impl_tuple_fetch {
type Item = ($($name::Item,)*);
type State = ($($name::State,)*);
#[allow(clippy::unused_unit)]
unsafe fn init(_world: &World, state: &Self::State, _last_change_tick: u32, _change_tick: u32) -> Self {
let ($($name,)*) = state;
($($name::init(_world, $name, _last_change_tick, _change_tick),)*)
@ -944,12 +945,14 @@ macro_rules! impl_tuple_fetch {
}
#[inline]
#[allow(clippy::unused_unit)]
unsafe fn table_fetch(&mut self, _table_row: usize) -> Self::Item {
let ($($name,)*) = self;
($($name.table_fetch(_table_row),)*)
}
#[inline]
#[allow(clippy::unused_unit)]
unsafe fn archetype_fetch(&mut self, _archetype_index: usize) -> Self::Item {
let ($($name,)*) = self;
($($name.archetype_fetch(_archetype_index),)*)
@ -958,6 +961,7 @@ macro_rules! impl_tuple_fetch {
// SAFETY: update_component_access and update_archetype_component_access are called for each item in the tuple
#[allow(non_snake_case)]
#[allow(clippy::unused_unit)]
unsafe impl<$($name: FetchState),*> FetchState for ($($name,)*) {
fn init(_world: &mut World) -> Self {
($($name::init(_world),)*)

View file

@ -290,16 +290,12 @@ where
// first, iterate from last to first until next item is found
'outer: for i in (0..K).rev() {
match self.cursors[i].next(&self.tables, &self.archetypes, &self.query_state) {
match self.cursors[i].next(self.tables, self.archetypes, self.query_state) {
Some(_) => {
// walk forward up to last element, propagating cursor state forward
for j in (i + 1)..K {
self.cursors[j] = self.cursors[j - 1].clone();
match self.cursors[j].next(
&self.tables,
&self.archetypes,
&self.query_state,
) {
match self.cursors[j].next(self.tables, self.archetypes, self.query_state) {
Some(_) => {}
None if i > 0 => continue 'outer,
None => return None,

View file

@ -97,7 +97,7 @@ pub fn topological_order<Labels: Clone>(
}
current.push(*node);
for dependency in graph.get(node).unwrap().keys() {
if check_if_cycles_and_visit(dependency, &graph, sorted, unvisited, current) {
if check_if_cycles_and_visit(dependency, graph, sorted, unvisited, current) {
return true;
}
}

View file

@ -350,7 +350,7 @@ where
#[inline]
fn component_access(&self) -> &Access<ComponentId> {
&self.system_meta.component_access_set.combined_access()
self.system_meta.component_access_set.combined_access()
}
#[inline]

View file

@ -1158,6 +1158,7 @@ macro_rules! impl_system_param_tuple {
type Item = ($($param::Item,)*);
#[inline]
#[allow(clippy::unused_unit)]
unsafe fn get_param(
state: &'a mut Self,
system_meta: &SystemMeta,
@ -1192,6 +1193,7 @@ macro_rules! impl_system_param_tuple {
$($param.apply(_world);)*
}
#[allow(clippy::unused_unit)]
fn default_config() -> ($(<$param as SystemParamState>::Config,)*) {
($(<$param as SystemParamState>::default_config(),)*)
}

View file

@ -369,7 +369,7 @@ async fn load_texture<'a>(
}
fn load_material(material: &Material, load_context: &mut LoadContext) -> Handle<StandardMaterial> {
let material_label = material_label(&material);
let material_label = material_label(material);
let pbr = material.pbr_metallic_roughness();

View file

@ -174,8 +174,8 @@ pub fn lights_node_system(
.chunks_exact_mut(point_light_size),
) {
slot.copy_from_slice(bytes_of(&PointLightUniform::new(
&point_light,
&global_transform,
point_light,
global_transform,
)));
}
@ -184,7 +184,7 @@ pub fn lights_node_system(
data[dir_light_uniform_start..dir_light_uniform_end]
.chunks_exact_mut(dir_light_size),
) {
slot.copy_from_slice(bytes_of(&DirectionalLightUniform::new(&dir_light)));
slot.copy_from_slice(bytes_of(&DirectionalLightUniform::new(dir_light)));
}
},
);

View file

@ -191,8 +191,8 @@ fn impl_struct(
let field_count = active_fields.len();
let field_indices = (0..field_count).collect::<Vec<usize>>();
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
let partial_eq_fn = match reflect_attrs.reflect_partial_eq {
TraitImpl::NotImplemented => quote! {
use #bevy_reflect_path::Struct;
@ -335,8 +335,8 @@ fn impl_tuple_struct(
let field_count = active_fields.len();
let field_indices = (0..field_count).collect::<Vec<usize>>();
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
let partial_eq_fn = match reflect_attrs.reflect_partial_eq {
TraitImpl::NotImplemented => quote! {
use #bevy_reflect_path::TupleStruct;
@ -448,9 +448,9 @@ fn impl_value(
bevy_reflect_path: &Path,
reflect_attrs: &ReflectAttrs,
) -> TokenStream {
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
let partial_eq_fn = reflect_attrs.get_partial_eq_impl();
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
TokenStream::from(quote! {

View file

@ -413,34 +413,34 @@ impl Mesh {
for (_, attributes) in self.attributes.iter_mut() {
let indices = indices.iter();
match attributes {
VertexAttributeValues::Float32(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(vec, indices),
}
}
}
@ -481,7 +481,7 @@ fn remove_resource_save(
index: u64,
) {
if let Some(RenderResourceId::Buffer(buffer)) =
render_resource_context.get_asset_resource(&handle, index)
render_resource_context.get_asset_resource(handle, index)
{
render_resource_context.remove_buffer(buffer);
render_resource_context.remove_asset_resource(handle, index);
@ -546,7 +546,7 @@ pub fn mesh_resource_provider_system(
buffer_usage: BufferUsage::INDEX,
..Default::default()
},
&data,
data,
);
render_resource_context.set_asset_resource(

View file

@ -164,7 +164,7 @@ impl PipelineCompiler {
});
let mut layout = render_resource_context.reflect_pipeline_layout(
&shaders,
shaders,
&specialized_descriptor.shader_stages,
true,
);
@ -252,7 +252,7 @@ impl PipelineCompiler {
render_resource_context.create_render_pipeline(
specialized_pipeline_handle.clone_weak(),
pipelines.get(&specialized_pipeline_handle).unwrap(),
&shaders,
shaders,
);
// track specialized shader pipelines

View file

@ -51,6 +51,6 @@ pub struct VertexAttribute {
/// Internally, `bevy_render` uses hashes to identify vertex attribute names.
pub fn get_vertex_attribute_name_id(name: &str) -> u64 {
let mut hasher = bevy_utils::AHasher::default();
hasher.write(&name.as_bytes());
hasher.write(name.as_bytes());
hasher.finish()
}

View file

@ -237,7 +237,7 @@ where
let commands = &mut self.commands;
render_context.begin_pass(
&self.descriptor,
&render_resource_bindings,
render_resource_bindings,
&mut |render_pass| {
for render_command in commands.drain(..) {
match render_command {

View file

@ -460,7 +460,7 @@ fn render_resources_node_system<T: RenderResources>(
queries.q1_mut().get_mut(entity)
{
if !setup_uniform_texture_resources::<T>(
&uniforms,
uniforms,
render_resource_context,
&mut render_pipelines.bindings,
) {
@ -475,7 +475,7 @@ fn render_resources_node_system<T: RenderResources>(
}
uniform_buffer_arrays.prepare_uniform_buffers(entity, uniforms);
if !setup_uniform_texture_resources::<T>(
&uniforms,
uniforms,
render_resource_context,
&mut render_pipelines.bindings,
) {
@ -507,7 +507,7 @@ fn render_resources_node_system<T: RenderResources>(
state.uniform_buffer_arrays.write_uniform_buffers(
entity,
&uniforms,
uniforms,
state.dynamic_uniforms,
render_resource_context,
&mut render_pipelines.bindings,
@ -524,7 +524,7 @@ fn render_resources_node_system<T: RenderResources>(
state.uniform_buffer_arrays.write_uniform_buffers(
entity,
&uniforms,
uniforms,
state.dynamic_uniforms,
render_resource_context,
&mut render_pipelines.bindings,
@ -656,7 +656,7 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(
if let Some(asset) = assets.get(asset_handle) {
let mut bindings =
asset_render_resource_bindings.get_or_insert_mut(&Handle::<T>::weak(asset_handle));
if !setup_uniform_texture_resources::<T>(&asset, render_resource_context, &mut bindings)
if !setup_uniform_texture_resources::<T>(asset, render_resource_context, &mut bindings)
{
asset_state.assets_waiting_for_textures.push(asset_handle);
}
@ -689,7 +689,7 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(
uniform_buffer_arrays.prepare_uniform_buffers(*asset_handle, asset);
let mut bindings =
asset_render_resource_bindings.get_or_insert_mut(&Handle::<T>::weak(*asset_handle));
if !setup_uniform_texture_resources::<T>(&asset, render_resource_context, &mut bindings) {
if !setup_uniform_texture_resources::<T>(asset, render_resource_context, &mut bindings) {
asset_state.assets_waiting_for_textures.push(*asset_handle);
}
}
@ -719,7 +719,7 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(
// TODO: only setup buffer if we haven't seen this handle before
state.uniform_buffer_arrays.write_uniform_buffers(
asset_handle,
&asset,
asset,
state.dynamic_uniforms,
render_resource_context,
&mut render_resource_bindings,
@ -733,7 +733,7 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(
// TODO: only setup buffer if we haven't seen this handle before
state.uniform_buffer_arrays.write_uniform_buffers(
*asset_handle,
&asset,
asset,
state.dynamic_uniforms,
render_resource_context,
&mut render_resource_bindings,

View file

@ -24,7 +24,7 @@ impl Node for TextureCopyNode {
let texture_events = world.get_resource::<Events<AssetEvent<Texture>>>().unwrap();
let textures = world.get_resource::<Assets<Texture>>().unwrap();
let mut copied_textures = HashSet::default();
for event in self.texture_event_reader.iter(&texture_events) {
for event in self.texture_event_reader.iter(texture_events) {
match event {
AssetEvent::Created { handle } | AssetEvent::Modified { handle } => {
if let Some(texture) = textures.get(handle) {

View file

@ -55,17 +55,17 @@ impl Node for WindowSwapChainNode {
// create window swapchain when window is resized or created
if self
.window_created_event_reader
.iter(&window_created_events)
.iter(window_created_events)
.any(|e| e.id == window.id())
|| self
.window_resized_event_reader
.iter(&window_resized_events)
.iter(window_resized_events)
.any(|e| e.id == window.id())
{
render_resource_context.create_swap_chain(window);
}
let swap_chain_texture = render_resource_context.next_swap_chain_texture(&window);
let swap_chain_texture = render_resource_context.next_swap_chain_texture(window);
output.set(
WINDOW_TEXTURE,
RenderResourceId::Texture(swap_chain_texture),

View file

@ -55,11 +55,11 @@ impl Node for WindowTextureNode {
if self
.window_created_event_reader
.iter(&window_created_events)
.iter(window_created_events)
.any(|e| e.id == window.id())
|| self
.window_resized_event_reader
.iter(&window_resized_events)
.iter(window_resized_events)
.any(|e| e.id == window.id())
{
let render_resource_context = render_context.resources_mut();

View file

@ -213,7 +213,7 @@ impl Shader {
pub fn get_spirv(&self, macros: Option<&[String]>) -> Result<Vec<u32>, ShaderError> {
match self.source {
ShaderSource::Spirv(ref bytes) => Ok(bytes.clone()),
ShaderSource::Glsl(ref source) => glsl_to_spirv(&source, self.stage, macros),
ShaderSource::Glsl(ref source) => glsl_to_spirv(source, self.stage, macros),
}
}
@ -288,7 +288,7 @@ impl ShaderStages {
pub fn iter(&self) -> ShaderStagesIterator {
ShaderStagesIterator {
shader_stages: &self,
shader_stages: self,
state: 0,
}
}

View file

@ -84,7 +84,7 @@ impl Texture {
);
for current_pixel in value.data.chunks_exact_mut(pixel.len()) {
current_pixel.copy_from_slice(&pixel);
current_pixel.copy_from_slice(pixel);
}
value
}

View file

@ -95,7 +95,7 @@ impl DynamicScene {
for registration in type_registry.iter() {
if let Some(map_entities_reflect) = registration.data::<ReflectMapEntities>() {
map_entities_reflect
.map_entities(world, &entity_map)
.map_entities(world, entity_map)
.unwrap();
}
}

View file

@ -27,7 +27,7 @@ impl AssetLoader for SceneLoader {
load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<()>> {
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 {
type_registry: &*self.type_registry.read(),
};

View file

@ -79,7 +79,7 @@ impl SceneSpawner {
) -> Result<(), SceneSpawnError> {
if let Some(instance_ids) = self.spawned_dynamic_scenes.get(&scene_handle) {
for instance_id in instance_ids {
if let Some(instance) = self.spawned_instances.get(&instance_id) {
if let Some(instance) = self.spawned_instances.get(instance_id) {
for entity in instance.entity_map.values() {
let _ = world.despawn(entity); // Ignore the result, despawn only cares if
// it exists.
@ -305,7 +305,7 @@ pub fn scene_spawner_system(world: &mut World) {
let mut updated_spawned_scenes = Vec::new();
for event in scene_spawner
.scene_asset_event_reader
.iter(&scene_asset_events)
.iter(scene_asset_events)
{
if let AssetEvent::Modified { handle } = event {
if scene_spawner.spawned_dynamic_scenes.contains_key(handle) {

View file

@ -243,15 +243,15 @@ pub fn flex_node_system(
for (entity, style, calculated_size) in query.iter() {
// TODO: remove node from old hierarchy if its root has changed
if let Some(calculated_size) = calculated_size {
flex_surface.upsert_leaf(entity, &style, *calculated_size, scaling_factor);
flex_surface.upsert_leaf(entity, style, *calculated_size, scaling_factor);
} else {
flex_surface.upsert_node(entity, &style, scaling_factor);
flex_surface.upsert_node(entity, style, scaling_factor);
}
}
}
for (entity, style, calculated_size) in changed_size_query.iter() {
flex_surface.upsert_leaf(entity, &style, *calculated_size, logical_to_physical_factor);
flex_surface.upsert_leaf(entity, style, *calculated_size, logical_to_physical_factor);
}
// TODO: handle removed nodes
@ -263,7 +263,7 @@ pub fn flex_node_system(
// update children
for (entity, children) in children_query.iter() {
flex_surface.update_children(entity, &children);
flex_surface.update_children(entity, children);
}
// compute layouts

View file

@ -225,13 +225,13 @@ fn get_texture_view<'a>(
attachment: &TextureAttachment,
) -> &'a wgpu::TextureView {
match attachment {
TextureAttachment::Name(name) => match global_render_resource_bindings.get(&name) {
Some(RenderResourceBinding::Texture(resource)) => refs.textures.get(&resource).unwrap(),
TextureAttachment::Name(name) => match global_render_resource_bindings.get(name) {
Some(RenderResourceBinding::Texture(resource)) => refs.textures.get(resource).unwrap(),
_ => {
panic!("Color attachment {} does not exist.", name);
}
},
TextureAttachment::Id(render_resource) => refs.textures.get(&render_resource).unwrap_or_else(|| &refs.swap_chain_frames.get(&render_resource).unwrap().output.view),
TextureAttachment::Id(render_resource) => refs.textures.get(render_resource).unwrap_or_else(|| &refs.swap_chain_frames.get(render_resource).unwrap().output.view),
TextureAttachment::Input(_) => panic!("Encountered unset `TextureAttachment::Input`. The `RenderGraph` executor should always set `TextureAttachment::Inputs` to `TextureAttachment::RenderResource` before running. This is a bug, please report it!"),
}
}
@ -250,7 +250,7 @@ fn create_wgpu_color_attachment<'a>(
let resolve_target = color_attachment
.resolve_target
.as_ref()
.map(|target| get_texture_view(global_render_resource_bindings, refs, &target));
.map(|target| get_texture_view(global_render_resource_bindings, refs, target));
wgpu::RenderPassColorAttachment {
ops: (&color_attachment.ops).wgpu_into(),

View file

@ -349,7 +349,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
.resources
.shader_modules
.read()
.get(&shader_handle)
.get(shader_handle)
.is_some()
{
return;
@ -439,7 +439,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
let layout = pipeline_descriptor.get_layout().unwrap();
for bind_group_descriptor in layout.bind_groups.iter() {
self.create_bind_group_layout(&bind_group_descriptor);
self.create_bind_group_layout(bind_group_descriptor);
}
let bind_group_layouts = self.resources.bind_group_layouts.read();
@ -490,7 +490,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
label: None,
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &vertex_shader_module,
module: vertex_shader_module,
entry_point: "main",
buffers: &owned_vertex_buffer_descriptors
.iter()
@ -555,16 +555,16 @@ impl RenderResourceContext for WgpuRenderResourceContext {
let wgpu_resource = match &indexed_binding.entry {
RenderResourceBinding::Texture(resource) => {
let texture_view = texture_views
.get(&resource)
.get(resource)
.unwrap_or_else(|| panic!("{:?}", resource));
wgpu::BindingResource::TextureView(texture_view)
}
RenderResourceBinding::Sampler(resource) => {
let sampler = samplers.get(&resource).unwrap();
let sampler = samplers.get(resource).unwrap();
wgpu::BindingResource::Sampler(sampler)
}
RenderResourceBinding::Buffer { buffer, range, .. } => {
let wgpu_buffer = buffers.get(&buffer).unwrap();
let wgpu_buffer = buffers.get(buffer).unwrap();
let size = NonZeroU64::new(range.end - range.start)
.expect("Size of the buffer needs to be greater than 0!");
wgpu::BindingResource::Buffer(wgpu::BufferBinding {
@ -684,7 +684,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
) -> Result<Shader, ShaderError> {
let spirv_data = match shader.source {
ShaderSource::Spirv(ref bytes) => bytes.clone(),
ShaderSource::Glsl(ref source) => glsl_to_spirv(&source, shader.stage, macros)?,
ShaderSource::Glsl(ref source) => glsl_to_spirv(source, shader.stage, macros)?,
};
Ok(Shader {
source: ShaderSource::Spirv(spirv_data),

View file

@ -163,7 +163,7 @@ impl BindGroupCounter {
*count > 0
};
if !retain {
bind_group_usage_counts.remove(&id);
bind_group_usage_counts.remove(id);
}
retain

View file

@ -102,7 +102,7 @@ impl WinitWindows {
}
}
let winit_window = winit_window_builder.build(&event_loop).unwrap();
let winit_window = winit_window_builder.build(event_loop).unwrap();
match winit_window.set_cursor_grab(window_descriptor.cursor_locked) {
Ok(_) => {}
@ -140,7 +140,7 @@ impl WinitWindows {
self.windows.insert(winit_window.id(), winit_window);
Window::new(
window_id,
&window_descriptor,
window_descriptor,
inner_size.width,
inner_size.height,
scale_factor,

View file

@ -92,10 +92,10 @@ fn save_scene_system(world: &mut World) {
// The TypeRegistry resource contains information about all registered types (including
// components). This is used to construct scenes.
let type_registry = world.get_resource::<TypeRegistry>().unwrap();
let scene = DynamicScene::from_world(&scene_world, &type_registry);
let scene = DynamicScene::from_world(&scene_world, type_registry);
// Scenes can be serialized like this:
info!("{}", scene.serialize_ron(&type_registry).unwrap());
info!("{}", scene.serialize_ron(type_registry).unwrap());
// TODO: save scene
}