Skip to content

Allow raw pointers in SIMD types - #85919

Merged
bors merged 3 commits into
rust-lang:masterfrom
workingjubilee:simd-ptrs-are-valid
Jun 5, 2021
Merged

Allow raw pointers in SIMD types#85919
bors merged 3 commits into
rust-lang:masterfrom
workingjubilee:simd-ptrs-are-valid

Conversation

@workingjubilee

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor

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
Copy Markdown
Member

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

@workingjubilee

workingjubilee commented Jun 2, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
Member

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

Comment thread compiler/rustc_middle/src/ty/sty.rs Outdated
@petrochenkov

Copy link
Copy Markdown
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
Copy Markdown
Member

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

Is this good? workingjubilee@c0ca382

@petrochenkov

Copy link
Copy Markdown
Contributor

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

@programmerjake

Copy link
Copy Markdown
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
Copy Markdown
Member Author

Updated appropriately~ And looks like CI passes!

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jun 3, 2021

Copy link
Copy Markdown
Collaborator

📌 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

bors commented Jun 5, 2021

Copy link
Copy Markdown
Collaborator

⌛ Testing commit d9a5df6 with merge 4e20754...

@bors

bors commented Jun 5, 2021

Copy link
Copy Markdown
Collaborator

☀️ 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