Skip to content
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

Disallow prints in all crates #664

Merged
merged 1 commit into from
Oct 5, 2023
Merged

Disallow prints in all crates #664

merged 1 commit into from
Oct 5, 2023

Conversation

georgwiese
Copy link
Collaborator

@georgwiese georgwiese commented Oct 4, 2023

As far as I can see, there is no way to configure this on a workspace level in stable Rust.

Note also that clippy isn't currently run in the CI. #661 fixes that. Running cargo clippy manually should catch all instances of println!() and print!(). I replaced all instances we had in the code with log::info!().

Also note that we currently have another lint error in the code base (also fixed in #661).

@georgwiese georgwiese marked this pull request as ready for review October 4, 2023 13:43
powdr_cli/src/main.rs Outdated Show resolved Hide resolved
@chriseth
Copy link
Member

chriseth commented Oct 4, 2023

Do we need to add that line to the main module of every crate or how does it work?

@georgwiese
Copy link
Collaborator Author

Do we need to add that line to the main module of every crate or how does it work?

Yes, I think so. In the future, this type of stuff can be configured in Cargo.toml (rust-lang/cargo#5034) but looks like his isn't available in stable Rust yet.

@@ -337,7 +339,7 @@ pub fn inputs_to_query_callback<T: FieldElement>(inputs: Vec<T>) -> impl Fn(&str
}
"\"print_char\"" => {
assert_eq!(items.len(), 2);
print!("{}", items[1].parse::<u8>().unwrap() as char);
log::info!("{}", items[1].parse::<u8>().unwrap() as char);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really sure about this one. This is not the main ebreak/ecall thin for riscv - do you know where it is used?

Copy link
Member

@chriseth chriseth Oct 4, 2023

Choose a reason for hiding this comment

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

Ah no it actually is the main one!

At some point, we should probably store this into a proper buffer so that it does not interfere with the logging.

Until then, it should probably stay print.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Searching for print_char, I only found this line, for the RISC-V ebreak instruction!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I changed it back to print!

@chriseth chriseth added this pull request to the merge queue Oct 5, 2023
Merged via the queue into main with commit 7d3a7d5 Oct 5, 2023
2 checks passed
@chriseth chriseth deleted the disallow-print branch October 5, 2023 10:39
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