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

improve simd_select error message when used with invalid mask type #137851

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

folkertdev
Copy link
Contributor

followup to #137828

This PR improves the error message for an invalid simd_select mask type, and adds testing for simd_scatter and simd_gather being used with invalid mask types.

the simd_masked_load and simd_masked_store intrinsics already generated a better error message:

simd_masked_load(Simd::<u8, 4>([1, 0, 1, 1]), arr.as_ptr(), default);
//~^ ERROR expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type
simd_masked_store(Simd([-1i8; 4]), arr.as_ptr(), Simd([5u32; 4]));
//~^ ERROR expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*mut u32`
simd_masked_store(Simd([-1i8; 4]), arr.as_ptr(), Simd([5u8; 4]));
//~^ ERROR expected element type `u8` of second argument `*const u8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*mut u8`
simd_masked_store(Simd([-1i8; 4]), arr.as_mut_ptr(), Simd([5u8; 2]));
//~^ ERROR expected third argument with length 4 (same as input type `Simd<i8, 4>`), found `Simd<u8, 2>` with length 2
simd_masked_store(Simd([1u32; 4]), arr.as_mut_ptr(), Simd([5u8; 4]));
//~^ ERROR expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type

r? @workingjubilee

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 1, 2025
Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

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

usually we don't focus much on error messages for intrinsics since they're internal-facing, but these ones are important enough given how many newer contributors wind up encountering them, so I'm happy to see some better diagnostics. thanks!

@workingjubilee
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 1, 2025

📌 Commit 3a6f269 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 1, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 3, 2025
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#137375 (Minor internal comments fix for `BufRead::read_line`)
 - rust-lang#137641 (More precisely document `Global::deallocate()`'s safety.)
 - rust-lang#137755 (doc: update Wasmtime flags)
 - rust-lang#137851 (improve `simd_select` error message when used with invalid mask type)
 - rust-lang#137860 (rustc_target: Add msync target feature and enable it on powerpcspe targets)
 - rust-lang#137871 (fix `RangeBounds::is_empty` documentation)
 - rust-lang#137873 (Disable `f16` on Aarch64 without `neon`)
 - rust-lang#137876 (Adjust triagebot.toml entries for `rustc_mir_build/src/builder/`)
 - rust-lang#137883 (edit mailmap)
 - rust-lang#137886 (`name()` and `trimmed_name()` for `stable_mir::crate_def::DefId`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bb089d7 into rust-lang:master Mar 3, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 3, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 3, 2025
Rollup merge of rust-lang#137851 - folkertdev:simd-intrinsic-mask-signed, r=workingjubilee

improve `simd_select` error message when used with invalid mask type

followup to rust-lang#137828

This PR improves the error message for an invalid `simd_select` mask type, and adds testing for `simd_scatter` and `simd_gather` being used with invalid mask types.

the `simd_masked_load` and `simd_masked_store` intrinsics already generated a better error message:

https://github.com/rust-lang/rust/blob/0c72c0d11adeba449886089c6bd5d48363f7a2cd/tests/ui/simd/masked-load-store-build-fail.rs#L24-L37

r? `@workingjubilee`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants