Merge branch 'xMAC94x/update-toolchain' into 'master'

fix master / update toolchain to `2020-08-15`

See merge request veloren/veloren!1302
This commit is contained in:
Marcel 2020-08-17 10:32:10 +00:00
commit 6d2c4b9c1a
26 changed files with 59 additions and 160 deletions

View File

@ -43,10 +43,7 @@ impl Alignment {
// TODO: Remove this hack // TODO: Remove this hack
pub fn is_friendly_to_players(&self) -> bool { pub fn is_friendly_to_players(&self) -> bool {
match self { matches!(self, Alignment::Npc | Alignment::Tame | Alignment::Owned(_))
Alignment::Npc | Alignment::Tame | Alignment::Owned(_) => true,
_ => false,
}
} }
} }
@ -129,19 +126,9 @@ pub enum Activity {
} }
impl Activity { impl Activity {
pub fn is_follow(&self) -> bool { pub fn is_follow(&self) -> bool { matches!(self, Activity::Follow { .. }) }
match self {
Activity::Follow { .. } => true,
_ => false,
}
}
pub fn is_attack(&self) -> bool { pub fn is_attack(&self) -> bool { matches!(self, Activity::Attack { .. }) }
match self {
Activity::Attack { .. } => true,
_ => false,
}
}
} }
impl Default for Activity { impl Default for Activity {

View File

@ -100,12 +100,7 @@ impl<
} }
impl Body { impl Body {
pub fn is_humanoid(&self) -> bool { pub fn is_humanoid(&self) -> bool { matches!(self, Body::Humanoid(_)) }
match self {
Body::Humanoid(_) => true,
_ => false,
}
}
// Note: this might need to be refined to something more complex for realistic // Note: this might need to be refined to something more complex for realistic
// behavior with less cylindrical bodies (e.g. wolfs) // behavior with less cylindrical bodies (e.g. wolfs)

View File

@ -73,7 +73,7 @@ pub enum CharacterState {
impl CharacterState { impl CharacterState {
pub fn is_wield(&self) -> bool { pub fn is_wield(&self) -> bool {
match self { matches!(self,
CharacterState::Wielding CharacterState::Wielding
| CharacterState::BasicMelee(_) | CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_) | CharacterState::BasicRanged(_)
@ -82,50 +82,34 @@ impl CharacterState {
| CharacterState::BasicBlock | CharacterState::BasicBlock
| CharacterState::LeapMelee(_) | CharacterState::LeapMelee(_)
| CharacterState::SpinMelee(_) | CharacterState::SpinMelee(_)
| CharacterState::ChargedRanged(_) => true, | CharacterState::ChargedRanged(_))
_ => false,
}
} }
pub fn is_attack(&self) -> bool { pub fn is_attack(&self) -> bool {
match self { matches!(self,
CharacterState::BasicMelee(_) CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_) | CharacterState::BasicRanged(_)
| CharacterState::DashMelee(_) | CharacterState::DashMelee(_)
| CharacterState::TripleStrike(_) | CharacterState::TripleStrike(_)
| CharacterState::LeapMelee(_) | CharacterState::LeapMelee(_)
| CharacterState::SpinMelee(_) | CharacterState::SpinMelee(_)
| CharacterState::ChargedRanged(_) => true, | CharacterState::ChargedRanged(_))
_ => false,
}
} }
pub fn is_aimed(&self) -> bool { pub fn is_aimed(&self) -> bool {
match self { matches!(self,
CharacterState::BasicMelee(_) CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_) | CharacterState::BasicRanged(_)
| CharacterState::DashMelee(_) | CharacterState::DashMelee(_)
| CharacterState::TripleStrike(_) | CharacterState::TripleStrike(_)
| CharacterState::BasicBlock | CharacterState::BasicBlock
| CharacterState::LeapMelee(_) | CharacterState::LeapMelee(_)
| CharacterState::ChargedRanged(_) => true, | CharacterState::ChargedRanged(_))
_ => false,
}
} }
pub fn is_block(&self) -> bool { pub fn is_block(&self) -> bool { matches!(self, CharacterState::BasicBlock) }
match self {
CharacterState::BasicBlock => true,
_ => false,
}
}
pub fn is_dodge(&self) -> bool { pub fn is_dodge(&self) -> bool { matches!(self, CharacterState::Roll(_)) }
match self {
CharacterState::Roll(_) => true,
_ => false,
}
}
/// Compares for shallow equality (does not check internal struct equality) /// Compares for shallow equality (does not check internal struct equality)
pub fn same_variant(&self, other: &Self) -> bool { pub fn same_variant(&self, other: &Self) -> bool {

View File

@ -25,10 +25,5 @@ pub enum MatCell {
impl Vox for MatCell { impl Vox for MatCell {
fn empty() -> Self { MatCell::None } fn empty() -> Self { MatCell::None }
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool { matches!(self, MatCell::None) }
match self {
MatCell::None => true,
_ => false,
}
}
} }

View File

@ -201,12 +201,7 @@ impl BlockKind {
} }
} }
pub fn is_fluid(&self) -> bool { pub fn is_fluid(&self) -> bool { matches!(self, BlockKind::Water) }
match self {
BlockKind::Water => true,
_ => false,
}
}
pub fn get_glow(&self) -> Option<u8> { pub fn get_glow(&self) -> Option<u8> {
// TODO: When we have proper volumetric lighting // TODO: When we have proper volumetric lighting

View File

@ -32,12 +32,7 @@ pub enum StructureBlock {
impl Vox for StructureBlock { impl Vox for StructureBlock {
fn empty() -> Self { StructureBlock::None } fn empty() -> Self { StructureBlock::None }
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool { matches!(self, StructureBlock::None) }
match self {
StructureBlock::None => true,
_ => false,
}
}
} }
#[derive(Debug)] #[derive(Debug)]

View File

@ -1,7 +1,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![cfg_attr(test, deny(rust_2018_idioms))] #![cfg_attr(test, deny(rust_2018_idioms))]
#![cfg_attr(test, deny(warnings))] #![cfg_attr(test, deny(warnings))]
#![feature(try_trait, const_if_match)] #![feature(try_trait)]
//! Crate to handle high level networking of messages with different //! Crate to handle high level networking of messages with different
//! requirements and priorities over a number of protocols //! requirements and priorities over a number of protocols

View File

@ -112,25 +112,19 @@ pub(crate) fn partial_eq_bincode(first: &bincode::ErrorKind, second: &bincode::E
bincode::ErrorKind::InvalidBoolEncoding(s) => f == s, bincode::ErrorKind::InvalidBoolEncoding(s) => f == s,
_ => false, _ => false,
}, },
bincode::ErrorKind::InvalidCharEncoding => match *second { bincode::ErrorKind::InvalidCharEncoding => {
bincode::ErrorKind::InvalidCharEncoding => true, matches!(*second, bincode::ErrorKind::InvalidCharEncoding)
_ => false,
}, },
bincode::ErrorKind::InvalidTagEncoding(f) => match *second { bincode::ErrorKind::InvalidTagEncoding(f) => match *second {
bincode::ErrorKind::InvalidTagEncoding(s) => f == s, bincode::ErrorKind::InvalidTagEncoding(s) => f == s,
_ => false, _ => false,
}, },
bincode::ErrorKind::DeserializeAnyNotSupported => match *second { bincode::ErrorKind::DeserializeAnyNotSupported => {
bincode::ErrorKind::DeserializeAnyNotSupported => true, matches!(*second, bincode::ErrorKind::DeserializeAnyNotSupported)
_ => false,
}, },
bincode::ErrorKind::SizeLimit => match *second { bincode::ErrorKind::SizeLimit => matches!(*second, bincode::ErrorKind::SizeLimit),
bincode::ErrorKind::SizeLimit => true, bincode::ErrorKind::SequenceMustHaveLength => {
_ => false, matches!(*second, bincode::ErrorKind::SequenceMustHaveLength)
},
bincode::ErrorKind::SequenceMustHaveLength => match *second {
bincode::ErrorKind::SequenceMustHaveLength => true,
_ => false,
}, },
bincode::ErrorKind::Custom(ref f) => match *second { bincode::ErrorKind::Custom(ref f) => match *second {
bincode::ErrorKind::Custom(ref s) => f == s, bincode::ErrorKind::Custom(ref s) => f == s,

View File

@ -1 +1 @@
nightly-2020-06-22 nightly-2020-08-15

View File

@ -50,17 +50,17 @@ impl Client {
} }
pub fn is_registered(&self) -> bool { pub fn is_registered(&self) -> bool {
match self.client_state { matches!(
ClientState::Registered | ClientState::Spectator | ClientState::Character => true, self.client_state,
_ => false, ClientState::Registered | ClientState::Spectator | ClientState::Character
} )
} }
pub fn is_ingame(&self) -> bool { pub fn is_ingame(&self) -> bool {
match self.client_state { matches!(
ClientState::Spectator | ClientState::Character => true, self.client_state,
_ => false, ClientState::Spectator | ClientState::Character
} )
} }
pub fn allow_state(&mut self, new_state: ClientState) { pub fn allow_state(&mut self, new_state: ClientState) {

View File

@ -33,6 +33,7 @@ pub fn handle_damage(server: &Server, uid: Uid, change: HealthChange) {
/// other players. If the entity that killed it had stats, then give it exp for /// other players. If the entity that killed it had stats, then give it exp for
/// the kill. Experience given is equal to the level of the entity that was /// the kill. Experience given is equal to the level of the entity that was
/// killed times 10. /// killed times 10.
#[allow(clippy::needless_collect)]
pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSource) { pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSource) {
let state = server.state_mut(); let state = server.state_mut();

View File

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

View File

@ -206,6 +206,7 @@ impl StateExt for State {
} }
} }
#[allow(clippy::map_identity)] // TODO: Pending review in #587
fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents) { fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents) {
let (body, stats, inventory, loadout) = components; let (body, stats, inventory, loadout) = components;
// Make sure physics are accepted. // Make sure physics are accepted.

View File

@ -338,7 +338,7 @@ impl<'a> System<'a> for Sys {
.filter(|o| o.get_pos().and_then(&is_near).unwrap_or(true)) .filter(|o| o.get_pos().and_then(&is_near).unwrap_or(true))
.cloned() .cloned()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if outcomes.len() > 0 { if !outcomes.is_empty() {
client.notify(ServerMsg::Outcomes(outcomes)); client.notify(ServerMsg::Outcomes(outcomes));
} }
} }

View File

@ -192,7 +192,7 @@ impl Sys {
}); });
// Give the player a welcome message // Give the player a welcome message
if settings.server_description.len() > 0 { if !settings.server_description.is_empty() {
client.notify( client.notify(
ChatType::CommandInfo ChatType::CommandInfo
.server_msg(settings.server_description.clone()), .server_msg(settings.server_description.clone()),

View File

@ -44,6 +44,7 @@ pub struct AudioFrontend {
listener: Listener, listener: Listener,
} }
#[allow(clippy::same_item_push)] // TODO: Pending review in #587
impl AudioFrontend { impl AudioFrontend {
/// Construct with given device /// Construct with given device
#[allow(clippy::redundant_clone)] // TODO: Pending review in #587 #[allow(clippy::redundant_clone)] // TODO: Pending review in #587

View File

@ -171,11 +171,7 @@ impl CombatEventMapper {
/// ::Equipping to mean the weapon is drawn. This will need updating if the /// ::Equipping to mean the weapon is drawn. This will need updating if the
/// animations change to match the wield_duration associated with the weapon /// animations change to match the wield_duration associated with the weapon
fn weapon_drawn(character: &CharacterState) -> bool { fn weapon_drawn(character: &CharacterState) -> bool {
character.is_wield() character.is_wield() || matches!(character, CharacterState::Equipping { .. })
|| match character {
CharacterState::Equipping { .. } => true,
_ => false,
}
} }
} }

View File

@ -395,10 +395,7 @@ impl<'a> Widget for Chat<'a> {
.widget_input(state.ids.chat_input) .widget_input(state.ids.chat_input)
.presses() .presses()
.key() .key()
.any(|key_press| match key_press.key { .any(|key_press| matches!(key_press.key, Key::Return if !state.input.is_empty()))
Key::Return if !state.input.is_empty() => true,
_ => false,
})
{ {
let msg = state.input.clone(); let msg = state.input.clone();
state.update(|s| { state.update(|s| {

View File

@ -477,10 +477,7 @@ impl Show {
|| self.spell || self.spell
|| self.help || self.help
|| self.intro || self.intro
|| match self.open_windows { || !matches!(self.open_windows, Windows::None)
Windows::None => false,
_ => true,
}
{ {
self.bag = false; self.bag = false;
self.esc_menu = false; self.esc_menu = false;
@ -2453,7 +2450,7 @@ impl Hud {
// conrod eats tabs. Un-eat a tabstop so tab completion can work // conrod eats tabs. Un-eat a tabstop so tab completion can work
if self.ui.ui.global_input().events().any(|event| { if self.ui.ui.global_input().events().any(|event| {
use conrod_core::{event, input}; use conrod_core::{event, input};
match event { matches!(event,
//event::Event::Raw(event::Input::Press(input::Button::Keyboard(input::Key::Tab))) //event::Event::Raw(event::Input::Press(input::Button::Keyboard(input::Key::Tab)))
// => true, // => true,
event::Event::Ui(event::Ui::Press( event::Event::Ui(event::Ui::Press(
@ -2462,9 +2459,7 @@ impl Hud {
button: event::Button::Keyboard(input::Key::Tab), button: event::Button::Keyboard(input::Key::Tab),
.. ..
}, },
)) => true, )))
_ => false,
}
}) { }) {
self.ui self.ui
.ui .ui

View File

@ -43,6 +43,7 @@ impl ParticleMgr {
} }
} }
#[allow(clippy::same_item_push)] // TODO: Pending review in #587
pub fn handle_outcome(&mut self, outcome: &Outcome, scene_data: &SceneData) { pub fn handle_outcome(&mut self, outcome: &Outcome, scene_data: &SceneData) {
let time = scene_data.state.get_time(); let time = scene_data.state.get_time();
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
@ -177,6 +178,7 @@ impl ParticleMgr {
} }
} }
#[allow(clippy::same_item_push)] // TODO: Pending review in #587
fn maintain_boltfirebig_particles(&mut self, scene_data: &SceneData, pos: &Pos) { fn maintain_boltfirebig_particles(&mut self, scene_data: &SceneData, pos: &Pos) {
let time = scene_data.state.get_time(); let time = scene_data.state.get_time();
@ -223,6 +225,7 @@ impl ParticleMgr {
} }
} }
#[allow(clippy::same_item_push)] // TODO: Pending review in #587
fn maintain_boost_particles(&mut self, scene_data: &SceneData) { fn maintain_boost_particles(&mut self, scene_data: &SceneData) {
let state = scene_data.state; let state = scene_data.state;
let ecs = state.ecs(); let ecs = state.ecs();

View File

@ -660,12 +660,7 @@ pub enum AudioOutput {
} }
impl AudioOutput { impl AudioOutput {
pub fn is_enabled(&self) -> bool { pub fn is_enabled(&self) -> bool { !matches!(self, Self::Off) }
match self {
Self::Off => false,
_ => true,
}
}
} }
/// `AudioSettings` controls the volume of different audio subsystems and which /// `AudioSettings` controls the volume of different audio subsystems and which
/// device is used. /// device is used.

View File

@ -30,23 +30,19 @@ impl Event {
} }
pub fn is_keyboard_or_mouse(&self) -> bool { pub fn is_keyboard_or_mouse(&self) -> bool {
match self.0 { matches!(self.0,
Input::Press(_) Input::Press(_)
| Input::Release(_) | Input::Release(_)
| Input::Motion(_) | Input::Motion(_)
| Input::Touch(_) | Input::Touch(_)
| Input::Text(_) => true, | Input::Text(_))
_ => false,
}
} }
pub fn is_keyboard(&self) -> bool { pub fn is_keyboard(&self) -> bool {
match self.0 { matches!(self.0,
Input::Press(Button::Keyboard(_)) Input::Press(Button::Keyboard(_))
| Input::Release(Button::Keyboard(_)) | Input::Release(Button::Keyboard(_))
| Input::Text(_) => true, | Input::Text(_))
_ => false,
}
} }
pub fn new_resize(dims: Vec2<f64>) -> Self { Self(Input::Resize(dims.x, dims.y)) } pub fn new_resize(dims: Vec2<f64>) -> Self { Self(Input::Resize(dims.x, dims.y)) }

View File

@ -111,29 +111,11 @@ pub enum RiverKind {
} }
impl RiverKind { impl RiverKind {
pub fn is_ocean(&self) -> bool { pub fn is_ocean(&self) -> bool { matches!(self, RiverKind::Ocean) }
if let RiverKind::Ocean = *self {
true
} else {
false
}
}
pub fn is_river(&self) -> bool { pub fn is_river(&self) -> bool { matches!(self, RiverKind::River { .. }) }
if let RiverKind::River { .. } = *self {
true
} else {
false
}
}
pub fn is_lake(&self) -> bool { pub fn is_lake(&self) -> bool { matches!(self, RiverKind::Lake { .. }) }
if let RiverKind::Lake { .. } = *self {
true
} else {
false
}
}
} }
impl PartialOrd for RiverKind { impl PartialOrd for RiverKind {

View File

@ -110,6 +110,7 @@ impl MapConfig {
/// into the correct format for a buffer and writes to it. /// into the correct format for a buffer and writes to it.
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587 #[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
#[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587
#[allow(clippy::map_identity)] // TODO: Pending review in #587
#[allow(clippy::many_single_char_names)] #[allow(clippy::many_single_char_names)]
pub fn generate( pub fn generate(
&self, &self,

View File

@ -93,21 +93,9 @@ pub enum StoreyFill {
} }
impl StoreyFill { impl StoreyFill {
fn has_lower(&self) -> bool { fn has_lower(&self) -> bool { matches!(self, StoreyFill::All) }
if let StoreyFill::All = self {
true
} else {
false
}
}
fn has_upper(&self) -> bool { fn has_upper(&self) -> bool { !matches!(self, StoreyFill::None) }
if let StoreyFill::None = self {
false
} else {
true
}
}
} }
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View File

@ -236,10 +236,7 @@ impl Settlement {
let origin = dir.map(|e| (e * 100.0) as i32); let origin = dir.map(|e| (e * 100.0) as i32);
let origin = self let origin = self
.land .land
.find_tile_near(origin, |plot| match plot { .find_tile_near(origin, |plot| matches!(plot, Some(&Plot::Field { .. })))
Some(&Plot::Field { .. }) => true,
_ => false,
})
.unwrap(); .unwrap();
if let Some(path) = self.town.as_ref().and_then(|town| { if let Some(path) = self.town.as_ref().and_then(|town| {
@ -520,7 +517,7 @@ impl Settlement {
.land .land
.get_at_block(wpos - self.origin) .get_at_block(wpos - self.origin)
.plot .plot
.map(|p| if let Plot::Hazard = p { true } else { false }) .map(|p| matches!(p, Plot::Hazard))
.unwrap_or(true), .unwrap_or(true),
..SpawnRules::default() ..SpawnRules::default()
} }