coeuvre / rust-2048

A 2048 clone with Piston game engine
MIT License
236 stars 40 forks source link

Build fails with error[E0642]: patterns aren't allowed in functions without bodies #38

Open MorgenAnSpyrys opened 1 year ago

MorgenAnSpyrys commented 1 year ago

Terminal output as follows

PowerShell 7.3.1 PS C:\Users\win10laptop\Dev\rust> git clone https://github.com/Coeuvre/rust-2048.git Cloning into 'rust-2048'... remote: Enumerating objects: 358, done. remote: Total 358 (delta 0), reused 0 (delta 0), pack-reused 358 Receiving objects: 100% (358/358), 378.48 KiB 2.44 MiB/s, done. Resolving deltas: 100% (224/224), done. PS C:\Users\win10laptop\Dev\rust> cd .\rust-2048\ PS C:\Users\win10laptop\Dev\rust\rust-2048> cargo run Updating crates.io index Downloaded adler32 v1.2.0
Downloaded linked-hash-map v0.5.6 Downloaded nodrop v0.1.14
Downloaded rand v0.3.14
Downloaded piston v0.27.0
Downloaded gfx_device_gl v0.12.0
Downloaded piston-shaders_graphics2d v0.1.0
Downloaded num_cpus v0.2.13
Downloaded piston-gfx_texture v0.20.0 Downloaded pistoncore-glutin_window v0.33.0 Downloaded piston-texture v0.5.0
Downloaded sdl2 v0.27.3
Downloaded pistoncore-sdl2_window v0.38.0
Downloaded vecmath v0.2.0
Downloaded xml-rs v0.3.4 Downloaded rustc-serialize v0.3.19
Downloaded winapi-build v0.1.1
Downloaded gfx_core v0.5.1 Downloaded lazy_static v0.2.11
Downloaded winapi v0.2.8
Downloaded num-rational v0.1.35
Downloaded gl v0.6.1
Downloaded khronos_api v0.0.8
Downloaded enum_primitive v0.1.0
Downloaded gif v0.9.2
Downloaded winit v0.5.11
Downloaded dwmapi-sys v0.1.0
Downloaded piston2d-graphics v0.19.0 Downloaded interpolation v0.1.0
Downloaded bitflags v0.6.0 Downloaded piston2d-gfx_graphics v0.35.0
Downloaded user32-sys v0.1.2
Downloaded color_quant v1.0.0
Downloaded pistoncore-event_loop v0.27.0
Downloaded shared_library v0.1.5 Downloaded piston-viewport v0.2.0
Downloaded bitflags v0.7.0 Downloaded piston-float v0.2.0
Downloaded rayon v0.4.0
Downloaded pistoncore-window v0.24.0
Downloaded num-integer v0.1.32 Downloaded shell32-sys v0.1.1 Downloaded gl_generator v0.5.2
Downloaded num-traits v0.1.35
Downloaded gdi32-sys v0.1.1
Downloaded pistoncore-input v0.15.0
Downloaded sdl2-sys v0.27.3
Downloaded gfx_gl v0.3.1
Downloaded num v0.1.35
Downloaded glutin v0.7.4
Downloaded log v0.3.6
Downloaded deque v0.3.1
Downloaded stb_truetype v0.2.0
Downloaded time v0.1.35 Downloaded rusttype v0.2.4
Downloaded scoped_threadpool v0.1.7
Downloaded piston2d-opengl_graphics v0.37.0 Downloaded khronos_api v1.0.0
Downloaded jpeg-decoder v0.1.6
Downloaded byteorder v0.4.2
Downloaded num-iter v0.1.32
Downloaded fnv v1.0.4
Downloaded libc v0.2.15
Downloaded gfx v0.13.0
Downloaded draw_state v0.6.0 Downloaded byteorder v1.4.3
Downloaded png v0.6.2
Downloaded deflate v0.7.20
Downloaded byteorder v0.5.3
Downloaded arrayvec v0.4.12 Downloaded read_color v0.1.0
Downloaded shader_version v0.2.1 Downloaded piston-shaders_graphics2d v0.2.1
Downloaded piston_window v0.61.0
Downloaded kernel32-sys v0.2.2
Downloaded inflate v0.1.1
Downloaded image v0.12.4 Downloaded lzw v0.10.0
Downloaded 78 crates (4.9 MB) in 2.70s Compiling bitflags v0.7.0 Compiling winapi-build v0.1.1 Compiling libc v0.2.15 Compiling log v0.3.6 Compiling khronos_api v1.0.0 Compiling num-traits v0.1.35 Compiling piston-float v0.2.0 Compiling winapi v0.2.8 Compiling shader_version v0.2.1 Compiling lazy_static v0.2.11 Compiling byteorder v1.4.3 Compiling bitflags v0.6.0 Compiling xml-rs v0.3.4
Compiling piston-viewport v0.2.0
Compiling rand v0.3.14 Compiling num_cpus v0.2.13 Compiling rustc-serialize v0.3.19 Compiling gdi32-sys v0.1.1 Compiling adler32 v1.2.0 Compiling draw_state v0.6.0 Compiling inflate v0.1.1 error[E0642]: patterns aren't allowed in functions without bodies --> C:\Users\win10laptop.cargo\registry\src\github.com-1ecc6299db9ec823\rustc-serialize-0.3.19\src\serialize.rs:147:45
147 ... &f_name: &str,
^^^^^^^ pattern not allowed in function without body

Compiling kernel32-sys v0.2.2 Compiling user32-sys v0.1.2 Compiling num-integer v0.1.32
Compiling gl_generator v0.5.2
Compiling deque v0.3.1 Compiling num-iter v0.1.32 Compiling shell32-sys v0.1.1 Compiling dwmapi-sys v0.1.0 Compiling num v0.1.35 Compiling rayon v0.4.0 Compiling deflate v0.7.20 For more information about this error, try rustc --explain E0642. Compiling byteorder v0.5.3 Compiling color_quant v1.0.0 error: could not compile rustc-serialize due to previous error warning: build failed, waiting for other jobs to finish... PS C:\Users\win10laptop\Dev\rust\rust-2048> cargo build Compiling rustc-serialize v0.3.19 Compiling kernel32-sys v0.2.2 Compiling gl v0.6.1 Compiling lzw v0.10.0 Compiling arrayvec v0.4.12 Compiling gfx_core v0.5.1 Compiling num-rational v0.1.35 Compiling byteorder v0.4.2 Compiling enum_primitive v0.1.0 Compiling jpeg-decoder v0.1.6 Compiling png v0.6.2 Compiling piston-texture v0.5.0 error[E0642]: patterns aren't allowed in functions without bodies
--> C:\Users\win10laptop.cargo\registry\src\github.com-1ecc6299db9ec823\rustc-serialize-0.3.19\src\serialize.rs:147:45 | 147 | ... &f_name: &str, | ^^^^^^^ pattern not allowed in function without body

Compiling gif v0.9.2 Compiling nodrop v0.1.14 Compiling scoped_threadpool v0.1.7 Compiling stb_truetype v0.2.0 Compiling user32-sys v0.1.2 Compiling image v0.12.4 Compiling shell32-sys v0.1.1 Compiling dwmapi-sys v0.1.0 For more information about this error, try rustc --explain E0642. error: could not compile rustc-serialize due to previous error warning: build failed, waiting for other jobs to finish...

dvnDC commented 1 year ago

I got the same error. rustc --explain E0642 is: Trait methods currently cannot take patterns as arguments.

Erroneous code example:

trait Foo {
    fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
                                //        in trait methods
}

You can instead use a single name for the argument:


trait Foo {
    fn foo(x_and_y: (i32, i32)); // ok!
}
tormol commented 1 year ago

This is a duplicate of #30, which is fixed by #31 or #32.

Deleting Cargo.lock is enough to fix this locally, because cargo then uses a newer version of that dependency.

But that still leaves one with an immediate runtime panic, which is fixed by #40.