← Back to context

Comment by pacifika

5 years ago

Didn't build on macos 11.5

``` Compiling sized-chunks v0.6.5 error[E0658]: `if` is not allowed in a `const fn` --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/sized-chunks-0.6.5/src/inline_array/mod.rs:119:5 | 119 | / if element_size == 0 { 120 | | usize::MAX 121 | | } else if element_align <= container_align && host_size > header_size { 122 | | (host_size - header_size) / element_size 123 | | } else { 124 | | 0 // larger alignment can't be guaranteed, so it'd be unsafe to store any elements 125 | | } | |_____^ | = note: for more information, see https://github.com/rust-lang/rust/issues/49146

error[E0658]: `if` is not allowed in a `const fn` --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/sized-chunks-0.6.5/src/inline_array/mod.rs:121:12 | 121 | } else if element_align <= container_align && host_size > header_size { | ____________^ 122 | | (host_size - header_size) / element_size 123 | | } else { 124 | | 0 // larger alignment can't be guaranteed, so it'd be unsafe to store any elements 125 | | } | |_____^ | = note: for more information, see https://github.com/rust-lang/rust/issues/49146

error[E0599]: no associated item named `MAX` found for type `usize` in the current scope --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/sized-chunks-0.6.5/src/inline_array/mod.rs:120:16 | 120 | usize::MAX | ^^^ associated item not found in `usize` | help: you are looking for the module in `std`, not the primitive type | 120 | std::usize::MAX |

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0599, E0658. For more information about an error, try `rustc --explain E0599`. error: could not compile `sized-chunks`. warning: build failed, waiting for other jobs to finish... error: build failed ```

If I had to guess, I'd say you're using a too old versions of rust.

In the future, one will be able to give a nice error when this happen (https://github.com/rust-lang/rust/issues/65262) But now it's true that it can be hard to know what the problem is.

  • Yep, the two missing features are `usize::MAX` (stabilized in Rust 1.43, April 2020), and control flow in const fns (stabilized in Rust 1.46, August 2020).