mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'tygyh/Resolve-all-'#-allow(clippy--for_loops_over_fallibles)]'-error-supressions' into 'master'
Resolve all '#[allow(clippy::or_fun_call)]' error supressions See merge request veloren/veloren!2607
This commit is contained in:
commit
6fb0395fd0
@ -44,7 +44,6 @@ pub struct ClientInit {
|
||||
}
|
||||
impl ClientInit {
|
||||
#[allow(clippy::op_ref)] // TODO: Pending review in #587
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn new(
|
||||
connection_args: ConnectionArgs,
|
||||
username: String,
|
||||
|
@ -15,7 +15,6 @@ use vek::*;
|
||||
|
||||
// /// NOTE: bone_idx must be in [0, 15] (may be bumped to [0, 31] at some
|
||||
// /// point).
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
// TODO: this function name...
|
||||
pub fn generate_mesh_base_vol_terrain<'a: 'b, 'b, V: 'a>(
|
||||
vol: V,
|
||||
@ -65,7 +64,9 @@ where
|
||||
let get_opacity = |vol: &mut V, pos: Vec3<i32>| vol.get(pos).map_or(true, |vox| vox.is_empty());
|
||||
let should_draw = |vol: &mut V, pos: Vec3<i32>, delta: Vec3<i32>, uv| {
|
||||
should_draw_greedy(pos, delta, uv, |vox| {
|
||||
vol.get(vox).map(|vox| *vox).unwrap_or(Cell::empty())
|
||||
vol.get(vox)
|
||||
.map(|vox| *vox)
|
||||
.unwrap_or_else(|_| Cell::empty())
|
||||
})
|
||||
};
|
||||
let create_opaque = |atlas_pos, pos, norm| {
|
||||
@ -97,7 +98,9 @@ where
|
||||
let (glowy, shiny) = cell
|
||||
.map(|c| (c.is_glowy(), c.is_shiny()))
|
||||
.unwrap_or_default();
|
||||
let col = cell.and_then(|vox| vox.get_color()).unwrap_or(Rgb::zero());
|
||||
let col = cell
|
||||
.and_then(|vox| vox.get_color())
|
||||
.unwrap_or_else(Rgb::zero);
|
||||
TerrainVertex::make_col_light_figure(light, glowy, shiny, col)
|
||||
},
|
||||
});
|
||||
@ -111,7 +114,6 @@ where
|
||||
(Mesh::new(), Mesh::new(), Mesh::new(), bounds)
|
||||
}
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn generate_mesh_base_vol_sprite<'a: 'b, 'b, V: 'a>(
|
||||
vol: V,
|
||||
(greedy, opaque_mesh, vertical_stripes): (
|
||||
@ -162,7 +164,7 @@ where
|
||||
for y in -1..greedy_size.y + 1 {
|
||||
for z in -1..greedy_size.z + 1 {
|
||||
let wpos = lower_bound + Vec3::new(x, y, z);
|
||||
let block = vol.get(wpos).map(|b| *b).unwrap_or(Cell::empty());
|
||||
let block = vol.get(wpos).map(|b| *b).unwrap_or_else(|_| Cell::empty());
|
||||
flat[i] = block;
|
||||
i += 1;
|
||||
}
|
||||
@ -197,8 +199,9 @@ where
|
||||
}
|
||||
};
|
||||
let get_glow = |_flat: &mut _, _pos: Vec3<i32>| 0.0;
|
||||
let get_color =
|
||||
move |flat: &mut _, pos: Vec3<i32>| flat_get(flat, pos).get_color().unwrap_or(Rgb::zero());
|
||||
let get_color = move |flat: &mut _, pos: Vec3<i32>| {
|
||||
flat_get(flat, pos).get_color().unwrap_or_else(Rgb::zero)
|
||||
};
|
||||
let get_opacity = move |flat: &mut _, pos: Vec3<i32>| flat_get(flat, pos).is_empty();
|
||||
let should_draw = move |flat: &mut _, pos: Vec3<i32>, delta: Vec3<i32>, uv| {
|
||||
should_draw_greedy_ao(vertical_stripes, pos, delta, uv, |vox| flat_get(flat, vox))
|
||||
@ -238,7 +241,6 @@ where
|
||||
(Mesh::new(), Mesh::new(), Mesh::new(), ())
|
||||
}
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn generate_mesh_base_vol_particle<'a: 'b, 'b, V: 'a>(
|
||||
vol: V,
|
||||
greedy: &'b mut GreedyMesh<'a>,
|
||||
@ -285,12 +287,14 @@ where
|
||||
vol.get(pos)
|
||||
.ok()
|
||||
.and_then(|vox| vox.get_color())
|
||||
.unwrap_or(Rgb::zero())
|
||||
.unwrap_or_else(Rgb::zero)
|
||||
};
|
||||
let get_opacity = |vol: &mut V, pos: Vec3<i32>| vol.get(pos).map_or(true, |vox| vox.is_empty());
|
||||
let should_draw = |vol: &mut V, pos: Vec3<i32>, delta: Vec3<i32>, uv| {
|
||||
should_draw_greedy(pos, delta, uv, |vox| {
|
||||
vol.get(vox).map(|vox| *vox).unwrap_or(Cell::empty())
|
||||
vol.get(vox)
|
||||
.map(|vox| *vox)
|
||||
.unwrap_or_else(|_| Cell::empty())
|
||||
})
|
||||
};
|
||||
let create_opaque = |_atlas_pos, pos: Vec3<f32>, norm| ParticleVertex::new(pos, norm);
|
||||
|
@ -228,7 +228,6 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
#[allow(clippy::many_single_char_names)]
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[allow(clippy::needless_range_loop)] // TODO: Pending review in #587
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn generate_mesh<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug + 'static>(
|
||||
vol: &'a VolGrid2d<V>,
|
||||
(range, max_texture_size, _boi): (Aabb<i32>, Vec2<u16>, &'a BlocksOfInterest),
|
||||
@ -381,7 +380,8 @@ pub fn generate_mesh<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug + '
|
||||
}
|
||||
};
|
||||
let get_glow = |_: &mut (), pos: Vec3<i32>| glow(pos + range.min);
|
||||
let get_color = |_: &mut (), pos: Vec3<i32>| flat_get(pos).get_color().unwrap_or(Rgb::zero());
|
||||
let get_color =
|
||||
|_: &mut (), pos: Vec3<i32>| flat_get(pos).get_color().unwrap_or_else(Rgb::zero);
|
||||
let get_opacity = |_: &mut (), pos: Vec3<i32>| !flat_get(pos).is_opaque();
|
||||
let flat_get = |pos| flat_get(pos);
|
||||
let should_draw = |_: &mut (), pos: Vec3<i32>, delta: Vec3<i32>, _uv| {
|
||||
|
@ -80,7 +80,6 @@ pub struct Shadow {
|
||||
|
||||
impl Globals {
|
||||
/// Create global consts from the provided parameters.
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
#[allow(clippy::too_many_arguments)] // TODO: Pending review in #587
|
||||
pub fn new(
|
||||
view_mat: Mat4<f32>,
|
||||
@ -140,7 +139,7 @@ impl Globals {
|
||||
medium: [if medium.is_liquid() { 1 } else { 0 }; 4],
|
||||
select_pos: select_pos
|
||||
.map(|sp| Vec4::from(sp) + Vec4::unit_w())
|
||||
.unwrap_or(Vec4::zero())
|
||||
.unwrap_or_else(Vec4::zero)
|
||||
.into_array(),
|
||||
gamma_exposure: [gamma, exposure, 0.0, 0.0],
|
||||
ambiance,
|
||||
|
@ -36,7 +36,6 @@ use common::{
|
||||
resources::DeltaTime,
|
||||
states::utils::StageSection,
|
||||
terrain::TerrainChunk,
|
||||
util::Dir,
|
||||
vol::RectRasterableVol,
|
||||
};
|
||||
use common_base::span;
|
||||
@ -488,8 +487,6 @@ impl FigureMgr {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::or_fun_call)]
|
||||
// TODO: Pending review in #587
|
||||
pub fn maintain(
|
||||
&mut self,
|
||||
renderer: &mut Renderer,
|
||||
@ -617,9 +614,7 @@ impl FigureMgr {
|
||||
// Velocity relative to the current ground
|
||||
let rel_vel = anim::vek::Vec3::<f32>::from(vel.0 - physics.ground_vel);
|
||||
|
||||
let look_dir = controller
|
||||
.map(|c| c.inputs.look_dir)
|
||||
.unwrap_or(Dir::default());
|
||||
let look_dir = controller.map(|c| c.inputs.look_dir).unwrap_or_default();
|
||||
let is_player = scene_data.player_entity == entity;
|
||||
let player_camera_mode = if is_player {
|
||||
camera_mode
|
||||
@ -723,7 +718,7 @@ impl FigureMgr {
|
||||
(c / (1.0 + DAMAGE_FADE_COEFFICIENT * h.last_change.0)) as f32
|
||||
})
|
||||
})
|
||||
.unwrap_or(vek::Rgba::broadcast(1.0))
|
||||
.unwrap_or_else(|| vek::Rgba::broadcast(1.0))
|
||||
// Highlight targeted collectible entities
|
||||
* if item.is_some() && scene_data.target_entity.map_or(false, |e| e == entity) {
|
||||
vek::Rgba::new(5.0, 5.0, 5.0, 1.0)
|
||||
|
@ -166,7 +166,6 @@ impl assets::Asset for SpriteSpec {
|
||||
}
|
||||
|
||||
/// Function executed by worker threads dedicated to chunk meshing.
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
|
||||
/// skip_remesh is either None (do the full remesh, including recomputing the
|
||||
/// light map), or Some((light_map, glow_map)).
|
||||
|
@ -1400,7 +1400,6 @@ impl Window {
|
||||
|
||||
pub fn needs_refresh_resize(&mut self) { self.needs_refresh_resize = true; }
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn logical_size(&self) -> Vec2<f64> {
|
||||
let (w, h) = self
|
||||
.window
|
||||
|
@ -5,7 +5,6 @@ use veloren_world::{index::Index, site::Settlement, IndexRef};
|
||||
const W: usize = 640;
|
||||
const H: usize = 480;
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
fn main() {
|
||||
let seed = 1337;
|
||||
let index = &Index::new(seed);
|
||||
@ -32,7 +31,7 @@ fn main() {
|
||||
|
||||
let color = settlement
|
||||
.get_color(index, pos.map(|e| e.floor() as i32))
|
||||
.unwrap_or(Rgb::new(35, 50, 20));
|
||||
.unwrap_or_else(|| Rgb::new(35, 50, 20));
|
||||
|
||||
buf[j * W + i] = u32::from_le_bytes([color.b, color.g, color.r, 255]);
|
||||
}
|
||||
|
@ -819,7 +819,6 @@ fn loc_suitable_for_site(sim: &WorldSim, loc: Vec2<i32>) -> bool {
|
||||
}
|
||||
|
||||
/// Attempt to search for a location that's suitable for site construction
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
fn find_site_loc(
|
||||
ctx: &mut GenCtx<impl Rng>,
|
||||
near: Option<(Vec2<i32>, f32)>,
|
||||
@ -833,7 +832,7 @@ fn find_site_loc(
|
||||
origin
|
||||
+ (Vec2::new(ctx.rng.gen_range(-1.0..1.0), ctx.rng.gen_range(-1.0..1.0))
|
||||
.try_normalized()
|
||||
.unwrap_or(Vec2::zero())
|
||||
.unwrap_or_else(Vec2::zero)
|
||||
* ctx.rng.gen::<f32>()
|
||||
* dist)
|
||||
.map(|e| e as i32)
|
||||
|
@ -224,7 +224,6 @@ impl World {
|
||||
+ 0.5
|
||||
}
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
#[allow(clippy::eval_order_dependence)]
|
||||
#[allow(clippy::result_unit_err)]
|
||||
pub fn generate_chunk(
|
||||
@ -252,7 +251,7 @@ impl World {
|
||||
.get(grid_border + TerrainChunkSize::RECT_SIZE.map(|e| e as i32) / 2)
|
||||
.and_then(|zcache| zcache.as_ref())
|
||||
.map(|zcache| zcache.sample.stone_col)
|
||||
.unwrap_or(index.colors.deep_stone_color.into()),
|
||||
.unwrap_or_else(|| index.colors.deep_stone_color.into()),
|
||||
);
|
||||
let water = Block::new(BlockKind::Water, Rgb::zero());
|
||||
|
||||
|
@ -430,7 +430,6 @@ impl Castle {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn apply_supplement<'a>(
|
||||
&'a self,
|
||||
// NOTE: Used only for dynamic elements like chests and entities!
|
||||
|
@ -73,7 +73,6 @@ impl<T> Skeleton<T> {
|
||||
}
|
||||
|
||||
#[allow(clippy::logic_bug)] // TODO: Pending review in #587
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn sample_closest(
|
||||
&self,
|
||||
pos: Vec3<i32>,
|
||||
@ -123,6 +122,6 @@ impl<T> Skeleton<T> {
|
||||
.or(Some((dist_locus, new_bm)));
|
||||
}
|
||||
});
|
||||
min.map(|(_, bm)| bm).unwrap_or(BlockMask::nothing())
|
||||
min.map(|(_, bm)| bm).unwrap_or_else(BlockMask::nothing)
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,6 @@ impl Settlement {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn place_paths(&mut self, rng: &mut impl Rng) {
|
||||
const PATH_COUNT: usize = 6;
|
||||
|
||||
|
@ -128,7 +128,6 @@ impl Dungeon {
|
||||
|
||||
pub fn difficulty(&self) -> u32 { self.difficulty }
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn apply_supplement<'a>(
|
||||
&'a self,
|
||||
// NOTE: Used only for dynamic elements like chests and entities!
|
||||
|
Loading…
Reference in New Issue
Block a user