Closed Bug 1921886 Opened 8 months ago Closed 8 months ago

[fog_control] error: creating a shared reference to mutable static is discouraged

Categories

(Data Platform and Tools Graveyard :: Glean Platform, defect)

defect

Tracking

(firefox133 fixed)

RESOLVED FIXED
Tracking Status
firefox133 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

Details

Attachments

(1 file)

A new or expanded lint in rustc nightly (1.83) is catching an error on the use of a static mut:

[task 2024-09-26T21:08:06.606Z] 21:08:06    ERROR -  error: creating a shared reference to mutable static is discouraged
[task 2024-09-26T21:08:06.606Z] 21:08:06     INFO -    --> toolkit/components/glean/src/lib.rs:57:9
[task 2024-09-26T21:08:06.606Z] 21:08:06     INFO -     |
[task 2024-09-26T21:08:06.606Z] 21:08:06     INFO -  57 |         PENDING_BUF.len()
[task 2024-09-26T21:08:06.607Z] 21:08:06     INFO -     |         ^^^^^^^^^^^^^^^^^ shared reference to mutable static
[task 2024-09-26T21:08:06.607Z] 21:08:06     INFO -     |
[task 2024-09-26T21:08:06.607Z] 21:08:06     INFO -     = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
[task 2024-09-26T21:08:06.608Z] 21:08:06     INFO -     = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
[task 2024-09-26T21:08:06.608Z] 21:08:06     INFO -     = note: `-D static-mut-refs` implied by `-D warnings`
[task 2024-09-26T21:08:06.609Z] 21:08:06     INFO -     = help: to override `-D warnings` add `#[allow(static_mut_refs)]`
[task 2024-09-26T21:08:06.609Z] 21:08:06    ERROR -  error: creating a shared reference to mutable static is discouraged
[task 2024-09-26T21:08:06.610Z] 21:08:06     INFO -    --> toolkit/components/glean/src/lib.rs:70:23
[task 2024-09-26T21:08:06.610Z] 21:08:06     INFO -     |
[task 2024-09-26T21:08:06.610Z] 21:08:06     INFO -  70 |     let pending_len = PENDING_BUF.len();
[task 2024-09-26T21:08:06.611Z] 21:08:06     INFO -     |                       ^^^^^^^^^^^^^^^^^ shared reference to mutable static
[task 2024-09-26T21:08:06.611Z] 21:08:06     INFO -     |
[task 2024-09-26T21:08:06.611Z] 21:08:06     INFO -     = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -     = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
[task 2024-09-26T21:08:06.612Z] 21:08:06    ERROR -  error: creating a shared reference to mutable static is discouraged
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -    --> toolkit/components/glean/src/lib.rs:74:35
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -     |
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -  74 |     std::ptr::copy_nonoverlapping(PENDING_BUF.as_ptr(), buf, pending_len);
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -     |                                   ^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -     |
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -     = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
[task 2024-09-26T21:08:06.612Z] 21:08:06     INFO -     = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
[task 2024-09-26T21:08:06.613Z] 21:08:06    ERROR -  error: could not compile `fog_control` (lib) due to 3 previous errors
Blocks: rustc-1.83
Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/1bcde66c13d3 Avoid static-mut-refs warning in fog_control. r=chutten
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Product: Data Platform and Tools → Data Platform and Tools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: