-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Dynamically sized types #6308
Comments
accepted for well-defined milestone |
Here is a rough plan I worked out: First snapshot will contain:
Second snapshot will contain
Third sdnapshot
Obviously the last step is a little vague. |
Sounds good. Exciting! There was some talk at the end of last discussion on this about alternatives to adding a full |
@graydon it seems I never responded to you. I had a long response prepared but I guess I closed (or lost?) the tab. Short version: I am open to discussion, but I think that as far as my personal preference goes, I'd prefer to change |
We probably don't want to allow unsizedness ever to "infect" containing types the same way the rest of the builtin bounds can, do we? The hardest case is with type parameters. For example:
and in another file:
edit: In fact, the first case should almost certainly be illegal, due to edit 2: This hints at other places where you'd need to use the |
I think there's three options WRT the first case:
|
I had not expected to allow either |
We'll also need Um... should construction of dynamically-sized vector element types be forbidden, or only construction of values inhabiting such type? What I mean is:
(Likewise for enums, structs, tuples, etc.) |
Consider this pattern:
To make this work we'll have to make the auto-generated impl for Clone and DeepClone have the Sized bound on it. |
OK, I have implemented a basic check for this, and added enough Keep in mind, the check is less strict than it will eventually need to be. It currently prohibits unsized types in function return types, bound locals (including arguments, patterns, and static globals), struct/vector/enum/tuple constructors, and by-value self. It does not yet prohibit referring to impossible types such as Stats:
33.4% function return type
|
Regarding bounds on type definitions: I think we should just permit them, at least builtin bounds (kinds). While not strictly required, it feels like we're working awfully hard to avoid them, and for no particular reason. It's easy enough to enforce the bounds at the creation site. It would also help to address an issue with Drop, because right now it makes no sense to have any bounds at all on the type parameters for a drop impl --- otherwise, what, you only run the dtor if the type parameter is owned? Regarding the statistics, that's great information to have. |
I didn't convert these into percentages, but here they are for the other libraries: libextra stats:
libsyntax stats:
librustc stats:
|
Nominating to change milestone. I feel like this is important enough that it ought to be a priority for 0.8. |
@bstrie We're not really using the 0.8 milestone. Maturity 1 is important as it gets. |
Nominating for close. Dupe of #12938. |
dupe is categorized as P-backcompat-lang and 1.0, so we can indeed close this ticket. |
update FIXME(rust-lang#6298) to point to open issue 15020 update FIXME(rust-lang#6268) to point to RFC 811 update FIXME(rust-lang#10520) to point to RFC 1751 remove FIXME for emscripten issue 4563 and include target in `test_estimate_scaling_factor` remove FIXME(rust-lang#18207) since node_id isn't used for `ref` pattern analysis remove FIXME(rust-lang#6308) since DST was implemented in rust-lang#12938 remove FIXME(rust-lang#2658) since it was decided to not reorganize module remove FIXME(rust-lang#20590) since it was decided to stay conservative with projection types remove FIXME(rust-lang#20297) since it was decided that solving the issue is unnecessary remove FIXME(rust-lang#27086) since closures do correspond to structs now remove FIXME(rust-lang#13846) and enable `function_sections` for windows remove mention of rust-lang#22079 in FIXME(rust-lang#22079) since this is a general FIXME remove FIXME(rust-lang#5074) since the restriction on borrow were lifted
add `internal-lints` feature to enable clippys internal lints (off by default) This PR moves the internal lint tests into a new subdirectory (I couldn't find a different way to compile-time-conditionally exclude them from compiletest) and only builds and tests internal lints if the `internal-lints` feature is enabled. Fixes rust-lang#6306 changelog: put internal lints behind a feature ("internal-lints")
Rollup of 4 pull requests Successful merges: - rust-lang#6308 (add `internal-lints` feature to enable clippys internal lints (off by default)) - rust-lang#6395 (switch Version/VersionReq usages to RustcVersion ) - rust-lang#6402 (Add Collapsible match lint) - rust-lang#6407 (CONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup changelog: rollup
As described here:
http://smallcultfollowing.com/babysteps/blog/2013/04/30/dynamically-sized-types/
Rough notes on the plan:
Thinking about dynamically sized types. What needs to change:
layout (e.g., (ptr, meta))
~[T]
,~str
, `~Trait', etcthe right thing based on the
ty::t
the structure of a pointer, probably a few
by essentially translating in trans from something like
AutoBorrowVec
into the combination ofdatum.deref()
and thendatum.take_ref()
separated from
&
etcSemantic questions:
Modify kindck (probably?) to enforce Sized requirement
We may want to allow kind bounds of type definitions:
struct Foo {
vec: ~[T] <--- we would want to know here that T:Sized
}
or maybe just enforce this bound at use points instead
To be implemented by @pcwalton and @nikomatsakis.
The text was updated successfully, but these errors were encountered: