dangling_pointers_from_temporaries lint does not warn when as_ptr() result escapes function #139249
Labels
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
L-dangling_pointers_from_temporaries
Lint: dangling_pointers_from_temporaries
L-false-negative
Lint: False negative (should have fired but didn't).
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Consider this basic dangling pointer from a temporary:
It produces a warning. Very good.
However, if instead we have an
Option<&str>
and we use someOption
methods to convert it to a pointer, we no longer get a warning:I believe the closure passed to
map_or
should be triggering the warning: it takesOption<CString>
as an argument, it callsas_ptr()
, it drops theOption<CString>
, and then it makes use of the pointer (to return it).The text was updated successfully, but these errors were encountered: