amethyst / amethyst-starter-2d

Seed project for 2D games
Other
201 stars 42 forks source link

Doesn't compile out of the box on mac #27

Open FabriceCastel opened 3 years ago

FabriceCastel commented 3 years ago

When I set the project up with the latest stable Rust release and cargo run it, I get 27 errors from lexical-core-0.4.6, it's various flavors of this:

error[E0308]: mismatched types
   --> /Users/fab/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.4.6/src/atof/algorithm/bigcomp.rs:243:55
    |
243 |     let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1);
    |                                                       ^^^^^^^^^^^^^^^ expected `usize`, found `u32`

error[E0277]: no implementation for `usize & u32`
   --> /Users/fab/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.4.6/src/atof/algorithm/bigcomp.rs:243:53
    |
243 |     let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1);
    |                                                     ^ no implementation for `usize & u32`
    |
    = help: the trait `BitAnd<u32>` is not implemented for `usize`

Seems related to https://github.com/rust-lang/rust/issues/81654, which leads me to believe this could be fixed with a dependency update. I'm relatively new to Rust so I haven't been able to fix it locally yet.

milesbxf commented 3 years ago

I just ran into the same issue, thanks for posting this and pointing at the Rust issue. I'm also new to Rust and couldn't figure out how to override the lexical transitive dependency. I then just ran cargo update in the project folder, and it updated lexical-core to 0.4.8, which seems to compile just fine:

$ cargo update
...
Updating lexical v2.2.2 -> v2.2.4
Updating lexical-core v0.4.6 -> v0.4.8
...
kotx commented 3 years ago

I actually ran into this issue on Windows as well. The above solution worked.

ryanisnan commented 3 years ago

This also worked for me on macOS Big Sur 11.5.2.

Xarvalus commented 3 years ago

I actually ran into this issue on Windows as well. The above solution worked.

Me too, the issue title maybe should be changed to generic as both Mac & Windows seems to be affected

alpha2303 commented 3 years ago

I faced the same issue in Linux as well (Pop OS 21.04). Updating the cargo packages via cargo update helped in compiling successfully.

asher-gh commented 2 years ago

After cargo update getting this error

error[E0308]: mismatched types
   --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/view.rs:209:9
    |
205 | extern fn has_marked_text(this: &Object, _sel: Sel) -> BOOL {
    |                                                        ---- expected `bool` because of return type
...
209 |         (marked_text.length() > 0) as i8
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `i8`

error[E0308]: mismatched types
   --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:103:26
    |
103 |             is_zoomed != 0
    |                          ^ expected `bool`, found integer

error[E0308]: mismatched types
   --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:175:57
    |
175 |                 self.window.setFrame_display_(new_rect, 0);
    |                                                         ^ expected `bool`, found integer

   Compiling glyph_brush v0.6.3
error[E0308]: mismatched types
    --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1301:48
     |
1301 |         window.setFrame_display_(current_rect, 0)
     |                                                ^ expected `bool`, found integer

   Compiling laminar v0.3.2
error[E0308]: mismatched types
    --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1308:48
     |
1308 |         window.setFrame_display_(current_rect, 0)
     |                                                ^ expected `bool`, found integer

   Compiling fern v0.6.0
error[E0308]: mismatched types
    --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1325:48
     |
1325 |         window.setFrame_display_(current_rect, 0)
     |                                                ^ expected `bool`, found integer

error[E0308]: mismatched types
    --> /Users/asher/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1332:48
     |
1332 |         window.setFrame_display_(current_rect, 0)
     |                                                ^ expected `bool`, found integer

   Compiling shred v0.10.2
For more information about this error, try `rustc --explain E0308`.
error: could not compile `winit` due to 7 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed
MrLast98 commented 1 year ago

Hey i get this error too! MacOs with M1, installed both via rustup and Brew (with arch -aarm64).

❯ cargo run
   Compiling winit v0.19.5
   Compiling thread_profiler v0.3.0
   Compiling num-complex v0.2.4
   Compiling env_logger v0.7.1
   Compiling colorful v0.2.2
   Compiling tuple_utils v0.3.0
   Compiling rawpointer v0.2.1
   Compiling clang-sys v1.6.1
   Compiling matrixmultiply v0.2.4
   Compiling specs v0.16.1
   Compiling alga v0.9.3
   Compiling rendy-memory v0.4.1
error[E0308]: mismatched types
   --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/view.rs:209:9
    |
205 | extern fn has_marked_text(this: &Object, _sel: Sel) -> BOOL {
    |                                                        ---- expected ``bool`` because of return type
...
209 |         (marked_text.length() > 0) as i8
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected ``bool``, found ``i8``

error[E0308]: mismatched types
   --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:103:26
    |
103 |             is_zoomed != 0
    |             ---------    ^ expected ``bool``, found integer
    |             |
    |             expected because this is ``bool``

error[E0308]: mismatched types
   --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:175:57
    |
175 |                 self.window.setFrame_display_(new_rect, 0);
    |                             -----------------           ^ expected ``bool``, found integer
    |                             |
    |                             arguments to this method are incorrect
    |
note: method defined here
   --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/cocoa-0.18.5/src/appkit.rs:932:15
    |
932 |     unsafe fn setFrame_display_(self, windowFrame: NSRect, display: BO...
    |               ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1301:48
     |
1301 |         window.setFrame_display_(current_rect, 0)
     |                -----------------               ^ expected ``bool``, found integer
     |                |
     |                arguments to this method are incorrect
     |
note: method defined here
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/cocoa-0.18.5/src/appkit.rs:932:15
     |
932  |     unsafe fn setFrame_display_(self, windowFrame: NSRect, display: B...
     |               ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1308:48
     |
1308 |         window.setFrame_display_(current_rect, 0)
     |                -----------------               ^ expected ``bool``, found integer
     |                |
     |                arguments to this method are incorrect
     |
note: method defined here
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/cocoa-0.18.5/src/appkit.rs:932:15
     |
932  |     unsafe fn setFrame_display_(self, windowFrame: NSRect, display: B...
     |               ^^^^^^^^^^^^^^^^^

   Compiling quickcheck v0.9.2
error[E0308]: mismatched types
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1325:48
     |
1325 |         window.setFrame_display_(current_rect, 0)
     |                -----------------               ^ expected ``bool``, found integer
     |                |
     |                arguments to this method are incorrect
     |
note: method defined here
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/cocoa-0.18.5/src/appkit.rs:932:15
     |
932  |     unsafe fn setFrame_display_(self, windowFrame: NSRect, display: B...
     |               ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/macos/window.rs:1332:48
     |
1332 |         window.setFrame_display_(current_rect, 0)
     |                -----------------               ^ expected ``bool``, found integer
     |                |
     |                arguments to this method are incorrect
     |
note: method defined here
    --> /Users/totemfallico/.cargo/registry/src/github.com-1ecc6299db9ec823/cocoa-0.18.5/src/appkit.rs:932:15
     |
932  |     unsafe fn setFrame_display_(self, windowFrame: NSRect, display: B...
     |               ^^^^^^^^^^^^^^^^^

For more information about this error, try ``rustc --explain E0308``.
error: could not compile ``winit`` due to 7 previous errors
warning: build failed, waiting for other jobs to finish...

Tried the above solution, cargo update, cargo run still fails with this same error. I don't think i would have to fix it manually, do it?

sawatzkylindsey commented 9 months ago

Any update on this? I'm trying with amethyst = 1.15.1 on OSX.