Skip to content

Fix warnings picked up by properly configured rust-analyzer#2676

Open
Savestate2A03 wants to merge 1 commit into
HDR-Development:pre-releasefrom
Savestate2A03:bugfix/remove-warnings
Open

Fix warnings picked up by properly configured rust-analyzer#2676
Savestate2A03 wants to merge 1 commit into
HDR-Development:pre-releasefrom
Savestate2A03:bugfix/remove-warnings

Conversation

@Savestate2A03
Copy link
Copy Markdown

While making HDR Development Environment Setup for WSL, I figured out how to properly set up rust-analyzer.

These were the two warnings that were presented to me after doing so:

// ---------------------------------------------------------------
warning: hiding a lifetime that's elided elsewhere is confusing
  --> src/matchup/containers.rs:88:21
   |
88 |     pub fn iter_mut(&mut self) -> CppVectorIteratorMut<T> {
   |                     ^^^^^^^^^     ^^^^^^^^^^^^^^^^^^^^^^^ the same lifetime is hidden here
   |                     |
   |                     the lifetime is elided here
   |
   = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: use `'_` for type paths
   |
88 |     pub fn iter_mut(&mut self) -> CppVectorIteratorMut<'_, T> {
   |                                                        +++
// ---------------------------------------------------------------
warning: transmuting an integer to a pointer creates a pointer without provenance
  --> fighters/common/src/function_hooks/vtables/demon.rs:14:48
   |
14 |         let collision_log: &mut CollisionLog = std::mem::transmute(log);
   |                                                ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
   = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
   = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
   = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
   = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
   = note: `#[warn(integer_to_ptr_transmutes)]` on by default
help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance
   |
14 -         let collision_log: &mut CollisionLog = std::mem::transmute(log);
14 +         let collision_log: &mut CollisionLog = &mut *std::ptr::with_exposed_provenance_mut::<dynamic::ext::CollisionLog>(log);
   |
// ---------------------------------------------------------------

This fixes them

@github-actions
Copy link
Copy Markdown

Download the artifacts for this pull request:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant