-
Notifications
You must be signed in to change notification settings - Fork 1.9k
RfC: Use todo!() instead of () for missing fields
#10105
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
Conversation
| "#, | ||
| r#" | ||
| fn some(, b: () ) {} | ||
| fn some(, b: Default::default() ) {} |
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 wrong.
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.
I think that's what the comment above says: FIXME: this is very wrong, but somewhat tricky to fix.
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.
Ye that's the macro at fault, nothing specific to this PR
|
I think it is harded to replace |
|
But with Maybe someone else can tell how he thinks about |
|
We should check if it implements the necessary trait certainly, and ideally also make this a config option as replacing that default path expression is a lot more work than replacing |
|
This should be consitent with Either way, we should extract the code for "come up with default expression for type" into assist/utils, and use that in both places. As to what's that expression is to be, I see the following choices:
I think |
|
@jo-so are you interested in trying to implement this configurably as outlined by matklad? If yes feel free to ask questions here or on zulip, if not that's also fine! |
|
To clarify -- I don't think we need configurability in this case, we should just pick a good choice. I am confident that |
|
I would prefer |
|
XCode has native support for placeholders. (search for placeholder in https://developer.apple.com/documentation/xcode/creating-organizing-and-editing-source-files) They are automatically inserted for arguments when autocompleting. They are saved as Maybe it is possible to emulate it using the javascript api of vscode? Or do lsp replacement inlay hints act as a single selectable entity in vscode? As for the file syntax, while |
|
First random thought on this: why not use todo!() instead? Will look as ugly as Default::default(), but work in (probably) all cases. |
|
I've found a way to do this in Emacs. So, I'm fine with everything even dropping the PR. |
The generated code with `()` doesn't compile in most of the cases. To signal the developer there's something to do, fill in `todo!()`. Because the file *missing_fields.rs* contains the string `todo!()` it needs an exception for the test *check_todo*.
Default::default() instead of () for missing fieldstodo!() instead of () for missing fields
|
bors r+ |
|
changelog fix (first contribution) use |
Most commonly a field of a struct can be initialized with its default value than an empty tuple.