-
Notifications
You must be signed in to change notification settings - Fork 893
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
Simplify process interface #3764
Conversation
@djc Wow, thank you so much for the hard work! I will definitely find some time to review the patch. OTOH I guess we can put this in 1.28? I really want to make 1.27.1 "patch only". |
I'm fine with holding this back until after 1.27.1 is released, though I also think the risk is pretty limited. |
f452990
to
2e19e1f
Compare
I'm fine in principle with this. there is a similar structure in the fork of |
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.
One nit you can ignore, and a file rename request - we don't use the mod.rs style in rustup.
src/cli/self_update.rs
Outdated
@@ -1340,8 +1340,10 @@ mod tests { | |||
.unwrap() // result | |||
.unwrap() // option | |||
); | |||
|
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.
Not sure this vertical white space helps anything much :)
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.
Personally I find the delineation of larger code blocks to help understand the structure of the code.
src/process/mod.rs
Outdated
@@ -0,0 +1,298 @@ | |||
use std::cell::RefCell; |
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.
please call this file src/process.rs
In terms of when to merge, this will conflict with #3367, which is already ready to merge but also waiting for 1.28 to open. |
I think we're just using upstream version 0.5.4 right now?
This is not actually true:
Personally, I've grown to substantially dislike the style where the parent module root lives in a separate directory from the child modules, since it keeps them farther away in the directory view of IDEs and such, making the code harder to navigate at least for me. I've tried it on several projects after the 2018 edition went stable and have ended up mostly reverting to the earlier style -- and I checked to see that this style is already quite common in the rustup codebase.
Well, it has quite a bit of unaddressed review feedback -- but, I'm happy to let #3367 land before this PR. |
Oh, I missed all that feedaback, will look at it.
Ah, its hangovers we hadn't refactored. We've tended not to make nonfunctional changes for various not particularly good reasons. Happy for us to have a discussion then about what style the project should take, but I've found the opposite - foo.rs means the module file path is always the same, whether or not the module has child modules, or is a leaf itself where a directory with just the module file would be tedious. |
Right. My preference would be to use single files when there are no child modules (in separate files), but I think as soon as we move to a directory it's better to keep everything contained in the same directory -- rather than having the code for a single module spread over two places, one file for the "root" and a directory containing further files for the children. @rami3l any thoughts? |
@djc @rbtcollins You're referring to I do understand that this is a niche, and That being said, I'm eventually okay with either way as long as they are consistent (looks like that isn't the case currently), and BTW we should probably get rid of that |
I've scaled this back a little for now -- it no longer moves the code around and just gets rid of the trait indirection in favor of an enum. |
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.
The latest changes look great!
To be frank, this has really addressed one of my pain points when doing #3803. Thank you so much 🙏
PS: I guess we can have the foo.rs
vs foo/mod.rs
discussion somewhere else, possibly after merging this one.
This makes the
Process
abstraction much easier to understand (in my opinion) by avoiding a trait abstraction (which had only a single implementation) and explicitly relying on the enum variants. Removes 250 lines of code and the need for the enum-dispatch dependency.