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

Support non-nightly version of Rust (beta or stable) #8

Closed
iceiix opened this issue Oct 28, 2018 · 2 comments
Closed

Support non-nightly version of Rust (beta or stable) #8

iceiix opened this issue Oct 28, 2018 · 2 comments

Comments

@iceiix
Copy link
Owner

iceiix commented Oct 28, 2018

Steven requires nightly Rust since it uses experimental features. To improve maintainability, would be nice to adapt it to work on either the beta or preferably stable version of Rust.

@iceiix
Copy link
Owner Author

iceiix commented Oct 28, 2018

It uses one experimental feature, in src/main.rs: #![feature(const_fn)]. This feature is coming soon to stable Rust: https://www.reddit.com/r/rust/comments/9msqfn/const_fn_soon_on_stable_rust/, however, removing the feature flag (and testing on nightly-2018-10-24), it is not the full const_fn, because: https://github.com/rust-lang/rust/issues/24111#issuecomment-414385646:

Another thing that came up on Discord are FP operations: We cannot currently guarantee that they will match real hardware. CTFE will follow IEEE exactly, but LLVM/hardware might not.

Instead, a subset of const_fn, called min_const_fn, was enabled. So removing the feature flag:

--- a/src/main.rs
+++ b/src/main.rs
@@ -13,7 +13,6 @@
 // limitations under the License.
 
 #![recursion_limit="300"]
-#![feature(const_fn)]
 
 extern crate sdl2;
 extern crate zip;

causes this compilation failure:

error: trait bounds other than `Sized` on const fn parameters are unstable                                                                                                                                         
  --> src/types/metadata.rs:30:7                                                                                                                                                                                   
   |                                                                                                                                                                                                               
30 | impl <T: MetaValue> MetadataKey<T> {                                                                                                                                                                          
   |       ^                                                                                                                                                                                                       
                                                                                                                                                                                                                   
error: only int, `bool` and `char` operations are stable in const fn                                                                                                                                               
  --> src/world/biome.rs:16:23                                                                                                                                                                                     
   |                                                                                                                                                                                                               
16 |             moisture: m*t,                                                                                                                                                                                    
   |                       ^^^                                                                                                                                                                                     
                                                                                                                                                                                                                   
error: aborting due to 2 previous errors                     

src/world/biome.rs uses const fn to define constant biomes, with temperature and moisture, both floating-point (f64). src/types/metadata.rs uses it to construct MetadataKey from i32 index.

@iceiix
Copy link
Owner Author

iceiix commented Nov 2, 2018

Rust 2018 is coming up, timely to target it.

Would also simplify the installation steps: https://github.com/Thinkofname/steven/wiki/Compiling-and-or-running documents nightly is required.

@iceiix iceiix transferred this issue from iceiix/steven Jan 12, 2019
iceiix added a commit that referenced this issue Feb 2, 2020
* Remove seemingly unneeded const on MetadataKey<T> new

* Change biome temperature/moisture to integer, x100 to remove floating-point so can use within stable 'const fn'

* Remove unstable const_fn feature, now using stable const fn: see https://www.reddit.com/r/rust/comments/9msqfn/const_fn_soon_on_stable_rust/

* Test on Rust beta (awaiting 1.31 release for stable)

* Update readme for beta Rust support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant