Skip to content

include_dir generates function calls that need promotion, leading to issues with Rust 1.79+ #99

@RalfJung

Description

@RalfJung

Apparently, this crate generates code like

Some(include_dir::Dir::new(
        "",
        &[include_dir::DirEntry::File(include_dir::File::new(
            "test_file.txt",
            b"",
        ))],
    ))

It then relies on the part in &[...] to be const-promoted. However, const-promotion of arbitrary function calls is problematic, and in Rust 1.79 it has been limited to only occur in straight-line code, causing compilation failures for some users of this crate.

The intended way to obtain 'static references to things computed by const fn is to make this explicitly const -- either via const { ... } blocks, or (when support for older versions of Rust is required), via explicit const items:

Some(include_dir::Dir::new(
        "",
        {
            const ENTRIES: &'static [DirEntry<'static>] = &[include_dir::DirEntry::File(include_dir::File::new(
                "test_file.txt",
                b"",
            ))];
            ENTRIES
        },
    ))

Would be good to get this crate updated to avoid problems related to promotion of function calls. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions