Description
We don't use error!
/warn!
/info!
a lot, but they come in handy for "debugging rustc
without a debug-assertions
build" situations, e.g. we use info!
to show the function being codegen'd (as it's low-overhead and really helpful for e.g. LLVM crashes).
While info!
makes sense for off-by-default debugging helpers like that, error!
/warn!
seem closer to user-facing diagnostics, where the main difference is them being usable outside of code which has access to a Session
(either due to running before the Session
is created, or just in dependencies that have access to log
/tracing
but not any rustc
-specific diagnostics APIs).
However, one surprising aspect is only error!
is enabled by default, while warn!
is not, meaning that, with the current defaults, one is forced to choose between error!
(which would output the word "error" which sounds more dire than "warning") or warn!
(which may never be seen by an user).
My usecase for warn!
is in the upcoming -Z self-profile
support for using hardware performance counters (which needs to be implemented in the separate measureme
project), e.g. this warn!
instructs the user to open an issue if they have an unrecognized (newer) CPU, but there's nothing preventing -Z self-profile
from working (if the newer CPUs aren't drastically different), so showing "error" seems quite inappropriate.
Sadly, I don't think log
env_logger
itself will change this behavior, so even if we change RUSTC_LOG
's default, measureme
might still have to use the less-appropriate error!
if it wants to account for being used in other projects.