initiative-sh / initiative.sh

A web-based command line for game masters
https://initiative.sh/
GNU General Public License v3.0
44 stars 4 forks source link

Fix clippy errors for Rust 1.70.0 #314

Closed ChrisRenfrow closed 1 year ago

ChrisRenfrow commented 1 year ago

Currently the "Code standards" job is failing for new builds with the following three errors:

error: the borrowed expression implements the required traits
  --> core/src/world/demographics.rs:74:43
   |
74 |             let dist = WeightedIndex::new(&weights).unwrap();
   |                                           ^^^^^^^^ help: change this to: `weights`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `-D clippy::needless-borrow` implied by `-D warnings`

    Checking bytes v1.1.0
error: this `impl` can be derived
   --> core/src/world/thing.rs:168:1
    |
168 | / impl Default for ThingRelations {
169 | |     fn default() -> Self {
170 | |         ThingRelations::None
171 | |     }
172 | | }
    | |_^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
    = note: `-D clippy::derivable-impls` implied by `-D warnings`
    = help: remove the manual implementation...
help: ...and instead derive it...
    |
20  + #[derive(Default)]
21  | pub enum ThingRelations {
    |
help: ...and mark the default variant
    |
21  ~     #[default]
22  ~     None,
    |

error: the borrowed expression implements the required traits
   --> core/src/world/word.rs:112:35
    |
112 |     let dist = WeightedIndex::new(&[LAND_ANIMALS.len(), COASTAL_ANIMALS.len()]).unwrap();
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `[LAND_ANIMALS.len(), COASTAL_ANIMALS.len()]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Seems like we should just be able to apply the suggestions without breaking anything. I'll start another PR for this.