Closed Bug 1674947 Opened 4 years ago Closed 4 years ago

warning: getting the inner pointer of a temporary `CString`

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: glandium, Assigned: glandium)

Details

Attachments

(1 file)

Recent rustc nightlies show this new warning:

warning: getting the inner pointer of a temporary `CString`
  --> xpcom/rust/gtest/nsstring/test.rs:15:56
   |
15 |         GTest_ExpectFailure(CString::new(msg).unwrap().as_ptr());
   |                             -------------------------- ^^^^^^ this pointer will be invalid
   |                             |
   |                             this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
   |
   = note: `#[warn(temporary_cstring_as_ptr)]` on by default
   = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
   = help: for more information, see https://doc.rust-lang.org/reference/destructors.html
Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/2d327d86e598
Fix warning: getting the inner pointer of a temporary `CString`. r=xpcom-reviewers,nika
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: