-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Readability improvements to rust code in this repo #147591
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: master
Are you sure you want to change the base?
Conversation
Some changes occurred in src/tools/opt-dist cc @Kobzol
The run-make-support library was changed cc @jieyouxu Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging. Some changes occurred in src/tools/compiletest cc @jieyouxu |
Also, please check if I broke MSRV. |
Please don't make such large PRs that touch everything, it's quite hard to review. We generally welcome cleanups to different parts of the tree (though avoid touching subtrees (rust-analzer, clippy, rustfmt, Miri)), but you always have to consider the review effort of these changes. Split them up, don't open it all at once, and we're happy :). |
Hey! Sorry, I don't know how to split it up anymore... is this one semi-fine or would I need to redo it all? |
Do not review the PR yet. I'm planning to add much more. |
Here is one approach to splitting into many commits (there are other ways, but this one will suit "break up one large commit").
|
I'd say that this one is already too big |
I'll add some context on why this PR is difficult to review, and why it basically has no chance to merge as is, let alone with even more changes. Hopefully, this context can help you to split the set of changes into reviewable and thus mergeable chunks, before you expend even more effort on creating an even larger set of changes in the same PR (that also has no chance to merge as is). What qualities of this PR makes it difficult to review?Firstly,
Does not inspire confidence for two reasons:
Secondly, this PR is already too large, as Nora said above. "Too large" is relative, and there's of course nuance to this. Before enumerating how you might split this PR to make it reviewable, let me just demonstrate what I mean by an easier to-review (sub-) PR: Note Example. If you picked only a single clippy lint, applied it to the In contrast, this PR does several things that make it effectively-impossible to review:
Now, I've written about what makes this PR very difficult to review. You may reasonably ask, well then, how do I make this set of changes easier to review and easier to merge? Making this set of changes possible to review and mergeA few tips:
Recommended subtree splitsOn the subtree-split axis (the other axis being the which clippy lint(s) as I discussed previously), I think a reasonable split is:
Caution
Design principle: Satisfying all clippy lints is a non-goalAs Boxy puts it (which I find is a very good characterization) in [2]:
This is particularly the case for the Now, Basically, carefully evaluate if a given clippy lint has a very good signal-to-noise ratio (and seems almost always an improvement in some property, such as clarity or correctness), then we can try to evaluate to enable (and thus enforce) that specifically for rust/src/bootstrap/src/core/build_steps/clippy.rs Lines 541 to 619 in 4422885
Footnotes |
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
I checked some of this changes, and I'd say that clippy is doing a good job here, I'd love to see just a compiler/ commit (or a separate PR) for that kind of clean up! |
@jieyouxu Thanks for the feedback. I did not blindly follow clippy: I only did the easiest changes like expect with a fn call -> unwrap_or_else, unnecessary references, un-nest useless branches, etc. Those alone were most the errors. |
Also, I did it all manually - I didn't just clippy --fix, as to manually see what fits best. |
Also also, does anyone know why the goddamn PR isn't working? It's just so next time I avoid the issue. |
Sounds good 👍 Then, we would only need to make this set of changes easier to review, by breaking it up into more reviewable chunks. |
Usually there will be a bot @rust-log-analyzer that would post a summary snippet of which job failed and what failed, but sometimes github webhooks can be missed or for whatever other reasons. In this case of failed PR CI, you can check the list of failed checks ![]() and look at the log for the failing job,
which might be from your compiler/bootstrap/coverage-dump tool changes. |
I looked at it, it was just... absolutely incomprehensible... |
stage 2 coverage tests (tests/coverage) failed, something with raw bytes comparing, seems like it needs to be reblessed, but I never touched a stage 2 tests before, so I'm not sure how to do this Can you try something like |
That does not look like a snapshot difference, that looks like a genuine failure. This is also why we recommended the splits, so that it's easier to see what changed and less work to rule out what isn't involved. I do not have the bandwidth to determine why this failure is happening. |
hm, can I do this? seems like it works, @jieyouxu mind to delegate me rights on this one sooner or later? r? Kivooeo |
let name_hash = i64::from_str_radix(&captures["name_hash"], 10).unwrap() as u64; | ||
let filenames_hash = i64::from_str_radix(&captures["filenames_hash"], 10).unwrap() as u64; | ||
let name_hash = captures["name_hash"].parse::<i64>().unwrap() as u64; | ||
let filenames_hash = captures["name_hash"].parse::<i64>().unwrap() as u64; |
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 change is breaking coverage tests (I test it locally)
I don't think it is particularly productive to review this PR in its current shape as-is. Even if you review it, I do not want to land this PR like this. Again, see split discussion above. |
I don't either and waiting on split |
Please double check everything as I might have done something wrong. Please draft as this is not complete. Satisfies clippy a lot more (from ~400 warnings to ~150)
(also haha back to back PRs go BRRRRRRRRRRRRR :P)