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

Add code generation for the slice type #1015

Merged
merged 1 commit into from
Mar 11, 2022
Merged

Conversation

philberty
Copy link
Member

This type must respect the layout of the FatPtr type in libcore. Rust
implements slices using Rustc types in libcore and uses a neat trick.

Addresses #849

@philberty philberty added this to the Macro Expansion milestone Mar 11, 2022
@philberty philberty requested a review from CohenArthur March 11, 2022 11:31
@philberty philberty mentioned this pull request Mar 11, 2022
18 tasks
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

This is cool!

This type must respect the layout of the FatPtr type in libcore. Rust
implements slices using Rustc types in libcore and uses a neat trick.

The slice is generated into the FatPtr which contains the pointer and
length of the slice. This is then placed into a union called Repr which
has 3 variants a mutable and immutable pointer to the FatPtr and a final
variant which is the raw FatPtr. This means we can use unsafe access to
the union to gain a pointer to the FatPtr.

Addresses #849
@philberty philberty force-pushed the phil/slice-code-gen-type branch from fa0a153 to 040b2ec Compare March 11, 2022 13:54
@philberty
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 11, 2022

Build succeeded:

@bors bors bot merged commit 8c88e8e into master Mar 11, 2022
@philberty philberty deleted the phil/slice-code-gen-type branch March 14, 2022 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants