Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Conversation

@ac000
Copy link
Member

@ac000 ac000 commented Dec 10, 2024

otel: Disable static_mut_refs warning for nxt_otel_rs_span_tx()

When compiling OTEL support with rustc 1.83.0 we started getting the
following warning

     Compiling otel v0.1.0 (/home/andrew/src/unit/src/otel)
  warning: creating a mutable reference to mutable static is discouraged
    --> src/lib.rs:42:9
     |
  42 |         SPAN_TX.take();
     |         ^^^^^^^^^^^^^^ mutable reference to mutable static
     |
     = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
     = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
     = note: `#[warn(static_mut_refs)]` on by default

  warning: `otel` (lib) generated 1 warning
      Finished `release` profile [optimized] target(s) in 1m 07s

However it *seems* our usage is OK, so we can disable this warning
(which it seems will soon turn into a hard error), fortunately we only
need to disable it for the nxt_otel_rs_span_tx() function.

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

@ac000 ac000 added this to the 1.34 milestone Dec 10, 2024
@ac000 ac000 requested a review from avahahn December 10, 2024 19:06
When compiling OTEL support with rustc 1.83.0 we started getting the
following warning

     Compiling otel v0.1.0 (/home/andrew/src/unit/src/otel)
  warning: creating a mutable reference to mutable static is discouraged
    --> src/lib.rs:42:9
     |
  42 |         SPAN_TX.take();
     |         ^^^^^^^^^^^^^^ mutable reference to mutable static
     |
     = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
     = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
     = note: `#[warn(static_mut_refs)]` on by default

  warning: `otel` (lib) generated 1 warning
      Finished `release` profile [optimized] target(s) in 1m 07s

However it *seems* our usage is OK, so we can disable this warning
(which it seems will soon turn into a hard error), fortunately we only
need to disable it for the nxt_otel_rs_span_tx() function.

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
@ac000
Copy link
Member Author

ac000 commented Dec 10, 2024

Rebased with master

$ git range-diff d2c3763f...f189d393
-:  -------- > 1:  d71ea64c java: update third-party components to their recent versions
1:  d2c3763f = 2:  f189d393 otel: Disable static_mut_refs warning for nxt_otel_rs_span_tx()

@ac000 ac000 merged commit f189d39 into nginx:master Dec 10, 2024
24 checks passed
@ac000 ac000 deleted the otel-dis-warn branch December 10, 2024 23:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants