Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Updates to compile with latest Rust #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

iceiix
Copy link

@iceiix iceiix commented Dec 28, 2020

Summary 🤔

Misc fixes to get Litecraft compiling again. It builds though there are several warnings:

warning: trait objects without an explicit `dyn` are deprecated
  --> src/core/resource_manager/resource.rs:32:45
   |
32 | type Result<T> = std::result::Result<T, Box<error::Error>>;
   |                                             ^^^^^^^^^^^^ help: use `dyn`: `dyn error::Error`
   |
   = note: `#[warn(bare_trait_objects)]` on by default

warning: trait objects without an explicit `dyn` are deprecated
  --> src/core/resource_manager/shader_manager.rs:25:45
   |
25 | type Result<T> = std::result::Result<T, Box<Error>>;
   |                                             ^^^^^ help: use `dyn`: `dyn Error`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/core/resource_manager/mod.rs:88:58
   |
88 |     pub fn font(resource: &Resource) -> Result<Font, Box<Error>> {
   |                                                          ^^^^^ help: use `dyn`: `dyn Error`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/gfx/canvas.rs:84:28
   |
84 |         let mut scene: Box<Scene> = Box::new(LoadingScene::new());
   |                            ^^^^^ help: use `dyn`: `dyn Scene`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/gfx/scene.rs:21:21
   |
21 |     ChangeScene(Box<Scene>),
   |                     ^^^^^ help: use `dyn`: `dyn Scene`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/gfx/shapes.rs:45:57
   |
45 |     pub fn new(display: &Display) -> Result<Shapes, Box<Error>> {
   |                                                         ^^^^^ help: use `dyn`: `dyn Error`

warning: use of deprecated function `std::mem::uninitialized`: use `mem::MaybeUninit` instead
   --> src/gfx/shapes.rs:166:1
    |
166 | implement_vertex!(Vertex3D, position, tex_coords, texture);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated function `std::mem::uninitialized`: use `mem::MaybeUninit` instead
   --> src/gfx/shapes.rs:166:1
    |
166 | implement_vertex!(Vertex3D, position, tex_coords, texture);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated function `std::mem::uninitialized`: use `mem::MaybeUninit` instead
   --> src/gfx/shapes.rs:167:1
    |
167 | implement_vertex!(Vertex2D, position, tex_coords);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: variable does not need to be mutable
   --> src/core/resource_manager/resource.rs:160:17
    |
160 |             let mut file = zipfile.by_name(&self.folder("assets"));
    |                 ----^^^^
    |                 |
    |                 help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

Test plan (required) 😏

Tested with cargo +nightly run, with rustc 1.50.0-nightly. The application begins to load:

Screen Shot 2020-12-28 at 1 32 32 PM

although it soon crashes:

warning: 10 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.23s
     Running `target/debug/litecraft`

  _    _ _                    __ _   
 | |  (_) |_ ___ __ _ _ __ _ / _| |_ 
 | |__| |  _/ -_) _| '_/ _` |  _|  _|
 |____|_|\__\___\__|_| \__,_|_|  \__|

2020-12-28 13:37:32 INFO  [litecraft] Starting Litecraft A1 for Minecraft 1.13.1...
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager] Loading font file '[litecraft:font:default]'
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Starting texture manager...
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::shader_manager] Starting shader manager...
2020-12-28 13:37:32 INFO  [litecraft::gfx::canvas] Starting script engine!
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[litecraft:texture:logo]'.
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::shader_manager] Loaded shader 'noise'
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::shader_manager] Loaded shader 'quad'
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::shader_manager] Loaded shader 'wallpaper'
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::shader_manager] Loaded shader 'logo'
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:panorama_0]'.
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:panorama_4]'.
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:panorama_5]'.
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:panorama_1]'.
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:panorama_3]'.
2020-12-28 13:37:32 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:panorama_2]'.
2020-12-28 13:37:33 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [litecraft:texture:logo] to GPU
2020-12-28 13:37:33 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [litecraft:texture:logo]
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [minecraft:texture:panorama_4] to GPU
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [minecraft:texture:panorama_4]
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [minecraft:texture:panorama_3] to GPU
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [minecraft:texture:panorama_3]
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [minecraft:texture:panorama_0] to GPU
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [minecraft:texture:panorama_0]
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [minecraft:texture:panorama_2] to GPU
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [minecraft:texture:panorama_2]
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [minecraft:texture:panorama_1] to GPU
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [minecraft:texture:panorama_1]
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Uploading texture [minecraft:texture:panorama_5] to GPU
2020-12-28 13:37:34 DEBUG [litecraft::core::resource_manager::texture_manager] Loaded texture [minecraft:texture:panorama_5]
2020-12-28 13:37:34 INFO  [litecraft::scenes::loading] All resources are now loaded, opening main menu
2020-12-28 13:37:34 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:minecraft]'.
2020-12-28 13:37:34 INFO  [litecraft::core::resource_manager::texture_manager] Loading texture '[minecraft:texture:widgets]'.
thread 'main' panicked at 'attempted to leave type `linked_hash_map::Node<u32, rusttype::gpu_cache::Row>` uninitialized, which is invalid', /rustc/d9a105fdd46c926ae606777a46dd90e5b838f92f/library/core/src/mem/mod.rs:659:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d9a105fdd46c926ae606777a46dd90e5b838f92f/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/d9a105fdd46c926ae606777a46dd90e5b838f92f/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/d9a105fdd46c926ae606777a46dd90e5b838f92f/library/core/src/panicking.rs:50:5
   3: core::mem::uninitialized
             at /rustc/d9a105fdd46c926ae606777a46dd90e5b838f92f/library/core/src/mem/mod.rs:659:9
   4: linked_hash_map::LinkedHashMap<K,V,S>::ensure_guard_node
             at /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/linked-hash-map-0.5.1/src/lib.rs:174:52
   5: linked_hash_map::LinkedHashMap<K,V,S>::insert
             at /.cargo/registry/src/github.com-1ecc6299db9ec823/linked-hash-map-0.5.1/src/lib.rs:304:9
   6: rusttype::gpu_cache::Cache::cache_queued
             at /.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.5.2/src/gpu_cache.rs:667:17
   7: conrod::backend::glium::Renderer::fill
             at /.cargo/git/checkouts/conrod-179bd34c00f75633/9097df4/./src/backend/glium.rs:654:21
   8: litecraft::gfx::canvas::Canvas::start
             at ./src/gfx/canvas.rs:125:17
   9: litecraft::main
             at ./src/main.rs:71:5
  10: core::ops::function::FnOnce::call_once
             at /rustc/d9a105fdd46c926ae606777a46dd90e5b838f92f/library/core/src/ops/function.rs:227:5

Closing issues 😉

Fixes #21
Fixes #23
Fixes #28

@iceiix
Copy link
Author

iceiix commented Dec 28, 2020

Screen Shot 2020-12-28 at 1 44 41 PM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant