Skip to content

move temporary_cstring_as_ptr from clippy to rustc #34111

Closed
@oli-obk

Description

@oli-obk

Quoting the docs of the lint:

What it does: This lint checks for getting the inner pointer of a temporary CString.
Why is this bad? The inner pointer of a CString is only valid as long as the CString is alive.

@akademik someone found in a recent discussion that there are hundreds of .unwrap().as_ptr() calls to be found on github (not all of them UB, but many).

I believe this amount of accidental UB is reason enough to add a "new" lint to rustc that prevents misusing this specific easy-to-misuse method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions