Clippy fixes (#206)

* Clippy fixes

* Clippy: add Default implementations

* Clippy: Simplify if let match

* Clippy: Fix never read variables

Co-authored-by: Max Ammann <max@maxammann.org>
This commit is contained in:
Julien Rebetez 2022-11-12 14:06:43 +01:00 committed by GitHub
parent fec6a408ee
commit c77ce85741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 16 deletions

View File

@ -80,7 +80,7 @@ pub fn validate_project_wgsl() {
{
format!(":{}:{} {}", line_number, line_position, error)
} else {
format!("{}", error)
error
},
WgslError::IoErr(error) => format!(": {:?}", error),
}

View File

@ -117,7 +117,7 @@ impl HeadlessMap {
&mut pipeline_context,
);
let mut processor = pipeline_context
let processor = pipeline_context
.take_processor::<HeadlessPipelineProcessor>()
.expect("Unable to get processor");

View File

@ -62,6 +62,12 @@ impl GeometryIndex {
}
}
impl Default for GeometryIndex {
fn default() -> Self {
Self::new()
}
}
/// Index of tiles which can be of two types: spatial or linear.
/// Spatial tiles are stored in a multi-dimentional tree which represents their position in the tile.
/// Linear tiles are simply stored in a vector.
@ -198,6 +204,12 @@ impl IndexProcessor {
}
}
impl Default for IndexProcessor {
fn default() -> Self {
Self::new()
}
}
impl GeomProcessor for IndexProcessor {
fn xy(&mut self, x: f64, y: f64, idx: usize) -> Result<(), GeozeroError> {
self.geo_writer.xy(x, y, idx)

View File

@ -140,13 +140,10 @@ impl TileRepository {
/// Create a new tile.
pub fn create_tile(&mut self, coords: WorldTileCoords) -> bool {
if let Some(entry) = coords.build_quad_key().map(|key| self.tree.entry(key)) {
match entry {
btree_map::Entry::Vacant(entry) => {
entry.insert(StoredTile::pending(coords));
}
_ => {}
}
if let Some(btree_map::Entry::Vacant(entry)) =
coords.build_quad_key().map(|key| self.tree.entry(key))
{
entry.insert(StoredTile::pending(coords));
}
true
}

View File

@ -44,6 +44,12 @@ pub struct KernelBuilder<E: Environment> {
http_client: Option<E::HttpClient>,
}
impl<E: Environment> Default for KernelBuilder<E> {
fn default() -> Self {
Self::new()
}
}
impl<E: Environment> KernelBuilder<E> {
pub fn new() -> Self {
Self {

View File

@ -30,3 +30,9 @@ impl Scheduler for TokioScheduler {
Ok(())
}
}
impl Default for TokioScheduler {
fn default() -> Self {
Self::new()
}
}

View File

@ -38,6 +38,12 @@ impl RendererBuilder {
}
}
impl Default for RendererBuilder {
fn default() -> Self {
Self::new()
}
}
pub enum InitializationResult {
Initialized(InitializedRenderer),
Uninizalized(UninitializedRenderer),
@ -110,7 +116,7 @@ impl UninitializedRenderer {
Ok(Renderer::initialize_headless(
existing_window,
self.wgpu_settings.clone(),
self.renderer_settings.clone(),
self.renderer_settings,
)
.await?)
}

View File

@ -264,11 +264,8 @@ impl Renderer {
#[cfg(target_arch = "wasm32")]
let trace_path = None;
// Maybe get features and limits based on what is supported by the adapter/backend
let mut features = wgpu::Features::empty();
let mut limits = settings.limits.clone();
features = adapter.features() | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
let mut features =
adapter.features() | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
if adapter_info.device_type == wgpu::DeviceType::DiscreteGpu {
// `MAPPABLE_PRIMARY_BUFFERS` can have a significant, negative performance impact for
// discrete GPUs due to having to transfer data across the PCI-E bus and so it
@ -276,7 +273,7 @@ impl Renderer {
// integrated GPUs.
features -= wgpu::Features::MAPPABLE_PRIMARY_BUFFERS;
}
limits = adapter.limits();
let mut limits = adapter.limits();
// Enforce the disabled features
if let Some(disabled_features) = settings.disabled_features {

View File

@ -582,6 +582,12 @@ impl RingIndex {
}
}
impl Default for RingIndex {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use lyon::tessellation::VertexBuffers;

View File

@ -37,3 +37,9 @@ impl FPSMeter {
}
}
}
impl Default for FPSMeter {
fn default() -> Self {
Self::new()
}
}