Ability to omit : () on const item declarations#149738
Ability to omit : () on const item declarations#149738GrigorenkoPV wants to merge 5 commits intorust-lang:mainfrom
: () on const item declarations#149738Conversation
This comment has been minimized.
This comment has been minimized.
939012d to
3ecc105
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #149891) made this pull request unmergeable. Please resolve the merge conflicts. |
|
☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts. |
3ecc105 to
97349b8
Compare
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
|
This PR is out of my comfort zone. since you reviewed the previous PR :) (also I suppose this also needs approval from rustfmt and clippy? not sure what is the best course of action here, I will leave it to the next reviewer to judge.) |
|
@joshtriplett @scottmcm at the very least this needs lang approval. Scott seems to have suggested this. I think I'm very much against it: if the plan is to have toplevel |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
If that's the plan, then I'd agree, but I'm skeptical of that plan because that makes them behave differently in different places without any syntax difference. I worry about things no longer doing what people wanted because they move a const block from item context to expression context. My suggestion was as a possible alternative to item-context const blocks. I don't know what overall lang thinks of that. |
|
Then I guess an opinion from T-lang is needed. @rustbot label +I-lang-nominated +S-waiting-on-t-lang -S-waiting-on-author |
constblocks #149226As suggested in #149174 (comment), this PR adds an ability to omit
: ()from const item declarations. If the type is omitted, it defaults to(). This is similar to how function declarations treat-> ().Implementation details:
#![feature(const_items_unit_type_default)]with the same tracking issue as for#![feature(const_block_items)]ast::ConstItem'styis changed fromBox<ast::Ty>intoast::FnRetTy, which is like anOption<Box<Ty>>but with aSpanfor theNonevariant.staticitems with unspecified type still give an error, just as beforeconstitems with an unspecified type no longer give the previous error, but instead demand that you have the new feature enabled and fallback to: ().constitems with no type specified inASTget a()in HIRTODO:
constitem #69396. Maybe instead of falling back to: (), fallback to: _(as it was before) when the feature is not enabled?constblocks #149226FnRetTyor rename it?()" substitution not during AST->HIR, but later on?: ()for static items too? for consistency. despitestatic: ()being kinda useless.