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

Cannot compile when default-features are disabled (false) #359

Closed
FirelightFlagboy opened this issue Jul 4, 2023 · 1 comment · Fixed by #360
Closed

Cannot compile when default-features are disabled (false) #359

FirelightFlagboy opened this issue Jul 4, 2023 · 1 comment · Fixed by #360
Assignees

Comments

@FirelightFlagboy
Copy link

Steps to reproduce

cargo new --lib foo
cd foo
cargo add flate2@1.0.26 --no-default-features
cargo check # or 'cargo build'

The error log I'm getting

cargo checks output
   Compiling flate2 v1.0.26
error[E0433]: failed to resolve: use of undeclared crate or module `miniz_oxide`
 --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:6:5
  |
6 | use miniz_oxide::deflate::core::CompressorOxide;
  |     ^^^^^^^^^^^ use of undeclared crate or module `miniz_oxide`

error[E0433]: failed to resolve: use of undeclared crate or module `miniz_oxide`
 --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:7:5
  |
7 | use miniz_oxide::inflate::stream::InflateState;
  |     ^^^^^^^^^^^ use of undeclared crate or module `miniz_oxide`

error[E0432]: unresolved imports `miniz_oxide`, `miniz_oxide::deflate::core::CompressorOxide`, `miniz_oxide::inflate::stream::InflateState`, `crate::ffi::Backend`, `crate::ffi::Deflate`, `crate::ffi::DeflateBackend`, `crate::ffi::ErrorMessage`, `crate::ffi::Inflate`, `crate::ffi::InflateBackend`
 --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:6:5
  |
6 | use miniz_oxide::deflate::core::CompressorOxide;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | use miniz_oxide::inflate::stream::InflateState;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 | pub use miniz_oxide::*;
  |         ^^^^^^^^^^^ use of undeclared crate or module `miniz_oxide`
  |
 ::: /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:6:24
  |
6 | use crate::ffi::{self, Backend, Deflate, DeflateBackend, ErrorMessage, Inflate, InflateBackend};
  |                        ^^^^^^^  ^^^^^^^  ^^^^^^^^^^^^^^  ^^^^^^^^^^^^  ^^^^^^^  ^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:10:32
   |
10 | pub const MZ_NO_FLUSH: isize = MZFlush::None as isize;
   |                                ^^^^^^^ use of undeclared type `MZFlush`

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:11:37
   |
11 | pub const MZ_PARTIAL_FLUSH: isize = MZFlush::Partial as isize;
   |                                     ^^^^^^^ use of undeclared type `MZFlush`

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:12:34
   |
12 | pub const MZ_SYNC_FLUSH: isize = MZFlush::Sync as isize;
   |                                  ^^^^^^^ use of undeclared type `MZFlush`

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:13:34
   |
13 | pub const MZ_FULL_FLUSH: isize = MZFlush::Full as isize;
   |                                  ^^^^^^^ use of undeclared type `MZFlush`

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:14:30
   |
14 | pub const MZ_FINISH: isize = MZFlush::Finish as isize;
   |                              ^^^^^^^ use of undeclared type `MZFlush`

error[E0433]: failed to resolve: use of undeclared type `DataFormat`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:31:9
   |
31 |         DataFormat::Zlib
   |         ^^^^^^^^^^ use of undeclared type `DataFormat`

error[E0433]: failed to resolve: use of undeclared type `DataFormat`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:33:9
   |
33 |         DataFormat::Raw
   |         ^^^^^^^^^^ use of undeclared type `DataFormat`

error[E0433]: failed to resolve: use of undeclared crate or module `inflate`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:72:19
   |
72 |         let res = inflate::stream::inflate(&mut self.inner, input, output, flush);
   |                   ^^^^^^^ use of undeclared crate or module `inflate`

error[E0433]: failed to resolve: use of undeclared type `MZStatus`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:78:17
   |
78 |                 MZStatus::Ok => Ok(Status::Ok),
   |                 ^^^^^^^^ use of undeclared type `MZStatus`

error[E0433]: failed to resolve: use of undeclared type `MZStatus`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:79:17
   |
79 |                 MZStatus::StreamEnd => Ok(Status::StreamEnd),
   |                 ^^^^^^^^ use of undeclared type `MZStatus`

error[E0433]: failed to resolve: use of undeclared type `MZStatus`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:80:17
   |
80 |                 MZStatus::NeedDict => {
   |                 ^^^^^^^^ use of undeclared type `MZStatus`

error[E0433]: failed to resolve: use of undeclared type `MZError`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:85:17
   |
85 |                 MZError::Buf => Ok(Status::BufError),
   |                 ^^^^^^^ use of undeclared type `MZError`

error[E0433]: failed to resolve: use of undeclared crate or module `deflate`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:149:19
    |
149 |         let res = deflate::stream::deflate(&mut self.inner, input, output, flush);
    |                   ^^^^^^^ use of undeclared crate or module `deflate`

error[E0433]: failed to resolve: use of undeclared type `MZStatus`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:155:17
    |
155 |                 MZStatus::Ok => Ok(Status::Ok),
    |                 ^^^^^^^^ use of undeclared type `MZStatus`

error[E0433]: failed to resolve: use of undeclared type `MZStatus`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:156:17
    |
156 |                 MZStatus::StreamEnd => Ok(Status::StreamEnd),
    |                 ^^^^^^^^ use of undeclared type `MZStatus`

error[E0433]: failed to resolve: use of undeclared type `MZStatus`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:157:17
    |
157 |                 MZStatus::NeedDict => mem::compress_failed(ErrorMessage),
    |                 ^^^^^^^^ use of undeclared type `MZStatus`

error[E0433]: failed to resolve: use of undeclared type `MZError`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:160:17
    |
160 |                 MZError::Buf => Ok(Status::BufError),
    |                 ^^^^^^^ use of undeclared type `MZError`

error[E0412]: cannot find type `DataFormat` in this scope
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:29:43
   |
29 | fn format_from_bool(zlib_header: bool) -> DataFormat {
   |                                           ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `MZ_DEFAULT_WINDOW_BITS` in module `ffi`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:198:59
    |
198 |             inner: Deflate::make(level, zlib_header, ffi::MZ_DEFAULT_WINDOW_BITS as u8),
    |                                                           ^^^^^^^^^^^^^^^^^^^^^^ not found in `ffi`

error[E0425]: cannot find value `MZ_DEFAULT_WINDOW_BITS` in module `ffi`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:368:52
    |
368 |             inner: Inflate::make(zlib_header, ffi::MZ_DEFAULT_WINDOW_BITS as u8),
    |                                                    ^^^^^^^^^^^^^^^^^^^^^^ not found in `ffi`

note: erroneous constant used
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:51:12
   |
51 |     None = ffi::MZ_NO_FLUSH as isize,
   |            ^^^^^^^^^^^^^^^^

note: erroneous constant used
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:60:12
   |
60 |     Sync = ffi::MZ_SYNC_FLUSH as isize,
   |            ^^^^^^^^^^^^^^^^^^

note: erroneous constant used
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:70:15
   |
70 |     Partial = ffi::MZ_PARTIAL_FLUSH as isize,
   |               ^^^^^^^^^^^^^^^^^^^^^

note: erroneous constant used
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:77:12
   |
77 |     Full = ffi::MZ_FULL_FLUSH as isize,
   |            ^^^^^^^^^^^^^^^^^^

note: erroneous constant used
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:83:14
   |
83 |     Finish = ffi::MZ_FINISH as isize,
   |              ^^^^^^^^^^^^^^

note: erroneous constant used
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:94:12
   |
94 |     None = ffi::MZ_NO_FLUSH as isize,
   |            ^^^^^^^^^^^^^^^^

note: erroneous constant used
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:103:12
    |
103 |     Sync = ffi::MZ_SYNC_FLUSH as isize,
    |            ^^^^^^^^^^^^^^^^^^

note: erroneous constant used
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/mem.rs:109:14
    |
109 |     Finish = ffi::MZ_FINISH as isize,
    |              ^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
  --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:70:21
   |
70 |         let flush = MZFlush::new(flush as i32).unwrap();
   |                     ^^^^^^^ use of undeclared type `MZFlush`

error[E0433]: failed to resolve: use of undeclared type `MZFlush`
   --> /home/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.26/src/ffi/rust.rs:148:21
    |
148 |         let flush = MZFlush::new(flush as i32).unwrap();
    |                     ^^^^^^^ use of undeclared type `MZFlush`

Some errors have detailed explanations: E0412, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `flate2` (lib) due to 25 previous errors

Expected behavior

Either:

  • the feature rust_backend should not be a feature since the code expect it

  • An early compile error indicating that I must choose a proper backend

    #[cfg(not(any(feature = "rust_backend", feature = "zlib", feature = "zlib-ng", feature = "zlib-ng-compat")))]
    compile_error!("You need to choose a backend between: rust_backend, zlib, zlib-ng and zlib-ng-compat");
@Byron
Copy link
Member

Byron commented Jul 5, 2023

Thanks for reporting and for researching solutions.

I tried to go with variant 2) and tried to reduce the amount of other errors shown to less than a page so folks have a chance to see the specialised message. It would be truly great if compilation could abort immediately when a compile_error is seen.

@Byron Byron closed this as completed in #360 Jul 6, 2023
CaptainVincent added a commit to CaptainVincent/mysql_async_wasi that referenced this issue Aug 16, 2023
Relative to rust-lang/flate2-rs#359
Users need to actively choose a backend.

Signed-off-by: vincent <vincent@secondstate.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants