Skip to content

invalid_from_utf8_unchecked does not fail for include_bytes! #115208

Closed
@oriongonza

Description

@oriongonza

This code should fail if invalid.txt contains invalid UTF-8.

let str = include_bytes!("../invalid.txt");
let str = unsafe { std::str::from_utf8_unchecked(str) };

This should fail as the byte sequence is known at compile time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions