Skip to content

Add TODO checker to cg_clif#1632

Open
reddevilmidzy wants to merge 1 commit intorust-lang:mainfrom
reddevilmidzy:mcp-963
Open

Add TODO checker to cg_clif#1632
reddevilmidzy wants to merge 1 commit intorust-lang:mainfrom
reddevilmidzy:mcp-963

Conversation

@reddevilmidzy
Copy link
Member

cc: rust-lang/rust#153166
MCP: rust-lang/compiler-team#963

After the commit rust-lang/rust@69f9c6a is merged here, CI will pass.

@reddevilmidzy reddevilmidzy changed the title Add TODO checker Add TODO checker to cg_clift Mar 7, 2026
@reddevilmidzy reddevilmidzy changed the title Add TODO checker to cg_clift Add TODO checker to cg_clif Mar 8, 2026
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Mar 15, 2026
Tidy: disallow TODO in other in-tree projects

Fixes: #152280
MCP: rust-lang/compiler-team#963

TODO

* [x] Add ci check to `cg_clif`: rust-lang/rustc_codegen_cranelift#1632
* [x] Add ci check to `cg_gcc`: rust-lang/rustc_codegen_gcc#861

r? lcnr
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Mar 16, 2026
Tidy: disallow TODO in other in-tree projects

Fixes: rust-lang/rust#152280
MCP: rust-lang/compiler-team#963

TODO

* [x] Add ci check to `cg_clif`: rust-lang/rustc_codegen_cranelift#1632
* [x] Add ci check to `cg_gcc`: rust-lang/rustc_codegen_gcc#861

r? lcnr
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Mar 16, 2026
Tidy: disallow TODO in other in-tree projects

Fixes: rust-lang/rust#152280
MCP: rust-lang/compiler-team#963

TODO

* [x] Add ci check to `cg_clif`: rust-lang/rustc_codegen_cranelift#1632
* [x] Add ci check to `cg_gcc`: rust-lang/rustc_codegen_gcc#861

r? lcnr
@reddevilmidzy reddevilmidzy marked this pull request as ready for review March 17, 2026 06:02
Comment on lines +49 to +51
if is_editor_temp(&file) {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already excluded by list_tracked_files, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right!, removed

let files = list_tracked_files()?;
let mut errors = Vec::new();
// Avoid embedding the task marker in source so greps only find real occurrences.
let todo_marker = "todo".to_ascii_uppercase();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are both excluding this file from the todo check and also avoid the literal string TODO. One of the two seems redundant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used lowercase so that grepping for the literal string TODO under the ./compiler paths in the rust-lang/rust repo wouldn’t match this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, SKIP_FILES is not needed anymore, I removed it.
It was left over from using TODO in the previous implementation... haha

}

let bytes =
fs::read(&file).map_err(|e| format!("Failed to read `{}`: {e}", file.display()))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do error handling. Just unwrap. The build system doesn't have to be robust against hardware/OS issues. It isn't robust in other places either.

continue;
}
let path = std::str::from_utf8(entry)
.map_err(|_| "Non-utf8 path returned by `git ls-files`".to_string())?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can also use unwrap.

Comment on lines +146 to +150
if let Err(err) = todo::run() {
eprintln!("{err}");
process::exit(1);
}
process::exit(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make todo::run() return ! and move the process::exit() into it?

for (i, line) in contents.split('\n').enumerate() {
let trimmed = line.trim();
if trimmed.contains(&todo_marker) {
errors.push(format!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can immediately print the error and increment an error counter.

fs::read(&file).map_err(|e| format!("Failed to read `{}`: {e}", file.display()))?;
let Ok(contents) = std::str::from_utf8(&bytes) else {
continue;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All source files should be valid UTF-8, so unwrap here is fine.

bjorn3 pushed a commit that referenced this pull request Mar 17, 2026
Tidy: disallow TODO in other in-tree projects

Fixes: rust-lang/rust#152280
MCP: rust-lang/compiler-team#963

TODO

* [x] Add ci check to `cg_clif`: #1632
* [x] Add ci check to `cg_gcc`: rust-lang/rustc_codegen_gcc#861

r? lcnr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants