yoanlcq / vek

Generic 2D-3D math swiss army knife for game engines, with SIMD support and focus on convenience.
https://docs.rs/vek
Apache License 2.0
282 stars 32 forks source link

rgb(a) and image features compile error #56

Closed ksaweryk closed 4 years ago

ksaweryk commented 4 years ago

When I try building vek v0.11.1 with rustc 1.46.0-nightly (0262de554 2020-06-07) with "rgb", "rgba" and "image" features, I get the following errors:

error[E0308]: mismatched types
    --> src/vec.rs:2123:56
     |
2123 |               fn from_slice(slice: &[Self::Subpixel]) -> &Self {
     |                  ----------                              ^^^^^ expected reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2124 |                   assert!(slice.len() >= Self::channel_count() as _);
2125 |                   unsafe { &*(slice.as_ptr() as *const _ as *const Self) };
     |                                                                           - help: consider removing this semicolon
...
3174 | /     vec_impl_all_vecs!{
3175 | |         c
3176 | |         #[repr(C)]
3177 | |     }
     | |_____- in this macro invocation
     |
     = note: expected reference `&vec::repr_c::rgb::Rgb<T>`
                found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2123:56
     |
2123 |               fn from_slice(slice: &[Self::Subpixel]) -> &Self {
     |                  ----------                              ^^^^^ expected reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2124 |                   assert!(slice.len() >= Self::channel_count() as _);
2125 |                   unsafe { &*(slice.as_ptr() as *const _ as *const Self) };
     |                                                                           - help: consider removing this semicolon
...
3185 | /     vec_impl_all_vecs!{
3186 | |         simd
3187 | |         #[repr(simd)]
3188 | |     }
     | |_____- in this macro invocation
     |
     = note: expected reference `&vec::repr_simd::rgb::Rgb<T>`
                found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2127:64
     |
2127 |               fn from_slice_mut(slice: &mut [Self::Subpixel]) -> &mut Self {
     |                  --------------                                  ^^^^^^^^^ expected mutable reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2128 |                   assert!(slice.len() >= Self::channel_count() as _);
2129 |                   unsafe { &mut *(slice.as_mut_ptr() as *mut _ as *mut Self) };
     |                                                                               - help: consider removing this semicolon
...
3174 | /     vec_impl_all_vecs!{
3175 | |         c
3176 | |         #[repr(C)]
3177 | |     }
     | |_____- in this macro invocation
     |
     = note: expected mutable reference `&mut vec::repr_c::rgb::Rgb<T>`
                        found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2127:64
     |
2127 |               fn from_slice_mut(slice: &mut [Self::Subpixel]) -> &mut Self {
     |                  --------------                                  ^^^^^^^^^ expected mutable reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2128 |                   assert!(slice.len() >= Self::channel_count() as _);
2129 |                   unsafe { &mut *(slice.as_mut_ptr() as *mut _ as *mut Self) };
     |                                                                               - help: consider removing this semicolon
...
3185 | /     vec_impl_all_vecs!{
3186 | |         simd
3187 | |         #[repr(simd)]
3188 | |     }
     | |_____- in this macro invocation
     |
     = note: expected mutable reference `&mut vec::repr_simd::rgb::Rgb<T>`
                        found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2225:56
     |
2225 |               fn from_slice(slice: &[Self::Subpixel]) -> &Self {
     |                  ----------                              ^^^^^ expected reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2226 |                   assert!(slice.len() >= Self::channel_count() as _);
2227 |                   unsafe { &*(slice.as_ptr() as *const _ as *const Self) };
     |                                                                           - help: consider removing this semicolon
...
3174 | /     vec_impl_all_vecs!{
3175 | |         c
3176 | |         #[repr(C)]
3177 | |     }
     | |_____- in this macro invocation
     |
     = note: expected reference `&vec::repr_c::rgba::Rgba<T>`
                found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2225:56
     |
2225 |               fn from_slice(slice: &[Self::Subpixel]) -> &Self {
     |                  ----------                              ^^^^^ expected reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2226 |                   assert!(slice.len() >= Self::channel_count() as _);
2227 |                   unsafe { &*(slice.as_ptr() as *const _ as *const Self) };
     |                                                                           - help: consider removing this semicolon
...
3185 | /     vec_impl_all_vecs!{
3186 | |         simd
3187 | |         #[repr(simd)]
3188 | |     }
     | |_____- in this macro invocation
     |
     = note: expected reference `&vec::repr_simd::rgba::Rgba<T>`
                found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2229:64
     |
2229 |               fn from_slice_mut(slice: &mut [Self::Subpixel]) -> &mut Self {
     |                  --------------                                  ^^^^^^^^^ expected mutable reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2230 |                   assert!(slice.len() >= Self::channel_count() as _);
2231 |                   unsafe { &mut *(slice.as_mut_ptr() as *mut _ as *mut Self) };
     |                                                                               - help: consider removing this semicolon
...
3174 | /     vec_impl_all_vecs!{
3175 | |         c
3176 | |         #[repr(C)]
3177 | |     }
     | |_____- in this macro invocation
     |
     = note: expected mutable reference `&mut vec::repr_c::rgba::Rgba<T>`
                        found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> src/vec.rs:2229:64
     |
2229 |               fn from_slice_mut(slice: &mut [Self::Subpixel]) -> &mut Self {
     |                  --------------                                  ^^^^^^^^^ expected mutable reference, found `()`
     |                  |
     |                  implicitly returns `()` as its body has no tail or `return` expression
2230 |                   assert!(slice.len() >= Self::channel_count() as _);
2231 |                   unsafe { &mut *(slice.as_mut_ptr() as *mut _ as *mut Self) };
     |                                                                               - help: consider removing this semicolon
...
3185 | /     vec_impl_all_vecs!{
3186 | |         simd
3187 | |         #[repr(simd)]
3188 | |     }
     | |_____- in this macro invocation
     |
     = note: expected mutable reference `&mut vec::repr_simd::rgba::Rgba<T>`
                        found unit type `()`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Following the compiler help messages and removing semicolons on lines: 2125, 2129, 2227 and 2231 in src/vec.rs seems to mitigate the issue.

yoanlcq commented 4 years ago

Hi,

Thanks for raising this, and sorry for the trouble. A new version, 0.11.2, is available with the fix.

Although my commit closed the issue, feel free to add to the discussion here :)