Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Grokmoo committed May 9, 2024
1 parent af773b9 commit 3e5e13c
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sulis_core/src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rlua::{self, UserData, UserDataMethods};
use crate::config::Config;

thread_local! {
static BENCH: RefCell<Vec<Bench>> = RefCell::new(Vec::new());
static BENCH: RefCell<Vec<Bench>> = const { RefCell::new(Vec::new()) };
}

pub fn start_bench(tag: Option<String>) -> Handle {
Expand Down
2 changes: 1 addition & 1 deletion sulis_core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::io::{event::ClickKind, InputActionKind, InputAction, KeyboardEvent};

thread_local! {
static CONFIG: RefCell<Config> = RefCell::new(Config::init());
static OLD_CONFIG: RefCell<Option<Config>> = RefCell::new(None);
static OLD_CONFIG: RefCell<Option<Config>> = const { RefCell::new(None) };
}

lazy_static! {
Expand Down
2 changes: 1 addition & 1 deletion sulis_core/src/io/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::config::{AudioConfig, Config};
use crate::resource::{sound_set::EntryBuilder, ResourceSet};

thread_local! {
static AUDIO_QUEUE: RefCell<Vec<QueueEntry>> = RefCell::new(Vec::new());
static AUDIO_QUEUE: RefCell<Vec<QueueEntry>> = const { RefCell::new(Vec::new()) };
}

#[derive(PartialEq, Eq)]
Expand Down
1 change: 1 addition & 0 deletions sulis_core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ pub fn all_resources<V: ?Sized>(map: &HashMap<String, Rc<V>>) -> Vec<Rc<V>> {
}

pub fn get_resource<V: ?Sized>(id: &str, map: &HashMap<String, Rc<V>>) -> Option<Rc<V>> {
#[allow(clippy::map_clone)]
map.get(id).map(Rc::clone)
}

Expand Down
2 changes: 1 addition & 1 deletion sulis_editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use sulis_core::util::{Offset, Scale};
use sulis_core::widgets::{list_box, Button, ConfirmationWindow, DropDown};

thread_local! {
static EXIT: Cell<bool> = Cell::new(false);
static EXIT: Cell<bool> = const { Cell::new(false) };
}

pub struct EditorControlFlowUpdater {
Expand Down
1 change: 1 addition & 0 deletions sulis_module/src/generator/encounter_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl EncounterParams {
module: &Module,
) -> Result<EncounterParams, Error> {
EncounterParams::build(builder, |id| {
#[allow(clippy::map_clone)]
module.encounters.get(id).map(Rc::clone)
})
}
Expand Down
2 changes: 1 addition & 1 deletion sulis_module/src/generator/maze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Maze {
}

while open_regions.len() > 1 {
let connector = match connectors.get(0) {
let connector = match connectors.first() {
None => break,
Some(conn) => *conn,
};
Expand Down
1 change: 1 addition & 0 deletions sulis_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Sulis. If not, see <http://www.gnu.org/licenses/>

#![allow(clippy::manual_range_contains)]
#![allow(clippy::map_clone)]

#[macro_use]
extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion sulis_state/src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Default for AI {
}

impl AI {
pub fn new() -> AI {
pub const fn new() -> AI {
AI {
ai: None,
next_state: State::Run,
Expand Down
2 changes: 1 addition & 1 deletion sulis_state/src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Default for AnimState {
type BoxedCB = Box<dyn ScriptCallback>;

impl AnimState {
pub fn new() -> AnimState {
pub const fn new() -> AnimState {
AnimState {
no_draw_anims: Vec::new(),
below_anims: Vec::new(),
Expand Down
1 change: 1 addition & 0 deletions sulis_state/src/area_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ impl AreaState {
}

pub fn targeter(&self) -> Option<Rc<RefCell<AreaTargeter>>> {
#[allow(clippy::useless_asref)]
self.targeter.as_ref().map(Rc::clone)
}

Expand Down
15 changes: 8 additions & 7 deletions sulis_state/src/game_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ use crate::{

thread_local! {
static TURN_MANAGER: Rc<RefCell<TurnManager>> = Rc::new(RefCell::new(TurnManager::default()));
static STATE: RefCell<Option<GameState>> = RefCell::new(None);
static AI: RefCell<AI> = RefCell::new(AI::new());
static CLEAR_ANIMS: Cell<bool> = Cell::new(false);
static MODAL_LOCKED: Cell<bool> = Cell::new(false);
static ANIMATIONS: RefCell<AnimState> = RefCell::new(AnimState::new());
static ANIMS_TO_ADD: RefCell<Vec<Anim>> = RefCell::new(Vec::new());
static COMBAT_INACTIVE_TIME: Cell<u32> = Cell::new(0);
static STATE: RefCell<Option<GameState>> = const { RefCell::new(None) };
static AI: RefCell<AI> = const { RefCell::new(AI::new()) };
static CLEAR_ANIMS: Cell<bool> = const { Cell::new(false) };
static MODAL_LOCKED: Cell<bool> = const { Cell::new(false) };
static ANIMATIONS: RefCell<AnimState> = const { RefCell::new(AnimState::new()) };
static ANIMS_TO_ADD: RefCell<Vec<Anim>> = const { RefCell::new(Vec::new()) };
static COMBAT_INACTIVE_TIME: Cell<u32> = const { Cell::new(0) };
}

pub struct GameState {
Expand Down Expand Up @@ -924,6 +924,7 @@ impl GameState {
}

pub fn get_area_state(id: &str) -> Option<Rc<RefCell<AreaState>>> {
#[allow(clippy::map_clone)]
STATE.with(|s| s.borrow().as_ref().unwrap().areas.get(id).map(Rc::clone))
}

Expand Down
1 change: 1 addition & 0 deletions sulis_state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Sulis. If not, see <http://www.gnu.org/licenses/>

#![allow(clippy::type_complexity)]
#![allow(clippy::map_clone)]

#[macro_use]
extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion sulis_state/src/script/script_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sulis_module::{ai::AITemplate, Ability, Item, Module};

thread_local! {
static SCRIPT_CACHE: RefCell<HashMap<String, Rc<ScriptState>>> = RefCell::new(HashMap::new());
static REPORTING: Cell<bool> = Cell::new(true);
static REPORTING: Cell<bool> = const { Cell::new(true) };
}

pub fn setup() -> Result<()> {
Expand Down
1 change: 1 addition & 0 deletions sulis_view/src/character_builder/level_up_finish_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl LevelUpFinishPane {
}

impl BuilderPane for LevelUpFinishPane {
#[allow(clippy::useless_asref)]
fn on_selected(&mut self, builder: &mut CharacterBuilder, widget: Rc<RefCell<Widget>>) {
builder.prev.borrow_mut().state.set_enabled(true);
builder.next.borrow_mut().state.set_enabled(false);
Expand Down

0 comments on commit 3e5e13c

Please sign in to comment.