Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C string char type to use portable type c_char. #186

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

Kerilk
Copy link
Contributor

@Kerilk Kerilk commented Dec 19, 2024

Hello,

Building the Vulkan runner failed on my ARM 64 Ubuntu virtual machine with the following error:

error[E0277]: a value of type `Vec<*const i8>` cannot be built from an iterator over elements of type `*const u8`
    --> examples/runners/ash/src/main.rs:319:18
     |
319  |                 .collect();
     |                  ^^^^^^^ value of type `Vec<*const i8>` cannot be built from `std::iter::Iterator<Item=*const u8>`
     |
     = help: the trait `FromIterator<*const u8>` is not implemented for `Vec<*const i8>`
             but trait `FromIterator<*const i8>` is implemented for it
     = help: for that trait implementation, expected `i8`, found `u8`
note: the method call chain might not have had the expected associated types
    --> examples/runners/ash/src/main.rs:318:18
     |
311  |               let layer_names = if options.debug_layer {
     |  _______________________________-
312  | |                 vec![CString::new("VK_LAYER_KHRONOS_validation").unwrap()]
313  | |             } else {
314  | |                 vec![]
315  | |             };
     | |_____________- this expression has type `Vec<CString>`
316  |               let layers_names_raw: Vec<*const i8> = layer_names
317  |                   .iter()
     |                    ------ `Iterator::Item` is `&CString` here
318  |                   .map(|raw_name| raw_name.as_ptr())
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `*const u8` here
note: required by a bound in `collect`
    --> /home/bvideau/.rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1967:19
     |
1967 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`


The c char type is unsigned on this platform.
This patch addresses the issue.

Copy link
Collaborator

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the PR! Looks like you need to run cargo fmt and then I can merge 🤙

@Kerilk
Copy link
Contributor Author

Kerilk commented Dec 21, 2024

Thanks, will do ASAP.

@Kerilk
Copy link
Contributor Author

Kerilk commented Dec 22, 2024

Ok, I pushed an update with my changes through cargo fmt. The issue is it touches other part of the file(s), so I did not stage those other changes. The CI will most probably still fail.

Copy link
Collaborator

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it passed, thanks again!

@LegNeato LegNeato added this pull request to the merge queue Dec 22, 2024
Merged via the queue into Rust-GPU:main with commit 561d2eb Dec 22, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants