Skip to content

Commit 9b88e0a

Browse files
committed
Auto merge of #75514 - gdhuper:gdhuper/replace_log_with_tracing, r=davidtwco
Replaced `log` with `tracing` ## Description Replaced `log` with `tracing` in the following crates: - [x] librustc_ast - [x] librustc_driver - [x] librustc_errors - [x] librustc_expand - [x] librustc_hir - [x] librustc_incremental - [x] librustc_infer - [x] librustc_interface - [x] librustc_lint - [x] librustc_metadata - [x] librustc_middle - [x] librustc_mir - [x] librustc_mir_build - [x] librustc_parse - [x] librustc_passes - [x] librustc_privacy - [x] librustc_query_system - [x] librustc_resolve - [x] librustc_save_analysis - [x] librustc_session - [x] librustc_span - [x] librustc_symbol_mangling - [x] librustc_target - [x] librustc_trait_selection - [x] librustc_traits - [x] librustc_ty - [x] librustc_typeck - [x] compiletest Fixes: #74747 ## Checklist: - [x] Code compiles / builds - [x] run tidy - [x] Cleanup any clippy warnings - [x] Update/add docs
2 parents 3f32505 + d2753f9 commit 9b88e0a

File tree

96 files changed

+109
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+109
-104
lines changed

src/librustc_ast/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_serialize = { path = "../librustc_serialize" }
14-
log = { package = "tracing", version = "0.1" }
14+
tracing = "0.1"
1515
rustc_span = { path = "../librustc_span" }
1616
rustc_data_structures = { path = "../librustc_data_structures" }
1717
rustc_index = { path = "../librustc_index" }

src/librustc_ast/util/literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_lexer::unescape::{unescape_byte_literal, unescape_literal, Mode};
1010
use rustc_span::symbol::{kw, sym, Symbol};
1111
use rustc_span::Span;
1212

13-
use log::debug;
1413
use std::ascii;
14+
use tracing::debug;
1515

1616
pub enum LitError {
1717
NotLiteral,

src/librustc_driver/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ crate-type = ["dylib"]
1212
[dependencies]
1313
lazy_static = "1.0"
1414
libc = "0.2"
15-
log = { package = "tracing", version = "0.1.18", features = ["release_max_level_info"] }
15+
tracing = { version = "0.1.18", features = ["release_max_level_info"] }
1616
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
1717
rustc_middle = { path = "../librustc_middle" }
1818
rustc_ast_pretty = { path = "../librustc_ast_pretty" }

src/librustc_driver/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#![recursion_limit = "256"]
1010

1111
#[macro_use]
12-
extern crate log;
12+
extern crate tracing;
1313
#[macro_use]
1414
extern crate lazy_static;
1515

@@ -1224,13 +1224,13 @@ pub fn install_ice_hook() {
12241224
}
12251225

12261226
/// This allows tools to enable rust logging without having to magically match rustc's
1227-
/// log crate version.
1227+
/// tracing crate version.
12281228
pub fn init_rustc_env_logger() {
12291229
init_env_logger("RUSTC_LOG")
12301230
}
12311231

12321232
/// This allows tools to enable rust logging without having to magically match rustc's
1233-
/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
1233+
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
12341234
/// other than `RUSTC_LOG`.
12351235
pub fn init_env_logger(env: &str) {
12361236
// Don't register a dispatcher if there's no filter to print anything

src/librustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010
doctest = false
1111

1212
[dependencies]
13-
log = { package = "tracing", version = "0.1" }
13+
tracing = "0.1"
1414
rustc_serialize = { path = "../librustc_serialize" }
1515
rustc_span = { path = "../librustc_span" }
1616
rustc_macros = { path = "../librustc_macros" }

src/librustc_errors/diagnostic_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::{Applicability, Handler, Level, StashKey};
22
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString};
33

4-
use log::debug;
54
use rustc_span::{MultiSpan, Span};
65
use std::fmt::{self, Debug};
76
use std::ops::{Deref, DerefMut};
87
use std::thread::panicking;
8+
use tracing::debug;
99

1010
/// Used for emitting structured error messages and other diagnostic information.
1111
///

src/librustc_errors/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::{
1818
pluralize, CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SuggestionStyle,
1919
};
2020

21-
use log::*;
2221
use rustc_data_structures::fx::FxHashMap;
2322
use rustc_data_structures::sync::Lrc;
2423
use rustc_span::hygiene::{ExpnKind, MacroKind};
@@ -30,6 +29,7 @@ use std::iter;
3029
use std::path::Path;
3130
use termcolor::{Ansi, BufferWriter, ColorChoice, ColorSpec, StandardStream};
3231
use termcolor::{Buffer, Color, WriteColor};
32+
use tracing::*;
3333

3434
/// Default column width, used in tests and when terminal dimensions cannot be determined.
3535
const DEFAULT_COLUMN_WIDTH: usize = 140;

src/librustc_errors/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern crate rustc_macros;
1111

1212
pub use emitter::ColorConfig;
1313

14-
use log::debug;
14+
use tracing::debug;
1515
use Level::*;
1616

1717
use emitter::{is_case_difference, Emitter, EmitterWriter};

src/librustc_expand/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212

1313
[dependencies]
1414
rustc_serialize = { path = "../librustc_serialize" }
15-
log = { package = "tracing", version = "0.1" }
15+
tracing = "0.1"
1616
rustc_span = { path = "../librustc_span" }
1717
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1818
rustc_ast_passes = { path = "../librustc_ast_passes" }

src/librustc_expand/mbe/macro_rules.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ use rustc_span::hygiene::Transparency;
2525
use rustc_span::symbol::{kw, sym, Ident, MacroRulesNormalizedIdent};
2626
use rustc_span::Span;
2727

28-
use log::debug;
2928
use std::borrow::Cow;
3029
use std::collections::hash_map::Entry;
3130
use std::{mem, slice};
31+
use tracing::debug;
3232

3333
crate struct ParserAnyMacro<'a> {
3434
parser: Parser<'a>,

src/librustc_hir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ rustc_span = { path = "../librustc_span" }
1818
rustc_serialize = { path = "../librustc_serialize" }
1919
rustc_ast = { path = "../librustc_ast" }
2020
lazy_static = "1"
21-
log = { package = "tracing", version = "0.1" }
21+
tracing = "0.1"
2222
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

src/librustc_hir/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use rustc_index::vec::IndexVec;
1515
use rustc_span::hygiene::ExpnId;
1616
use rustc_span::symbol::{sym, Symbol};
1717

18-
use log::debug;
1918
use std::fmt::Write;
2019
use std::hash::Hash;
20+
use tracing::debug;
2121

2222
/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
2323
/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`

src/librustc_incremental/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_graphviz = { path = "../librustc_graphviz" }
14-
log = { package = "tracing", version = "0.1" }
14+
tracing = "0.1"
1515
rand = "0.7"
1616
rustc_middle = { path = "../librustc_middle" }
1717
rustc_data_structures = { path = "../librustc_data_structures" }

src/librustc_incremental/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[macro_use]
99
extern crate rustc_middle;
1010
#[macro_use]
11-
extern crate log;
11+
extern crate tracing;
1212

1313
mod assert_dep_graph;
1414
pub mod assert_module_sources;

src/librustc_infer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_graphviz = { path = "../librustc_graphviz" }
14-
log = { package = "tracing", version = "0.1" }
14+
tracing = "0.1"
1515
rustc_middle = { path = "../librustc_middle" }
1616
rustc_data_structures = { path = "../librustc_data_structures" }
1717
rustc_errors = { path = "../librustc_errors" }

src/librustc_infer/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern crate rustc_macros;
3333
#[macro_use]
3434
extern crate rustc_data_structures;
3535
#[macro_use]
36-
extern crate log;
36+
extern crate tracing;
3737
#[macro_use]
3838
extern crate rustc_middle;
3939

src/librustc_interface/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
libc = "0.2"
14-
log = { package = "tracing", version = "0.1" }
14+
tracing = "0.1"
1515
rayon = { version = "0.3.0", package = "rustc-rayon" }
1616
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1717
rustc_ast = { path = "../librustc_ast" }

src/librustc_interface/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
198198
}
199199

200200
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
201-
log::trace!("run_compiler");
201+
tracing::trace!("run_compiler");
202202
let stderr = config.stderr.take();
203203
util::setup_callbacks_and_run_in_thread_pool_with_globals(
204204
config.opts.edition,

src/librustc_interface/passes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::interface::{Compiler, Result};
22
use crate::proc_macro_decls;
33
use crate::util;
44

5-
use log::{info, warn};
65
use once_cell::sync::Lazy;
76
use rustc_ast::mut_visit::MutVisitor;
87
use rustc_ast::{self, ast, visit};
@@ -39,6 +38,7 @@ use rustc_span::symbol::Symbol;
3938
use rustc_span::{FileName, RealFileName};
4039
use rustc_trait_selection::traits;
4140
use rustc_typeck as typeck;
41+
use tracing::{info, warn};
4242

4343
use rustc_serialize::json;
4444
use tempfile::Builder as TempFileBuilder;
@@ -104,7 +104,7 @@ pub fn configure_and_expand(
104104
krate: ast::Crate,
105105
crate_name: &str,
106106
) -> Result<(ast::Crate, BoxedResolver)> {
107-
log::trace!("configure_and_expand");
107+
tracing::trace!("configure_and_expand");
108108
// Currently, we ignore the name resolution data structures for the purposes of dependency
109109
// tracking. Instead we will run name resolution and include its output in the hash of each
110110
// item, much like we do for macro expansion. In other words, the hash reflects not just
@@ -229,7 +229,7 @@ fn configure_and_expand_inner<'a>(
229229
resolver_arenas: &'a ResolverArenas<'a>,
230230
metadata_loader: &'a MetadataLoaderDyn,
231231
) -> Result<(ast::Crate, Resolver<'a>)> {
232-
log::trace!("configure_and_expand_inner");
232+
tracing::trace!("configure_and_expand_inner");
233233
pre_expansion_lint(sess, lint_store, &krate);
234234

235235
let mut resolver = Resolver::new(sess, &krate, crate_name, metadata_loader, &resolver_arenas);
@@ -342,7 +342,7 @@ fn configure_and_expand_inner<'a>(
342342
});
343343

344344
if let Some(PpMode::PpmSource(PpSourceMode::PpmEveryBodyLoops)) = sess.opts.pretty {
345-
log::debug!("replacing bodies with loop {{}}");
345+
tracing::debug!("replacing bodies with loop {{}}");
346346
util::ReplaceBodyWithLoop::new(&mut resolver).visit_crate(&mut krate);
347347
}
348348

src/librustc_interface/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'tcx> Queries<'tcx> {
168168
pub fn expansion(
169169
&self,
170170
) -> Result<&Query<(ast::Crate, Steal<Rc<RefCell<BoxedResolver>>>, Lrc<LintStore>)>> {
171-
log::trace!("expansion");
171+
tracing::trace!("expansion");
172172
self.expansion.compute(|| {
173173
let crate_name = self.crate_name()?.peek().clone();
174174
let (krate, lint_store) = self.register_plugins()?.take();

src/librustc_interface/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use log::info;
21
use rustc_ast::ast::{AttrVec, BlockCheckMode};
32
use rustc_ast::mut_visit::{visit_clobber, MutVisitor, *};
43
use rustc_ast::ptr::P;
@@ -33,6 +32,7 @@ use std::path::{Path, PathBuf};
3332
use std::sync::{Arc, Mutex, Once};
3433
#[cfg(not(parallel_compiler))]
3534
use std::{panic, thread};
35+
use tracing::info;
3636

3737
/// Adds `target_feature = "..."` cfgs for a variety of platform
3838
/// specific features (SSE, NEON etc.).

src/librustc_lint/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustc_lint"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
log = { package = "tracing", version = "0.1" }
12+
tracing = "0.1"
1313
unicode-security = "0.0.5"
1414
rustc_middle = { path = "../librustc_middle" }
1515
rustc_ast_pretty = { path = "../librustc_ast_pretty" }

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ use rustc_trait_selection::traits::misc::can_type_implement_copy;
5151

5252
use crate::nonstandard_style::{method_context, MethodLateContext};
5353

54-
use log::{debug, trace};
5554
use std::fmt::Write;
55+
use tracing::{debug, trace};
5656

5757
// hardwired lints from librustc_middle
5858
pub use rustc_session::lint::builtin::*;

src/librustc_lint/early.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use rustc_session::Session;
2323
use rustc_span::symbol::Ident;
2424
use rustc_span::Span;
2525

26-
use log::debug;
2726
use std::slice;
27+
use tracing::debug;
2828

2929
macro_rules! run_early_pass { ($cx:expr, $f:ident, $($args:expr),*) => ({
3030
$cx.pass.$f(&$cx.context, $($args),*);

src/librustc_lint/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ use rustc_session::lint::LintPass;
2828
use rustc_span::symbol::Symbol;
2929
use rustc_span::Span;
3030

31-
use log::debug;
3231
use std::any::Any;
3332
use std::cell::Cell;
3433
use std::slice;
34+
use tracing::debug;
3535

3636
/// Extract the `LintStore` from the query context.
3737
/// This function exists because we've erased `LintStore` as `dyn Any` in the context.

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use rustc_target::abi::Abi;
1919
use rustc_target::abi::{Integer, LayoutOf, TagEncoding, VariantIdx, Variants};
2020
use rustc_target::spec::abi::Abi as SpecAbi;
2121

22-
use log::debug;
2322
use std::cmp;
23+
use tracing::debug;
2424

2525
declare_lint! {
2626
UNUSED_COMPARISONS,

src/librustc_lint/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_span::symbol::Symbol;
1717
use rustc_span::symbol::{kw, sym};
1818
use rustc_span::{BytePos, Span, DUMMY_SP};
1919

20-
use log::debug;
20+
use tracing::debug;
2121

2222
declare_lint! {
2323
pub UNUSED_MUST_USE,

src/librustc_metadata/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
[dependencies]
1313
flate2 = "1.0"
1414
libc = "0.2"
15-
log = { package = "tracing", version = "0.1" }
15+
tracing = "0.1"
1616
memmap = "0.7"
1717
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1818
rustc_middle = { path = "../librustc_middle" }

src/librustc_metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ use rustc_span::symbol::{sym, Symbol};
2626
use rustc_span::{Span, DUMMY_SP};
2727
use rustc_target::spec::{PanicStrategy, TargetTriple};
2828

29-
use log::{debug, info};
3029
use proc_macro::bridge::client::ProcMacro;
3130
use std::path::Path;
3231
use std::{cmp, env, fs};
32+
use tracing::{debug, info};
3333

3434
#[derive(Clone)]
3535
pub struct CStore {

src/librustc_metadata/dependency_format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
159159
let name = tcx.crate_name(cnum);
160160
let src = tcx.used_crate_source(cnum);
161161
if src.dylib.is_some() {
162-
log::info!("adding dylib: {}", name);
162+
tracing::info!("adding dylib: {}", name);
163163
add_library(tcx, cnum, RequireDynamic, &mut formats);
164164
let deps = tcx.dylib_dependency_formats(cnum);
165165
for &(depnum, style) in deps.iter() {
166-
log::info!("adding {:?}: {}", style, tcx.crate_name(depnum));
166+
tracing::info!("adding {:?}: {}", style, tcx.crate_name(depnum));
167167
add_library(tcx, depnum, style, &mut formats);
168168
}
169169
}
@@ -191,7 +191,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
191191
&& tcx.dep_kind(cnum) == CrateDepKind::Explicit
192192
{
193193
assert!(src.rlib.is_some() || src.rmeta.is_some());
194-
log::info!("adding staticlib: {}", tcx.crate_name(cnum));
194+
tracing::info!("adding staticlib: {}", tcx.crate_name(cnum));
195195
add_library(tcx, cnum, RequireStatic, &mut formats);
196196
ret[cnum.as_usize() - 1] = Linkage::Static;
197197
}

src/librustc_metadata/locator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ use rustc_span::Span;
230230
use rustc_target::spec::{Target, TargetTriple};
231231

232232
use flate2::read::DeflateDecoder;
233-
use log::{debug, info, warn};
234233
use std::io::{Read, Result as IoResult, Write};
235234
use std::ops::Deref;
236235
use std::path::{Path, PathBuf};
237236
use std::{cmp, fmt, fs};
237+
use tracing::{debug, info, warn};
238238

239239
#[derive(Clone)]
240240
crate struct CrateLocator<'a> {

src/librustc_metadata/rmeta/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ use rustc_span::source_map::{respan, Spanned};
3737
use rustc_span::symbol::{sym, Ident, Symbol};
3838
use rustc_span::{self, hygiene::MacroKind, BytePos, ExpnId, Pos, Span, SyntaxContext, DUMMY_SP};
3939

40-
use log::debug;
4140
use proc_macro::bridge::client::ProcMacro;
4241
use std::cell::Cell;
4342
use std::io;
4443
use std::mem;
4544
use std::num::NonZeroUsize;
4645
use std::path::Path;
46+
use tracing::debug;
4747

4848
pub use cstore_impl::{provide, provide_extern};
4949
use rustc_span::hygiene::HygieneDecodeContext;

0 commit comments

Comments
 (0)