diff --git a/client/src/addr.rs b/client/src/addr.rs index 59958d574e..01c1e0e92b 100644 --- a/client/src/addr.rs +++ b/client/src/addr.rs @@ -55,7 +55,7 @@ pub(crate) async fn try_connect( f: F, ) -> Result where - F: Fn(std::net::SocketAddr) -> network::ConnectAddr, + F: Fn(SocketAddr) -> network::ConnectAddr, { use crate::error::Error; let mut participant = None; @@ -77,7 +77,7 @@ where fn sort_ipv6(s: impl Iterator, prefer_ipv6: bool) -> Vec { let (mut first_addrs, mut second_addrs) = s.partition::, _>(|a| a.is_ipv6() == prefer_ipv6); - std::iter::Iterator::chain(first_addrs.drain(..), second_addrs.drain(..)).collect::>() + Iterator::chain(first_addrs.drain(..), second_addrs.drain(..)).collect::>() } #[cfg(test)] diff --git a/client/src/bin/bot/main.rs b/client/src/bin/bot/main.rs index d4362b9b12..d4529199f2 100644 --- a/client/src/bin/bot/main.rs +++ b/client/src/bin/bot/main.rs @@ -183,7 +183,7 @@ impl BotClient { } fn create_default_body() -> Body { - comp::body::humanoid::Body { + Body { species: comp::body::humanoid::Species::Human, body_type: comp::body::humanoid::BodyType::Male, hair_style: 0, @@ -208,14 +208,14 @@ impl BotClient { let client = match self.bot_clients.get_mut(&cred.username) { Some(c) => c, None => { - tracing::trace!(?cred.username, "skip not logged in client"); + trace!(?cred.username, "skip not logged in client"); continue; }, }; let list = client.character_list(); if list.loading || list.characters.is_empty() { - tracing::trace!(?cred.username, "skip client as it has no character"); + trace!(?cred.username, "skip client as it has no character"); continue; } diff --git a/client/src/bin/bot/settings.rs b/client/src/bin/bot/settings.rs index 1fa34730f2..54d35387ec 100644 --- a/client/src/bin/bot/settings.rs +++ b/client/src/bin/bot/settings.rs @@ -36,7 +36,7 @@ impl Settings { let mut new_path = path.to_owned(); new_path.pop(); new_path.push("settings.invalid.ron"); - if let Err(e) = std::fs::rename(&path, &new_path) { + if let Err(e) = fs::rename(&path, &new_path) { warn!(?e, ?path, ?new_path, "Failed to rename settings file."); } }, diff --git a/client/src/bin/swarm/main.rs b/client/src/bin/swarm/main.rs index 690ff39266..c776f8186f 100644 --- a/client/src/bin/swarm/main.rs +++ b/client/src/bin/swarm/main.rs @@ -217,8 +217,8 @@ fn run_client( let entity = client.entity(); // Move or stay still depending on specified options // TODO: make sure server cheat protections aren't triggering - let pos = common::comp::Pos(position(index, opt) + world_center); - let vel = common::comp::Vel(Default::default()); + let pos = comp::Pos(position(index, opt) + world_center); + let vel = comp::Vel(Default::default()); client .state_mut() .write_component_ignore_entity_dead(entity, pos); diff --git a/client/src/lib.rs b/client/src/lib.rs index 6398a07cf0..6fd6f35414 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -321,7 +321,7 @@ impl Client { ping_stream.send(PingMsg::Ping)?; // Wait for initial sync - let mut ping_interval = tokio::time::interval(core::time::Duration::from_secs(1)); + let mut ping_interval = tokio::time::interval(Duration::from_secs(1)); let ( state, lod_base, @@ -601,7 +601,7 @@ impl Client { let mut raw = vec![0u8; 4 * world_map_rgba.len()]; LittleEndian::write_u32_into(rgb, &mut raw); Ok(Arc::new( - image::DynamicImage::ImageRgba8({ + DynamicImage::ImageRgba8({ // Should not fail if the dimensions are correct. let map = image::ImageBuffer::from_raw(u32::from(map_size.x), u32::from(map_size.y), raw); @@ -991,7 +991,7 @@ impl Client { .map_or(false, |cs| matches!(cs, CharacterState::Glide(_))) } - pub fn split_swap_slots(&mut self, a: comp::slot::Slot, b: comp::slot::Slot) { + pub fn split_swap_slots(&mut self, a: Slot, b: Slot) { match (a, b) { (Slot::Equip(equip), slot) | (slot, Slot::Equip(equip)) => self.control_action( ControlAction::InventoryAction(InventoryAction::Swap(equip, slot)), @@ -1004,7 +1004,7 @@ impl Client { } } - pub fn split_drop_slot(&mut self, slot: comp::slot::Slot) { + pub fn split_drop_slot(&mut self, slot: Slot) { match slot { Slot::Equip(equip) => { self.control_action(ControlAction::InventoryAction(InventoryAction::Drop(equip))) @@ -1238,9 +1238,7 @@ impl Client { pub fn max_group_size(&self) -> u32 { self.max_group_size } - pub fn invite(&self) -> Option<(Uid, std::time::Instant, std::time::Duration, InviteKind)> { - self.invite - } + pub fn invite(&self) -> Option<(Uid, Instant, Duration, InviteKind)> { self.invite } pub fn group_info(&self) -> Option<(String, Uid)> { self.group_leader.map(|l| ("Group".into(), l)) // TODO @@ -1529,7 +1527,7 @@ impl Client { pub fn send_chat(&mut self, message: String) { match validate_chat_msg(&message) { Ok(()) => self.send_msg(ClientGeneral::ChatMsg(message)), - Err(ChatMsgValidationError::TooLong) => tracing::warn!( + Err(ChatMsgValidationError::TooLong) => warn!( "Attempted to send a message that's too long (Over {} bytes)", MAX_BYTES_CHAT_MSG ), @@ -1568,7 +1566,7 @@ impl Client { .map_or((None, None), |inv| { let tool_kind = |slot| { inv.equipped(slot).and_then(|item| match &*item.kind() { - comp::item::ItemKind::Tool(tool) => Some(tool.kind), + ItemKind::Tool(tool) => Some(tool.kind), _ => None, }) }; @@ -2013,7 +2011,7 @@ impl Client { }, ServerGeneral::SetPlayerEntity(uid) => { if let Some(entity) = self.state.ecs().entity_from_uid(uid.0) { - let old_player_entity = core::mem::replace( + let old_player_entity = mem::replace( &mut *self.state.ecs_mut().write_resource(), PlayerEntity(Some(entity)), ); @@ -2161,7 +2159,7 @@ impl Client { timeout, kind, } => { - self.invite = Some((inviter, std::time::Instant::now(), timeout, kind)); + self.invite = Some((inviter, Instant::now(), timeout, kind)); }, ServerGeneral::InvitePending(uid) => { if !self.pending_invites.insert(uid) { @@ -2236,7 +2234,7 @@ impl Client { }); }, ServerGeneral::UpdatePendingTrade(id, trade, pricing) => { - tracing::trace!("UpdatePendingTrade {:?} {:?}", id, trade); + trace!("UpdatePendingTrade {:?} {:?}", id, trade); self.pending_trade = Some((id, trade, pricing)); }, ServerGeneral::FinishedTrade(result) => { @@ -2871,7 +2869,7 @@ mod tests { //tick let events_result: Result, Error> = - client.tick(comp::ControllerInputs::default(), clock.dt(), |_| {}); + client.tick(ControllerInputs::default(), clock.dt(), |_| {}); //chat functionality client.send_chat("foobar".to_string()); @@ -2886,11 +2884,11 @@ mod tests { }, Event::Disconnect => {}, Event::DisconnectionNotification(_) => { - tracing::debug!("Will be disconnected soon! :/") + debug!("Will be disconnected soon! :/") }, Event::Notification(notification) => { let notification: Notification = notification; - tracing::debug!("Notification: {:?}", notification); + debug!("Notification: {:?}", notification); }, _ => {}, } diff --git a/common/assets/src/lib.rs b/common/assets/src/lib.rs index e5052b39d1..e009ff24ec 100644 --- a/common/assets/src/lib.rs +++ b/common/assets/src/lib.rs @@ -179,7 +179,7 @@ pub struct DotVoxAsset(pub DotVoxData); pub struct DotVoxLoader; impl Loader for DotVoxLoader { - fn load(content: std::borrow::Cow<[u8]>, _: &str) -> Result { + fn load(content: Cow<[u8]>, _: &str) -> Result { let data = dot_vox::load_bytes(&content).map_err(|err| err.to_owned())?; Ok(DotVoxAsset(data)) } @@ -201,7 +201,7 @@ impl Asset for ObjAsset { pub struct ObjAssetLoader; impl Loader for ObjAssetLoader { - fn load(content: std::borrow::Cow<[u8]>, _: &str) -> Result { + fn load(content: Cow<[u8]>, _: &str) -> Result { let data = wavefront::Obj::from_reader(&*content)?; Ok(ObjAsset(data)) } @@ -407,7 +407,7 @@ pub mod asset_tweak { /// assert_eq!(y1, 10); /// /// // you may want to remove this file later - /// std::fs::remove_file(tweak_path); + /// fs::remove_file(tweak_path); /// ``` pub fn tweak_expect(specifier: Specifier) -> T where diff --git a/common/build.rs b/common/build.rs index 3a1d6ed8e9..4f560e1dd3 100644 --- a/common/build.rs +++ b/common/build.rs @@ -54,7 +54,7 @@ fn main() { } // Check if git-lfs is working - if std::env::var("DISABLE_GIT_LFS_CHECK").is_err() && cfg!(not(feature = "no-assets")) { + if env::var("DISABLE_GIT_LFS_CHECK").is_err() && cfg!(not(feature = "no-assets")) { let asset_path: PathBuf = ["..", "assets", "voxygen", "background", "bg_main.jpg"] .iter() .collect(); diff --git a/common/net/src/msg/server.rs b/common/net/src/msg/server.rs index be95b5ddbe..f0849271c4 100644 --- a/common/net/src/msg/server.rs +++ b/common/net/src/msg/server.rs @@ -141,23 +141,23 @@ pub enum ServerGeneral { CharacterEdited(character::CharacterId), CharacterSuccess, //Ingame related - GroupUpdate(comp::group::ChangeNotification), + GroupUpdate(comp::group::ChangeNotification), /// Indicate to the client that they are invited to join a group Invite { - inviter: sync::Uid, - timeout: std::time::Duration, + inviter: Uid, + timeout: Duration, kind: InviteKind, }, /// Indicate to the client that their sent invite was not invalid and is /// currently pending - InvitePending(sync::Uid), + InvitePending(Uid), /// Note: this could potentially include all the failure cases such as /// inviting yourself in which case the `InvitePending` message could be /// removed and the client could consider their invite pending until /// they receive this message Indicate to the client the result of their /// invite InviteComplete { - target: sync::Uid, + target: Uid, answer: InviteAnswer, kind: InviteKind, }, diff --git a/common/net/src/sync/sync_ext.rs b/common/net/src/sync/sync_ext.rs index e6ba3dcd79..d32b4b049c 100644 --- a/common/net/src/sync/sync_ext.rs +++ b/common/net/src/sync/sync_ext.rs @@ -56,7 +56,7 @@ impl WorldSyncExt for specs::World { } fn create_entity_synced(&mut self) -> specs::EntityBuilder { - self.create_entity().marked::() + self.create_entity().marked::() } fn delete_entity_and_clear_from_uid_allocator(&mut self, uid: u64) { diff --git a/common/net/src/sync/track.rs b/common/net/src/sync/track.rs index fa18d18466..2ec672885e 100644 --- a/common/net/src/sync/track.rs +++ b/common/net/src/sync/track.rs @@ -33,7 +33,7 @@ where pub fn removed(&self) -> &BitSet { &self.removed } - pub fn record_changes<'a>(&mut self, storage: &specs::ReadStorage<'a, C>) { + pub fn record_changes<'a>(&mut self, storage: &ReadStorage<'a, C>) { self.inserted.clear(); self.modified.clear(); self.removed.clear(); @@ -86,8 +86,8 @@ impl UpdateTracker { pub fn get_updates_for<'a, P>( &self, - uids: &specs::ReadStorage<'a, Uid>, - storage: &specs::ReadStorage<'a, C>, + uids: &ReadStorage<'a, Uid>, + storage: &ReadStorage<'a, C>, entity_filter: impl Join + Copy, buf: &mut Vec<(u64, CompUpdateKind

)>, ) where @@ -127,7 +127,7 @@ impl UpdateTracker { /// entity. pub fn get_update<'a, P>( &self, - storage: &specs::ReadStorage<'a, C>, + storage: &ReadStorage<'a, C>, entity: Entity, ) -> Option> where diff --git a/common/src/bin/asset_migrate.rs b/common/src/bin/asset_migrate.rs index a2ba646cbd..e7d9503e6d 100644 --- a/common/src/bin/asset_migrate.rs +++ b/common/src/bin/asset_migrate.rs @@ -50,7 +50,7 @@ fn walk_tree(dir: &Path, root: &Path) -> io::Result> { Ok(buff) } -fn walk_with_migrate(tree: Walk, from: &Path, to: &Path) -> std::io::Result<()> +fn walk_with_migrate(tree: Walk, from: &Path, to: &Path) -> io::Result<()> where NewV: From, OldV: DeserializeOwned, diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index ab90b814b3..f802d2ed2c 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -46,7 +46,7 @@ fn armor_stats() -> Result<(), Box> { "Description", ])?; - for item in comp::item::Item::new_from_asset_glob("common.items.armor.*") + for item in Item::new_from_asset_glob("common.items.armor.*") .expect("Failed to iterate over item folders!") { match &*item.kind() { @@ -118,8 +118,8 @@ fn weapon_stats() -> Result<(), Box> { // Does all items even outside weapon folder since we check if itemkind was a // tool anyways - let items: Vec = comp::Item::new_from_asset_glob("common.items.*") - .expect("Failed to iterate over item folders!"); + let items: Vec = + Item::new_from_asset_glob("common.items.*").expect("Failed to iterate over item folders!"); for item in items.iter() { if let comp::item::ItemKind::Tool(tool) = &*item.kind() { @@ -207,8 +207,8 @@ fn all_items() -> Result<(), Box> { let mut wtr = csv::Writer::from_path("items.csv")?; wtr.write_record(&["Path", "Name"])?; - for item in comp::item::Item::new_from_asset_glob("common.items.*") - .expect("Failed to iterate over item folders!") + for item in + Item::new_from_asset_glob("common.items.*").expect("Failed to iterate over item folders!") { wtr.write_record(&[ item.item_definition_id() @@ -305,7 +305,7 @@ fn entity_drops(entity_config: &str) -> Result<(), Box> { "Quantity", ])?; - fn write_entity_loot( + fn write_entity_loot( wtr: &mut csv::Writer, asset_path: &str, ) -> Result<(), Box> { diff --git a/common/src/bin/csv_import/main.rs b/common/src/bin/csv_import/main.rs index f19ae44b37..00eac0ad23 100644 --- a/common/src/bin/csv_import/main.rs +++ b/common/src/bin/csv_import/main.rs @@ -72,7 +72,7 @@ fn armor_stats() -> Result<(), Box> { .expect("Failed to iterate over item folders!") { match &*item.kind() { - comp::item::ItemKind::Armor(armor) => { + ItemKind::Armor(armor) => { if let ArmorKind::Bag = armor.kind { continue; } @@ -190,20 +190,20 @@ fn armor_stats() -> Result<(), Box> { let quality = if let Some(quality_raw) = record.get(headers["Quality"]) { match quality_raw { - "Low" => comp::item::Quality::Low, - "Common" => comp::item::Quality::Common, - "Moderate" => comp::item::Quality::Moderate, - "High" => comp::item::Quality::High, - "Epic" => comp::item::Quality::Epic, - "Legendary" => comp::item::Quality::Legendary, - "Artifact" => comp::item::Quality::Artifact, - "Debug" => comp::item::Quality::Debug, + "Low" => Quality::Low, + "Common" => Quality::Common, + "Moderate" => Quality::Moderate, + "High" => Quality::High, + "Epic" => Quality::Epic, + "Legendary" => Quality::Legendary, + "Artifact" => Quality::Artifact, + "Debug" => Quality::Debug, _ => { eprintln!( "Unknown quality variant for {:?}", item.item_definition_id() ); - comp::item::Quality::Debug + Quality::Debug }, } } else { @@ -211,7 +211,7 @@ fn armor_stats() -> Result<(), Box> { "Could not unwrap quality for {:?}", item.item_definition_id() ); - comp::item::Quality::Debug + Quality::Debug }; let description = record @@ -284,7 +284,7 @@ fn weapon_stats() -> Result<(), Box> { .expect("Failed to iterate over item folders!"); for item in items.iter() { - if let comp::item::ItemKind::Tool(tool) = &*item.kind() { + if let ItemKind::Tool(tool) = &*item.kind() { if let Ok(ref record) = record { if item.item_definition_id() == ItemDefinitionId::Simple( @@ -328,19 +328,19 @@ fn weapon_stats() -> Result<(), Box> { let hands = if let Some(hands_raw) = record.get(headers["Hands"]) { match hands_raw { - "One" | "1" | "1h" => comp::item::tool::Hands::One, - "Two" | "2" | "2h" => comp::item::tool::Hands::Two, + "One" | "1" | "1h" => Hands::One, + "Two" | "2" | "2h" => Hands::Two, _ => { eprintln!( "Unknown hand variant for {:?}", item.item_definition_id() ); - comp::item::tool::Hands::Two + Hands::Two }, } } else { eprintln!("Could not unwrap hand for {:?}", item.item_definition_id()); - comp::item::tool::Hands::Two + Hands::Two }; let crit_chance: f32 = record @@ -392,20 +392,20 @@ fn weapon_stats() -> Result<(), Box> { let quality = if let Some(quality_raw) = record.get(headers["Quality"]) { match quality_raw { - "Low" => comp::item::Quality::Low, - "Common" => comp::item::Quality::Common, - "Moderate" => comp::item::Quality::Moderate, - "High" => comp::item::Quality::High, - "Epic" => comp::item::Quality::Epic, - "Legendary" => comp::item::Quality::Legendary, - "Artifact" => comp::item::Quality::Artifact, - "Debug" => comp::item::Quality::Debug, + "Low" => Quality::Low, + "Common" => Quality::Common, + "Moderate" => Quality::Moderate, + "High" => Quality::High, + "Epic" => Quality::Epic, + "Legendary" => Quality::Legendary, + "Artifact" => Quality::Artifact, + "Debug" => Quality::Debug, _ => { eprintln!( "Unknown quality variant for {:?}", item.item_definition_id() ); - comp::item::Quality::Debug + Quality::Debug }, } } else { @@ -413,7 +413,7 @@ fn weapon_stats() -> Result<(), Box> { "Could not unwrap quality for {:?}", item.item_definition_id() ); - comp::item::Quality::Debug + Quality::Debug }; let description = record.get(headers["Description"]).expect(&format!( diff --git a/common/src/cmd.rs b/common/src/cmd.rs index ec9f79845b..2d47ddda59 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -804,7 +804,7 @@ impl ServerChatCommand { } /// Produce an iterator over all the available commands - pub fn iter() -> impl Iterator { ::iter() } + pub fn iter() -> impl Iterator { ::iter() } /// A message that explains what the command does pub fn help_string(&self) -> String { diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 115fea7714..6975bce212 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -300,18 +300,14 @@ impl CharacterState { pub fn behavior(&self, j: &JoinData, output_events: &mut OutputEvents) -> StateUpdate { match &self { CharacterState::Idle(data) => data.behavior(j, output_events), - CharacterState::Talk => states::talk::Data.behavior(j, output_events), + CharacterState::Talk => talk::Data.behavior(j, output_events), CharacterState::Climb(data) => data.behavior(j, output_events), CharacterState::Wallrun(data) => data.behavior(j, output_events), CharacterState::Glide(data) => data.behavior(j, output_events), CharacterState::GlideWield(data) => data.behavior(j, output_events), CharacterState::Stunned(data) => data.behavior(j, output_events), - CharacterState::Sit => { - states::sit::Data::behavior(&states::sit::Data, j, output_events) - }, - CharacterState::Dance => { - states::dance::Data::behavior(&states::dance::Data, j, output_events) - }, + CharacterState::Sit => sit::Data::behavior(&sit::Data, j, output_events), + CharacterState::Dance => dance::Data::behavior(&dance::Data, j, output_events), CharacterState::BasicBlock(data) => data.behavior(j, output_events), CharacterState::Roll(data) => data.behavior(j, output_events), CharacterState::Wielding(data) => data.behavior(j, output_events), @@ -347,17 +343,17 @@ impl CharacterState { ) -> StateUpdate { match &self { CharacterState::Idle(data) => data.handle_event(j, output_events, action), - CharacterState::Talk => states::talk::Data.handle_event(j, output_events, action), + CharacterState::Talk => talk::Data.handle_event(j, output_events, action), CharacterState::Climb(data) => data.handle_event(j, output_events, action), CharacterState::Wallrun(data) => data.handle_event(j, output_events, action), CharacterState::Glide(data) => data.handle_event(j, output_events, action), CharacterState::GlideWield(data) => data.handle_event(j, output_events, action), CharacterState::Stunned(data) => data.handle_event(j, output_events, action), CharacterState::Sit => { - states::sit::Data::handle_event(&states::sit::Data, j, output_events, action) + states::sit::Data::handle_event(&sit::Data, j, output_events, action) }, CharacterState::Dance => { - states::dance::Data::handle_event(&states::dance::Data, j, output_events, action) + states::dance::Data::handle_event(&dance::Data, j, output_events, action) }, CharacterState::BasicBlock(data) => data.handle_event(j, output_events, action), CharacterState::Roll(data) => data.handle_event(j, output_events, action), diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 1cf1a8a88e..563d7e1bd6 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -263,8 +263,8 @@ impl TagExampleInfo for ItemTag { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum ItemKind { /// Something wieldable - Tool(tool::Tool), - ModularComponent(modular::ModularComponent), + Tool(Tool), + ModularComponent(ModularComponent), Lantern(Lantern), Armor(armor::Armor), Glider, @@ -373,7 +373,7 @@ pub enum ItemName { #[derive(Clone, Debug)] pub enum ItemBase { Simple(Arc), - Modular(modular::ModularBase), + Modular(ModularBase), } impl Serialize for ItemBase { @@ -1262,7 +1262,7 @@ mod tests { fn test_assets_items() { let ids = all_item_defs_expect(); for item in ids.iter().map(|id| Item::new_from_asset_expect(id)) { - std::mem::drop(item) + drop(item) } } } diff --git a/common/src/comp/inventory/item/modular.rs b/common/src/comp/inventory/item/modular.rs index ea4d364cd0..c73bf03b87 100644 --- a/common/src/comp/inventory/item/modular.rs +++ b/common/src/comp/inventory/item/modular.rs @@ -41,8 +41,8 @@ impl MaterialStatManifest { /// needed for tests to load it without actual assets pub fn with_empty() -> Self { Self { - tool_stats: hashbrown::HashMap::default(), - armor_stats: hashbrown::HashMap::default(), + tool_stats: HashMap::default(), + armor_stats: HashMap::default(), } } } diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 89d31acd42..391cca1df5 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -84,7 +84,7 @@ impl ItemSpec { let mut rng = rand::thread_rng(); match self { ItemSpec::Item(item_asset) => Item::new_from_asset(item_asset) - .map(std::mem::drop) + .map(drop) .map_err(ValidationError::ItemAssetError), ItemSpec::Choice(choices) => { // TODO: check for sanity of weigts? @@ -100,7 +100,7 @@ impl ItemSpec { material, hands, } => item::modular::random_weapon(*tool, *material, *hands, &mut rng) - .map(std::mem::drop) + .map(drop) .map_err(ValidationError::ModularWeaponCreationError), } } @@ -1219,7 +1219,7 @@ mod tests { #[test] fn test_loadout_presets() { for preset in Preset::iter() { - std::mem::drop(LoadoutBuilder::empty().with_preset(preset)); + drop(LoadoutBuilder::empty().with_preset(preset)); } } diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 3dd3177521..e2454d763d 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -269,7 +269,7 @@ impl Inventory { /// item or the same item again if that slot was not found. pub fn insert_at(&mut self, inv_slot_id: InvSlotId, item: Item) -> Result, Item> { match self.slot_mut(inv_slot_id) { - Some(slot) => Ok(core::mem::replace(slot, Some(item))), + Some(slot) => Ok(mem::replace(slot, Some(item))), None => Err(item), } } @@ -319,7 +319,7 @@ impl Inventory { .err() .and(Some(item)) } else { - let old_item = core::mem::replace(slot_item, item); + let old_item = mem::replace(slot_item, item); // No need to recount--we know the count is the same. Some(old_item) }) @@ -808,8 +808,8 @@ impl Inventory { /// Used only when loading in persistence code. pub fn persistence_update_all_item_states( &mut self, - ability_map: &item::tool::AbilityMap, - msm: &item::MaterialStatManifest, + ability_map: &AbilityMap, + msm: &MaterialStatManifest, ) { self.slots_mut().for_each(|slot| { if let Some(item) = slot { diff --git a/common/src/comp/inventory/slot.rs b/common/src/comp/inventory/slot.rs index fb19152618..f68ecc77cd 100644 --- a/common/src/comp/inventory/slot.rs +++ b/common/src/comp/inventory/slot.rs @@ -110,7 +110,7 @@ pub enum ArmorSlot { } impl Slot { - pub fn can_hold(self, item_kind: &item::ItemKind) -> bool { + pub fn can_hold(self, item_kind: &ItemKind) -> bool { match (self, item_kind) { (Self::Inventory(_), _) => true, (Self::Equip(slot), item_kind) => slot.can_hold(item_kind), @@ -119,7 +119,7 @@ impl Slot { } impl EquipSlot { - pub fn can_hold(self, item_kind: &item::ItemKind) -> bool { + pub fn can_hold(self, item_kind: &ItemKind) -> bool { match (self, item_kind) { (Self::Armor(slot), ItemKind::Armor(armor::Armor { kind, .. })) => slot.can_hold(kind), (Self::ActiveMainhand, ItemKind::Tool(_)) => true, @@ -134,7 +134,7 @@ impl EquipSlot { } impl ArmorSlot { - fn can_hold(self, armor: &item::armor::ArmorKind) -> bool { + fn can_hold(self, armor: &ArmorKind) -> bool { matches!( (self, armor), (Self::Head, ArmorKind::Head) diff --git a/common/src/comp/inventory/trade_pricing.rs b/common/src/comp/inventory/trade_pricing.rs index 6b2924525d..5a07f0858b 100644 --- a/common/src/comp/inventory/trade_pricing.rs +++ b/common/src/comp/inventory/trade_pricing.rs @@ -519,12 +519,12 @@ fn get_scaling(contents: &AssetGuard, good: Good) -> f32 { } #[cfg(test)] -impl std::cmp::PartialOrd for ItemDefinitionIdOwned { +impl PartialOrd for ItemDefinitionIdOwned { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } #[cfg(test)] -impl std::cmp::Ord for ItemDefinitionIdOwned { +impl Ord for ItemDefinitionIdOwned { fn cmp(&self, other: &Self) -> Ordering { match self { ItemDefinitionIdOwned::Simple(na) => match other { @@ -781,7 +781,7 @@ impl TradePricing { for (_, recipe) in book.iter() { let (ref asset_path, amount) = recipe.output; if let ItemKind::ModularComponent( - crate::comp::inventory::item::modular::ModularComponent::ToolSecondaryComponent { + inventory::item::modular::ModularComponent::ToolSecondaryComponent { toolkind, stats: _, hand_restriction: _, diff --git a/common/src/comp/melee.rs b/common/src/comp/melee.rs index 6fd5acdb01..802b9e61d3 100644 --- a/common/src/comp/melee.rs +++ b/common/src/comp/melee.rs @@ -405,9 +405,7 @@ impl MeleeConstructor { if let Some(ref mut scaled) = &mut self.scaled { *scaled = scaled.adjusted_by_stats(stats, regen); } - if let Some(CombatEffect::Buff(combat::CombatBuff { strength, .. })) = - &mut self.damage_effect - { + if let Some(CombatEffect::Buff(CombatBuff { strength, .. })) = &mut self.damage_effect { *strength *= stats.buff_strength; } self diff --git a/common/src/event.rs b/common/src/event.rs index 274a5f8853..46b5a15787 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -126,7 +126,7 @@ pub enum ServerEvent { }, // TODO: to avoid breakage when adding new fields, perhaps have an `NpcBuilder` type? CreateNpc { - pos: comp::Pos, + pos: Pos, stats: comp::Stats, skill_set: comp::SkillSet, health: Option, @@ -142,7 +142,7 @@ pub enum ServerEvent { projectile: Option, }, CreateShip { - pos: comp::Pos, + pos: Pos, ship: comp::ship::Body, mountable: bool, agent: Option, diff --git a/common/src/generation.rs b/common/src/generation.rs index 46051ea406..81e5a73aad 100644 --- a/common/src/generation.rs +++ b/common/src/generation.rs @@ -167,7 +167,7 @@ pub struct EntityInfo { // Loadout pub inventory: Vec<(u32, Item)>, pub loadout: LoadoutBuilder, - pub make_loadout: Option) -> LoadoutBuilder>, + pub make_loadout: Option) -> LoadoutBuilder>, // Skills pub skillset_asset: Option, @@ -176,7 +176,7 @@ pub struct EntityInfo { // Economy // we can't use DHashMap, do we want to move that into common? - pub trading_information: Option, + pub trading_information: Option, //Option>, /* price and available amount */ } @@ -394,7 +394,7 @@ impl EntityInfo { #[must_use] pub fn with_lazy_loadout( mut self, - creator: fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder, + creator: fn(LoadoutBuilder, Option<&SiteInformation>) -> LoadoutBuilder, ) -> Self { self.make_loadout = Some(creator); self @@ -576,7 +576,7 @@ mod tests { match field { Meta::SkillSetAsset(asset) => { - std::mem::drop(SkillSetBuilder::from_asset_expect(&asset)); + drop(SkillSetBuilder::from_asset_expect(&asset)); }, } } diff --git a/common/src/link.rs b/common/src/link.rs index 9cdee123c0..6ef53aa4a0 100644 --- a/common/src/link.rs +++ b/common/src/link.rs @@ -28,9 +28,7 @@ pub struct Is { } impl Is { - pub fn delete(&self, data: ::DeleteData<'_>) { - R::Link::delete(&self.link, data) - } + pub fn delete(&self, data: ::DeleteData<'_>) { Link::delete(&self.link, data) } } impl Clone for Is { diff --git a/common/src/lottery.rs b/common/src/lottery.rs index c3f52018fe..38ca914e72 100644 --- a/common/src/lottery.rs +++ b/common/src/lottery.rs @@ -108,7 +108,7 @@ impl> LootSpec { warn!(?e, "error while loading item: {}", item.as_ref()); None }, - Option::Some, + Some, ), Self::ItemQuantity(item, lower, upper) => { let range = *lower..=*upper; @@ -148,7 +148,7 @@ impl> LootSpec { ); None }, - Option::Some, + Some, ), Self::ModularWeaponPrimaryComponent { tool, diff --git a/common/src/outcome.rs b/common/src/outcome.rs index d261312e8d..b0a2ebc963 100644 --- a/common/src/outcome.rs +++ b/common/src/outcome.rs @@ -54,7 +54,7 @@ pub enum Outcome { }, SkillPointGain { uid: Uid, - skill_tree: comp::skillset::SkillGroupKind, + skill_tree: SkillGroupKind, total_points: u16, }, ComboChange { diff --git a/common/src/skillset_builder.rs b/common/src/skillset_builder.rs index 643571f638..900b4237c7 100644 --- a/common/src/skillset_builder.rs +++ b/common/src/skillset_builder.rs @@ -167,7 +167,7 @@ mod tests { fn test_all_skillset_assets() { let skillsets = assets::read_expect_dir::("common.skillset", true); for skillset in skillsets { - std::mem::drop({ + drop({ let mut skillset_builder = SkillSetBuilder::default(); let nodes = &*skillset.0; let tree = skills_from_nodes(nodes); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 136913815c..5d1cde28ba 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -303,7 +303,7 @@ impl Body { /// set footwear in idle data and potential state change to Skate pub fn handle_skating(data: &JoinData, update: &mut StateUpdate) { - if let Idle(crate::states::idle::Data { + if let Idle(idle::Data { is_sneaking, mut footwear, }) = data.character @@ -313,19 +313,17 @@ pub fn handle_skating(data: &JoinData, update: &mut StateUpdate) { inv.equipped(EquipSlot::Armor(ArmorSlot::Feet)) .map(|armor| match armor.kind().as_ref() { ItemKind::Armor(a) => a.stats(data.msm).ground_contact, - _ => crate::comp::inventory::item::armor::Friction::Normal, + _ => Friction::Normal, }) }); - update.character = Idle(crate::states::idle::Data { + update.character = Idle(idle::Data { is_sneaking: *is_sneaking, footwear, }); } if data.physics.skating_active { - update.character = CharacterState::Skate(crate::states::skate::Data::new( - data, - footwear.unwrap_or(Friction::Normal), - )); + update.character = + CharacterState::Skate(skate::Data::new(data, footwear.unwrap_or(Friction::Normal))); } } } @@ -687,7 +685,7 @@ pub fn attempt_talk(data: &JoinData<'_>, update: &mut StateUpdate) { pub fn attempt_sneak(data: &JoinData<'_>, update: &mut StateUpdate) { if data.physics.on_ground.is_some() && data.body.is_humanoid() { - update.character = CharacterState::Idle(idle::Data { + update.character = Idle(idle::Data { is_sneaking: true, footwear: data.character.footwear(), }); diff --git a/common/src/trade.rs b/common/src/trade.rs index 2e357ba8a7..6d03dfae73 100644 --- a/common/src/trade.rs +++ b/common/src/trade.rs @@ -341,7 +341,7 @@ pub enum Good { impl Default for Good { fn default() -> Self { - Good::Terrain(crate::terrain::BiomeKind::Void) // Arbitrary + Good::Terrain(BiomeKind::Void) // Arbitrary } } diff --git a/common/src/util/dir.rs b/common/src/util/dir.rs index 90742b4b1e..0cec04489b 100644 --- a/common/src/util/dir.rs +++ b/common/src/util/dir.rs @@ -165,7 +165,7 @@ impl std::ops::Neg for Dir { /// Additionally, it avoids unnecessary calculations if they are near identical /// Assumes `from` and `to` are normalized and returns a normalized vector #[inline(always)] -fn slerp_normalized(from: vek::Vec3, to: vek::Vec3, factor: f32) -> vek::Vec3 { +fn slerp_normalized(from: Vec3, to: Vec3, factor: f32) -> Vec3 { debug_assert!(!to.map(f32::is_nan).reduce_or()); debug_assert!(!from.map(f32::is_nan).reduce_or()); // Ensure from is normalized diff --git a/common/src/volumes/chunk.rs b/common/src/volumes/chunk.rs index 699a5d1f25..3bcacf65c8 100644 --- a/common/src/volumes/chunk.rs +++ b/common/src/volumes/chunk.rs @@ -277,9 +277,9 @@ impl Chunk { { if vox != self.default { let idx = self.force_idx_unchecked(pos); - core::mem::replace(&mut self.vox[idx], vox) + mem::replace(&mut self.vox[idx], vox) } else if let Some(idx) = self.idx_unchecked(pos) { - core::mem::replace(&mut self.vox[idx], vox) + mem::replace(&mut self.vox[idx], vox) } else { self.default.clone() } diff --git a/common/state/src/build_areas.rs b/common/state/src/build_areas.rs index 8d1e273e77..7e520f7ac0 100644 --- a/common/state/src/build_areas.rs +++ b/common/state/src/build_areas.rs @@ -22,7 +22,7 @@ pub enum BuildAreaError { const RESERVED_BUILD_AREA_NAMES: &[&str] = &["world"]; impl BuildAreas { - pub fn areas(&self) -> &Depot> { &self.areas } + pub fn areas(&self) -> &Depot> { &self.areas } pub fn area_names(&self) -> &HashMap>> { &self.area_names } diff --git a/common/systems/tests/character_state.rs b/common/systems/tests/character_state.rs index d2f00609c1..77db306723 100644 --- a/common/systems/tests/character_state.rs +++ b/common/systems/tests/character_state.rs @@ -27,7 +27,7 @@ mod tests { state } - fn create_entity(state: &mut State, ori: Ori) -> specs::Entity { + fn create_entity(state: &mut State, ori: Ori) -> Entity { let body = common::comp::Body::Humanoid(common::comp::humanoid::Body::random_with( &mut thread_rng(), &common::comp::humanoid::Species::Human, diff --git a/common/systems/tests/phys/basic.rs b/common/systems/tests/phys/basic.rs index d61f6de6b8..c57dc03cbb 100644 --- a/common/systems/tests/phys/basic.rs +++ b/common/systems/tests/phys/basic.rs @@ -36,14 +36,14 @@ fn dont_fall_outside_world() -> Result<(), Box> { assert_relative_eq!(pos.0.x, 1000.0); assert_relative_eq!(pos.0.y, 1000.0); assert_relative_eq!(pos.0.z, 265.0); - assert_eq!(vel.0, vek::Vec3::zero()); + assert_eq!(vel.0, Vec3::zero()); utils::tick(&mut state, DT); let (pos, vel, _) = utils::get_transform(&state, p1)?; assert_relative_eq!(pos.0.x, 1000.0); assert_relative_eq!(pos.0.y, 1000.0); assert_relative_eq!(pos.0.z, 265.0); - assert_eq!(vel.0, vek::Vec3::zero()); + assert_eq!(vel.0, Vec3::zero()); Ok(()) } @@ -56,7 +56,7 @@ fn fall_simple() -> Result<(), Box> { assert_relative_eq!(pos.0.x, 16.0); assert_relative_eq!(pos.0.y, 16.0); assert_relative_eq!(pos.0.z, 265.0); - assert_eq!(vel.0, vek::Vec3::zero()); + assert_eq!(vel.0, Vec3::zero()); utils::tick(&mut state, DT); let (pos, vel, _) = utils::get_transform(&state, p1)?; @@ -145,7 +145,7 @@ fn walk_simple() -> Result<(), Box> { } let (pos, vel, _) = utils::get_transform(&state, p1)?; assert_relative_eq!(pos.0.z, 257.0); // make sure it landed on ground - assert_eq!(vel.0, vek::Vec3::zero()); + assert_eq!(vel.0, Vec3::zero()); let mut actions = Controller::default(); actions.inputs.move_dir = Vec2::new(1.0, 0.0); diff --git a/network/examples/fileshare/main.rs b/network/examples/fileshare/main.rs index 4ec8c1324d..f821a211af 100644 --- a/network/examples/fileshare/main.rs +++ b/network/examples/fileshare/main.rs @@ -62,7 +62,7 @@ fn main() { } fn file_exists(file: &str) -> Result<(), String> { - let file: std::path::PathBuf = shellexpand::tilde(file).parse().unwrap(); + let file: PathBuf = shellexpand::tilde(file).parse().unwrap(); if file.exists() { Ok(()) } else { diff --git a/network/examples/network-speed/main.rs b/network/examples/network-speed/main.rs index 894bd7f14e..931989c2ac 100644 --- a/network/examples/network-speed/main.rs +++ b/network/examples/network-speed/main.rs @@ -192,16 +192,16 @@ fn client(address: ConnectAddr, runtime: Arc) { } if id > 2000000 { println!("Stop"); - std::thread::sleep(std::time::Duration::from_millis(2000)); + thread::sleep(Duration::from_millis(2000)); break; } } drop(s1); - std::thread::sleep(std::time::Duration::from_millis(2000)); + thread::sleep(Duration::from_millis(2000)); info!("Closing participant"); runtime.block_on(p1.disconnect()).unwrap(); - std::thread::sleep(std::time::Duration::from_millis(2000)); + thread::sleep(Duration::from_millis(2000)); info!("DROPPING! client"); drop(client); - std::thread::sleep(std::time::Duration::from_millis(2000)); + thread::sleep(Duration::from_millis(2000)); } diff --git a/network/protocol/benches/protocols.rs b/network/protocol/benches/protocols.rs index 6cd709efe4..ef807392bb 100644 --- a/network/protocol/benches/protocols.rs +++ b/network/protocol/benches/protocols.rs @@ -192,8 +192,8 @@ mod utils { cap: usize, metrics: Option, ) -> [(MpscSendProtocol, MpscRecvProtocol); 2] { - let (s1, r1) = async_channel::bounded(cap); - let (s2, r2) = async_channel::bounded(cap); + let (s1, r1) = bounded(cap); + let (s2, r2) = bounded(cap); let m = metrics.unwrap_or_else(|| { ProtocolMetricCache::new("mpsc", Arc::new(ProtocolMetrics::new().unwrap())) }); @@ -222,8 +222,8 @@ mod utils { cap: usize, metrics: Option, ) -> [(TcpSendProtocol, TcpRecvProtocol); 2] { - let (s1, r1) = async_channel::bounded(cap); - let (s2, r2) = async_channel::bounded(cap); + let (s1, r1) = bounded(cap); + let (s2, r2) = bounded(cap); let m = metrics.unwrap_or_else(|| { ProtocolMetricCache::new("tcp", Arc::new(ProtocolMetrics::new().unwrap())) }); @@ -252,8 +252,8 @@ mod utils { cap: usize, metrics: Option, ) -> [(QuicSendProtocol, QuicRecvProtocol); 2] { - let (s1, r1) = async_channel::bounded(cap); - let (s2, r2) = async_channel::bounded(cap); + let (s1, r1) = bounded(cap); + let (s2, r2) = bounded(cap); let m = metrics.unwrap_or_else(|| { ProtocolMetricCache::new("quic", Arc::new(ProtocolMetrics::new().unwrap())) }); diff --git a/network/protocol/src/mpsc.rs b/network/protocol/src/mpsc.rs index a9afd297c4..fb9cf8112d 100644 --- a/network/protocol/src/mpsc.rs +++ b/network/protocol/src/mpsc.rs @@ -202,8 +202,8 @@ pub mod test_utils { cap: usize, metrics: Option, ) -> [(MpscSendProtocol, MpscRecvProtocol); 2] { - let (s1, r1) = async_channel::bounded(cap); - let (s2, r2) = async_channel::bounded(cap); + let (s1, r1) = bounded(cap); + let (s2, r2) = bounded(cap); let m = metrics.unwrap_or_else(|| { ProtocolMetricCache::new("mpsc", Arc::new(ProtocolMetrics::new().unwrap())) }); diff --git a/network/protocol/src/quic.rs b/network/protocol/src/quic.rs index c261a342f2..566364e017 100644 --- a/network/protocol/src/quic.rs +++ b/network/protocol/src/quic.rs @@ -543,8 +543,8 @@ mod test_utils { drop_ratio: f32, metrics: Option, ) -> [(QuicSendProtocol, QuicRecvProtocol); 2] { - let (s1, r1) = async_channel::bounded(cap); - let (s2, r2) = async_channel::bounded(cap); + let (s1, r1) = bounded(cap); + let (s2, r2) = bounded(cap); let m = metrics.unwrap_or_else(|| { ProtocolMetricCache::new("quic", Arc::new(ProtocolMetrics::new().unwrap())) }); @@ -804,8 +804,7 @@ mod tests { let sid = Sid::new(1); let (s, r) = async_channel::bounded(10); let m = ProtocolMetricCache::new("quic", Arc::new(ProtocolMetrics::new().unwrap())); - let mut r = - super::QuicRecvProtocol::new(super::test_utils::QuicSink { receiver: r }, m.clone()); + let mut r = super::QuicRecvProtocol::new(QuicSink { receiver: r }, m.clone()); const DATA1: &[u8; 69] = b"We need to make sure that its okay to send OPEN_STREAM and DATA_HEAD "; @@ -861,8 +860,7 @@ mod tests { let sid = Sid::new(1); let (s, r) = async_channel::bounded(10); let m = ProtocolMetricCache::new("quic", Arc::new(ProtocolMetrics::new().unwrap())); - let mut r = - super::QuicRecvProtocol::new(super::test_utils::QuicSink { receiver: r }, m.clone()); + let mut r = super::QuicRecvProtocol::new(QuicSink { receiver: r }, m.clone()); let mut bytes = BytesMut::with_capacity(1500); OTFrame::OpenStream { diff --git a/network/protocol/src/tcp.rs b/network/protocol/src/tcp.rs index 5529490e05..4fae046683 100644 --- a/network/protocol/src/tcp.rs +++ b/network/protocol/src/tcp.rs @@ -360,8 +360,8 @@ mod test_utils { cap: usize, metrics: Option, ) -> [(TcpSendProtocol, TcpRecvProtocol); 2] { - let (s1, r1) = async_channel::bounded(cap); - let (s2, r2) = async_channel::bounded(cap); + let (s1, r1) = bounded(cap); + let (s2, r2) = bounded(cap); let m = metrics.unwrap_or_else(|| { ProtocolMetricCache::new("tcp", Arc::new(ProtocolMetrics::new().unwrap())) }); @@ -603,8 +603,7 @@ mod tests { let sid = Sid::new(1); let (s, r) = async_channel::bounded(10); let m = ProtocolMetricCache::new("tcp", Arc::new(ProtocolMetrics::new().unwrap())); - let mut r = - super::TcpRecvProtocol::new(super::test_utils::TcpSink { receiver: r }, m.clone()); + let mut r = super::TcpRecvProtocol::new(TcpSink { receiver: r }, m.clone()); const DATA1: &[u8; 69] = b"We need to make sure that its okay to send OPEN_STREAM and DATA_HEAD "; @@ -653,8 +652,7 @@ mod tests { let sid = Sid::new(1); let (s, r) = async_channel::bounded(10); let m = ProtocolMetricCache::new("tcp", Arc::new(ProtocolMetrics::new().unwrap())); - let mut r = - super::TcpRecvProtocol::new(super::test_utils::TcpSink { receiver: r }, m.clone()); + let mut r = super::TcpRecvProtocol::new(TcpSink { receiver: r }, m.clone()); let mut bytes = BytesMut::with_capacity(1500); OTFrame::OpenStream { diff --git a/network/src/api.rs b/network/src/api.rs index d5322502a7..511f90c361 100644 --- a/network/src/api.rs +++ b/network/src/api.rs @@ -107,7 +107,7 @@ pub struct Stream { #[derive(Debug)] pub enum NetworkError { NetworkClosed, - ListenFailed(std::io::Error), + ListenFailed(io::Error), ConnectFailed(NetworkConnectError), } @@ -117,7 +117,7 @@ pub enum NetworkConnectError { /// Either a Pid UUID clash or you are trying to hijack a connection InvalidSecret, Handshake(InitProtocolError), - Io(std::io::Error), + Io(io::Error), } /// Error type thrown by [`Participants`](Participant) methods @@ -168,7 +168,7 @@ pub struct StreamParams { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, ConnectAddr, ListenAddr, Pid}; /// -/// # fn main() -> std::result::Result<(), Box> { +/// # fn main() -> Result<(), Box> { /// // Create a Network, listen on port `2999` to accept connections and connect to port `8080` to connect to a (pseudo) database Application /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -272,7 +272,7 @@ impl Network { #[cfg(feature = "metrics")] registry: Option<&Registry>, ) -> Self { let p = participant_id; - let span = tracing::info_span!("network", ?p); + let span = info_span!("network", ?p); span.in_scope(|| trace!("Starting Network")); let (scheduler, listen_sender, connect_sender, connected_receiver, shutdown_sender) = Scheduler::new( @@ -295,7 +295,7 @@ impl Network { scheduler.run().await; trace!("Stopping scheduler and his own thread"); } - .instrument(tracing::info_span!("network", ?p)), + .instrument(info_span!("network", ?p)), ); Self { local_pid: participant_id, @@ -340,7 +340,7 @@ impl Network { /// [`ListenAddr`]: crate::api::ListenAddr #[instrument(name="network", skip(self, address), fields(p = %self.local_pid))] pub async fn listen(&self, address: ListenAddr) -> Result<(), NetworkError> { - let (s2a_result_s, s2a_result_r) = oneshot::channel::>(); + let (s2a_result_s, s2a_result_r) = oneshot::channel::>(); debug!(?address, "listening on address"); self.listen_sender .lock() @@ -428,7 +428,7 @@ impl Network { /// use tokio::runtime::Runtime; /// use veloren_network::{ConnectAddr, ListenAddr, Network, Pid}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on port `2020` TCP and opens returns their Pid /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -567,7 +567,7 @@ impl Participant { /// use tokio::runtime::Runtime; /// use veloren_network::{ConnectAddr, ListenAddr, Network, Pid, Promises}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, connect on port 2100 and open a stream /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -634,7 +634,7 @@ impl Participant { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, Pid, ListenAddr, ConnectAddr, Promises}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, connect on port 2110 and wait for the other side to open a stream /// // Note: It's quite unusual to actively connect, but then wait on a stream to be connected, usually the Application taking initiative want's to also create the first Stream. /// let runtime = Runtime::new().unwrap(); @@ -691,7 +691,7 @@ impl Participant { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, Pid, ListenAddr, ConnectAddr}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on port `2030` TCP and opens returns their Pid and close connection. /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -775,7 +775,7 @@ impl Participant { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, Pid, ListenAddr, ConnectAddr, Promises, ParticipantEvent}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, connect on port 2040 and wait for the other side to open a stream /// // Note: It's quite unusual to actively connect, but then wait on a stream to be connected, usually the Application taking initiative want's to also create the first Stream. /// let runtime = Runtime::new().unwrap(); @@ -889,7 +889,7 @@ impl Stream { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, ListenAddr, ConnectAddr, Pid}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on Port `2200` and wait for a Stream to be opened, then answer `Hello World` /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -931,7 +931,7 @@ impl Stream { /// use bincode; /// use veloren_network::{Network, ListenAddr, ConnectAddr, Pid, Message}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); /// # let remote1 = Network::new(Pid::new(), &runtime); @@ -999,7 +999,7 @@ impl Stream { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, ListenAddr, ConnectAddr, Pid}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on Port `2220` and wait for a Stream to be opened, then listen on it /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -1033,7 +1033,7 @@ impl Stream { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, ListenAddr, ConnectAddr, Pid}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on Port `2230` and wait for a Stream to be opened, then listen on it /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -1089,7 +1089,7 @@ impl Stream { /// use tokio::runtime::Runtime; /// use veloren_network::{Network, ListenAddr, ConnectAddr, Pid}; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on Port `2240` and wait for a Stream to be opened, then listen on it /// let runtime = Runtime::new().unwrap(); /// let network = Network::new(Pid::new(), &runtime); @@ -1141,7 +1141,7 @@ impl Stream { } } -impl core::cmp::PartialEq for Participant { +impl PartialEq for Participant { fn eq(&self, other: &Self) -> bool { //don't check local_pid, 2 Participant from different network should match if // they are the "same" @@ -1293,8 +1293,8 @@ impl From for NetworkError { fn from(_err: oneshot::error::RecvError) -> Self { NetworkError::NetworkClosed } } -impl From for NetworkError { - fn from(_err: std::io::Error) -> Self { NetworkError::NetworkClosed } +impl From for NetworkError { + fn from(_err: io::Error) -> Self { NetworkError::NetworkClosed } } impl From> for StreamError { @@ -1346,7 +1346,7 @@ impl core::fmt::Display for NetworkConnectError { } /// implementing PartialEq as it's super convenient in tests -impl core::cmp::PartialEq for StreamError { +impl PartialEq for StreamError { fn eq(&self, other: &Self) -> bool { match self { StreamError::StreamClosed => match other { diff --git a/network/src/channel.rs b/network/src/channel.rs index 4fd31f1c21..41650c58a0 100644 --- a/network/src/channel.rs +++ b/network/src/channel.rs @@ -94,7 +94,7 @@ impl Protocols { metrics: Arc, s2s_stop_listening_r: oneshot::Receiver<()>, c2s_protocol_s: mpsc::UnboundedSender, - ) -> std::io::Result<()> { + ) -> io::Result<()> { use socket2::{Domain, Socket, Type}; let domain = Domain::for_address(addr); let socket2_socket = Socket::new(domain, Type::STREAM, None)?; @@ -109,7 +109,7 @@ impl Protocols { socket2_socket.bind(&socket2_addr)?; socket2_socket.listen(1024)?; let std_listener: std::net::TcpListener = socket2_socket.into(); - let listener = tokio::net::TcpListener::from_std(std_listener)?; + let listener = net::TcpListener::from_std(std_listener)?; trace!(?addr, "Tcp Listener bound"); let mut end_receiver = s2s_stop_listening_r.fuse(); tokio::spawn(async move { @@ -143,7 +143,7 @@ impl Protocols { Ok(()) } - pub(crate) fn new_tcp(stream: tokio::net::TcpStream, metrics: ProtocolMetricCache) -> Self { + pub(crate) fn new_tcp(stream: net::TcpStream, metrics: ProtocolMetricCache) -> Self { let (r, w) = stream.into_split(); let sp = TcpSendProtocol::new(TcpDrain { half: w }, metrics.clone()); let rp = TcpRecvProtocol::new( @@ -453,14 +453,14 @@ impl network_protocol::RecvProtocol for RecvProtocols { #[derive(Debug)] pub enum MpscError { - Send(tokio::sync::mpsc::error::SendError), + Send(mpsc::error::SendError), Recv, } #[cfg(feature = "quic")] #[derive(Debug)] pub enum QuicError { - Send(std::io::Error), + Send(io::Error), Connection(quinn::ConnectionError), Write(quinn::WriteError), Read(quinn::ReadError), @@ -470,8 +470,8 @@ pub enum QuicError { /// Error types for Protocols #[derive(Debug)] pub enum ProtocolsError { - Tcp(std::io::Error), - Udp(std::io::Error), + Tcp(io::Error), + Udp(io::Error), #[cfg(feature = "quic")] Quic(QuicError), Mpsc(MpscError), @@ -527,12 +527,12 @@ impl UnreliableSink for TcpSink { //// MPSC #[derive(Debug)] pub struct MpscDrain { - sender: tokio::sync::mpsc::Sender, + sender: mpsc::Sender, } #[derive(Debug)] pub struct MpscSink { - receiver: tokio::sync::mpsc::Receiver, + receiver: mpsc::Receiver, } #[async_trait] @@ -666,7 +666,7 @@ impl UnreliableSink for QuicSink { let (mut buffer, result, mut recvstream, id) = loop { use futures_util::FutureExt; // first handle all bi streams! - let (a, b) = tokio::select! { + let (a, b) = select! { biased; Some(n) = self.bi.next().fuse() => (Some(n), None), Some(n) = self.recvstreams_r.recv().fuse() => (None, Some(n)), diff --git a/network/src/lib.rs b/network/src/lib.rs index a7da1cf5fc..858d15da20 100644 --- a/network/src/lib.rs +++ b/network/src/lib.rs @@ -44,7 +44,7 @@ //! use veloren_network::{ConnectAddr, ListenAddr, Network, Pid, Promises}; //! //! // Client -//! async fn client(runtime: &Runtime) -> std::result::Result<(), Box> { +//! async fn client(runtime: &Runtime) -> Result<(), Box> { //! sleep(std::time::Duration::from_secs(1)).await; // `connect` MUST be after `listen` //! let client_network = Network::new(Pid::new(), runtime); //! let server = client_network @@ -58,7 +58,7 @@ //! } //! //! // Server -//! async fn server(runtime: &Runtime) -> std::result::Result<(), Box> { +//! async fn server(runtime: &Runtime) -> Result<(), Box> { //! let server_network = Network::new(Pid::new(), runtime); //! server_network //! .listen(ListenAddr::Tcp("127.0.0.1:12345".parse().unwrap())) @@ -71,7 +71,7 @@ //! Ok(()) //! } //! -//! fn main() -> std::result::Result<(), Box> { +//! fn main() -> Result<(), Box> { //! let runtime = Runtime::new().unwrap(); //! runtime.block_on(async { //! let (result_c, result_s) = join!(client(&runtime), server(&runtime),); diff --git a/network/src/message.rs b/network/src/message.rs index f821511450..e9c03c3c07 100644 --- a/network/src/message.rs +++ b/network/src/message.rs @@ -75,7 +75,7 @@ impl Message { /// # use tokio::runtime::Runtime; /// # use std::sync::Arc; /// - /// # fn main() -> std::result::Result<(), Box> { + /// # fn main() -> Result<(), Box> { /// // Create a Network, listen on Port `2300` and wait for a Stream to be opened, then listen on it /// # let runtime = Runtime::new().unwrap(); /// # let network = Network::new(Pid::new(), &runtime); diff --git a/network/src/metrics.rs b/network/src/metrics.rs index 3e160667fd..9e97b4efa8 100644 --- a/network/src/metrics.rs +++ b/network/src/metrics.rs @@ -175,7 +175,7 @@ impl NetworkMetrics { Ok(()) } - pub(crate) fn connect_requests_cache(&self, protocol: &ListenAddr) -> prometheus::IntCounter { + pub(crate) fn connect_requests_cache(&self, protocol: &ListenAddr) -> IntCounter { self.incoming_connections_total .with_label_values(&[protocollisten_name(protocol)]) } diff --git a/network/src/participant.rs b/network/src/participant.rs index 2836b81e65..06f7310582 100644 --- a/network/src/participant.rs +++ b/network/src/participant.rs @@ -474,7 +474,7 @@ impl BParticipant { recv_protocols.is_empty() }; - let mut defered_orphan = DeferredTracer::new(tracing::Level::WARN); + let mut defered_orphan = DeferredTracer::new(Level::WARN); loop { let (event, addp, remp) = select!( @@ -705,7 +705,7 @@ impl BParticipant { .map(|(timeout_time, _)| *timeout_time) .unwrap_or_default(), ); - let timeout = tokio::select! { + let timeout = select! { _ = wait_for_manager() => false, _ = timeout => true, }; @@ -825,7 +825,7 @@ mod tests { watch::Receiver, JoinHandle<()>, ) { - let runtime = Arc::new(tokio::runtime::Runtime::new().unwrap()); + let runtime = Arc::new(Runtime::new().unwrap()); let runtime_clone = Arc::clone(&runtime); let (b2s_prio_statistic_s, b2s_prio_statistic_r) = diff --git a/network/src/scheduler.rs b/network/src/scheduler.rs index 89bb14a580..cc46bf320b 100644 --- a/network/src/scheduler.rs +++ b/network/src/scheduler.rs @@ -402,7 +402,7 @@ impl Scheduler { use network_protocol::InitProtocol; let init_result = protocol .initialize(send_handshake, local_pid, local_secret) - .instrument(tracing::info_span!("handshake", ?cid)) + .instrument(info_span!("handshake", ?cid)) .await; match init_result { Ok((pid, sid, secret)) => { @@ -447,7 +447,7 @@ impl Scheduler { tokio::spawn( bparticipant .run(participant_channels.b2s_prio_statistic_s) - .instrument(tracing::info_span!("remote", ?p)), + .instrument(info_span!("remote", ?p)), ); //create a new channel within BParticipant and wait for it to run let (b2s_create_channel_done_s, b2s_create_channel_done_r) = @@ -516,7 +516,7 @@ impl Scheduler { }, } } - .instrument(tracing::info_span!("")), + .instrument(info_span!("")), ); /*WORKAROUND FOR SPAN NOT TO GET LOST*/ } } diff --git a/network/tests/helper.rs b/network/tests/helper.rs index 517e8ea3a9..acea2434a5 100644 --- a/network/tests/helper.rs +++ b/network/tests/helper.rs @@ -15,11 +15,11 @@ use veloren_network::{ConnectAddr, ListenAddr, Network, Participant, Pid, Promis // sleep time when only internal rust calculations are done #[allow(dead_code)] -pub const SLEEP_INTERNAL: std::time::Duration = std::time::Duration::from_millis(3000); +pub const SLEEP_INTERNAL: Duration = Duration::from_millis(3000); // sleep time when we interact with the system, e.g. actually send TCP/UDP // package #[allow(dead_code)] -pub const SLEEP_EXTERNAL: std::time::Duration = std::time::Duration::from_millis(5000); +pub const SLEEP_EXTERNAL: Duration = Duration::from_millis(5000); #[allow(dead_code)] pub fn setup(tracing: bool, sleep: u64) -> (u64, u64) { diff --git a/network/tests/integration.rs b/network/tests/integration.rs index 473844b31a..7571ff483e 100644 --- a/network/tests/integration.rs +++ b/network/tests/integration.rs @@ -118,7 +118,7 @@ fn stream_simple_udp_3msg() { #[test] #[ignore] -fn tcp_and_udp_2_connections() -> std::result::Result<(), Box> { +fn tcp_and_udp_2_connections() -> Result<(), Box> { let (_, _) = helper::setup(false, 0); let r = Arc::new(Runtime::new().unwrap()); let network = Network::new(Pid::new(), &r); @@ -145,7 +145,7 @@ fn tcp_and_udp_2_connections() -> std::result::Result<(), Box std::result::Result<(), Box> { +fn failed_listen_on_used_ports() -> Result<(), Box> { let (_, _) = helper::setup(false, 0); let r = Arc::new(Runtime::new().unwrap()); let network = Network::new(Pid::new(), &r); @@ -176,7 +176,7 @@ fn failed_listen_on_used_ports() -> std::result::Result<(), Box std::result::Result<(), Box> { +fn api_stream_send_main() -> Result<(), Box> { let (_, _) = helper::setup(false, 0); // Create a Network, listen on Port `1200` and wait for a Stream to be opened, // then answer `Hello World` @@ -205,7 +205,7 @@ fn api_stream_send_main() -> std::result::Result<(), Box> } #[test] -fn api_stream_recv_main() -> std::result::Result<(), Box> { +fn api_stream_recv_main() -> Result<(), Box> { let (_, _) = helper::setup(false, 0); // Create a Network, listen on Port `1220` and wait for a Stream to be opened, // then listen on it diff --git a/plugin/rt/src/lib.rs b/plugin/rt/src/lib.rs index 30d37635e3..31d3498b0d 100644 --- a/plugin/rt/src/lib.rs +++ b/plugin/rt/src/lib.rs @@ -55,7 +55,7 @@ pub fn read_input(ptr: i64, len: i64) -> Result where T: DeserializeOwned, { - let slice = unsafe { ::std::slice::from_raw_parts(from_i64(ptr) as _, from_i64(len) as _) }; + let slice = unsafe { std::slice::from_raw_parts(from_i64(ptr) as _, from_i64(len) as _) }; bincode::deserialize(slice).map_err(|_| "Failed to deserialize function input") } diff --git a/server-cli/src/settings.rs b/server-cli/src/settings.rs index 0ca35bde70..b771a49299 100644 --- a/server-cli/src/settings.rs +++ b/server-cli/src/settings.rs @@ -31,7 +31,7 @@ impl Settings { let mut new_path = path.to_owned(); new_path.pop(); new_path.push("settings.invalid.ron"); - if let Err(e) = std::fs::rename(&path, &new_path) { + if let Err(e) = fs::rename(&path, &new_path) { warn!(?e, ?path, ?new_path, "Failed to rename settings file."); } }, diff --git a/server-cli/src/tui_runner.rs b/server-cli/src/tui_runner.rs index 495164b192..5284dd1891 100644 --- a/server-cli/src/tui_runner.rs +++ b/server-cli/src/tui_runner.rs @@ -100,7 +100,7 @@ impl Tui { }, Ok(_) => { debug!(?line, "basic mode: command entered"); - crate::cli::parse_command(line.trim(), &mut msg_s); + cli::parse_command(line.trim(), &mut msg_s); }, } } diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 32e8f50b27..9d38922a36 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -273,7 +273,7 @@ fn uuid(server: &Server, entity: EcsEntity, descriptor: &str) -> CmdResult .ok_or_else(|| format!("Cannot get player information for {:?}", descriptor)) } -fn real_role(server: &Server, uuid: Uuid, descriptor: &str) -> CmdResult { +fn real_role(server: &Server, uuid: Uuid, descriptor: &str) -> CmdResult { server .editable_settings() .admins @@ -294,7 +294,7 @@ fn uid(server: &Server, target: EcsEntity, descriptor: &str) -> CmdResult { .ok_or_else(|| format!("Cannot get uid for {:?}", descriptor)) } -fn area(server: &mut Server, area_name: &str) -> CmdResult>> { +fn area(server: &mut Server, area_name: &str) -> CmdResult>> { server .state .mut_resource::() @@ -458,13 +458,13 @@ fn handle_drop_all( if let Some(mut inventory) = server .state .ecs() - .write_storage::() + .write_storage::() .get_mut(target) { items = inventory.drain().collect(); } - let mut rng = rand::thread_rng(); + let mut rng = thread_rng(); let item_to_place = items .into_iter() @@ -512,7 +512,7 @@ fn handle_give_item( server .state .ecs() - .write_storage::() + .write_storage::() .get_mut(target) .map(|mut inv| { // NOTE: Deliberately ignores items that couldn't be pushed. @@ -530,7 +530,7 @@ fn handle_give_item( server .state .ecs() - .write_storage::() + .write_storage::() .get_mut(target) .map(|mut inv| { for i in 0..give_amount { @@ -618,7 +618,7 @@ fn handle_make_npc( Err(_err) => return Err(format!("Failed to load entity config: {}", entity_config)), }; - let mut loadout_rng = rand::thread_rng(); + let mut loadout_rng = thread_rng(); for _ in 0..number { let comp::Pos(pos) = position(server, target, "target")?; let entity_info = EntityInfo::at(pos).with_entity_config( @@ -861,7 +861,7 @@ fn handle_home( _action: &ServerChatCommand, ) -> CmdResult<()> { let home_pos = server.state.mut_resource::().0; - let time = *server.state.mut_resource::(); + let time = *server.state.mut_resource::