tgstation / rust-g

Rust based libraries for tgstation
MIT License
28 stars 100 forks source link

Clippy unhappy with compiling 3.1.0 on Windows #166

Closed FluffyGhoster closed 7 months ago

FluffyGhoster commented 7 months ago

I am trying to update our (Aurorastation) rust_g version from 2.1.0 (+ some customized additions) to 3.10 (keeping the customized additions we have)

It seems on windows, the compile for the windows platform fails with:

error: initializer for `thread_local` value can be made `const`
  --> src\pathfinder.rs:11:48
   |
11 | static NODES: RefCell<Vec<Option<Rc<Node>>>> = RefCell::new(Vec::new());
   |                                                ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(Vec::new()) }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
   = note: `-D clippy::thread-local-initializer-can-be-made-const` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::thread_local_initializer_can_be_made_const)]`
error: initializer for `thread_local` value can be made `const`
  --> src\redis_pubsub.rs:10:76
   |
10 |     static REQUEST_SENDER: RefCell<Option<flume::Sender<PubSubRequest>>> = RefCell::new(None);
   |                                                                            ^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(None) }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
error: initializer for `thread_local` value can be made `const`
  --> src\redis_pubsub.rs:11:82
   |
11 |     static RESPONSE_RECEIVER: RefCell<Option<flume::Receiver<PubSubResponse>>> = RefCell::new(None);
   |                                                                                  ^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(None) }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
error: initializer for `thread_local` value can be made `const`
 --> src\redis_reliablequeue.rs:7:52
  |
7 |     static REDIS_CLIENT: RefCell<Option<Client>> = RefCell::new(None);
  |                                                    ^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(None) }`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
error: file opened with `create`, but `truncate` behavior not defined
  --> src\unzip.rs:50:14
   |
50 |             .create(true)
   |              ^^^^^^^^^^^^- help: add: `.truncate(true)`
   |
   = help: if you intend to overwrite an existing file entirely, call `.truncate(true)`
   = help: if you instead know that you may want to keep some parts of the old file, call `.truncate(false)`
   = help: alternatively, use `.append(true)` to append to the file instead of overwriting it
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options
   = note: `-D clippy::suspicious-open-options` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::suspicious_open_options)]`

I have also ported over the change made in #165 but without luck; I do not know much if anything about rust, but seeing the same error also happening in #160 it seems Clippy doesn't like some core rust_g code, hence opening this bug report

If I am wrong on the above assumption, please, do feel free to close this and let me know that I did something wrong on my side

optimumtact commented 7 months ago

what version of rust are you compiling with

FluffyGhoster commented 7 months ago

what version of rust are you compiling with

The CI says "info: latest update on 2024-03-21, rust version 1.77.0 (aedd173a2 2024-03-17)"

ZeWaka commented 7 months ago

i have fixed this in current master

FluffyGhoster commented 7 months ago

Seems to be working now, thank you so much!