Frommi / miniz_oxide

Rust replacement for miniz
MIT License
168 stars 48 forks source link

Unable to compile using miniz_oxide with 'use of unstable library' errors #57

Closed VerbTheNoun95 closed 4 years ago

VerbTheNoun95 commented 4 years ago

I've been trying to compile a simple script that uses miniz_ozide and am running into a few errors when running cargo build. They mostly look like they're related to the use of unstable library features in deflate. Output below, with the path edited to $HOME.

   Compiling miniz_oxide v0.3.2                                                                                                                                                                                                    
   Compiling rand_chacha v0.1.1                                                                                                                                                                                                    
   Compiling rand_pcg v0.1.2                                                                                                                                                                                                       
   Compiling rand v0.6.5                                                                                                                                                                                                           
   Compiling rustc_version v0.2.3                                                                                                                                                                                                  
   Compiling proc-macro2 v0.4.30                                                                                                                                                                                                   
   Compiling rand_hc v0.1.0                                                                                                                                                                                                        
error[E0658]: use of unstable library feature 'try_from' (see issue #33417)                                                                                                                                                        
 --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:3:5                                                                                                                          
  |                                                                                                                                                                                                                                
3 | use std::convert::TryInto;                                                                                                                                                                                                     
  |     ^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                      

error[E0658]: use of unstable library feature 'try_from' (see issue #33417)                                                                                                                                                        
 --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:6:5                                                                                                                          
  |                                                                                                                                                                                                                                
6 | use std::convert::TryInto;                                                                                                                                                                                                     
  |     ^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                      

error[E0658]: use of unstable library feature 'int_to_from_bytes' (see issue #52963)                                                                                                                                               
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:634:25                                                                                                                     
    |                                                                                                                                                                                                                              
634 |             let bytes = u64::to_le_bytes(self.bit_buffer);                                                                                                                                                                   
    |                         ^^^^^^^^^^^^^^^^                                                                                                                                                                                     

error[E0658]: use of unstable library feature 'try_from' (see issue #33417)                                                                                                                                                        
    --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:1124:52                                                                                                                   
     |                                                                                                                                                                                                                             
1124 |         let bytes: [u8; 4] = self.b.dict[pos..end].try_into().unwrap();                                                                                                                                                     
     |                                                    ^^^^^^^^                                                                                                                                                                 

error[E0658]: use of unstable library feature 'int_to_from_bytes' (see issue #52963)                                                                                                                                               
    --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:1125:9                                                                                                                    
     |                                                                                                                                                                                                                             
1125 |         u32::from_le_bytes(bytes)                                                                                                                                                                                           
     |         ^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                  

error[E0277]: the trait bound `[u8; 4]: std::convert::From<&[u8]>` is not satisfied                                                                                                                                                
    --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:1124:52                                                                                                                   
     |                                                                                                                                                                                                                             
1124 |         let bytes: [u8; 4] = self.b.dict[pos..end].try_into().unwrap();                                                                                                                                                     
     |                                                    ^^^^^^^^ the trait `std::convert::From<&[u8]>` is not implemented for `[u8; 4]`                                                                                          
     |                                                                                                                                                                                                                             
     = note: required because of the requirements on the impl of `std::convert::TryFrom<&[u8]>` for `[u8; 4]`                                                                                                                      
     = note: required because of the requirements on the impl of `std::convert::TryInto<[u8; 4]>` for `&[u8]`                                                                                                                      

error[E0658]: use of unstable library feature 'try_from' (see issue #33417)                                                                                                                                                        
    --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:1133:56                                                                                                                   
     |                                                                                                                                                                                                                             
1133 |         let bytes: [u8; 8] = self.b.dict[pos..pos + 8].try_into().unwrap();                                                                                                                                                 
     |                                                        ^^^^^^^^                                                                                                                                                             

error[E0658]: use of unstable library feature 'int_to_from_bytes' (see issue #52963)                                                                                                                                               
    --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:1134:9                                                                                                                    
     |                                                                                                                                                                                                                             
1134 |         u64::from_le_bytes(bytes)                                                                                                                                                                                           
     |         ^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                  

error[E0277]: the trait bound `[u8; 8]: std::convert::From<&[u8]>` is not satisfied                                                                                                                                                
    --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/deflate/core.rs:1133:56                                                                                                                   
     |                                                                                                                                                                                                                             
1133 |         let bytes: [u8; 8] = self.b.dict[pos..pos + 8].try_into().unwrap();                                                                                                                                                 
     |                                                        ^^^^^^^^ the trait `std::convert::From<&[u8]>` is not implemented for `[u8; 8]`                                                                                      
     |                                                                                                                                                                                                                             
     = note: required because of the requirements on the impl of `std::convert::TryFrom<&[u8]>` for `[u8; 8]`                                                                                                                      
     = note: required because of the requirements on the impl of `std::convert::TryInto<[u8; 8]>` for `&[u8]`                                                                                                                      

error[E0658]: use of unstable library feature 'try_from' (see issue #33417)                                                                                                                                                        
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:342:44                                                                                                                     
    |                                                                                                                                                                                                                              
342 |         let two_bytes = iter.as_ref()[..2].try_into().unwrap();                                                                                                                                                              
    |                                            ^^^^^^^^                                                                                                                                                                          

error[E0658]: use of unstable library feature 'int_to_from_bytes' (see issue #52963)                                                                                                                                               
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:343:9                                                                                                                      
    |                                                                                                                                                                                                                              
343 |         u16::from_le_bytes(two_bytes)                                                                                                                                                                                        
    |         ^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                   

error[E0277]: the trait bound `[u8; 2]: std::convert::From<&[u8]>` is not satisfied                                                                                                                                                
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:342:44                                                                                                                     
    |                                                                                                                                                                                                                              
342 |         let two_bytes = iter.as_ref()[..2].try_into().unwrap();                                                                                                                                                              
    |                                            ^^^^^^^^ the trait `std::convert::From<&[u8]>` is not implemented for `[u8; 2]`                                                                                                   
    |                                                                                                                                                                                                                              
    = note: required because of the requirements on the impl of `std::convert::TryFrom<&[u8]>` for `[u8; 2]`                                                                                                                       
    = note: required because of the requirements on the impl of `std::convert::TryInto<[u8; 2]>` for `&[u8]`                                                                                                                       

error[E0658]: use of unstable library feature 'try_from' (see issue #33417)                                                                                                                                                        
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:357:54                                                                                                                     
    |                                                                                                                                                                                                                              
357 |         let four_bytes: [u8; 4] = iter.as_ref()[..4].try_into().unwrap();                                                                                                                                                    
    |                                                      ^^^^^^^^                                                                                                                                                                

error[E0658]: use of unstable library feature 'int_to_from_bytes' (see issue #52963)                                                                                                                                               
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:358:9                                                                                                                      
    |                                                                                                                                                                                                                              
358 |         u32::from_le_bytes(four_bytes)                                                                                                                                                                                       
    |         ^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                   

error[E0277]: the trait bound `[u8; 4]: std::convert::From<&[u8]>` is not satisfied                                                                                                                                                
   --> $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/miniz_oxide-0.3.2/src/inflate/core.rs:357:54                                                                                                                     
    |                                                                                                                                                                                                                              
357 |         let four_bytes: [u8; 4] = iter.as_ref()[..4].try_into().unwrap();                                                                                                                                                    
    |                                                      ^^^^^^^^ the trait `std::convert::From<&[u8]>` is not implemented for `[u8; 4]`                                                                                         
    |                                                                                                                                                                                                                              
    = note: required because of the requirements on the impl of `std::convert::TryFrom<&[u8]>` for `[u8; 4]`                                                                                                                       
    = note: required because of the requirements on the impl of `std::convert::TryInto<[u8; 4]>` for `&[u8]`                                                                                                                       

   Compiling rand_isaac v0.1.1                                                                                                                                                                                                     
error: aborting due to 15 previous errors                                                                                                                                                                                          

Some errors occurred: E0277, E0658.                                                                                                                                                                                                
For more information about an error, try `rustc --explain E0277`.                                                                                                                                                                  
error: Could not compile `miniz_oxide`.                                                                                                                                                                                            
warning: build failed, waiting for other jobs to finish...
error: build failed
oyvindln commented 4 years ago

TryInto was added in 1.34.0, so that's the minimum required version for the latest versions of miniz_oxide (I'll add a note about it in the readme.). If it's just for testing stuff, and you're stuck with an older version of rust, you can use the 0.2 version of miniz_oxide instead, main change was removal of internal unsafe code.

HeroicKatora commented 4 years ago

@oyvindln Do I understand this correctly, that rustc 1.34 is a minimum required version for the 0.3 release series and that a bump to that required version would only be done as part of a major version (0.4)? Or do intend to reserve the ability to upgrade to newer stable versions in minor versions as well?

VerbTheNoun95 commented 4 years ago

It's 1.31, so that makes sense. Rust isn't managed by my distro's package manager and rustup returns everything up to date. I'll reinstall rust, but it looks like this isn't an issue with the package so I'll close the issue.

oyvindln commented 4 years ago

@HeroicKatora Yeah will update to a new major version if the requirement changes. It's a breaking change after all.