Fixed suppressed clippy warnings for #587 - clone_on_copy

This commit is contained in:
Ben Wallis 2020-06-18 22:25:48 +01:00
parent babf452686
commit 6da7a11d33
8 changed files with 18 additions and 27 deletions

View File

@ -38,7 +38,6 @@ impl<'a> System<'a> for Sys {
);
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
fn run(
&mut self,
(
@ -181,7 +180,7 @@ impl<'a> System<'a> for Sys {
) {
// Send client intial info about the entities in this region if it was not
// already within the set of subscribed regions
if subscription.regions.insert(key.clone()) {
if subscription.regions.insert(key) {
if let Some(region) = region_map.get(key) {
for (pos, vel, ori, _, entity) in (
&positions,

View File

@ -173,15 +173,14 @@ impl AudioFrontend {
}
}
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
pub fn set_listener_pos(&mut self, pos: &Vec3<f32>, ori: &Vec3<f32>) {
self.listener_pos = pos.clone();
self.listener_pos = *pos;
self.listener_ori = ori.normalized();
let up = Vec3::new(0.0, 0.0, 1.0);
let pos_left = up.cross(self.listener_ori.clone()).normalized();
let pos_right = self.listener_ori.cross(up.clone()).normalized();
let pos_left = up.cross(self.listener_ori).normalized();
let pos_right = self.listener_ori.cross(up).normalized();
self.listener_ear_left = pos_left;
self.listener_ear_right = pos_right;

View File

@ -28,15 +28,14 @@ pub enum ItemKey {
Empty,
}
impl From<&Item> for ItemKey {
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
fn from(item: &Item) -> Self {
match &item.kind {
ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()),
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(kind.clone()),
ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()),
ItemKind::Utility { kind, .. } => ItemKey::Utility(kind.clone()),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
ItemKind::Ingredient { kind, .. } => ItemKey::Ingredient(kind.clone()),
ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(*kind),
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(*kind),
ItemKind::Armor { kind, .. } => ItemKey::Armor(*kind),
ItemKind::Utility { kind, .. } => ItemKey::Utility(*kind),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(*kind),
ItemKind::Ingredient { kind, .. } => ItemKey::Ingredient(*kind),
}
}
}

View File

@ -35,7 +35,6 @@ impl CharSelectionState {
}
impl PlayState for CharSelectionState {
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
fn play(&mut self, _: Direction, global_state: &mut GlobalState) -> PlayStateResult {
// Set up an fps clock.
let mut clock = Clock::start();
@ -127,7 +126,7 @@ impl PlayState for CharSelectionState {
time: client.state().get_time(),
delta_time: client.state().ecs().read_resource::<DeltaTime>().0,
tick: client.get_tick(),
body: humanoid_body.clone(),
body: humanoid_body,
gamma: global_state.settings.graphics.gamma,
mouse_smoothing: global_state.settings.gameplay.smooth_pan_enable,
figure_lod_render_distance: global_state
@ -145,7 +144,7 @@ impl PlayState for CharSelectionState {
self.scene.render(
global_state.window.renderer_mut(),
self.client.borrow().get_tick(),
humanoid_body.clone(),
humanoid_body,
loadout.as_ref(),
);

View File

@ -339,14 +339,13 @@ impl CharSelectionUi {
}
}
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
pub fn get_character_list(&self) -> Option<Vec<CharacterItem>> {
match &self.mode {
Mode::Select(data) => data.clone(),
Mode::Create {
name, body, tool, ..
} => {
let body = comp::Body::Humanoid(body.clone());
let body = comp::Body::Humanoid(*body);
Some(vec![CharacterItem {
character: Character {
@ -398,7 +397,6 @@ impl CharSelectionUi {
}
// TODO: Split this into multiple modules or functions.
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
#[allow(clippy::useless_let_if_seq)] // TODO: Pending review in #587
#[allow(clippy::unnecessary_operation)] // TODO: Pending review in #587
fn update_layout(&mut self, client: &mut Client) -> Vec<Event> {
@ -910,7 +908,7 @@ impl CharSelectionUi {
events.push(Event::AddCharacter {
alias: name.clone(),
tool: tool.map(|tool| tool.to_string()),
body: comp::Body::Humanoid(body.clone()),
body: comp::Body::Humanoid(*body),
});
to_select = true;

View File

@ -39,8 +39,7 @@ impl Widget for GhostImage {
}
}
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
fn style(&self) -> Self::Style { self.style.clone() }
fn style(&self) -> Self::Style { self.style }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs { state, .. } = args;

View File

@ -1041,13 +1041,12 @@ impl<K: Copy + Eq + Hash, T: Clone> MapVec<K, T> {
pub fn get(&self, entry: K) -> &T { self.entries.get(&entry).unwrap_or(&self.default) }
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
pub fn map<U: Default>(self, mut f: impl FnMut(K, T) -> U) -> MapVec<K, U> {
MapVec {
entries: self
.entries
.into_iter()
.map(|(s, v)| (s.clone(), f(s, v)))
.map(|(s, v)| (s, f(s, v)))
.collect(),
default: U::default(),
}

View File

@ -27,7 +27,6 @@ impl<V: Default> Default for SmallCache<V> {
}
}
impl<V: Default> SmallCache<V> {
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
pub fn get<F: FnOnce(Vec2<i32>) -> V>(&mut self, key: Vec2<i32>, f: F) -> &V {
let idx = calc_idx(key) % CACHE_LEN;
@ -57,7 +56,7 @@ impl<V: Default> SmallCache<V> {
for i in 0..4 {
let idx = idx + i * i;
if self.index[idx].is_none() {
self.index[idx] = Some(key.clone());
self.index[idx] = Some(key);
self.data[idx] = f(key);
return &self.data[idx];
}
@ -66,7 +65,7 @@ impl<V: Default> SmallCache<V> {
let step = super::seed_expan::diffuse(self.random) as usize % 4;
let idx = step * step + idx;
self.random = self.random.wrapping_add(1);
self.index[idx] = Some(key.clone());
self.index[idx] = Some(key);
self.data[idx] = f(key);
&self.data[idx]
}