-
Notifications
You must be signed in to change notification settings - Fork 13.3k
DST syntax #13398
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
DST syntax #13398
Conversation
let arg_tys: Vec<ty::t> = ty::ty_fn_args(ctor_ty).iter().map(|a| *a).collect(); | ||
for i in range(0, args.len()) { | ||
let t = arg_tys.get(i); | ||
// Allow the last field in an enum to be unsized. |
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.
It was not obvious to me why this is allowed. It would be nice to extend this comment explaining why this is allowed. ( @nick29581 thanks for the explaining it to me )
@flaper87 Can you more concretely explain your objection to I think the analogous change, assuming we use the The whole point is that we are making a statement about the types that may implement this trait, not about the trait itself. (i.e. that was @nikomatsakis objection to e.g. I don't see how |
@pnkfelix sorry for the quite vague comment. My concern is about how I believe You also mentioned |
The exact syntax is still open discussion - my preference is also for the Sized? notation. Given that is might take a while to settle on syntax, I would like to land this as is and fix the syntax as a follow-up. |
Addressed @flaper87's comments. r? |
@@ -3379,14 +3432,16 @@ pub fn check_representable(tcx: &ty::ctxt, | |||
/// is representable, but not instantiable. | |||
pub fn check_instantiable(tcx: &ty::ctxt, | |||
sp: Span, | |||
item_id: ast::NodeId) { | |||
item_id: ast::NodeId) -> bool { |
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.
Nit: place return type on next line
This patch passes all compile-fail tests, at least:
|
With more changes |
r=nikomatsakis |
And allow the last field of a struct or variant to be unsized.
Now with proper checking of enums and allows unsized fields as the last field in a struct or variant. This PR only checks passing of unsized types and distinguishing them from sized ones. To be safe we also need to control storage. Closes issues #12969 and #13121, supersedes #13375 (all the discussion there is valid here too).
Fixes rust-lang#13375 I've added the lint next to the other attribute-related ones. Not sure if this is the correct place, since while we are looking after the `packed`-attribute (there is nothing we can do about types defined elsewhere), we are more concerned about the type's representation set by the attribute (instead of "duplicate attributes" and such). The lint simply looks at the attributes themselves without concern for the item-kind, since items where `repr` is not allowed end up in a compile-error anyway. I'm somewhat concerned about the level of noise this lint would cause if/when it goes into stable, although it does _not_ come up in `lintcheck`. ``` changelog: [`repr_packed_without_abi`]: Initial implementation ```
Now with proper checking of enums and allows unsized fields as the last field in a struct or variant. This PR only checks passing of unsized types and distinguishing them from sized ones. To be safe we also need to control storage.
Closes issues #12969 and #13121, supersedes #13375 (all the discussion there is valid here too).