Skip to content
Snippets Groups Projects
  • Dmitry Ivanov's avatar
    2952e4bd
    fix: rust 1.78 doesn't like references to `static mut` objects · 2952e4bd
    Dmitry Ivanov authored
    This patch fixes a couple of warnings that look like this:
    
    ```
    warning: creating a shared reference to mutable static is discouraged
      --> src/error_injection.rs:23:43
       |
    23 |     let Some(injected_errors) = (unsafe { &INJECTED_ERRORS }) else {
       |                                           ^^^^^^^^^^^^^^^^ shared reference to mutable static
       |
       = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
       = note: this will be a hard error in the 2024 edition
       = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
    help: use `addr_of!` instead to create a raw pointer
       |
    23 |     let Some(injected_errors) = (unsafe { addr_of!(INJECTED_ERRORS) }) else {
       |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    ```
    2952e4bd
    History
    fix: rust 1.78 doesn't like references to `static mut` objects
    Dmitry Ivanov authored
    This patch fixes a couple of warnings that look like this:
    
    ```
    warning: creating a shared reference to mutable static is discouraged
      --> src/error_injection.rs:23:43
       |
    23 |     let Some(injected_errors) = (unsafe { &INJECTED_ERRORS }) else {
       |                                           ^^^^^^^^^^^^^^^^ shared reference to mutable static
       |
       = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
       = note: this will be a hard error in the 2024 edition
       = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
    help: use `addr_of!` instead to create a raw pointer
       |
    23 |     let Some(injected_errors) = (unsafe { addr_of!(INJECTED_ERRORS) }) else {
       |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    ```
error_injection.rs 2.41 KiB