Skip to content

Truck-Tutorial example code does not compile #69

@PeterDessev

Description

@PeterDessev

The code listed in section 2.1, First Empty Window, in the truck-tutorial page produces the following error in truck-polymesh:

Output of cargo build on code from First Empty Window
Compiling truck-polymesh v0.1.0
error[E0277]: the trait bound `cgmath::point::Point3<f64>: CastIntVector` is not satisfied
   --> C:\Users\Peter\.cargo\registry\src\index.crates.io-6f17d22bba15001f\truck-polymesh-0.1.0\src\healing.rs:82:52
    |
82  |         let vert_map = sub_put_together_same_attrs(&mesh.positions);
    |                        --------------------------- ^^^^^^^^^^^^^^^ the trait `CastIntVector` is not implemented for `cgmath::point::Point3<f64>`
    |                        |
    |                        required by a bound introduced by this call
    |
    = help: the following other types implement trait `CastIntVector`:
              cgmath::Vector2<f64>
              cgmath::Vector3<f64>
              cgmath::Point3<f64>
note: required by a bound in `sub_put_together_same_attrs`
   --> C:\Users\Peter\.cargo\registry\src\index.crates.io-6f17d22bba15001f\truck-polymesh-0.1.0\src\healing.rs:139:42
    |
139 | fn sub_put_together_same_attrs<T: Copy + CastIntVector>(attrs: &[T]) -> Vec<usize> {
    |                                          ^^^^^^^^^^^^^ required by this bound in `sub_put_together_same_attrs`

error[E0277]: the trait bound `cgmath::vector::Vector2<f64>: CastIntVector` is not satisfied
   --> C:\Users\Peter\.cargo\registry\src\index.crates.io-6f17d22bba15001f\truck-polymesh-0.1.0\src\healing.rs:87:54
    |
87  |             let uv_map = sub_put_together_same_attrs(&mesh.uv_coords);
    |                          --------------------------- ^^^^^^^^^^^^^^^ the trait `CastIntVector` is not implemented for `cgmath::vector::Vector2<f64>`
    |                          |
    |                          required by a bound introduced by this call
    |
    = help: the following other types implement trait `CastIntVector`:
              cgmath::Vector2<f64>
              cgmath::Vector3<f64>
              cgmath::Point3<f64>
note: required by a bound in `sub_put_together_same_attrs`
   --> C:\Users\Peter\.cargo\registry\src\index.crates.io-6f17d22bba15001f\truck-polymesh-0.1.0\src\healing.rs:139:42
    |
139 | fn sub_put_together_same_attrs<T: Copy + CastIntVector>(attrs: &[T]) -> Vec<usize> {
    |                                          ^^^^^^^^^^^^^ required by this bound in `sub_put_together_same_attrs`

error[E0277]: the trait bound `cgmath::vector::Vector3<f64>: CastIntVector` is not satisfied
   --> C:\Users\Peter\.cargo\registry\src\index.crates.io-6f17d22bba15001f\truck-polymesh-0.1.0\src\healing.rs:93:56
    |
93  |             let norm_map = sub_put_together_same_attrs(&mesh.normals);
    |                            --------------------------- ^^^^^^^^^^^^^ the trait `CastIntVector` is not implemented for `cgmath::vector::Vector3<f64>`
    |                            |
    |                            required by a bound introduced by this call
    |
    = help: the following other types implement trait `CastIntVector`:
              cgmath::Vector2<f64>
              cgmath::Vector3<f64>
              cgmath::Point3<f64>
note: required by a bound in `sub_put_together_same_attrs`
   --> C:\Users\Peter\.cargo\registry\src\index.crates.io-6f17d22bba15001f\truck-polymesh-0.1.0\src\healing.rs:139:42
    |
139 | fn sub_put_together_same_attrs<T: Copy + CastIntVector>(attrs: &[T]) -> Vec<usize> {
    |                                          ^^^^^^^^^^^^^ required by this bound in `sub_put_together_same_attrs`

   Compiling winit v0.24.0
For more information about this error, try `rustc --explain E0277`.
error: could not compile `truck-polymesh` (lib) due to 3 previous errors

Steps to reproduce

I have so far been able to reproduce this multiple times on the same Windows 10 x64 machine across workspaces and after running cargo clean. I currently don't have access to another Windows machine on which I can test this.

Possible Fixes

The code listed in the truck-tutorial-code v0.1 repository compiles and executes as expected. Updating the code listed in the tutorial to reflect that of the repository would be an easy and quick fix.

Specifically, by changing the Cargo.toml dependencies section to reflect the versions in the truck-tutorial-code v0.1 repository, Rust was able to successfully compile the program on my machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions