diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f48bb18ac6..34dfb8de6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,7 @@ variables: # https://docs.gitlab.com/ee/ci/yaml/#shallow-cloning GIT_DEPTH: 3 GIT_CLEAN_FLAGS: -f - CACHE_IMAGE_TAG: d7756444 + CACHE_IMAGE_TAG: 59fdc4df TAG_REGEX: '/^v[0-9]+\.[0-9]+\.[0-9]+$/' default: diff --git a/.gitlab/scripts/coverage.sh b/.gitlab/scripts/coverage.sh index 396924871e..f7b397f3dc 100755 --- a/.gitlab/scripts/coverage.sh +++ b/.gitlab/scripts/coverage.sh @@ -2,6 +2,5 @@ echo "modifying files in 5s, ctrl+c to abort" && sleep 5 find ./* -name "Cargo.toml" -exec sed -i 's/, "simd"]/]/g' {} \; find ./* -name "Cargo.toml" -exec sed -i 's/"simd"]/]/g' {} \; -sed -i 's/vek /#vek /g' ./Cargo.toml; export VELOREN_ASSETS="$(pwd)/assets"; time cargo tarpaulin --skip-clean -v -- --test-threads=2; diff --git a/client/src/lib.rs b/client/src/lib.rs index 421a4930c7..e4769b5381 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1634,7 +1634,7 @@ impl Client { // 1 as a buffer so that if the player moves back in that direction the chunks // don't need to be reloaded if (chunk_pos - key) - .map(|e: i32| (e.abs() as u32).saturating_sub(2)) + .map(|e: i32| (e.unsigned_abs()).saturating_sub(2)) .magnitude_squared() > view_distance.pow(2) { diff --git a/common/base/src/lib.rs b/common/base/src/lib.rs index ae099f308a..5c78484061 100644 --- a/common/base/src/lib.rs +++ b/common/base/src/lib.rs @@ -161,6 +161,12 @@ impl Drop for GuardlessSpan { } } +/// Just implemented so that we dont need to have +/// #[allow(clippy::drop_non_drop)] everywhere +impl Drop for ProfSpan { + fn drop(&mut self) {} +} + #[macro_export] macro_rules! no_guard_span { ($level:ident, $name:expr, $($fields:tt)*) => { diff --git a/common/src/comp/combo.rs b/common/src/comp/combo.rs index b04f460b86..bca2cc5917 100644 --- a/common/src/comp/combo.rs +++ b/common/src/comp/combo.rs @@ -30,7 +30,7 @@ impl Combo { self.counter = if amount > 0 { self.counter.saturating_add(amount as u32) } else { - self.counter.saturating_sub(amount.abs() as u32) + self.counter.saturating_sub(amount.unsigned_abs()) }; self.last_increase = time; } diff --git a/common/src/comp/inventory/item/modular.rs b/common/src/comp/inventory/item/modular.rs index 066726bc3f..6d27ae8dee 100644 --- a/common/src/comp/inventory/item/modular.rs +++ b/common/src/comp/inventory/item/modular.rs @@ -259,7 +259,7 @@ fn make_tagexample_def( toolkind.identifier_name() ); let kind = ItemKind::TagExamples { - item_ids: exemplars.get(&tag).cloned().unwrap_or_else(Vec::new), + item_ids: exemplars.get(&tag).cloned().unwrap_or_default(), }; let quality = Quality::Common; diff --git a/common/src/comp/inventory/trade_pricing.rs b/common/src/comp/inventory/trade_pricing.rs index 8ff2217051..df29e8ad5a 100644 --- a/common/src/comp/inventory/trade_pricing.rs +++ b/common/src/comp/inventory/trade_pricing.rs @@ -75,7 +75,7 @@ pub struct MaterialFrequency(Vec<(f32, Good)>); // price[i] = 1/frequency[i] * 1/sum(frequency) * 1/sum(1/frequency) // scaling individual components so that ratio is inverted and the sum of all // inverted elements is equivalent to inverse of the original sum -fn vector_invert(result: &mut Vec<(f32, Good)>) { +fn vector_invert(result: &mut [(f32, Good)]) { let mut oldsum: f32 = 0.0; let mut newsum: f32 = 0.0; for (value, _good) in result.iter_mut() { @@ -421,7 +421,7 @@ impl TradePricing { // re-look up prices and sort the vector by ascending material cost, return // whether first cost is finite - fn sort_by_price(&self, recipes: &mut Vec) -> bool { + fn sort_by_price(&self, recipes: &mut [RememberedRecipe]) -> bool { for recipe in recipes.iter_mut() { recipe.material_cost = self.calculate_material_cost_sum(recipe); } diff --git a/common/src/region.rs b/common/src/region.rs index f8c1e7fda3..84926fdc5b 100644 --- a/common/src/region.rs +++ b/common/src/region.rs @@ -135,7 +135,7 @@ impl RegionMap { // Calculate distance outside border if key != current_region && (Vec2::::from(pos) - Self::key_pos(current_region)) - .map(|e| e.abs() as u32) + .map(|e| e.unsigned_abs()) .reduce_max() > TETHER_LENGTH { diff --git a/rust-toolchain b/rust-toolchain index fdace0b319..f6f9b5b6c6 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2021-12-19 +nightly-2022-04-25 diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index f564051a6c..543830d242 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -318,7 +318,7 @@ impl<'a> System<'a> for Sys { // 1 since chunks need neighbors to be meshed // 1 to act as a buffer if the player moves in that direction let adjusted_dist_sqr = (chunk_pos - key) - .map(|e: i32| (e.abs() as u32).saturating_sub(2)) + .map(|e: i32| (e.unsigned_abs()).saturating_sub(2)) .magnitude_squared(); if adjusted_dist_sqr <= presence.view_distance.pow(2) { @@ -341,7 +341,7 @@ impl<'a> System<'a> for Sys { .iter() .map(|(k, _)| k) // Don't check every chunk every tick (spread over 16 ticks) - .filter(|k| k.x.abs() as u64 % 4 + (k.y.abs() as u64 % 4) * 4 == tick.0 % 16) + .filter(|k| k.x.unsigned_abs() % 4 + (k.y.unsigned_abs() % 4) * 4 == (tick.0 % 16) as u32) // There shouldn't be to many pending chunks so we will just check them all .chain(chunk_generator.pending_chunks()) .for_each(|chunk_key| { @@ -536,7 +536,7 @@ pub fn chunk_in_vd( let player_chunk_pos = terrain.pos_key(player_pos.map(|e| e as i32)); let adjusted_dist_sqr = (player_chunk_pos - chunk_pos) - .map(|e: i32| e.abs() as u32) + .map(|e: i32| e.unsigned_abs()) .magnitude_squared(); adjusted_dist_sqr <= (vd.max(crate::MIN_VD) + UNLOAD_THRESHOLD).pow(2) diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 3f0432713c..bbf9caeab6 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -1,5 +1,6 @@ #![feature(generic_associated_types, bool_to_option)] #![allow(incomplete_features)] +#![allow(clippy::single_match)] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index fe7fa67c4a..19188b69ae 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -1260,7 +1260,7 @@ impl<'a> Widget for Diary<'a> { (None, None) => String::new(), } }, - unknown => unreachable!(unknown), + unknown => unreachable!("{}", unknown), }; let mut number = Text::new(&value) diff --git a/voxygen/src/hud/hotbar.rs b/voxygen/src/hud/hotbar.rs index 2a13ef58a0..cd758e8d3b 100644 --- a/voxygen/src/hud/hotbar.rs +++ b/voxygen/src/hud/hotbar.rs @@ -52,6 +52,7 @@ impl State { pub fn clear_slot(&mut self, slot: Slot) { self.slots[slot as usize] = None; } + #[allow(clippy::only_used_in_recursion)] // false positive pub fn add_inventory_link(&mut self, slot: Slot, item: &Item) { self.slots[slot as usize] = Some(SlotContents::Inventory( item.item_hash(), diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 8184998303..e66757b05f 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1062,8 +1062,9 @@ impl Hud { let slot_manager = slots::SlotManager::new( ui.id_generator(), - Vec2::broadcast(40.0) - // TODO(heyzoos) Will be useful for whoever works on rendering the number of items "in hand". + Vec2::broadcast(40.0), + // TODO(heyzoos) Will be useful for whoever works on rendering the number of items + // "in hand". // fonts.cyri.conrod_id, // Vec2::new(1.0, 1.0), // fonts.cyri.scale(12), diff --git a/voxygen/src/render/renderer/shadow_map.rs b/voxygen/src/render/renderer/shadow_map.rs index d7b6fb2d66..170b48282f 100644 --- a/voxygen/src/render/renderer/shadow_map.rs +++ b/voxygen/src/render/renderer/shadow_map.rs @@ -129,6 +129,7 @@ impl ShadowMap { }; clear(&cube_tex); clear(&tex); + #[allow(clippy::drop_non_drop)] drop(clear); queue.submit(std::iter::once(encoder.finish())); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 220b741cd3..028447fbb1 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -5261,11 +5261,9 @@ impl FigureMgr { &CharacterState::Idle(common::states::idle::Data { is_sneaking: false, }), - &Last { - 0: CharacterState::Idle(common::states::idle::Data { - is_sneaking: false, - }), - }, + &Last(CharacterState::Idle(common::states::idle::Data { + is_sneaking: false, + })), ), }; @@ -5394,11 +5392,9 @@ impl FigureMgr { &CharacterState::Idle(common::states::idle::Data { is_sneaking: false, }), - &Last { - 0: CharacterState::Idle(common::states::idle::Data { - is_sneaking: false, - }), - }, + &Last(CharacterState::Idle(common::states::idle::Data { + is_sneaking: false, + })), ), }; @@ -5494,11 +5490,9 @@ impl FigureMgr { &CharacterState::Idle(common::states::idle::Data { is_sneaking: false, }), - &Last { - 0: CharacterState::Idle(common::states::idle::Data { - is_sneaking: false, - }), - }, + &Last(CharacterState::Idle(common::states::idle::Data { + is_sneaking: false, + })), ), }; diff --git a/voxygen/src/ui/img_ids.rs b/voxygen/src/ui/img_ids.rs index 660675dc07..dd515ba514 100644 --- a/voxygen/src/ui/img_ids.rs +++ b/voxygen/src/ui/img_ids.rs @@ -154,8 +154,8 @@ macro_rules! image_ids { } impl $Ids { - pub fn load(ui: &mut crate::ui::Ui) -> Result { - use crate::ui::img_ids::GraphicCreator; + pub fn load(ui: &mut $crate::ui::Ui) -> Result { + use $crate::ui::img_ids::GraphicCreator; Ok(Self { $($( $name: ui.add_graphic(<$T as GraphicCreator>::new_graphic($specifier)?), )*)* }) @@ -169,12 +169,12 @@ macro_rules! image_ids_ice { ($($v:vis struct $Ids:ident { $( <$T:ty> $( $name:ident: $specifier:expr ),* $(,)? )* })*) => { $( $v struct $Ids { - $($( $v $name: crate::ui::GraphicId, )*)* + $($( $v $name: $crate::ui::GraphicId, )*)* } impl $Ids { - pub fn load(ui: &mut crate::ui::ice::IcedUi) -> Result { - use crate::ui::img_ids::GraphicCreator; + pub fn load(ui: &mut $crate::ui::ice::IcedUi) -> Result { + use $crate::ui::img_ids::GraphicCreator; Ok(Self { $($( $name: ui.add_graphic(<$T as GraphicCreator>::new_graphic($specifier)?), )*)* }) @@ -191,12 +191,12 @@ macro_rules! rotation_image_ids { ($($v:vis struct $Ids:ident { $( <$T:ty> $( $name:ident: $specifier:expr ),* $(,)? )* })*) => { $( $v struct $Ids { - $($( $v $name: crate::ui::img_ids::Rotations, )*)* + $($( $v $name: $crate::ui::img_ids::Rotations, )*)* } impl $Ids { - pub fn load(ui: &mut crate::ui::Ui) -> Result { - use crate::ui::img_ids::GraphicCreator; + pub fn load(ui: &mut $crate::ui::Ui) -> Result { + use $crate::ui::img_ids::GraphicCreator; Ok(Self { $($( $name: ui.add_graphic_with_rotations(<$T as GraphicCreator>::new_graphic($specifier)?), )*)* }) diff --git a/voxygen/src/ui/widgets/item_tooltip.rs b/voxygen/src/ui/widgets/item_tooltip.rs index 9d76661775..26a9ea8fcf 100644 --- a/voxygen/src/ui/widgets/item_tooltip.rs +++ b/voxygen/src/ui/widgets/item_tooltip.rs @@ -462,7 +462,10 @@ impl<'a> Widget for ItemTooltip<'a> { let quality = get_quality_col(item); - let equip_slot = inventory.equipped_items_of_kind(item.kind().clone()); + let first_equipped = inventory + .equipped_items_of_kind(item.kind().clone()) + .next() + .cloned(); let (title, desc) = (item.name().to_string(), item.description().to_string()); @@ -661,7 +664,7 @@ impl<'a> Widget for ItemTooltip<'a> { .down_from(state.ids.stats[2], V_PAD_STATS) .set(state.ids.stats[3], ui); - if let Some(equipped_item) = equip_slot.cloned().next() { + if let Some(equipped_item) = first_equipped { if let ItemKind::Tool(equipped_tool) = equipped_item.kind() { let tool_stats = tool .stats @@ -965,7 +968,7 @@ impl<'a> Widget for ItemTooltip<'a> { }, } - if let Some(equipped_item) = equip_slot.cloned().next() { + if let Some(equipped_item) = first_equipped { if let ItemKind::Armor(equipped_armor) = equipped_item.kind() { let diff = armor.stats - equipped_armor.stats; let protection_diff = util::option_comparison( diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 87e7a82b35..ef63797780 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -1077,7 +1077,7 @@ pub fn merchant_loadout( .bag(ArmorSlot::Bag4, Some(bag4)) } -fn sort_wares(bag: &mut Vec) { +fn sort_wares(bag: &mut [Item]) { use common::comp::item::TagExampleInfo; bag.sort_by(|a, b| { diff --git a/world/src/site2/tile.rs b/world/src/site2/tile.rs index 4f82952b6f..e058642191 100644 --- a/world/src/site2/tile.rs +++ b/world/src/site2/tile.rs @@ -68,7 +68,7 @@ impl TileGrid { Spiral2d::new() .take(MAX_SEARCH_CELLS as usize) .map(|r| tpos + r) - .find_map(|tpos| (&mut f)(tpos, self.get(tpos)).zip(Some(tpos))) + .find_map(|tpos| f(tpos, self.get(tpos)).zip(Some(tpos))) } pub fn grow_aabr(