-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
desugaring-based placement-in (just in, no box); take-5 branch #27215
Merged
Merged
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1829fa5
Hack for "unsafety hygiene" -- `push_unsafe!` and `pop_unsafe!`.
pnkfelix 866250c
prototype Placer protocol for unstable overloaded-box and placement-in.
pnkfelix d79bbbc
Revise placement-in expansion to use `push/pop_unsafe` and `move_val_…
pnkfelix b325e4f
Add feature-gates for desugaring-based `box` and placement-`in`.
pnkfelix 75da81e
Change signature for `move_val_init` intrinsic to take `*mut T` for `…
pnkfelix cb5f0b4
Avoid feature-warnings on stage0.
pnkfelix 07afe91
Allow unstable code to be injected by placement-`in` expansion.
pnkfelix 9ca1c61
Instrumentation in effort to understand treatment of `allow_internal_…
pnkfelix bb95235
Factor feature gate tests for box syntax into two separate files.
pnkfelix 4a5fb4b
Add necessary feature gate opt-in for the pushpop_unsafe test.
pnkfelix a9d7997
Update the `intrinsic-move-val.rs` test to reflect its newer signature.
pnkfelix 8046533
Update `issue-14084.rs` test to reflect changes to error output.
pnkfelix e0b4479
Add new feature gate opt-in necessary for `new-box-syntax.rs`.
pnkfelix 9f6f35b
Added support for parsing `in PLACE { BLOCK_CONTENT }`.
pnkfelix 9d6cc05
uncomment feature-gate testing for `in PLACE BLOCK` now that its in t…
pnkfelix a81f88d
Add actual use of the `struct Structure` lying dormant in `new-box-sy…
pnkfelix 7a70034
refine set of allowed warnings in `new-box-syntax.rs` test.
pnkfelix 505cd8a
Add test of placement-in syntax, analogous to `new-box-syntax.rs`
pnkfelix abad7d6
placate `make tidy`.
pnkfelix 1905a49
address review feedback: remove dupe feature opt-in.
pnkfelix 73df224
Review feedback: add unstable marker to Placer API and put in bound t…
pnkfelix 225298c
fix doc-tests by opting into `placement_in_syntax` feature where nece…
pnkfelix 5682e2a
fix pretty printing tests by opting into the features that the expand…
pnkfelix 565df57
Update suggestion from parenthesized-box-expr-message to reflect new …
pnkfelix 44bb0dd
review feedback: Use checked-arith instead of saturated-arith for `pu…
pnkfelix 2d68d09
review feedback: common-subexpression-elim across functions in pushpo…
pnkfelix d066a7b
update compile-fail/pushpop-unsafe-rejects.rs to reflect switch from …
pnkfelix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,10 @@ | |
#![feature(no_std)] | ||
#![feature(nonzero)] | ||
#![feature(optin_builtin_traits)] | ||
#![feature(placement_in_syntax)] | ||
#![feature(raw)] | ||
#![feature(staged_api)] | ||
#![feature(placement_in_syntax)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate feature? (Should we have a lint for this?) |
||
#![feature(unboxed_closures)] | ||
#![feature(unique)] | ||
#![feature(unsafe_no_drop_flag, filling_drop)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you expect
align_of
to return for a trait?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably
align_of
would be bounded by anAligned
trait, a supertrait ofSized
, implemented by all types except traits.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a non-issue because you can't allocate a box for a trait object (or at least, you first allocate a box for the concrete type). I think the use case we were primarily interested in was something like
box [v; n]
wheren
is NOT a compile-time constant. It's not clear how best to handle this (if we should at all), but it might be neat if it worked. (It would allocate enough space for ann
-length array and initialize to 0.) Evaluation order is kind of weird, since you must evaluaten
beforev
-- well, I guess that's not true, since we're going to be copyingv
into each spot, so we could still evaluate thev
first. Anyway, I think that's the only case where it makes sense to allocate a box for an unsized type without having an actual value in hand.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I've been wanting this for ages, but it was blocked on having a placement API at all.
That is correct, you evaluate
v
first, thenn
, then allocaten * sizeof(v)
bytes and only afterwards you can copyv
inton
different slots.You can also do it for trait objects from
Sized
types: you allocate the size of the type, write the typed value in, then save the vtable pointer in the fat pointer without any unsizing step.Direct allocation of unsized types is necessary to construct types that do not allow type-param-based unsizing, such as:
Wouldn't
&str(*b"foo")
be a nice desugaring of"foo"
? Admittedly, it couldn't be exposed everywhere without allowing invalid UTF-8. Unsafe fields/constructors, anyone?