ZeroNetX / zeronet-rs

Rust Implementation of ZeroNet Protocol
https://zeronet.dev
Other
70 stars 8 forks source link

Build fails on latest nightly toolchain #34

Closed zolagonano closed 1 year ago

zolagonano commented 1 year ago

Seems like drain_filter feature has been renamed to extract_if: https://github.com/rust-lang/rust/issues/43244

Errors:

error[E0635]: unknown feature `drain_filter`
 --> src/main.rs:1:12
  |
1 | #![feature(drain_filter)]
  |            ^^^^^^^^^^^^

error[E0599]: no method named `drain_filter` found for struct `Vec<std::result::Result<(bool, std::string::String, zerucontent::File), core::error::Error>>` in the current scope
   --> src/io/site.rs:329:24
    |
329 |         let errs = res.drain_filter(|res| res.is_err()).collect::<Vec<_>>();
    |                        ^^^^^^^^^^^^ method not found in `Vec<Result<(bool, String, File), Error>>`

error[E0599]: no method named `drain_filter` found for struct `Vec<std::string::String>` in the current scope
   --> src/io/utils.rs:320:11
    |
320 |     peers.drain_filter(|peer| !peer.is_empty()).collect()
    |           ^^^^^^^^^^^^ method not found in `Vec<String>`

error[E0599]: no method named `drain_filter` found for struct `Vec<std::result::Result<bool, core::error::Error>>` in the current scope
   --> src/io/site.rs:232:24
    |
232 |         let errs = res.drain_filter(|res| !res.is_ok()).collect::<Vec<_>>();
    |                        ^^^^^^^^^^^^ method not found in `Vec<Result<bool, Error>>`

error[E0599]: no method named `drain_filter` found for struct `Vec<std::result::Result<zerucontent::Content, core::error::Error>>` in the current scope
   --> src/io/site.rs:243:14
    |
242 |           let errs = content_res
    |  ____________________-
243 | |             .drain_filter(|res| !res.is_ok())
    | |             -^^^^^^^^^^^^ method not found in `Vec<Result<Content, Error>>`
    | |_____________|
    | 

error[E0599]: no method named `drain_filter` found for struct `Vec<std::result::Result<bool, core::error::Error>>` in the current scope
   --> src/io/site.rs:264:24
    |
264 |         let errs = res.drain_filter(|res| !res.is_ok()).collect::<Vec<_>>();
    |                        ^^^^^^^^^^^^ method not found in `Vec<Result<bool, Error>>`

error[E0599]: no method named `drain_filter` found for struct `Vec<IpPort>` in the current scope
  --> src/discovery/mod.rs:44:22
   |
42 |                   let mut _res: Vec<Peer> = res
   |  ___________________________________________-
43 | |                     .unwrap()
44 | |                     .drain_filter(|a| a.port > 1) //consider ips with no port
   | |                     -^^^^^^^^^^^^ method not found in `Vec<IpPort>`
   | |_____________________|
   | 

error: future cannot be sent between threads safely
   --> src/io/site.rs:465:62
    |
465 |       async fn init_download(&mut self) -> Result<bool, Error> {
    |  ______________________________________________________________^
466 | |         if !&self.site_path().is_dir() {
467 | |             fs::create_dir_all(self.site_path()).await?;
468 | |         }
...   |
480 | |         Ok(verified)
481 | |     }
    | |_____^ future created by async block is not `Send`
    |
note: opaque type is declared here
   --> src/io/site.rs:204:44
    |
204 |     async fn download_site_files(&self) -> Result<(), Error> {
    |                                            ^^^^^^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
   --> src/io/site.rs:465:14
    |
465 |     async fn init_download(&mut self) -> Result<bool, Error> {
    |              ^^^^^^^^^^^^^
note: future is not `Send` as it awaits another future which is not `Send`
   --> src/io/site.rs:475:21
    |
475 |             let _ = self.download_site_files().await;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl futures::Future<Output = std::result::Result<(), core::error::Error>>`, which is not `Send`
    = note: required for the cast from `Pin<Box<[async block@src/io/site.rs:465:62: 481:6]>>` to `Pin<Box<(dyn futures::Future<Output = std::result::Result<bool, core::error::Error>> + std::marker::Send + 'async_trait)>>`

error: future cannot be sent between threads safely
   --> src/io/site.rs:465:62
    |
465 |       async fn init_download(&mut self) -> Result<bool, Error> {
    |  ______________________________________________________________^
466 | |         if !&self.site_path().is_dir() {
467 | |             fs::create_dir_all(self.site_path()).await?;
468 | |         }
...   |
480 | |         Ok(verified)
481 | |     }
    | |_____^ future created by async block is not `Send`
    |
note: opaque type is declared here
   --> src/io/site.rs:312:49
    |
312 |     pub async fn check_site_integrity(&self) -> Result<Vec<(String, zerucontent::File)>, Error> {
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
   --> src/io/site.rs:465:14
    |
465 |     async fn init_download(&mut self) -> Result<bool, Error> {
    |              ^^^^^^^^^^^^^
note: future is not `Send` as it awaits another future which is not `Send`
   --> src/io/site.rs:290:27
    |
290 |                 let res = self.check_site_integrity().await?;
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl futures::Future<Output = std::result::Result<Vec<(std::string::String, zerucontent::File)>, core::error::Error>>`, which is not `Send`
    = note: required for the cast from `Pin<Box<[async block@src/io/site.rs:465:62: 481:6]>>` to `Pin<Box<(dyn futures::Future<Output = std::result::Result<bool, core::error::Error>> + std::marker::Send + 'async_trait)>>`

error[E0599]: no method named `drain_filter` found for struct `Vec<std::string::String>` in the current scope
   --> src/io/utils.rs:333:14
    |
333 |     trackers.drain_filter(|peer| !peer.is_empty()).collect()
    |              ^^^^^^^^^^^^ method not found in `Vec<String>`

Some errors have detailed explanations: E0599, E0635.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `zeronet` (bin "zeronet" test) due to 10 previous errors
canewsin commented 1 year ago

Blocked on https://github.com/ZeroNetX/zeronet-rs/issues/36