Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to compile on rustc >= 1.41.0 #2

Closed
transkatgirl opened this issue Jun 7, 2020 · 3 comments
Closed

Fails to compile on rustc >= 1.41.0 #2

transkatgirl opened this issue Jun 7, 2020 · 3 comments

Comments

@transkatgirl
Copy link

When running the cargo install hyperbuild command, hyperbuild fails to compile if the user is using a recent version of rustc.

Output (rustc 1.41.0):

    Updating crates.io index
  Installing hyperbuild v0.0.45
   ...
   Compiling hyperbuild v0.0.45
error[E0716]: temporary value dropped while borrowed
   --> /home/katattakd/.cargo/registry/src/github.com-1ecc6299db9ec823/hyperbuild-0.0.45/src/spec/tag/omission.rs:149:86
    |
149 |   pub static CLOSING_TAG_OMISSION_RULES: Map<&'static [u8], &ClosingTagOmissionRule> = phf_map! {
    |  ______________________________________________________________________________________^
150 | |     b"li" => LI_CLOSING_TAG_OMISSION_RULE,
151 | |     b"dt" => DT_CLOSING_TAG_OMISSION_RULE,
152 | |     b"dd" => DD_CLOSING_TAG_OMISSION_RULE,
...   |
163 | |     b"th" => TH_CLOSING_TAG_OMISSION_RULE,
164 | | };
    | | ^
    | | |
    | | creates a temporary which is freed while still in use
    | |_temporary value is freed at the end of this statement
    |   cast requires that borrow lasts for `'static`
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0716]: temporary value dropped while borrowed
   --> /home/katattakd/.cargo/registry/src/github.com-1ecc6299db9ec823/hyperbuild-0.0.45/src/spec/tag/whitespace.rs:51:91
    |
51  |   static TAG_WHITESPACE_MINIFICATION: Map<&'static [u8], &'static WhitespaceMinification> = phf_map! {
    |  ___________________________________________________________________________________________^
52  | |     // Content tags.
53  | |     b"address" => CONTENT,
54  | |     b"audio" => CONTENT,
...   |
159 | |     b"pre" => WHITESPACE_SENSITIVE,
160 | | };
    | | ^
    | | |
    | | creates a temporary which is freed while still in use
    | |_temporary value is freed at the end of this statement
    |   cast requires that borrow lasts for `'static`
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0716]: temporary value dropped while borrowed
    --> /tmp/hyperbuild/debug/build/hyperbuild-eec30dbf52dbad28/out/gen_attrs.rs:7093:42
     |
7093 |   pub static ATTRS: AttrMap = AttrMap::new(phf::phf_map! {
     |  __________________________________________^
7094 | |     b"textrendering" => TEXTRENDERING_ATTR,
7095 | |     b"dx" => DX_ATTR,
7096 | |     b"restart" => RESTART_ATTR,
...    |
7493 | |     b"tablevalues" => TABLEVALUES_ATTR,
7494 | | });
     | | ^- temporary value is freed at the end of this statement
     | | |
     | |_creates a temporary which is freed while still in use
     |   cast requires that borrow lasts for `'static`
     |
     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for moreinfo)

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0716`.
error: failed to compile `hyperbuild v0.0.45`, intermediate artifacts can be found at `/tmp/hyperbuild`

Caused by:
  could not compile `hyperbuild`.

To learn more, run the command again with --verbose.

The above error is the same in newer versions of rust.

Ouput (rustc 1.40.0):

    Updating crates.io index
  Installing hyperbuild v0.0.45
   ...
   Compiling hyperbuild v0.0.45
    Finished release [optimized] target(s) in 2m 21s
  Installing /home/katattakd/.cargo/bin/hyperbuild
   Installed package `hyperbuild v0.0.45` (executable `hyperbuild`)
@wilsonzlin
Copy link
Owner

This seems to be rust-phf/rust-phf#187 which itself is caused by rust-lang/rust#70584. Not sure if we can work around the regression, will take a deeper look later.

@kornelski
Copy link

It looks like it won't be an easy fix in Rust, and it may take a while before it's fixed.

Could you make a release with a regular hashmap in the meantime?

@wilsonzlin
Copy link
Owner

I've switched all usages of phf over to lazy_static with the built in std::collections::Hash{Set,Map} data structures; everything seems to be working OK. It's now building on Rust 1.44.1.

The Python module was also not compiling due to PyO3 needing a newer Rust version, so now it's also working again.

Would like to revisit phf in the future if the bug gets fixed but I think the one-off initialisation costs are probably intangible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants