Merge branch 'shandley/fix-clippy-warnings' into 'master'

Fix clippy warnings after toolchain update

See merge request veloren/veloren!1103
This commit is contained in:
Marcel 2020-06-23 07:59:39 +00:00
commit 3628bfc2a6
32 changed files with 54 additions and 44 deletions

View File

@ -58,7 +58,7 @@ impl<'a> System<'a> for Sys {
);
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn run(
&mut self,
(

View File

@ -92,7 +92,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_give_item(
server: &mut Server,
client: EcsEntity,
@ -191,7 +191,7 @@ fn handle_jump(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_goto(
server: &mut Server,
client: EcsEntity,
@ -333,7 +333,7 @@ fn handle_health(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_alias(
server: &mut Server,
client: EcsEntity,
@ -380,7 +380,7 @@ fn handle_alias(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn handle_tp(
server: &mut Server,
@ -431,7 +431,7 @@ fn handle_tp(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::redundant_clone)] // TODO: Pending review in #587
fn handle_spawn(
server: &mut Server,
@ -578,7 +578,7 @@ fn handle_build(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_help(
server: &mut Server,
client: EcsEntity,
@ -760,7 +760,7 @@ fn handle_light(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_lantern(
server: &mut Server,
client: EcsEntity,
@ -873,7 +873,7 @@ fn handle_waypoint(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_adminify(
server: &mut Server,
client: EcsEntity,
@ -915,7 +915,7 @@ fn handle_adminify(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn handle_tell(
server: &mut Server,
@ -1002,7 +1002,7 @@ fn handle_debug_column(
#[cfg(feature = "worldgen")]
#[allow(clippy::blacklisted_name)] // TODO: Pending review in #587
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_debug_column(
server: &mut Server,
client: EcsEntity,
@ -1224,7 +1224,7 @@ fn handle_debug(
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn handle_remove_lights(
server: &mut Server,
client: EcsEntity,
@ -1277,7 +1277,7 @@ fn handle_remove_lights(
}
#[allow(clippy::chars_next_cmp)] // TODO: Pending review in #587
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn handle_sudo(

View File

@ -48,7 +48,7 @@ pub fn handle_lantern(server: &mut Server, entity: EcsEntity) {
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn handle_mount(server: &mut Server, mounter: EcsEntity, mountee: EcsEntity) {
let state = server.state_mut();

View File

@ -29,7 +29,7 @@ pub fn snuff_lantern(storage: &mut WriteStorage<comp::LightEmitter>, entity: Ecs
storage.remove(entity);
}
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
#[allow(clippy::let_and_return)] // TODO: Pending review in #587
pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::InventoryManip) {
let state = server.state_mut();

View File

@ -33,7 +33,7 @@ pub struct ServerMetrics {
}
impl TickMetrics {
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn new(registry: &Registry, tick: Arc<AtomicU64>) -> Result<Self, Box<dyn Error>> {
let player_online = IntGauge::with_opts(Opts::new(
"player_online",

View File

@ -37,7 +37,7 @@ impl<'a> System<'a> for Sys {
TrackedComps<'a>,
);
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn run(
&mut self,
(

View File

@ -36,7 +36,7 @@ impl<'a> System<'a> for Sys {
WriteStorage<'a, Client>,
);
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::manual_saturating_arithmetic)] // TODO: Pending review in #587
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
fn run(
@ -398,7 +398,7 @@ impl<'a> System<'a> for Sys {
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::manual_saturating_arithmetic)] // TODO: Pending review in #587
pub fn chunk_in_vd(
player_pos: Vec3<f32>,

View File

@ -9,7 +9,7 @@ impl Animation for GlideWieldAnimation {
type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
type Skeleton = CharacterSkeleton;
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton(
skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,

View File

@ -12,6 +12,7 @@ impl Animation for BetaAnimation {
const UPDATE_FN: &'static [u8] = b"character_beta\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_beta")]
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, _velocity, _global_time): Self::Dependency,

View File

@ -14,7 +14,7 @@ impl Animation for ChargeAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_charge")]
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, velocity, orientation, last_ori, _global_time): Self::Dependency,

View File

@ -13,7 +13,7 @@ impl Animation for GlideWieldAnimation {
const UPDATE_FN: &'static [u8] = b"character_glidewield\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_glidewield")]
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,

View File

@ -13,7 +13,7 @@ impl Animation for GlidingAnimation {
const UPDATE_FN: &'static [u8] = b"character_gliding\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_gliding")]
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,

View File

@ -11,7 +11,7 @@ impl Animation for JumpAnimation {
const UPDATE_FN: &'static [u8] = b"character_jump\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_jump")]
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, orientation, last_ori, global_time): Self::Dependency,

View File

@ -12,7 +12,7 @@ impl Animation for RollAnimation {
const UPDATE_FN: &'static [u8] = b"character_roll\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_roll")]
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, orientation, last_ori, _global_time): Self::Dependency,

View File

@ -13,7 +13,7 @@ impl Animation for RunAnimation {
const UPDATE_FN: &'static [u8] = b"character_run\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_run")]
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,

View File

@ -16,6 +16,7 @@ impl Animation for SpinAnimation {
const UPDATE_FN: &'static [u8] = b"character_spin\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_spin")]
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, _global_time): Self::Dependency,

View File

@ -13,7 +13,7 @@ impl Animation for SwimAnimation {
const UPDATE_FN: &'static [u8] = b"character_swim\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_swim")]
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,

View File

@ -28,7 +28,7 @@ impl<'a> System<'a> for Sys {
WriteStorage<'a, HpFloaterList>,
);
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn run(
&mut self,
(entities, my_entity, dt, mut my_exp_floater_list, uids, pos, stats, mut hp_floater_lists): Self::SystemData,

View File

@ -64,6 +64,7 @@ impl State {
// TODO: remove
// Adds ability3 slot if it is missing and should be present
// Removes if it is there and shouldn't be present
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
pub fn maintain_ability3(&mut self, client: &client::Client) {
use specs::WorldExt;
let loadouts = client.state().ecs().read_storage::<common::comp::Loadout>();

View File

@ -2154,7 +2154,7 @@ impl Hud {
handled
}
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
pub fn maintain(
&mut self,
client: &Client,

View File

@ -399,6 +399,7 @@ impl CharSelectionUi {
// TODO: Split this into multiple modules or functions.
#[allow(clippy::useless_let_if_seq)] // TODO: Pending review in #587
#[allow(clippy::unnecessary_operation)] // TODO: Pending review in #587
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
fn update_layout(&mut self, client: &mut Client) -> Vec<Event> {
let mut events = Vec::new();

View File

@ -17,7 +17,7 @@ impl From<gfx::PipelineStateError<String>> for RenderError {
}
impl From<gfx::PipelineStateError<&str>> for RenderError {
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn from(err: gfx::PipelineStateError<&str>) -> Self {
match err {
gfx::PipelineStateError::DescriptorInit(err) => {

View File

@ -1981,7 +1981,7 @@ impl<V: RectRasterableVol> Terrain<V> {
}
/// Maintain terrain data. To be called once per tick.
#[allow(clippy::for_loop_over_option)] // TODO: Pending review in #587
#[allow(clippy::for_loops_over_fallibles)] // TODO: Pending review in #587
#[allow(clippy::len_zero)] // TODO: Pending review in #587
pub fn maintain(
&mut self,

View File

@ -25,7 +25,7 @@ impl<'a> BlockGen<'a> {
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn sample_column<'b>(
column_gen: &ColumnGen<'a>,
cache: &'b mut SmallCache<Option<ColumnSample<'a>>>,
@ -36,7 +36,7 @@ impl<'a> BlockGen<'a> {
.as_ref()
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
fn get_cliff_height(
column_gen: &ColumnGen<'a>,
cache: &mut SmallCache<Option<ColumnSample<'a>>>,
@ -91,7 +91,7 @@ impl<'a> BlockGen<'a> {
)
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn get_z_cache(&mut self, wpos: Vec2<i32>) -> Option<ZCache<'a>> {
let BlockGen {
column_cache,

View File

@ -70,7 +70,7 @@ impl<'a, R: Rng> GenCtx<'a, R> {
}
impl Civs {
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn generate(seed: u32, sim: &mut WorldSim) -> Self {
let mut this = Self::default();
let rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
@ -602,7 +602,7 @@ 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::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
fn find_site_loc(ctx: &mut GenCtx<impl Rng>, near: Option<(Vec2<i32>, f32)>) -> Option<Vec2<i32>> {
const MAX_ATTEMPTS: usize = 100;

View File

@ -173,6 +173,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
#[allow(clippy::nonminimal_bool)] // TODO: Pending review in #587
#[allow(clippy::single_match)] // TODO: Pending review in #587
#[allow(clippy::bind_instead_of_map)] // TODO: Pending review in #587
fn get(&self, wpos: Vec2<i32>) -> Option<ColumnSample<'a>> {
let wposf = wpos.map(|e| e as f64);
let chunk_pos = wpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| e / sz as i32);

View File

@ -64,7 +64,7 @@ impl World {
pub fn sample_blocks(&self) -> BlockGen { BlockGen::new(ColumnGen::new(&self.sim)) }
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
pub fn generate_chunk(
&self,

View File

@ -109,7 +109,8 @@ impl MapConfig {
/// to the caller to provide a function that translates this information
/// into the correct format for a buffer and writes to it.
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
#[allow(clippy::many_single_char_names)]
pub fn generate(
&self,

View File

@ -306,6 +306,7 @@ pub struct WorldSim {
impl WorldSim {
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
#[allow(clippy::let_and_return)] // TODO: Pending review in #587
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
pub fn generate(seed: u32, opts: WorldOpts) -> Self {
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
@ -1321,7 +1322,7 @@ impl WorldSim {
}
/// Prepare the world for simulation
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn seed_elements(&mut self) {
let mut rng = self.rng.clone();
@ -1490,7 +1491,7 @@ impl WorldSim {
}
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn get_gradient_approx(&self, chunk_pos: Vec2<i32>) -> Option<f32> {
let a = self.get(chunk_pos)?;
if let Some(downhill) = a.downhill {
@ -1509,7 +1510,7 @@ impl WorldSim {
self.get_interpolated(wpos, |chunk| chunk.alt)
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn get_wpos(&self, wpos: Vec2<i32>) -> Option<&SimChunk> {
self.get(
wpos.map2(Vec2::from(TerrainChunkSize::RECT_SIZE), |e, sz: u32| {
@ -1710,7 +1711,7 @@ impl WorldSim {
Some(z0 + z1 + z2 + z3)
}
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn get_nearest_path(&self, wpos: Vec2<i32>) -> Option<(f32, Vec2<f32>)> {
let chunk_pos = wpos.map2(Vec2::from(TerrainChunkSize::RECT_SIZE), |e, sz: u32| {
e.div_euclid(sz as i32)
@ -1816,6 +1817,7 @@ pub struct RegionInfo {
impl SimChunk {
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
fn generate(posi: usize, gen_ctx: &GenCtx, gen_cdf: &GenCdf) -> Self {
let pos = uniform_idx_as_vec2(posi);
let wposf = (pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32)).map(|e| e as f64);

View File

@ -217,7 +217,7 @@ pub fn uniform_noise<F: Float + Send>(
/// guarantees that for any point between the given chunk (on the top left) and
/// its top-right/down-right/down neighbors, the twelve chunks surrounding this
/// box (its "perimeter") are also inspected.
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_conversion)] // TODO: Pending review in #587
pub fn local_cells(posi: usize) -> impl Clone + Iterator<Item = usize> {
let pos = uniform_idx_as_vec2(posi);
// NOTE: want to keep this such that the chunk index is in ascending order!

View File

@ -370,6 +370,7 @@ impl Floor {
}
}
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
fn create_route(&mut self, _ctx: &mut GenCtx<impl Rng>, a: Vec2<i32>, b: Vec2<i32>) {
let heuristic = move |l: &Vec2<i32>| (l - b).map(|e| e.abs()).reduce_max() as f32;
let neighbors = |l: &Vec2<i32>| {
@ -567,6 +568,7 @@ impl Floor {
.min_by_key(|nearest| rpos.distance_squared(*nearest))
}
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
pub fn col_sampler(&self, pos: Vec2<i32>, floor_z: i32) -> impl FnMut(i32) -> BlockMask + '_ {
let rpos = pos - self.tile_offset * TILE_SIZE;
let tile_pos = rpos.map(|e| e.div_euclid(TILE_SIZE));

View File

@ -151,7 +151,7 @@ impl Settlement {
pub fn get_origin(&self) -> Vec2<i32> { self.origin }
/// Designate hazardous terrain based on world data
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
pub fn designate_from_world(&mut self, sim: &WorldSim, rng: &mut impl Rng) {
let tile_radius = self.radius() as i32 / AREA_SIZE as i32;
let hazard = self.land.hazard;