jmagnuson / linemux

Asynchronous tailing library in Rust
Apache License 2.0
45 stars 12 forks source link

tests fail with --no-default-features #71

Open jonassmedegaard opened 1 year ago

jonassmedegaard commented 1 year ago

Building and testing with option --no-default-features fails like this:

81s   --> src/events.rs:14:5
 81s    |
 81s 14 | use tokio::sync::mpsc;
 81s    |     ^^^^^ use of undeclared crate or module `tokio`
 81s 
 81s error[E0433]: failed to resolve: use of undeclared crate or module `tokio`
 81s   --> src/reader.rs:14:5
 81s    |
 81s 14 | use tokio::fs::{metadata, File};
 81s    |     ^^^^^ use of undeclared crate or module `tokio`
 81s 
 81s error[E0433]: failed to resolve: use of undeclared crate or module `tokio`
 81s   --> src/reader.rs:15:5
 81s    |
 81s 15 | use tokio::io::{AsyncBufReadExt, AsyncSeekExt, BufReader, Lines};
 81s    |     ^^^^^ use of undeclared crate or module `tokio`
 81s 
 81s error[E0599]: no method named `poll_next_line` found for struct `Pin<_>` in the current scope
 81s    --> src/reader.rs:270:63
 81s     |
 81s 270 | ...                   let res = ready!(Pin::new(reader).poll_next_line(cx));
 81s     |                                                         ^^^^^^^^^^^^^^ method not found in `Pin<_>`
 81s 
 81s error[E0277]: the size for values of type `dyn futures_util::Future<Output = Result<std::fs::Metadata, std::io::Error>> + Send + Sync` cannot be known at compilation time
 81s    --> src/reader.rs:484:53
 81s     |
 81s 484 |                         let metadata_fut = Box::pin(metadata(path.clone()));
 81s     |                                            -------- ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
 81s     |                                            |
 81s     |                                            required by a bound introduced by this call
 81s     |
 81s     = help: the trait `Sized` is not implemented for `dyn futures_util::Future<Output = Result<std::fs::Metadata, std::io::Error>> + Send + Sync`
 81s note: required by a bound in `Box::<T>::pin`
 81s 
 81s Some errors have detailed explanations: E0277, E0433, E0599.
 81s For more information about an error, try `rustc --explain E0277`.
 81s error: could not compile `linemux` due to 5 previous errors
jmagnuson commented 10 months ago

Thanks for the report. It's somewhat moot right now since tokio is currently the only supported runtime, but this error is due to the overall desire to support other runtimes like async-std, and cargo's inability to declare that exactly one feature of a set is enabled at build time (likely https://github.com/rust-lang/cargo/issues/2980).

Looking at how sqlx handles this, they expose various facades which panic on execution if no runtime is set (example). That may be a specific design decision, since it should be possible to fail at compile time via compile_error!.