PoiScript / orgize

A Rust library for parsing org-mode files.
https://poiscript.github.io/orgize/
MIT License
277 stars 34 forks source link

Compilation issue from dependency: jetscii v0.4.4 #52

Closed jrhawley closed 2 years ago

jrhawley commented 2 years ago

Hi there,

This is a great library, thanks for all the work you've put into it.

The issue

I'm trying to use this library, but I'm running into a compilation error with one of orgize's dependencies: jetscii. I'm using orgize v0.8.4 in Cargo.toml, and I get this error when trying to compile:

error: generic parameters may not be used in const operations
   --> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/jetscii-0.4.4/src/simd.rs:109:13
    |
109 |             T::CONTROL_BYTE,
    |             ^^^^^^^^^^^^^^^ cannot perform const operation using `T`
    |
    = note: type parameters may not be used in const expressions

error: generic parameters may not be used in const operations
   --> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/jetscii-0.4.4/src/simd.rs:148:13
    |
148 |             T::CONTROL_BYTE,
    |             ^^^^^^^^^^^^^^^ cannot perform const operation using `T`
    |
    = note: type parameters may not be used in const expressions

error: could not compile `jetscii` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

Possible fix

Jetscii has since updated its MSRV to Rust 1.51, and the issue appears fixed in version >= 0.5.0 of the library. When I upgrade the all the package versions in Cargo.toml, and change this line in parse_properties_drawer() from

    let (_, map) = fold_many0(
        parse_node_property,
        PropertiesMap::new(),
        |mut acc: PropertiesMap<_, _>, (name, value)| {
            acc.insert(name.into(), value.into());
            acc
        },
    )(content)?;

to

    let (_, map) = fold_many0(
        parse_node_property,
        PropertiesMap::new,       // no brackets for the `init` parameter in `fold_many0`
        |mut acc: PropertiesMap<_, _>, (name, value)| {
            acc.insert(name.into(), value.into());
            acc
        },
    )(content)?;

Everything compiles after this change. Based on the files I'm trying to parse, this fix works for me.

I'm not sure how version-specific the dependencies are, since I run into other compilation errors when I only upgrade jetscii's version, but not other crates. I'm also not sure how this change fits into the broader context of the rest of the library, so I figured I'd send a PR in the hopes that you might know better.

Thanks again for the library, so far.

PoiScript commented 2 years ago

Sorry for the inconvenience, please upgrade to v0.9.0 which includes the latest version of jetscii. :)