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

Allow raw pointers in SIMD types #85919

Merged
merged 3 commits into from
Jun 5, 2021

Conversation

workingjubilee
Copy link
Contributor

Closes #85915 by loosening the strictness in typechecking and adding a test to guarantee it passes.

This still might be too strict, as references currently do pass monomorphization, but my understanding is that they are not guaranteed to be "scalar" in the same way.

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 2, 2021
@programmerjake
Copy link
Member

what happens when you try to use struct Simd([*mut str; 4])? does it error properly?

@workingjubilee
Copy link
Contributor Author

workingjubilee commented Jun 2, 2021

That likely will produce a monomorphization-time error, which is already reachable via the open-ended Param(_) case. If you can provide test cases for them, I would be happy to follow up and close more issues.

@programmerjake
Copy link
Member

afaict references have exactly the same "scalarness" guarantees as raw pointers -- both of them can be fat pointers (e.g. *const dyn Trait) or thin pointers.

@programmerjake
Copy link
Member

That likely will produce a monomorphization-time error, which is already reachable via the open-ended Param(_) case. If you can provide test cases for them, I would be happy to follow up and close more issues.

submitted a pull request adding the requested test case: workingjubilee#1

@workingjubilee
Copy link
Contributor Author

Ah, I meant if you could find something that does pass and doesn't error... a monomorphization time error (which is currently what happens) is the expected result. It's ugly and undesirable but the status quo, and improving on that is left for later work.

@programmerjake
Copy link
Member

force pushed my pull request since github's working again. added passing test as requested.

@petrochenkov
Copy link
Contributor

@workingjubilee
Could you add a test case for a fat raw pointer - #85919 (comment) ?

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2021
@programmerjake
Copy link
Member

Could you add a test case for a fat raw pointer - #85919 (comment) ?

Is this good? workingjubilee@c0ca382

@petrochenkov
Copy link
Contributor

@programmerjake
I'd add one more case where *mut [u8] is used directly rather than through a type parameter.

@programmerjake
Copy link
Member

@programmerjake
I'd add one more case where *mut [u8] is used directly rather than through a type parameter.

added: workingjubilee@4dbe392

build-fail test for simd type with an element type that's a wide pointer
test for SIMD element type of optional nonnull ptr to extern type
test that wide ptr simd element type of *mut [u8] fails
@workingjubilee workingjubilee added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 2, 2021
@workingjubilee
Copy link
Contributor Author

Updated appropriately~ And looks like CI passes!

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 3, 2021

📌 Commit d9a5df6 has been approved by petrochenkov

@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 Jun 3, 2021
@bors
Copy link
Contributor

bors commented Jun 5, 2021

⌛ Testing commit d9a5df6 with merge 4e20754...

@bors
Copy link
Contributor

bors commented Jun 5, 2021

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 4e20754 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 5, 2021
@bors bors merged commit 4e20754 into rust-lang:master Jun 5, 2021
@rustbot rustbot added this to the 1.54.0 milestone Jun 5, 2021
@workingjubilee workingjubilee deleted the simd-ptrs-are-valid branch October 4, 2021 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustc struggles to recognize legal vectors-of-pointers
6 participants