diff options
| author | Stypox <stypox@pm.me> | 2025-06-11 10:23:43 +0200 |
|---|---|---|
| committer | Stypox <stypox@pm.me> | 2025-06-11 10:42:50 +0200 |
| commit | fc96ca8bbad7fb4c7546fb98807e826723fc6c1d (patch) | |
| tree | 5bef18d13625bb5395ff4d32d04385d023886f60 /compiler/rustc_driver_impl | |
| parent | 0d74252537b6fd3ae6287486dbeec437cf021efa (diff) | |
| download | rust-fc96ca8bbad7fb4c7546fb98807e826723fc6c1d.tar.gz rust-fc96ca8bbad7fb4c7546fb98807e826723fc6c1d.zip | |
Use closure to allow passing custom tracing layers
The previous method, where a layer would be passed directly, required to pass a "no-op" layer when no custom layer was needed. This should have in theory worked, however having a no-op layer seems to change the way the tracing lib applies filters internally, leading to some debug!() being printed despite them being out of the minimum level for the filters. Note however that this behavior was very inconsistent, and e.g. some debug!() would get printed and some others wouldn't, for no apparent reason.
Diffstat (limited to 'compiler/rustc_driver_impl')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 83552af5a0e..038b93dda08 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1507,13 +1507,15 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) { } } -pub fn init_logger_with_additional_layer( +pub fn init_logger_with_additional_layer<F, T>( early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig, - additional_tracing_layer: impl rustc_log::Layer<rustc_log::Registry> + Send + Sync, -) { - if let Err(error) = rustc_log::init_logger_with_additional_layer(cfg, additional_tracing_layer) - { + build_subscriber: F, +) where + F: FnOnce() -> T, + T: rustc_log::BuildSubscriberRet, +{ + if let Err(error) = rustc_log::init_logger_with_additional_layer(cfg, build_subscriber) { early_dcx.early_fatal(error.to_string()); } } |
