-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Ability to omit : () on const item declarations
#149738
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
base: main
Are you sure you want to change the base?
Conversation
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.) |
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.
Clippy changes look good to me.
Cool PR in my opinion
|
@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 |
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.