From 95bca5418af76b7360287049d84c2a7625ffcbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Wed, 3 May 2023 17:28:55 +0200 Subject: [PATCH] update toolchain to `nightly-2023-04-20` --- client/src/bin/bot/main.rs | 1 - common/src/comp/agent.rs | 2 +- common/src/comp/inventory/item/mod.rs | 5 +-- common/src/comp/skillset/mod.rs | 1 - common/src/skillset_builder.rs | 11 ++--- common/src/terrain/biome.rs | 7 +--- common/src/terrain/site.rs | 7 +--- common/src/typed.rs | 4 +- rust-toolchain | 2 +- server/src/events/inventory_manip.rs | 1 - server/src/sys/chunk_serialize.rs | 1 - voxygen/src/lib.rs | 1 - voxygen/src/render/mod.rs | 42 ++++++------------- voxygen/src/window.rs | 6 +-- .../examples/chunk_compression_benchmarks.rs | 5 +-- world/examples/world_block_statistics.rs | 5 +-- world/src/sim/util.rs | 1 - world/src/site2/plot/dungeon.rs | 2 +- world/src/site2/plot/gnarling.rs | 2 - 19 files changed, 31 insertions(+), 75 deletions(-) diff --git a/client/src/bin/bot/main.rs b/client/src/bin/bot/main.rs index f1c31e449b..ca7298d81b 100644 --- a/client/src/bin/bot/main.rs +++ b/client/src/bin/bot/main.rs @@ -117,7 +117,6 @@ impl BotClient { pub fn handle_register(&mut self, prefix: &str, password: &str, count: Option) { let usernames = match count { Some(n) => (0..n) - .into_iter() .map(|i| format!("{}{:03}", prefix, i)) .collect::>(), None => vec![prefix.to_string()], diff --git a/common/src/comp/agent.rs b/common/src/comp/agent.rs index cb34b91852..d8bcb6a0f6 100644 --- a/common/src/comp/agent.rs +++ b/common/src/comp/agent.rs @@ -503,7 +503,7 @@ impl Timer { /// Reset the timer for the given action, returning true if the timer was /// not already reset. pub fn reset(&mut self, action: TimerAction) -> bool { - std::mem::replace(&mut self.action_starts[Self::idx_for(action)], None).is_some() + self.action_starts[Self::idx_for(action)].take().is_some() } /// Start the timer for the given action, even if it was already started. diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 06c9a49a21..2716aac923 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -330,7 +330,7 @@ impl ItemKind { // Used for inventory sorting, what comes before the first colon (:) is used as // a broader category pub fn get_itemkind_string(&self) -> String { - let result = match self { + match self { // Using tool and toolkind to sort tools by kind ItemKind::Tool(tool) => format!("Tool: {:?}", tool.kind), ItemKind::ModularComponent(modular_component) => { @@ -346,8 +346,7 @@ impl ItemKind { ItemKind::Utility { kind } => format!("Utility: {:?}", kind), ItemKind::Ingredient { descriptor } => format!("Ingredient: {}", descriptor), ItemKind::TagExamples { item_ids } => format!("TagExamples: {:?}", item_ids), - }; - result + } } pub fn has_durability(&self) -> bool { diff --git a/common/src/comp/skillset/mod.rs b/common/src/comp/skillset/mod.rs index 21bb5ebda3..6b14321b5e 100644 --- a/common/src/comp/skillset/mod.rs +++ b/common/src/comp/skillset/mod.rs @@ -81,7 +81,6 @@ lazy_static! { .map(|skill| { let max_level = skill.max_level(); (1..=max_level) - .into_iter() .map(|level| skill.skill_cost(level)) .sum::() }) diff --git a/common/src/skillset_builder.rs b/common/src/skillset_builder.rs index f3df4511f1..d330f2c834 100644 --- a/common/src/skillset_builder.rs +++ b/common/src/skillset_builder.rs @@ -112,8 +112,7 @@ impl SkillSetBuilder { pub fn with_skill(mut self, skill: Skill, level: u16) -> Self { let Some(group) = skill.skill_group_kind() else { let err = format!( - "Tried to add skill: {:?} which does not have an associated skill group.", - skill + "Tried to add skill: {skill:?} which does not have an associated skill group." ); common_base::dev_panic!(err, or return self); }; @@ -121,8 +120,7 @@ impl SkillSetBuilder { let SkillSetBuilder(ref mut skill_set) = self; if skill_is_applied(skill_set, skill, level) { let err = format!( - "Tried to add skill: {:?} with level {:?} which is already applied", - skill, level, + "Tried to add skill: {skill:?} with level {level:?} which is already applied" ); common_base::dev_panic!(err, or return self); } @@ -135,9 +133,8 @@ impl SkillSetBuilder { } if !skill_is_applied(skill_set, skill, level) { let err = format!( - "Failed to add skill: {:?}. Verify that it has the appropriate skill group \ - available and meets all prerequisite skills.", - skill + "Failed to add skill: {skill:?}. Verify that it has the appropriate skill group \ + available and meets all prerequisite skills." ); common_base::dev_panic!(err); } diff --git a/common/src/terrain/biome.rs b/common/src/terrain/biome.rs index 8b6c83c8b4..c40956863f 100644 --- a/common/src/terrain/biome.rs +++ b/common/src/terrain/biome.rs @@ -1,8 +1,9 @@ use serde::{Deserialize, Serialize}; use strum::EnumIter; -#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, EnumIter)] +#[derive(Default, Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, EnumIter)] pub enum BiomeKind { + #[default] Void, Lake, Grassland, @@ -16,7 +17,3 @@ pub enum BiomeKind { Savannah, Taiga, } - -impl Default for BiomeKind { - fn default() -> BiomeKind { BiomeKind::Void } -} diff --git a/common/src/terrain/site.rs b/common/src/terrain/site.rs index fdcee627fd..8358daaf2d 100644 --- a/common/src/terrain/site.rs +++ b/common/src/terrain/site.rs @@ -1,11 +1,12 @@ use serde::{Deserialize, Serialize}; -#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Default, Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum SiteKindMeta { Dungeon(DungeonKindMeta), Cave, Settlement(SettlementKindMeta), Castle, + #[default] Void, } @@ -22,7 +23,3 @@ pub enum SettlementKindMeta { DesertCity, SavannahPit, } - -impl Default for SiteKindMeta { - fn default() -> SiteKindMeta { SiteKindMeta::Void } -} diff --git a/common/src/typed.rs b/common/src/typed.rs index ea7d97f66a..752c8d908d 100644 --- a/common/src/typed.rs +++ b/common/src/typed.rs @@ -321,7 +321,7 @@ macro_rules! make_case_elim { elim.reduce(((self,), context)) } - pub fn elim_case_pure<'a, 'b, Type>(&'a self, cases: &'b $mod::PureCases) -> &'b Type + pub fn elim_case_pure<'a, Type>(&self, cases: &'a $mod::PureCases) -> &'a Type { let (expr, ()) = self.elim(cases, ()); expr @@ -425,7 +425,7 @@ macro_rules! make_proj_elim { elim.reduce(((self,), context)) } - pub fn elim_proj_pure<'a, 'b, Type>(&'a self, cases: &'b $mod::PureProj) -> &'b Type + pub fn elim_proj_pure<'a, Type>(&self, cases: &'a $mod::PureProj) -> &'a Type { let (expr, ()) = self.elim(cases, ()); expr diff --git a/rust-toolchain b/rust-toolchain index c7c6217087..b27a258d1a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2022-11-28 +nightly-2023-04-20 diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index bb62a7ba03..f86f23d31f 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -786,7 +786,6 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv }) .and_then(|r| { let items = (0..amount) - .into_iter() .filter_map(|_| { r.craft_simple( &mut inventory, diff --git a/server/src/sys/chunk_serialize.rs b/server/src/sys/chunk_serialize.rs index 0810aa9951..4226ea0429 100644 --- a/server/src/sys/chunk_serialize.rs +++ b/server/src/sys/chunk_serialize.rs @@ -110,7 +110,6 @@ impl<'a> System<'a> for Sys { .get_key_arc_real(chunk_key) .map(|chunk| (Arc::clone(chunk), chunk_key, meta)) }) - .into_iter() .peekable(); while chunks_iter.peek().is_some() { diff --git a/voxygen/src/lib.rs b/voxygen/src/lib.rs index ccb5eb34d3..bee0a87570 100644 --- a/voxygen/src/lib.rs +++ b/voxygen/src/lib.rs @@ -6,7 +6,6 @@ array_methods, array_zip, drain_filter, - once_cell, trait_alias, option_get_or_insert_default, map_try_insert, diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index d77cf8806a..9764930c0c 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -70,12 +70,13 @@ pub trait Vertex: Clone + bytemuck::Pod { use serde::{Deserialize, Serialize}; /// Anti-aliasing modes -#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum AaMode { /// Fast approximate antialiasing. /// /// This is a screen-space technique, and therefore works fine with greedy /// meshing. + #[default] Fxaa, /// Multisampling AA, up to 4 samples per pixel. /// @@ -121,12 +122,8 @@ impl AaMode { } } -impl Default for AaMode { - fn default() -> Self { AaMode::Fxaa } -} - /// Cloud modes -#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum CloudMode { /// No clouds. As cheap as it gets. None, @@ -144,6 +141,7 @@ pub enum CloudMode { Ultra, /// Lots of detail with good-but-costly derivation of parameters. #[serde(other)] + #[default] High, } @@ -151,12 +149,8 @@ impl CloudMode { pub fn is_enabled(&self) -> bool { *self != CloudMode::None } } -impl Default for CloudMode { - fn default() -> Self { CloudMode::High } -} - /// Fluid modes -#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum FluidMode { /// "Low" water. This water implements no waves, no reflections, no /// diffraction, and no light attenuation through water. As a result, @@ -180,32 +174,26 @@ pub enum FluidMode { /// which causes attenuation to be computed incorrectly; this can be /// addressed by using shadow maps (at least for terrain). #[serde(other)] + #[default] Medium, } -impl Default for FluidMode { - fn default() -> Self { FluidMode::Medium } -} - /// Reflection modes -#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum ReflectionMode { /// No or minimal reflections. Low, /// High quality reflections with screen-space raycasting and /// all the bells & whistles. + #[default] High, // Medium quality screen-space reflections. #[serde(other)] Medium, } -impl Default for ReflectionMode { - fn default() -> Self { ReflectionMode::High } -} - /// Lighting modes -#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum LightingMode { /// Ashikhmin-Shirley BRDF lighting model. Attempts to generate a /// physically plausible (to some extent) lighting distribution. @@ -222,13 +210,10 @@ pub enum LightingMode { /// Standard Blinn-Phong shading, combing Lambertian diffuse reflections and /// specular highlights. #[serde(other)] + #[default] BlinnPhong, } -impl Default for LightingMode { - fn default() -> Self { LightingMode::BlinnPhong } -} - /// Shadow map settings. #[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] pub struct ShadowMapMode { @@ -314,7 +299,7 @@ impl From for wgpu::PresentMode { /// Bloom factor /// Controls fraction of output image luminosity that is blurred bloom -#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum BloomFactor { Low, High, @@ -322,13 +307,10 @@ pub enum BloomFactor { Custom(f32), // other variant has to be placed last #[serde(other)] + #[default] Medium, } -impl Default for BloomFactor { - fn default() -> Self { Self::Medium } -} - impl BloomFactor { /// Fraction of output image luminosity that is blurred bloom pub fn fraction(self) -> f32 { diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index fd1e62ae04..0713ad4a0e 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -1359,16 +1359,14 @@ impl Window { pub fn scale_factor(&self) -> f64 { self.scale_factor } } -#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Default, Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] pub enum FullscreenMode { Exclusive, #[serde(other)] + #[default] Borderless, } -impl Default for FullscreenMode { - fn default() -> Self { FullscreenMode::Borderless } -} #[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] #[serde(default)] pub struct FullScreenSettings { diff --git a/world/examples/chunk_compression_benchmarks.rs b/world/examples/chunk_compression_benchmarks.rs index 5cf915701c..46727195b9 100644 --- a/world/examples/chunk_compression_benchmarks.rs +++ b/world/examples/chunk_compression_benchmarks.rs @@ -1190,10 +1190,7 @@ fn main() { if !SKIP_VOLGRID { let _ = volgrid.insert(spiralpos, Arc::new(chunk)); - if (1usize..20) - .into_iter() - .any(|i| (2 * i + 1) * (2 * i + 1) == count) - { + if (1usize..20).any(|i| (2 * i + 1) * (2 * i + 1) == count) { use std::fs::File; let mut f = File::create(&format!("chonkjpegs/{}_{}.jpg", sitename, count)) .unwrap(); diff --git a/world/examples/world_block_statistics.rs b/world/examples/world_block_statistics.rs index bd478b75dd..a0bf81309f 100644 --- a/world/examples/world_block_statistics.rs +++ b/world/examples/world_block_statistics.rs @@ -85,12 +85,9 @@ fn generate(db_path: &str, ymin: Option, ymax: Option) -> Result<(), B let (tx, rx) = mpsc::channel(); rayon::spawn(move || { let coords: Vec<_> = (ymin.unwrap_or(1)..ymax.unwrap_or(sz.y as i32)) - .into_iter() .flat_map(move |y| { let tx = tx.clone(); - (1..sz.x as i32) - .into_iter() - .map(move |x| (tx.clone(), x, y)) + (1..sz.x as i32).map(move |x| (tx.clone(), x, y)) }) .collect(); coords.into_par_iter().for_each(|(tx, x, y)| { diff --git a/world/src/sim/util.rs b/world/src/sim/util.rs index bc7d49a4a6..f94d584b2f 100644 --- a/world/src/sim/util.rs +++ b/world/src/sim/util.rs @@ -218,7 +218,6 @@ pub fn local_cells(map_size_lg: MapSizeLg, posi: usize) -> impl Clone + Iterator let grid_size = 3i32; let grid_bounds = 2 * grid_size + 1; (0..grid_bounds * grid_bounds) - .into_iter() .map(move |index| { Vec2::new( pos.x + (index % grid_bounds) - grid_size, diff --git a/world/src/site2/plot/dungeon.rs b/world/src/site2/plot/dungeon.rs index b44b9df3f8..1b092edcc9 100644 --- a/world/src/site2/plot/dungeon.rs +++ b/world/src/site2/plot/dungeon.rs @@ -948,7 +948,7 @@ pub fn inscribed_polystar( use std::f32::consts::TAU; let rpos: Vec2 = pos.xy().as_() - origin.as_(); let is_border = rpos.magnitude_squared() > (radius - 2.0).powi(2); - let is_line = (0..sides).into_iter().any(|i| { + let is_line = (0..sides).any(|i| { let f = |j: f32| { let t = j * TAU / sides as f32; radius * Vec2::new(t.cos(), t.sin()) diff --git a/world/src/site2/plot/gnarling.rs b/world/src/site2/plot/gnarling.rs index 9606622410..837390d8c6 100644 --- a/world/src/site2/plot/gnarling.rs +++ b/world/src/site2/plot/gnarling.rs @@ -112,7 +112,6 @@ impl GnarlingFortification { let num_points = (wall_radius / 15).max(5); let outer_wall_corners = (0..num_points) - .into_iter() .map(|a| { let angle = a as f32 / num_points as f32 * core::f32::consts::TAU; Vec2::new(angle.cos(), angle.sin()).map(|a| (a * wall_radius as f32) as i32) @@ -448,7 +447,6 @@ impl Structure for GnarlingFortification { const SECTIONS_PER_WALL_SEGMENT: usize = 8; (0..(SECTIONS_PER_WALL_SEGMENT as i32)) - .into_iter() .map(move |a| { let get_point = |a| point + (next_point - point) * a / (SECTIONS_PER_WALL_SEGMENT as i32);