-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
optimize tidy check on src/tools/tidy/src/issues.txt
#123339
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
0ae5bae
to
6e5caac
Compare
if bless && !remaining_issue_names.is_empty() { | ||
let issues_txt_header = r#" | ||
/* | ||
============================================================ | ||
⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️ | ||
============================================================ | ||
*/ | ||
[ | ||
"#; |
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 genuinely do not think we should remove this.
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 understand the concern but I'm not sure how this will help. If someone adds a line to the end of this file, reviewers won't be able to see this header anyway.
How about hardcoding the current length and checking if it's not equal to the lines in this file? This way we will continuously be aware of it without relying on reviewers mistakes.
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.
It is not for informing a reviewer.
const ISSUES_ENTRY_LIMIT
is already checked.
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.
It is not for informing a reviewer.
It has to. When someone accidentally adds a line, reviewer should be aware of this information.
const ISSUES_ENTRY_LIMIT is already checked.
What I mean is this:
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 5b3b948d4a1..86e72823036 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -100,6 +100,9 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
}
pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
+ // This can be decreased but can never be increased.
+ const EXPECTED_LINE_COUNT: usize = 4372;
+
let path = &root_path.join("tests");
check_entries(&path, bad);
@@ -120,6 +123,8 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
})
.collect();
+ assert_eq!(EXPECTED_LINE_COUNT, allowed_issue_names.len(), "If you have added new lines to issues.txt, please revert them; otherwise, decrease the EXPECTED_LINE_COUNT.");
+
if !is_sorted && !bless {
tidy_error!(
bad,
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.
It has to. When someone accidentally adds a line, reviewer should be aware of this information.
The vast majority of the information in the Rust repository is addressed directly at the contributor, and only incidentally useful to a reviewer, so I disagree with this "has to" assertion.
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.
Anyways, the reason there's nothing exactingly doing assert_eq!
is because there was a request in the original PR to make this list --bless
able, to reduce annoyance. So I implemented that. Making sure this number --bless
es only up and not down would require a lot of fiddly logic, I would think? And it would also invite merge conflicts on the value a lot.
☔ The latest upstream changes (presumably #123429) made this pull request unmergeable. Please resolve the merge conflicts. |
It seems like we ought to be able to move to using include_str!() and skip a fixed header before iterating through the lines, without making any other, unrelated changes to the behavior (e.g., adding an assertion about a specific number). |
2e202e9
to
e9904e7
Compare
@rustbot ready |
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.
r=me with nits fixed
src/tools/tidy/src/ui_tests.rs
Outdated
let mut is_sorted = true; | ||
let allowed_issue_names: BTreeSet<_> = include_str!("issues.txt") | ||
.lines() | ||
.skip(issues_txt_header.lines().count()) // skip the header lines |
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 should probably be a strip_prefix(issues_txt_header), so that we assert that the contents of that block have not changed.
src/tools/tidy/src/ui_tests.rs
Outdated
is_sorted = false; | ||
} | ||
|
||
prev_line = line.clone(); |
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.
FWIW, there's some needless copying going on here AFAICT. BTreeSet<&'static str>
should be fine (and should be what you get from iterating lines).
e9904e7
to
49c10e4
Compare
@bors r=Mark-Simulacrum |
…Mark-Simulacrum optimize tidy check on `src/tools/tidy/src/issues.txt` This change applies to the following: - Handles `is_sorted` in the first iteration without needing a second. - Fixes line sorting on `--bless`. - Reads `issues.txt` as str rather than making it part of the source code. Fixes rust-lang#123002
…Mark-Simulacrum optimize tidy check on `src/tools/tidy/src/issues.txt` This change applies to the following: - Handles `is_sorted` in the first iteration without needing a second. - Fixes line sorting on `--bless`. - Reads `issues.txt` as str rather than making it part of the source code. Fixes rust-lang#123002
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock) - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`) - rust-lang#123321 (Bump dependencies) - rust-lang#123339 (optimize tidy check on `src/tools/tidy/src/issues.txt`) - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs) - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step) r? `@ghost` `@rustbot` modify labels: rollup
…Mark-Simulacrum optimize tidy check on `src/tools/tidy/src/issues.txt` This change applies to the following: - Handles `is_sorted` in the first iteration without needing a second. - Fixes line sorting on `--bless`. - Reads `issues.txt` as str rather than making it part of the source code. Fixes rust-lang#123002
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock) - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`) - rust-lang#123339 (optimize tidy check on `src/tools/tidy/src/issues.txt`) - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs) - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step) r? `@ghost` `@rustbot` modify labels: rollup
49c10e4
to
b0f2e60
Compare
This change applies to the following: - Handles `is_sorted` in the first iteration without needing a second. - Fixes line sorting on `--bless`. - Reads `issues.txt` as str rather than making it part of the source code. Signed-off-by: onur-ozkan <work@onurozkan.dev>
@bors r=Mark-Simulacrum (corrected the usage of |
☀️ Test successful - checks-actions |
Finished benchmarking commit (773fb88): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 666.761s -> 668.041s (0.19%) |
This change applies to the following:
is_sorted
in the first iteration without needing a second.--bless
.issues.txt
as str rather than making it part of the source code.Fixes #123002