-
Notifications
You must be signed in to change notification settings - Fork 515
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
Remove outdated doc that no longer holds true #261
Conversation
Remove outdated comment More here: rust-lang/rustc-dev-guide#261
Hmm... thanks @king6cong! It does indeed appear that the docs need to be updated, but I'm not really knowledgeable enough to say how. It seems that one still needs debug-assertions enabled to get In particular, I would rather update the doc than simply delete obsolete parts. Would you be interested in digging into this a bit more? |
@mark-i-m Thanks for the insight 😄 https://github.com/rust-lang/rust/blob/master/src/librustc/Cargo.toml#L19
These three will remove |
eb1e813
to
62cd91d
Compare
@mark-i-m
|
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.
Overall, looks good to me!
I left one minor comment, and I had the following question:
remove information about putting expensive/crashy operations inside an fmt::Debug impl, which is not needed because if expressions are evaluated, it will be formatted.
Sorry, how did you come to this conclusion? Does debug!
only evaluate expressions if debug logging is enabled?
src/compiler-debugging.md
Outdated
### How to keep or remove `debug!` and `trace!` calls from the resulting binary | ||
|
||
While calls to `error!`, `warn!` and `info!` are included in every build of the compiler, | ||
calls to `debug!` and `trace!` are only included in the program if the |
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.
calls to `debug!` and `trace!` are only included in the program if the | |
calls to `debug!` and `trace!` are only included in the program if |
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.
Updated
expressions will be evaluate and fmt will be called if debug logging is enabled. These two come together, both or neither. related code here:also verified:#[macro_use]
extern crate log;
extern crate env_logger;
use std::fmt;
struct ExpensiveOperationContainer {}
impl ExpensiveOperationContainer {
fn new() -> ExpensiveOperationContainer {
println!("ExpensiveOperationContainer::new called");
ExpensiveOperationContainer {}
}
}
impl fmt::Debug for ExpensiveOperationContainer {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
println!("Debug::fmt called");
fmt::Debug::fmt("", fmt)
}
}
fn main() {
env_logger::init();
warn!("{:?}", ExpensiveOperationContainer::new());
error!("{:?}", ExpensiveOperationContainer::new());
} Run with warn enabled:
Run with warn disabled:
We can see if logging is enabled, |
Thanks @king6cong for investigating! This looks good to me :) |
old: https://github.com/rust-lang/rust/blob/90346eae18e83887517e096c17678a74838ff995/src/liblog/macros.rs#L163-L166
new: https://github.com/rust-lang-nursery/log/blob/433731637477b27f573a3e40cd2297c5a776ff1b/src/macros.rs#L136-L144
I can't find conditional compilation that will remove
debug!
, only find runtimecfg!(debug_assertions)
check in the old liblog, maybe I need to dig into the more distant history.https://github.com/rust-lang-nursery/log/blob/433731637477b27f573a3e40cd2297c5a776ff1b/src/macros.rs#L36-L41
It seems RUST_LOG's presence alone does not make a difference, it's the value that matters
I think if expressions are evaluated, they are certain to be formatted, which makes this unnecessary?
I am not sure about these, please correct me if I'm wrong 😄